How to Manage Multiple Solutions in COMSOL Multiphysics®
If you’re looking for ways to manage multiple solutions, version 5.3 of the COMSOL Multiphysics® software offers several new tools for doing so. These include options for combining two solutions into one; storing solutions in different data sets so that they can be postprocessed and analyzed individually; and joining solutions to, for example, compare them. In this blog post, we will look at how to use these new tools.
Combining Solutions via Concatenation and Summation
Let’s say that we want to run a time-dependent simulation in two steps:
- From the starting time to an intermediate time
- From the intermediate time to an ending time
Further, let’s say that in the second time-dependent study step, we make some changes to the physics that represent a change in the conditions for the simulated device at the intermediate time. However, when postprocessing the results, we want to treat the output from the two study steps as a single continuous time-dependent solution.
We can achieve such a combined solution using the Combine Solutions study step, which is new in version 5.3 of COMSOL Multiphysics®. The Combine Solutions study step makes it possible to concatenate two solutions created in other study steps in the model. As an alternative to the concatenation of solutions (time-dependent or parametric solutions, for example), it is also possible to use summations to combine solutions (such as creating a solution that is the sum of various eigenmodes).
Example: Combining Two Time-Dependent Simulations
As an example of a concatenated solution, let’s look at the Axisymmetric Transient Heat Transfer example model. This model shows how a cylindrical object heats up when the temperature on its exterior boundaries changes from 0°C to 1000°C at the start of the simulation, which runs for 190 s.
Let’s see what happens if we add another time-dependent study step, which starts at 190 s where the boundaries are instead thermally insulated. To combine the two time-dependent simulations, a Combine Solutions study step provides a concatenation of the first and second study step. (In the settings, the second study step is called the Current solution, as it’s the solution computed in the step just above Combine Solutions.)
As a reference, we add a third time-dependent study step, which demonstrates that the heating of the boundaries continues uninterrupted during the time space of the two combined solutions. The study now contains the study steps shown below.
The study steps for a combined solution and a reference solution with only heating.
In the Settings window for the Combine Solutions study step, we specify the study steps to concatenate.
In the settings for the Combine Solutions study step, we can choose the type of solution operation and the solutions to combine.
When we compute the study, the study steps create corresponding solvers and Solution Store nodes in the solver configuration and also solution data sets for analyzing the results from the solvers. The data sets and corresponding solver configuration are shown below.
The data sets (left) and solver configuration (right). The top data set refers to the output from the third and final time-dependent study step.
In addition, we add the following data sets:
- A Revolution 2D data set to visualize the 2D axisymmetric solution in a corresponding 3D cylindrical geometry
- Two Cut Point 2D data sets to evaluate and plot a graph of the temperature in a reference location
- One of these data sets refers to the concatenated solution
- The other refers to the continuous solution
- A Join data set to evaluate and plot the difference between the concatenated solution and continuous solution
The following plot shows the temperature versus time for the concatenated solution, where heating is replaced by insulation after 190 s, and the continuous solution, where the heating continues during the time span of the entire simulation.
The concatenated solution (pink, solid) and the continuous solution (black, dashed). As expected, the temperature increase slows down when insulation is added.
Using a Join data set, we can plot the temperature difference between the two solutions. Until the point in time when insulation is added, the temperatures are the same, as expected.
Temperature difference between the two solutions.
The temperature distribution in the full 3D geometry is available using the Revolve 2D data set.
Temperature distribution in a segment of the full 3D geometry at the end of the continuous simulation.
Running a Simulation Multiple Times and Storing the Solutions in Different Data Sets
Another case where it is of interest to manage multiple solutions is when we run a simulation multiple times (with some variation in the model or settings) and want to postprocess and analyze the results from each run.
After computing an initial instance of the model, we right-click the Solver Configurations node in the study and choose Create Solution Copy to make a Solution – Copy solution and a corresponding data set available for our current solution (pointing to the Solution – Copy solution node under Solver Configurations).
When we then recompute with changes to the model or solver settings, the new solution is available through the original Solution data set, so that we can postprocess and evaluate both solutions by pointing to one of the two data sets (we can extend this approach to create additional solutions). We can also use a Join data set to combine solutions from two different Solution data sets (as a difference, for example).
Another option for creating additional Solution data sets is to right-click a Solution data set and choose Duplicate (or press Ctrl+Shift+D). The difference between this and the Solution Copy operation is that a duplicated Solution data set does not create a new solution and, by default, refers to the same solution as the original data set. For instance, we can use a duplicated data set to add a Selection node, if it is of interest to postprocess the solution in only a part of the model geometry. As of the latest version of COMSOL Multiphysics, Selection nodes are also available for most plot types in the plot groups. This enables us to directly hide boundaries for specific plots without having to create a separate data set, for example.
Example: Multiple Solutions for a Wrench Model
To illustrate these concepts, let’s open the Stresses and Strains in a Wrench example model.
One option is to use a parametric sweep or load case to investigate the stresses and deflections in the wrench for various forces applied as a boundary load at the end of the wrench. But let’s see what happens if the load’s direction is reversed so that the wrench is pulled upward (instead of pressed downward as it is in the example model from the Application Gallery). We can then store the original solution using a solution copy so that both cases can be postprocessed and analyzed individually.
To verify that the stresses are close to zero for a difference between the two cases, we also add a Join data set that contains the difference between the two solutions. By duplicating the original solution data set twice, we create two additional solution data sets — one for the wrench only and one for the bolt only — using Selection nodes. The model then contains the data sets shown below.
The wrench model’s data sets for comparing the two cases and for postprocessing using only the wrench and only the bolt.
The Solution data set on the left refers to the latest computed solutions; that is, the case where the load is reversed. The other Solution data set contains a copy of the first solution; that is, the cases with the original load direction.
The solution with a load acting upward (left) and the original solution, with a load acting downward (right).
The Join data set provides the difference between the two solutions above.
The difference in effective stresses is close to zero, evaluated using a Join data set.
The last two Solution data sets restrict the original solution to the bolt only and to the wrench only, defined by selections of boundaries that represent the bolt and the wrench, respectively.
Results for the wrench only (left) and the bolt only (right). These plots use data sets with applied selections.
It is now possible to analyze and plot the results in a flexible way for both load cases: for the difference between those solutions and for individual parts of the model’s geometry.
Concluding Thoughts on How to Manage Multiple Solutions in COMSOL Multiphysics®
These examples illustrate some of the flexible and powerful options that are available in version 5.3 of the COMSOL Multiphysics® software. The options for concatenating, using summations, and copying solutions make it possible to combine solutions for easier postprocessing as well as to store and analyze multiple solutions for different variants of a model. The options for duplicating and joining data sets make it possible to compare solutions and to visualize aspects of the same solution, perhaps for a certain part of the model. These tools are generally applicable and useful in many cases beyond what we have shown here.
- Learn more about Join data sets in this blog post: Solution Joining for Parametric, Eigenfrequency, and Time-Dependent Problems
- To get started with managing multiple solutions, download the tutorial models featured in this blog post:
- See other new features and functionality in COMSOL Multiphysics® version 5.3 on the Release Highlights page
- COMSOL Now
- Today in Science
- COMSOL Now
- Today in Science