Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Time-stepping

Please login with a confirmed email address before reporting spam

Hi,

I would like to run some simulations which use an exponential time step, and I have figured out how to set that in my "range" of solutions shown, but I was also wondering if there was a way to have more than one "Max time step" (within the solver) over the course of the simulation. In other words, when running the earlier phases I don't want the time step within COMSOL to be too large (maybe around 10-30 seconds), but later when I am looking at jumps of weeks at a time, I would want a much larger jump (maybe around an hour) to avoid having simulations which take forever to run. Is this possible? Can I set it so that as the jumps in my set range increase, the time step used by COMSOL also increases?

Thanks,
Shoshana

10 Replies Last Post Dec 6, 2015, 9:23 p.m. EST

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Nov 28, 2014, 4:03 a.m. EST
Will this do?

10^{range(-3,0.1,1)},10^{range(1,0.5,5)}

br
Lasse
Will this do? 10^{range(-3,0.1,1)},10^{range(1,0.5,5)} br Lasse

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Nov 30, 2014, 3:02 a.m. EST
Hi Lasse,

Thanks, that is helpful - I think I may try something like that for my viewed time steps.

Now the question is in terms of setting the maximum - if I do two separate ranges, as you suggested, then can I similarly write two separate maximum time step values (say 0.1, 10) and will it then know to use 0.1 as the maximum time step for my first range and 10 as the maximum time step for my second range?

On a related note, is there any way to actually see what time steps were used within the solver? As in, just because I say that 10 seconds is the max time step I'll allow may not mean that every single time step it uses will be exactly 10 seconds, does it? Is there any way for me to output the values of the time steps, just so I have a sense of how many steps it used in solving?

Thanks for the help!
Shoshana
Hi Lasse, Thanks, that is helpful - I think I may try something like that for my viewed time steps. Now the question is in terms of setting the maximum - if I do two separate ranges, as you suggested, then can I similarly write two separate maximum time step values (say 0.1, 10) and will it then know to use 0.1 as the maximum time step for my first range and 10 as the maximum time step for my second range? On a related note, is there any way to actually see what time steps were used within the solver? As in, just because I say that 10 seconds is the max time step I'll allow may not mean that every single time step it uses will be exactly 10 seconds, does it? Is there any way for me to output the values of the time steps, just so I have a sense of how many steps it used in solving? Thanks for the help! Shoshana

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 1, 2014, 3:42 a.m. EST
Hi

The solver log contains info about the actual steps taken so that the solver can reach convergence. Also the convergence plot shows the inverse of the steps. Steps you define are the points where the solution is stored, but you can interpolate into any time point in post-processing. I guess that in the Range definition the second number is the maximum step taken. But this I do not know for sure.

Lasse
Hi The solver log contains info about the actual steps taken so that the solver can reach convergence. Also the convergence plot shows the inverse of the steps. Steps you define are the points where the solution is stored, but you can interpolate into any time point in post-processing. I guess that in the Range definition the second number is the maximum step taken. But this I do not know for sure. Lasse

Henrik Sönnerlind COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 1, 2014, 4:48 a.m. EST
Hi Shoshana,

You cannot change the maximum time step within one study step. If it is really important, you can use several study steps, where each new study step takes the results from the previous study step as initial conditions.

A question to ask if it seems like you need to manually control the maximum time step, is "Are my convergence criteria tight enough, and are my variables appropriately scaled?".

The automatic time stepping in the solver should in most cases be able to see that something interesting is happening, and adjust the time step based on that. This will be more efficient, since the time step is kept short only when necessary.

Regards,
Henrik
Hi Shoshana, You cannot change the maximum time step within one study step. If it is really important, you can use several study steps, where each new study step takes the results from the previous study step as initial conditions. A question to ask if it seems like you need to manually control the maximum time step, is "Are my convergence criteria tight enough, and are my variables appropriately scaled?". The automatic time stepping in the solver should in most cases be able to see that something interesting is happening, and adjust the time step based on that. This will be more efficient, since the time step is kept short only when necessary. Regards, Henrik

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 1, 2014, 5:00 a.m. EST
Hi Henrik,

This is very helpful, thanks! In my case I will want to see results by the hour, or maybe even minute, in the earlier phases, and later will only be interested in much larger changes in time (weeks, months). For those later parts, I can have internal time steps as large as a half a day or a day at a time, but of course this would not be possible when looking at hours. Will COMSOL know not to jump by an hour at a time when I'm looking at 2 vs. 4 hours? Will it automatically do at least a certain number of steps between points of interest? Is there any way to additionally set a minimum number of steps between points of interest? Just want to make sure I'm not losing too much accuracy, while still running manageable simulations.

Thanks for the help!
Shoshana
Hi Henrik, This is very helpful, thanks! In my case I will want to see results by the hour, or maybe even minute, in the earlier phases, and later will only be interested in much larger changes in time (weeks, months). For those later parts, I can have internal time steps as large as a half a day or a day at a time, but of course this would not be possible when looking at hours. Will COMSOL know not to jump by an hour at a time when I'm looking at 2 vs. 4 hours? Will it automatically do at least a certain number of steps between points of interest? Is there any way to additionally set a minimum number of steps between points of interest? Just want to make sure I'm not losing too much accuracy, while still running manageable simulations. Thanks for the help! Shoshana

Henrik Sönnerlind COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 1, 2014, 7:36 a.m. EST
Hi Shoshana,

