Efficient Parameter Control and Usage in COMSOL Multiphysics®

June 4, 2019

Using parameters to set up and control your models is definitely one of the most powerful and easy-to-use features of the COMSOL Multiphysics® software. However, with increasing model complexity, more and more parameters are usually introduced. Hence, you need good tools to keep your model parameters organized. Learn about the available features in the COMSOL® software for keeping your models and parameters organized.

What Kind of Model Needs Parameters?

In principle, any model can benefit from a proper parameter list. Globally defined parameters allow an efficient workflow and can be used anywhere throughout your model. In the majority of models, parameters are used to control the geometry and physics settings. Also, postprocessing can benefit from specific results parameters. Nevertheless, there are certain simulation projects where parameters are mandatory, such as models with:

Features for Working Efficiently with Parameters

There are many features and functionalities connected to parameters when using them in the modeling workflow. Parameters are globally defined quantities. They can be organized into multiple nodes. Sometimes, you may want to consider multiple variations for a group of parameters. This can be done using parameter cases. These parameters or parameter cases are input for parametric sweeps or sweeps over the parameter cases. Further, there are specific postprocessing parameters. They can only be used in postprocessing; e.g., to control animations.

A screenshot of the model showing all of the parameter-related features.
Screenshot of a model showing all of the parameter-related features in the Global Definitions, Study, and Results sections.

When you have defined all your parameters (and other definitions; e.g., variables, functions, etc.), you need to apply them throughout your model. Especially in models with lots of parameters, the exact names are usually not easy to remember. Here, it is very helpful to use the keyboard shortcuts. Pressing Ctrl+Space opens a tree with available parameters and variables that you can insert. You can search and filter the content by entering text in the search field.

A screenshot showing the use of Ctrl+Space in an expression field.
Ctrl+Space used in an expression field. Here, the letter “u” was typed in to use the automatic filter.

Organizing Your Parameters

With increasing model complexity, the parameter list tends to get longer and longer. To keep the long list user friendly, the parameters in the global definitions can be distributed using several parameter nodes. This setup allows you to logically group the parameters used; e.g., for the geometry or physics settings. It is further recommended to attach units to the parameters. This helps keep the models consistent unit-wise. For the documentation, a description of the parameters should also be a mandatory step in the workflow. These descriptions are especially useful when models are exchanged between colleagues or customers.

A screenshot of the model settings with two logically structured parameter nodes.
A model setting with two logically structured parameter nodes.

Using and setting several parameter nodes is definitely a best practice for building new models. However, there are models with extensive parameter lists, such as legacy models with only one very long list of parameters. (The functionality of using several parameter lists was introduced with version 5.4 of COMSOL Multiphysics.) In such cases, it is recommended to create further Parameter nodes. It’s actually pretty easy to move parameters into separate nodes. Just multiselect several rows in the table with the Shift or Ctrl key (depending on whether the parameters you want to move are consecutive or not), then right-click and choose Move to New Parameters. This will create a new node that contains those parameters. In the same way, you can also move parameters between existing parameter nodes.

A screenshot showing how you can move parameters between existing nodes in the model settings.

In another case, a model can have a logical parameters section that contains a lot of parameters of different importance to the model. Of course, a proper parameter description is helpful in such cases, but scrolling the full list to change a few important and frequently used parameters is a cumbersome task. Hence, these kinds of models tend to have a parameter list that is again incomprehensible. Obviously, you could go and re- and/or substructure the parameter nodes from more to less important. However, you now have two criteria — logic and importance — for the parameter organization, which might bring a lot of editing when the underlying criteria change. To gain control and prioritize such parameters, an efficient solution is to use forms.

Using Forms to Customize Parameter Control

To avoid the splitting of the parameter nodes into too many logical- and importance-based individual nodes, you could take advantage of the functionality of the Application Builder. It allows you to create a user-defined form that has fast parameter access, and you can keep your parameters organized logically with only a few parameter nodes. The second criterion of importance is especially well suited for the Application Builder, since the criterion is usually only triggered for a change of the input value. Also, the importance criterion might change throughout your simulation task. Hence, you can benefit from the easy and fast adjustable forms, which let you access and organize your parameters.

