Extract the matrices of the COMSOL Multiphysics linearized system with the function mphmatrix. To call the function
mphmatrix, specify a solver node and the list of the system matrices to extract:
where <soltag> is the solver node tag used to assemble the system matrices and
out is a cell array containing the list of the matrices to evaluate. The output data
str returned by
mphmatrix is a MATLAB
® structure, and the fields correspond to the assembled system matrices.
where method corresponds to the type of linearization point — the initial value expression (
'init') or a solution (
'sol').
where <initsoltag> is the solver tag to use for linearization points. You can also set the
initsol property to
'zero', which corresponds to using a null solution vector as a linearization point. The default is the current solver node where the assemble node is associated.
where <solnum> is an integer value corresponding to the solution number. The default value is the last solution number available with the current solver configuration.
where <nodetag> is the tag of a solution sequence node such as dependent variable or solver nodes.
where <eigname> is a string and
<eigref> a possibly complex number.
Set the symmetry property to specify manually the symmetry type for the matrix evaluation. The
symmetry property supports the following values:
where sym can be either of one of the following value:
Use the nullfun property to specify the method for computation of matrices needed for constraint handling:
If the system contains a complex function, use the property complexfun to specify how to handle such a function. Set this property to
on to use a complex-valued function with real input:
The following illustrates how to use the mphmatrix command to extract eliminated system matrices of a stationary analysis and linear matrix system at the MATLAB prompt.
The model consists of a linear heat transfer problem solved on a unit square with a 1e5 W/m^2 surface heat source and temperature constraint. Only one quarter of the geometry is represented in the model. For simplification reasons, the mesh is made of four quad elements and the discretization is set with linear element.
Now compare the solution vectors U and
U1 computed by COMSOL Multiphysics and by the matrix operation, respectively.