Retrieving Solution Information and Solution Datasets Based on Parameter Values
A model can contain several solution vectors computed with different values of parameters, such as time, eigenvalue, or model parameters. These solution vectors can be available in different solution datasets. Use the function mphsolutioninfo to retrieve the solution vector corresponding to a specified study parameter value.
The parameters used in a study can be group in two distinct solution number types:
The inner solution, containing the solution computed with parameters such as eigenvalues, time steps, or continuation parameter combinations.
The outer solution, containing the solution computed with parameters defined in parametric sweep.
To get information about all solution object and solution dataset combinations in the model enter the command:
info = mphsolutioninfo(model)
The output info is a structure containing these fields:
The substructure info.sol# has these fields:
You can also retrieve the solution objects and solution datasets related to a specific parameter value with the command:
info = mphsolutioninfo(model,'parameters',{'e1','v1','tol1'})
where e1 is the expression name and v1 the value of the expression.
The property parameters can also be set as a 1-by-N cell array, where N corresponds to the number of parameters to specify.
This section includes information about Specifying the Solution Object and the Output Format. It also includes the Retrieving Solution Information section.
Specifying the Solution Object
To retrieve the information of a specific solution object, set the soltag property with the solver tag soltag associated to the solution object:
info = mphsolutioninfo(model, 'soltag', <soltag>)
If there are several solution datasets attached to the solver (for example, solution datasets with different selections), specify the dataset to use to get the solution object information with the dataset property:
info = mphsolutioninfo(model, 'dataset', <dsettag>)
where dsettag the tag of the solution dataset to use.
Output Format
To include the cellmap field in the info.sol# substructure, set the property cellmap to on:
info = mphsolutioninfo(model, 'cellmap', 'on')
Improve the visibility of the map table by sorting the rows using either the column number or the name in the map header:
info = mphsolutioninfo(model, 'sort', <idx>)
where <idx> is a positive integer equal to the column number or a string corresponding to the name of the column header.
Retrieving Solution Information
This example shows how to use the function mphsolutioninfo to retrieve solution information in a mode combining a parametric sweep and transient analysis.
Start by loading the base model model_tutorial_llmatlab from the COMSOL Multiphysics Application Libraries; this model contains the base settings for a thermal analysis:
model = mphopen('model_tutorial_llmatlab');
Now create a study combining a parametric sweep and a transient study step. The parametric sweep is used to vary the parameters that set the heat source and the bottom temperature. This is done with the following commands:
std = model.study.create('std');
param = std.feature.create('param', 'Parametric');
param.setIndex('pname', 'power', 0);
param.setIndex('plistarr', '30 60 90',0);
param.setIndex('pname', 'Temp', 1);
param.setIndex('plistarr', '300 320', 1);
time = std.feature.create('time', 'Transient');
time.set('tlist', 'range(0,1,25)');
Set the sweep type to generate all possible combinations of the parameters power and tf and compute the study:
param.set('sweeptype', 'filled');
mphrun(model);
Once the solution is computed (it takes about 90 seconds), you can retrieve the solution information in the model:
info = mphsolutioninfo(model)
The output info is a structure containing nine fields. By navigating in the info structure you can retrieve how the solutions are stored in the model.
info.sol1 contains the solution information related to the solver sequence sol1. The associated dataset is dset1.
info.sol2 contains the solution information for the parametric sequence. This regroups the solution vectors computed for all outer parameters.
The other substructures contain the solution information for all possible outer solution combinations.
Get the relation between the parameter values and the inner and outer solution numbers:
map = info.sol2.map
Retrieve the solution information related to the parameters power = 60 W:
info = mphsolutioninfo(model, 'parameters', {'power',60,0})
Retrieve the solution information related to the parameters power = 60 W, Temp = 300 K, and t = 10.4 seconds; for the time, use a tolerance of 0.5 seconds to find the appropriate inner solution number:
info = mphsolutioninfo(model, 'parameters', {{'power',60,0},...
{'Temp',300,0},{'t',10.4,0.5}})
To get the list of the solutions that contain the given parameters, enter:
solnum = info.solutions
Code for use with MATLAB®
model = mphopen('model_tutorial_llmatlab');
std = model.study.create('std');
param = std.feature.create('param', 'Parametric');
param.setIndex('pname', 'power', 0);
param.setIndex('plistarr', '30 60 90',0);
param.setIndex('pname', 'Temp', 1);
param.setIndex('plistarr', '300 320', 1);
time = std.feature.create('time', 'Transient');
time.set('tlist', 'range(0,1,25)');
param.set('sweeptype', 'filled');
mphrun(model);
info = mphsolutioninfo(model)
map = info.sol2.map
info = mphsolutioninfo(model, 'parameters', {'power',60,0})
info = mphsolutioninfo(model, 'parameters', {{'power',60,0},...
{'Temp',300,0},{'t',10.4,0.5}})
solnum = info.solutions