You cannot force the solver to take a certain number of steps between the output times. But since the time stepping is internally controlled by an error estimate, it will take several steps, unless the solution is more or less linear in time.

When the solution is very smooth, the internal time step can actually be significantly larger than the requested output times. The output will then just be a series of interpolations between the time points actually solved for.

By using the 'Steps Taken by Solver' control, you can to some extent adjust the behavior of the time stepping, but you cannot force more than one solver step per output step. From User Guide:

Steps Taken by Solver

To modify how the time-stepping methods select the time steps, choose an option from the Steps taken by solver list. Select:

• 'Free' to let the time-stepping method choose time steps freely. The times specified in the Times field in the General section are not considered when a time step is chosen.

• 'Intermediate' to force the time-stepping method to take at least one step in each subinterval of the times specified in the Times field in the General section.

• 'Strict' to force the time-stepping method to take steps that end at the times specified in the Times field in the General section. The solver takes additional steps in between these times if necessary.

The bottom line is: If possible. try to use good tolerance settings, and let the solver decide the time steps.

Regards,
Henrik
Hi Shoshana, You cannot force the solver to take a certain number of steps between the output times. But since the time stepping is internally controlled by an error estimate, it will take several steps, unless the solution is more or less linear in time. When the solution is very smooth, the internal time step can actually be significantly larger than the requested output times. The output will then just be a series of interpolations between the time points actually solved for. By using the 'Steps Taken by Solver' control, you can to some extent adjust the behavior of the time stepping, but you cannot force more than one solver step per output step. From User Guide: Steps Taken by Solver To modify how the time-stepping methods select the time steps, choose an option from the Steps taken by solver list. Select: • 'Free' to let the time-stepping method choose time steps freely. The times specified in the Times field in the General section are not considered when a time step is chosen. • 'Intermediate' to force the time-stepping method to take at least one step in each subinterval of the times specified in the Times field in the General section. • 'Strict' to force the time-stepping method to take steps that end at the times specified in the Times field in the General section. The solver takes additional steps in between these times if necessary. The bottom line is: If possible. try to use good tolerance settings, and let the solver decide the time steps. Regards, Henrik

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 1, 2014, 7:41 a.m. EST
Hi Henrik,

Good to know, thanks! In other words, the internal time steps will be as large as they can be within my allowed maximum, and within the level of accuracy I set based on tolerance. That makes sense - this should definitely help.

Thanks so much for your help, I really appreciate it!
Shoshana
Hi Henrik, Good to know, thanks! In other words, the internal time steps will be as large as they can be within my allowed maximum, and within the level of accuracy I set based on tolerance. That makes sense - this should definitely help. Thanks so much for your help, I really appreciate it! Shoshana

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 1, 2014, 2:27 p.m. EST
Hi Shoshana

"... the internal time steps will be as large as they can be within my allowed maximum ..."

this applies ONLY if you select "Intermediate" or "Strict".
In the default "Free" stepping mode, the solver MIGHT take steps LARGER than yours !
and then interpolate as Henrik explains

I normally leave the default for diffusion type equations (if I do not use a 2^range(-4,1,4) power series, or a 10^range(,,) power series)
but for periodic or pulse type boundary conditions, I mostly select "Intermediate" or "Strict" stepping mode

--
Good luck
Ivar
Hi Shoshana "... the internal time steps will be as large as they can be within my allowed maximum ..." this applies ONLY if you select "Intermediate" or "Strict". In the default "Free" stepping mode, the solver MIGHT take steps LARGER than yours ! and then interpolate as Henrik explains I normally leave the default for diffusion type equations (if I do not use a 2^range(-4,1,4) power series, or a 10^range(,,) power series) but for periodic or pulse type boundary conditions, I mostly select "Intermediate" or "Strict" stepping mode -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 2, 2014, 2:03 a.m. EST
Hi Ivar,

Thanks for clarifying! I will be sure to keep that in mind.

Best,
Shoshana
Hi Ivar, Thanks for clarifying! I will be sure to keep that in mind. Best, Shoshana

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Dec 6, 2015, 9:23 p.m. EST
Hi,
I too have a doubt regarding time stepping. I am trying to model a time dependant thermal expansion of a metal sphere.
I tried both free and strict time steps (both generalized alpha) and visualized the thermal expansion volume change. But both of them are giving me entirely different results.
While using free, the metal expands and goes back to normal only after shrinking a bit in size very quickly and with a sudden fluctuation. But the same study does not converge if I check the nearly incompressible box true in solid mechanics module.
At the same time if I use strict time steps, it gives solution as if the metal was incompressible without shrinking even without checking incompressible box true. Here the volume settles in to original volume in time.
Could anyone clarify why the physics changes considerably and how to verify which one of them is true?
Hi, I too have a doubt regarding time stepping. I am trying to model a time dependant thermal expansion of a metal sphere. I tried both free and strict time steps (both generalized alpha) and visualized the thermal expansion volume change. But both of them are giving me entirely different results. While using free, the metal expands and goes back to normal only after shrinking a bit in size very quickly and with a sudden fluctuation. But the same study does not converge if I check the nearly incompressible box true in solid mechanics module. At the same time if I use strict time steps, it gives solution as if the metal was incompressible without shrinking even without checking incompressible box true. Here the volume settles in to original volume in time. Could anyone clarify why the physics changes considerably and how to verify which one of them is true?

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.