mphinputmatrix
Add a matrix system for linear solvers.
Syntax
mphinputmatrix(model,str,soltag,soltypetag)
Description
mphinputmatrix(model,str,soltag,soltypetag) adds the system matrices and vectors stored in the MATLAB® structure str to the model. The system matrices is associated to the linear solver configuration defined with the tag soltag and solved with the solver defined with the tag soltypetag.
soltypetag can only be one of the following solver type: Stationary, Eigenvalue, Time.
A valid structure for a stationary solver includes the following fields:
A valid structure for a time-dependent/ eigenvalue solver includes the following fields:
There is also the possibility to include the constraint force Jacobian vector NF.
Once the matrix system is loaded in the model, the solver configuration is set ready to run.
Note: The system matrices are not stored in the model when it is saved as an MPH-file or loaded into the COMSOL Desktop.
Example
Create a model with a square geometry
model = ModelUtil.create('Model');
comp = model.component.create('comp1', true);
geom = comp.geom.create('geom1', 2);
geom.create('sq1', 'Square');
geom.run;
Add an Equation General Form physics interface
g = comp.physics.create('g', 'GeneralFormPDE', 'geom1');
g.prop('ShapeProperty').set('order', 1)
g.prop('ShapeProperty').set('boundaryFlux', false);
cons = g.create('cons1', 'Constraint', 1).set('R', 'u');
cons.selection.set([1 2]);
Create a mapped mesh
map = comp.mesh.create('mesh1').create('map1', 'Map');
map.create('dis1', 'Distribution').set('numelem', 2);
map.feature('dis1').selection.set([1 2]);
Set-up the study and the solver configuration for a stationary problem:
std = model.study.create('std1');
std.create('stat', 'Stationary');
sol = model.sol.create('sol1');
sol.study('std1');
sol.feature.create('st1', 'StudyStep').set('studystep', 'stat');
sol.feature.create('v1', 'Variables');
sol.feature.create('s1', 'Stationary');
Extract the linear stationary matrix system in MATLAB:
str = mphmatrix(model,'sol1','out',{'K','L','M','N'},...
'initmethod','sol','initsol','zero');
Change the linear system by scaling the stiffness matrix:
str.K = str.K*0.5;
Insert the system matrix back to the model:
mphinputmatrix(model,str,'sol1','s1')
Run the solver configuration:
model.sol('sol1').runAll;
See also
mphmatrix, mphxmeshinfo