Problem Description

I am solving a transient model and changed the stepsize in the Times: field in the Study Settings, but the solver is still taking exactly the same timesteps. It seems the timesteps that the solver is taking are not related to the times that I have specified. Why is this?

I increased the total timespan that I am simulating, and now the solver timesteps and results are quite different. Why?

How do I get the solver to take different timesteps?

Solution

The stepsize entry in the Times: field shown in the screenshot below only controls at what times the data is written out. Increasing the number of output timesteps between the start and end time does not by default change the timesteps that the solver actually takes. The software internally uses either an adaptive or fixed timestepping. When using adaptive timestepping, the software estimates an initial timestep based upon the total simulation time, so changing the total simulation time can affect the timesteps and results.

Default settings of the time dependent solver.

Adaptive Timestepping

Most time-dependent problems in COMSOL Multiphysics are by default solved with an adaptive timestepping scheme. This means that the software will automatically adjust the timestep size to maintain the desired Relative Tolerance. The default setting for this is Physics Controlled as shown in the screenshot above. It can also be changed to User Controlled and then you can manually enter a different relative tolerance, as shown in the screenshot below. Lowering the relative tolerance to smaller numbers will result in smaller timesteps, which increases solution accuracy, and solving time.

A user-controlled relative tolerance.

Re-solving the model with a tighter relative tolerance, as well as re-solving with a finer mesh, is how you get the solver to reduce the timestep and verify your model. To gain trust in the results of a transient model, you must compare your model against other models run with finer meshes and finer timesteps. It is important that you do so to verify your model results.

If your model includes loads that are abruptly changing in time, you should also include the Events interface within your model. This will tell the solver how to accurately capture abrupt changes in the solution. For guidance in using Events, see: Knowledge Base 1245: Solving Models with Pulsed Loads in Time

When the solver starts, it estimates an initial timestep size to take based upon the total simulation time. Thus, if you solve the same model twice, for different total times, the initial timestep can be different. This can lead to different results if there is something significant happening immediately after the start time. To specify the initial time step size, go to the Time-Dependent Solver settings, Time Stepping section, enable the Initial step: option and enter a fixed initial step size, as shown in the screenshot below. Note that the software is still free to choose a timestep smaller than this value, but will not make it larger. Also consider if Events can be used instead.

Specifying the initial timestep size that the solver tries to take.

During the solution, the solver will automatically make the timestep smaller as needed to resolve any fast variations in the solution, as needed. It will also make the timestep larger during periods when the solution is only varying gradually. You can control the maximum timestep taken by going to the Time-Dependent Solver settings, Time Stepping section, and change the Maximum step constraint: from its default value of Automatic to either Constant or Expression, as shown in the screenshot below. The Constant option specifies a maximum possible timestep, and the Expression option can make the maximum timestep constraint vary based upon any global expression in the model.

Specifying the maximum possible timestep size that the solver will take.

Manual Timestepping

It is also possible that your model uses a constant timestepping scheme. Some classes of problems, such as transient pressure acoustics models, are solved with a fixed timestep by default. Many wave-type problems (where the solution fields oscillate in time and space) are better solved with a fixed timestep.
To find out if a fixed timestep is being used, go to the Time-Dependent Solver settings, Time Stepping section. There, you will see the method used to compute the solution. This will be either BDF, Generalized alpha, or Runge-Kutta. For a description of these methods, see Knowledge Base 1062: BDF, Generalized Alpha, and Runge-Kutta Methods Below that, you will see a pull-down for the Steps taken by solver, this will be either Free, Intermediate, Strict, or Manual. The Free option lets the solver freely choose the timestep as described above. The Manual timestep option fixes the timestep.

Other Solver Options

There are two other timestepping options: Intermediate and Strict. These modify the behavior of the free timestepping algorithm by forcing the solver to take additional timesteps. With the Intermediate option, the solver will take one additional timestep within each interval between the requested output times, but the solver is still free to choose when this intermediate step occurs. The Strict option forces the solver to take a timestep at exactly the requested output times. Thus, when using either of these options, the requested output times will affect the solver timesteps. These options are rarely used, as they are usually not strongly motivated as compared to tightening the Relative Tolerance, using Events, or setting the Maximum step size, as discussed earlier.

If you want to output the results at the exact timesteps taken by the solver, go to the Time-Dependent Solver settings, Output section, and set the Times to store: to Steps taken by solver, as shown below. Be aware that this option may generate a lot of output data. When the Specified values option is used (the default) the software will write out data at the requested time-points by interpolating between the actual solver timesteps.

Disclaimer

COMSOL makes every reasonable effort to verify the information you view on this page. Resources and documents are provided
for your information only, and COMSOL makes no explicit or implied claims to their validity. COMSOL does not assume any
legal liability for the accuracy of the data disclosed. Any trademarks referenced in this document are the property of
their respective owners. Consult your product manuals for complete trademark details.