These forms are based on the Application Builder functionality paired together with the COMSOL Multiphysics platform product. The setting of such a form takes only a few steps and there is no need for programming. Based on the number of important parameters, two form versions will be discussed in the following sections. 

Case 1: Simple Forms

A simple form can be created within a few seconds. This type of form is recommended for models where only a few parameters are changed frequently. To create such a form, switch to the Application Builder by clicking on the Application Builder icon in the Home or Developer tab on the ribbon. Next, click on the New Form button in the Home tab of the Application Builder. This will start the Form Wizard, where you can set standard inputs and outputs as well as action buttons for a simulation application. In our case, we want to use the form in the Model Builder; hence, choosing the relevant parameters as inputs is sufficient. If you have set the units as well as a description, they will be recognized automatically and added to the form. In the Preview section, you can see what your parameter access will look like.

A screenshot of the Form Wizard showing parameter control with the most important geometry parameters selected.
Screenshot of the Form Wizard for the easy creation of a form to control the input parameters. Here, the most important geometry parameters are chosen.

Once you have chosen the needed parameters, you can click OK and the form is ready to use in the Model Builder. If you need to update the form for certain parameters, it is possible to easily adjust it at any time. To remove a no-longer-required parameter, simply select the relevant feature in the Form Editor with the mouse and press delete. To quickly add new relevant parameters, you can use the Editor Tools window.

A screenshot showing the adjustment of the form geomMajor.
Adjustment of the form geomMajor. The Layer 1 items are prepared to be chosen in order to remove them. On the left side, the Editor Tools are visible, allowing you to quickly add new parameters to the form.

Case 2: Advanced Forms

The second case will discuss models where more parameters from various logical parameter sections are important. The needed setting is a small extension of the simple form above. To create such a form, go once again to the Application Builder. This time, though, create more simple forms, each containing a logical group of parameters. In the example below, three groups are identified: major and minor geometry parameters as well as some important physical parameters. To organize these forms, you can put them together into a main form having a Form Collection object. Using Form Collection, it is very easy to choose and organize the three subforms in the respective setting.

A screenshot showing how you would create an advanced form.
Creating an advanced form. The parameterControl form is the main form using the Form Collection feature (settings shown in the second window from right). Three subforms are used for display in the Form Collection window.

Deploying the Form

Originally, forms were only used to create custom user interfaces in simulation applications. As of COMSOL Multiphysics® version 5.4, it is also possible to use them directly in the Model Builder. The created forms can be added as a node under Global Definitions. This can be done, for example, via the Developer tab on the ribbon by clicking on Settings Form and choosing the respective form. When selected in the Model Builder, the form is then displayed in the Settings window, and there you can access your most relevant parameters. Please note that any data change, either in the form or in the parameter node, is always synchronized.

A screenshot showing the parameter control form added to the COMSOL Multiphysics®.
The parameter control form added to the Model Builder. In the settings, you can now centrally overview and control your most important settings.

Concluding Remarks on Controlling Parameters in COMSOL®

You have learned about the different features for working efficiently with parameters. The features dealing with parameters allow you to accelerate the setting up of your models, leading to a streamlined workflow and thus faster results.

In addition, you can quickly build forms to help you organize and control your parameters. To do so, the blog post showcased the functionality of the Application Builder, which is transforming COMSOL Multiphysics into a versatile development tool for simulations with extended possibilities. By using forms and methods, you can automate almost any pre- or postprocessing step as well as control all settings in the model tree. Both can be added under Global Definitions.

Next Step

Learn more about how COMSOL Multiphysics can suit your modeling needs by contacting us for a software evaluation:


Comments (1)

Leave a Comment
Log In | Registration
Loading...
Ricardo Pascual
Ricardo Pascual
July 1, 2020

Thanks for the article. This facility is very useful! Do you have a video/printed tutorial of this?

ricardo.pascual@csiro.au

EXPLORE COMSOL BLOG