解决方法编号: | 1254 |
标题: | Controlling the Time Dependent solver timesteps |
平台: | |
版本: | All versions |
类别: | Solver |
关键字: |
问题描述
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?
解决方法
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.
It is not possible to explicitly control the smallest timestep that the adaptive timestepper takes. When you observe the solver taking very small timesteps this is an indication that your model is approaching a singularity, that the solution is shooting off to infinity, or that the solution is changing faster than is resolvable given the current relative tolerance and mesh size. See also: Knowledge Base 1261: Performing a Mesh Refinement Study, Knowledge Base 1127: Improving convergence in nonlinear time dependent models , and Knowledge Base 1240: Manually Setting the Scaling of Variables.
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.
Switching between the options for the steps taken by the solver.
When using Manual timestepping, you can explicitly set the timestep taken, and the relative tolerance entry no longer affects the solver behavior. For guidance in how to choose the timestep for wave-type problems, see: Knowledge Base 1118: BDF, Resolving time-dependent waves and Knowledge Base 1244: Solving Wave-Type Problems with Step Changes in the Loads
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.
Saving the data at the timesteps taken by the solver.
If you want to reduce the amount of data that is stored in your model, also see: Knowledge Base 1255: Reducing the amount of data stored in a model
免责声明
COMSOL 尽一切合理的努力验证您在此页面上查看的信息。本页面提供的资源和文档仅供参考，COMSOL 对其有效性不作任何明示或暗示的声明。COMSOL 对所披露数据的准确性不承担任何法律责任。本文档中引用的任何商标均为其各自所有者的财产。有关完整的商标详细信息，请参阅产品手册。