Using a Job Configuration to Store Parametric Results on File
As an example of the use of a job configuration, right-click the Job Configurations () node and add a Parametric Sweep (Job Configurations) to run a parametric study, storing the model and associated data and plots for each parameter step to individual files. This is useful if you, for example, want to:
The following steps describe the most important parts of setting up a job configuration to accomplish the desired file output:
1
Start with a model that does not contain any parametric sweep and define your outputs. Then add them to the Export node (by right-clicking and adding Data, Plot, and image nodes as desired) and assign each data or plot output to a file.
2
Create a parametric sweep study by right-clicking the study node and adding a Parametric Sweep. Add the parameters you want to sweep over in Parameters under Global Definitions. Now add the parameters in Parameter name in the parametric sweep node you created and set the Parameter values you want to sweep over. In some cases COMSOL Multiphysics chooses to use the more efficient parametric solver when sweeping. Set the Use parametric solver under Study Extensions to Off if you want to avoid this. Use the Keep solutions in memory setting Only last to conserve memory. In that case use the Accumulated Probe table to store the data you want to use for later processing. You can also choose to store the models on file by enabling the Save each solution as model file and then entering a filename in the Filename field, or clicking Browse to choose a name and location for the model files. The models created during the simulation can then be found in a Save model to File node under Job Configurations. The default settings are configurable in the Preferences dialog box.
3
If you want to create output files with the parametric sweep for further analysis, right-click the main study node and select Show Default Solver. Select the parametric node under Job Configurations that corresponds to the parametric sweep from which you want to export data. You can see which parametric sweep the node corresponds to from the Defined by study step list. Note that if you run a stationary study, you need to switch off Use parametric solver in the Study Extensions section (see above) to get the node under Job Configurations.
-
Right-click the Parametric node and select Results>Plot Group if you want to run a Plot Group for each parameter value in the sweep. In most cases use the Plot settings under Results While Solving (in the study step’s Settings window) instead.
-
Right-click the Parametric node and select Results>Derived Value to run a Derived Values node for each parameter value in the sweep. This functionality is similar to probes but is useful if you have already set up a Derived Values node that you want to use during the sweep. The values are stored in a table (similar to probes) for further processing.
-
Right-click the Parametric node and select Results>Export to File if you want to export data to a file for each parameter value in the sweep, running an Export node under Results. Note that after the sweep, the files created are listed in the node and can be opened in a browser using the Open button.
Advanced Job Configurations
Because a job configuration defines a sequence of steps, you can create highly advanced models that use different solvers and sweeps as input to each other and perform different types of postprocessing during a sweep. Here are some suggestions:
Create a parametric job configuration that uses two solvers. The first solver is used as input to the second solver. One way to create such a sweep is to create two studies. Let the second study use the first as input from the Values of Dependent Variables. Create a Parametric Sweep in the first study and select to keep Only last solution. Run Show Default Solver in both studies and enter the Job Configurations node of the first study. Right-click the Parametric node and add a Solver. Select the new solver and set it to run the second solver from the second study. Also check the Keep all solutions settings. Right-click the Parametric node and select Run. You can add further functionality to the sequence such as Export to File to suit your needs.
Another possibility is to create a parametric sweep that runs a Cluster Computing node. This gives you similar functionality as the distributed parametric sweep, but the results are stored in separate files. Note that this requires several licenses, one for each process running simultaneously. One way to create this is to add a Cluster Sweep node by right-clicking the study. This node creates such a sweep automatically. It also sets up synchronization of solutions and accumulated probe tables when the synchronization is enabled. Another, more complicated, way is to add a Cluster Computing node by right-clicking the study. Note that you need the Advanced Study Options enabled. If you added the Cluster Computing node, then run Show Default Solver and select the Job Configurations node. Right-click and add a Parametric node. Right-click the new Parametric node and enable it. Right-click again and add a Job node. Set the job sequence to point to the Cluster Computing node. This sets up the new Parametric node to start a new process for each parameter. After you have set the parameters that you want to compute for, right-click and select Run. The resulting models are stored in External Process nodes under the batch job run by the cluster computing node. To get exported data during the runs, you can use the functionality Export to File described above or enable the synchronization of solutions and accumulated probe tables in the Batch node.
Create a parametric sweep that runs a solver and a class file that uses the COMSOL API to modify the solution. This can be useful if you want COMSOL Multiphysics to communicate with another program. You do this by adding a Parametric Sweep node to the study that you want to use. Run Show Default Solver and enter the Job Configurations node. Right-click the Parametric node and select Other>External Class. You can also modify the Parametric node by, for example, adding a Stop condition.
The default names for the nodes that you add under the Parametric node use a dynamic naming, so that the sequence that is run and, when applicable, the data storage node appear in the node name. By renaming the node to a user-defined name, you disable the dynamic naming.