Using the Previous Solution Operator in Transient Modeling
COMSOL Multiphysics version 5.1 includes a Previous Solution operator within time-dependent studies. This operator allows you to evaluate quantities at the previous time step when using the default implicit time-stepping algorithm. Let us take a look at how this operator is implemented and then examine how it can be used for various modeling needs.
Transient Modeling and Time-Stepping
When you are solving a transient model, the COMSOL software by default uses an implicit time-stepping algorithm with adaptive time step size. This has the advantage of being unconditionally stable for many classes of problems and it lets the software choose the optimal time step size for the specified solver tolerances, thereby reducing the computational cost of the solution.
Two classes of time-stepping algorithms are available: a backward difference formula (BDF) and a generalized-alpha method. These algorithms use the solutions at several previous time steps (up to five) to numerically approximate the time derivatives of the fields and to predict the solution at the next time step.
However, these previous solutions are not by default accessible within the model. The Previous Solution operator makes the solution at the previous time step available as a field variable in the model. This Previous Solution operator is available for both transient as well as stationary problems solved using the continuation method. Let us take a look at how you can implement and use this Previous Solution operator in a transient model in COMSOL Multiphysics.
Implementing the Previous Solution Operator in COMSOL Multiphysics
Using the Previous Solution operator requires only two additional features within the model tree. You must add an ODE and DAE interface to store the fields that you are interested in and you must add the Previous Solution feature to the Time-Dependent Solver. Let us take a look at the implementation in terms of a transient heat transfer example: The laser heating of a wafer with a moving heat load, solved on a rotating coordinate system.
The first step is to add a Domain ODEs and DAEs interface to the model, since we will be interested in tracking the solution at the previous time step throughout the volume of the part. If we were only interested in the previous solution across a boundary, edge, or point, or in some global quantity, we could also use a Boundary, Edge, Point, or Global ODEs and DAEs interface.
The Domain ODEs and DAEs interface for tracking the solution at the previous time step.
The screenshot above shows the relevant settings for the Domain ODEs and DAEs interface. Note that the units of both the dependent variable and the source are set to Temperature. It is a good modeling practice to appropriately set units. The discretization is set to a Lagrange Quadratic, which matches the discretization used by the Heat Transfer in Solids interface. You will always want to make sure that you are using the appropriate discretization. The name of the field variable here is left at the default “u”, although you can rename it to anything you would like.
The equation being solved by the Domain ODEs and DAEs interface.
The screenshot above shows the equation that stores the temperature solution at the previous time step. This equation can be read as:
nojac() operator is needed, since we do not want this equation to contribute to the Jacobian (the system matrix). Lastly, we need to specify that this equation should be evaluated at the previous time step. This is done within the Solver Configurations.
The Previous Solution feature added to the Solver Configuration.
The screenshot above shows the Previous Solution feature added to the Time-Dependent Solver. Once you add this feature, simply select the appropriate field variable to be evaluated at the previous time step. It will also be faster (although not necessary) to use the Segregated Solver rather than the Fully Coupled solver.
And that is all there is to it. You can now solve the model just as you usually do and you will be able to evaluate the temperature at the previous computational time step.
A More Practical Example: Keeping Track of the Maximum Temperature
Of course, having the solution at the previous time step isn’t really all that interesting in itself, but we can do quite a bit more than just store this solution. For example, we can apply logical expressions directly with the ODEs and DAEs equation interface. Consider the equation:
This equation can be read as: “If the temperature at the previous time step is greater than u, set u equal to temperature. Otherwise, leave u unchanged.”
That is, it stores the maximum temperature reached at the previous time step at every point in the modeling domain. You can now evaluate the variables T and u at any point in the model to get both the temperature over time and the maximum temperature attained. To get the maximum temperature, you will want to take the maximum of the temperature at the previous time step and the temperature at the current time step, so you can introduce a variable in the model:
MaxTemp = max(T,u)
This will return the maximum temperature up to that time as shown in the plot below.
Temperature at a point plotted over time. The variable MaxTemp is also plotted and shows the maximum temperature reached up to that instant in time.
We have shown here the implementation of the newly introduced Previous Solution operator for time-dependent models. The three steps to use this functionality appropriately are:
- Choose the appropriate ODEs and DAEs interface and discretization.
- Enter an appropriate equation.
- Add the Previous Solution feature to the Solver Configurations.
We have shown how to evaluate the maximum temperature in this example, but there is a great deal more that can be done with this functionality, so stay tuned!
- COMSOL Now
- Fluid & Heat
- Structural & Acoustics
- Today in Science