Parametric Sweep
Use a Parametric Sweep () study to find the solution to a sequence of stationary or time-dependent problems that arise when you vary some parameters of interest. The parametric sweep can include multiple independent parameters directly for a full multiparameter sweep (solve for the first value of the first parameter combined with all values of the second parameter, then the second value of the first parameter combined with all values of the second parameter, and so on, or use a specified combination of parameter values). You can also add more than one Parametric Sweep node to create nested parametric sweeps. The inner sweep in a nested parametric sweep can also be another type of sweep, such as a sweep over materials by adding a Material Sweep node below the Parametric Sweep node. The program then treats the parametric sweeps as a “nested for-loop” and indicates the nested structure using indentations of the sweep nodes’ names.
See Table Surface for information about how to plot the variation of some quantity as a function of two parameters as a 2D surface plot where you vary two parameters and fix the others.
It is only possible to use one Sensitivity or Optimization study step feature in any study, unless there is an Optimization study step, in which case you can combine the Optimization study step with one or more Parametric Sweep study steps; however, you cannot have an Optimization study step over a Parametric Sweep study step, if a gradient-based method is used. You can use several Parametric Sweep nodes if desired, but they cannot be combined with the other study step types.
The Settings window has the following sections:
Study Settings
Use the Sweep type list to specify the type of sweep to perform. The Specified combinations type (the default) solves for a number of given combinations of values, while the All combinations type solves for all combinations of values. Using all combinations can lead to a very large number of solutions. The Parameter switch type makes it possible to run sweeps over selected parameter groups and associated parameter cases (see Parameters and Parameter Cases). Using the Parameter switch sweep type, you can run specified sweeps for all or selected parameter cases for a parameter group, and if you have more than one parameter group, you might want to compute all combinations of these groups. You can do so by setting up a complete parameter list as an outer sweep with all parameter groups and their parameter cases in the parameter switch table (see below). The Parameter switch sweep type can also be combined with other parametric sweeps using any sweep type.
For Specified combinations and All combinations, use the table with Parameter name, Parameter value list, and (optional) Parameter unit to specify parameter names, values, and units for the parametric solver. Use the Add button () to add a row to the table. Each row has one parameter name, a corresponding parameter value list, and an optional unit. The unit becomes orange if the unit that you specify does not match the unit given for the parameter where it is defined. For the Specified combinations sweep type, the list of values must have equal length. When you click in the Parameter value list column to define the parameter values, you can click the Range button () to define a range of parameter values. The parameter unit overrides the unit of the global parameter. If no parameter unit is given, parameter values without explicit dimensions are considered dimensionless.
For Parameter switch, add parameters to switch by clicking the Add button () to add a Parameters node in the Switch column for which to switch its parameters. In the Cases column, choose the parameter cases to include. The default is All (also when there are no parameter cases); choose User defined to specify the parameter cases to include under Case numbers. Then, during postprocessing, you can choose from the specified case numbers in lists for the added Parameters nodes under the Dataset list in the Data sections for plots and data evaluations. Use the Move Up (), Move Down (), and Delete () buttons as needed to rearrange the list of Parameters nodes for a parameter switch.
The list of parameters in the Parameter name column contains parameters from Parameters nodes where the Show in parameter selections check box is selected.
If more than one parameter name has been specified, the lists of parameter values are interpreted as follows: Assume that the parameter names are p1 and p2, and that p1 has the list 1 3 and p2 has the list 2 4. For the Specified combinations sweep type, the solver first uses p1 equal to 1 and p2 equal to 2. Thereafter, it uses p1 equal to 3 and p2 equal to 4. And when the sweep type is All combinations, the solver uses the following order for the parameter combinations: 1 2, 1 4, 3 2, and 3 4.
An alternative to specifying parameter names and values directly in the table is to specify them in a text file. Use the Load from File button () to browse to such a text file. The program appends the read parameter names, values, and units to the current table. The format of the text file must be such that the parameter names appear in the first column, and the values for each parameter appear in the next columns, comma separated (1,3,5) or separated with a space, row-wise enclosed with quotation marks and with spaces separating the values (such as "1 3 5"). Finally (separated by a space), the format includes an optional unit using unit syntax such as [m/s]. Click the Save to File button () to save the contents of the table to a text file (or to a Microsoft Excel Workbook spreadsheet if the license includes LiveLink™ for Excel®).
The loading and saving of parameter table data using Excel includes the units in the Parameter unit column. The unit column is ignored when saving and loading parameter data to *.txt, *.csv, and *.dat files.
You can use the Keep solutions list under Memory settings for jobs to control how to store the solutions from the individual parametric sweep solutions. Select All to store all the parametric sweep solutions in memory, or select Only last to store only the last solution from the parametric sweep. If you select Only last and the parametric solver is used, all solutions are kept in memory. When only the last solution is stored, you can also select the Save each solution as model file check box. It stores the separate parametric sweep solutions and their corresponding models in separate MPH-files. Enter a filename in the Filename field or click Browse to choose a name and location for the model files. Click the downward arrow for the File Location Actions menu () to choose Copy File Location () and (if you have copied a file location) Paste File Location (). You can also use probes to collect some solution values of interest during the sweep rather than storing all solutions, which can save memory and solution time.
Output while Solving
Select the Plot check box to allow plotting of results while solving. Then select what to plot from the Plot group list. The software plots the dataset of the selected plot group as soon as the results become available.
Use the Probes list to select probes to update during the parametric sweep. The default is All, which selects all probes for plotting and tabulation of probe data. Select Manual to open a list with all available probes. Use the Move Up (), Move Down (), Delete (), and Add () buttons to make the list contain the probes that you want to see results from while solving. Select None to disable probe updating for parametric sweep. Note that the control of tables and plot windows is done using the probe settings.
If a probe is updated on the Parametric Sweep level and also through another solution process (for example, a time-dependent simulation) this probe is not updated at the Parametric Sweep level. When the probes themselves (not the probe expression) depend on model parameters, the update of these probes is only correct for parameter sweeps that are done through outer parametric sweeps (not by a parametric solver). Outer parametric sweeps are performed by a Parametric node under Job Configurations. COMSOL Multiphysics currently does not autodetect model parameters in probes, so you might want to select Off from the Use parametric solver list in the Study Extensions section for the Parametric Sweep study node.
Select the Accumulated probe table check box to activate the accumulation of probe updates for both the variation on the solver level (time, frequency, and so forth) and on the parametric sweep level. Use the Output table to select where to put the data. Select the Use all probes check box if all the model probes should be accumulated in the table. If not selected, the probes selected from the Probes list are used.
No plots are generated automatically from the accumulated probe tables. When a full variation has been accumulated, then the Format: Filled is available for the table (see the Settings window for Table). This format makes it possible to modify the table data and make response surfaces directly from the Results view toolbar Surface Plot button.
Also, if the Use parametric solver setting is Automatic and the solver decides to use the parametric solver instead of a parametric sweep, an accumulated probe table is not created.
Settings for Reduced-Order Models
The Keep reduced-order models check box is selected by default. Then, these additional settings are available:
From the Add to tag list, choose Parameter name and value (the default), Index, or Parameter name and nonzero value (the latter option discards all zero values).
The Clear previous check box is selected by default to clear previous versions of the reduced-order models so that you can update all reduced-order models by running the study again.
The Keep the generating reduced-order models check box is selected by default. If selected, the generating reduced-order models are saved in addition to the reduced-order model copies.
To make sure that each solution is saved as a Model MPH-file, select Off from the Use parametric solver list in the Study Extensions section (see below). With that setting, the solver uses an outer sweep instead of an inner sweep, and it is then possible to save each solution to file.
Advanced Settings
From the Use parametric solver list, select one of the following options:
Automatic (the default) to generate a Parametric job configuration, unless the problem and parameters are such that the parametric sweep can be realized through a Stationary Solver with a Parametric solver subnode (), which is more efficient.
Off to always generate a Parametric job configuration.
From the Default solver sequence generation list, select one of the following options:
Using global parameters (the default), to use parameter values from the global parameters.
Using first parameter tuple, to use the first set of parameter values.
Using last parameter tuple, to use the last set of parameter values.
Using each parameter tuple, to use the all sets of parameter values.
From the Default solver sequence generation list you can control when a solver sequence should be generated during a parametric sweep (see also the settings for the Solution node under Job Configurations):
Choose Using global parameters (the default).
Choose Using first parameter tuple, Using last parameter tuple, or Using each parameter tuple to instead use the first tuple (set) of parameter values, the last tuple of parameter values, or each tuple of parameter values to control when a solver sequence should be generated.
By default, the solver sequence builds meshes based on the values of the global parameters. These meshes can then influence the generated solver sequence. In some cases, the global parameter values could lead to invalid meshes. Also, the solver sequence is, in the default case, optimized for the global parameter values, which could lead to another choice of solver than the preferred solver. Using one of the other available options in the Default solver sequence generation list can avoid such behavior.
Select the Reuse solution from previous step check box, if you want to reuse the converged values of variables from the previous sweep step as initial condition for the next step during the sweep. If a Parametric Sweep study step wraps an Optimization study step, select this check box to reuse variables solved for (both control variables and PDE variables) from the previous converged optimization call. This option is useful for parameters not handled with continuation. See Reuse Solution from Previous Step List for information about reusing solutions.
If you are running a parametric sweep and want to distribute it by sending one parameter value to each compute node, select the Distribute parametric sweep check box. To enable this option, click the Show More Options button () and select Solver and Job Configurations in the Show More Options dialog box. Note that if the Distribute parametric sweep check box is selected, Solution under Initial values of variables solved for in the Values of Dependent Variables section in the study step node’s settings cannot be set to Current. Each node is assigned disjoint sets of parameters; hence, the initial solution is undefined for all nodes other than the first.
To reduce the size of MPH-files for models using parametric sweeps, you have the option of storing only the last solution in the sweep in the file. If you want to use this setting as the default, open the Preferences dialog box and click Parametric Sweep. Then choose Only last from the Keep solutions list. You then have the further option of saving each solution as a model file. To do this, select the Save each solution as model file check box and then enter a filename in the Filename field, or click Browse to choose a name and location for the model files. The default option in the Keep solutions list, All, stores all solutions in the file.
Stationary for information about the continuation parametric solver versus parametric sweeps.