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 step dependent on a variable

Please login with a confirmed email address before reporting spam

Hello, I am currently dealing withabout the storage of time steps in time-dependent simulations. In my model, charging and uncharging processes occur. The beginning and end of the phases are controlled by the "event" physics and depend on the value of a variable. Unfortunately, the duration of the phases differs (the charging phase are about 1h, the discharging about 1min). For this reason, the time-dependent solver only works if I specify a small maximum time step of 20 seconds.As a result, the calculation takes much longer than it should and unnecessary data is stored.

Is there therefore a way to set up the time steps to be saved/calculated depending on a variable?

Thanks Stefanie


4 Replies Last Post Oct 7, 2019, 2:57 p.m. EDT
Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 5 years ago Oct 4, 2019, 6:11 a.m. EDT

Stefanie,

you may consider to run two time dependent study steps in a sequence with adapted time stepping settings. The second step taking the result of the first step as the initial condition.

Cheers Edgar

-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Stefanie, you may consider to run two time dependent study steps in a sequence with adapted time stepping settings. The second step taking the result of the first step as the initial condition. Cheers Edgar

Henrik Sönnerlind COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 years ago Oct 4, 2019, 9:27 a.m. EDT
Updated: 5 years ago Oct 4, 2019, 9:32 a.m. EDT

Hi,

Maybe you can use Maximum step constraint = Expression and Times to store = Steps taken by solver

As expression you use something related to the expression that triggers the event. A potential problem is that if the solver takes very small time steps somewhere for numerical reasons, you can get a lot of solutions stored.

If the amount of data you generate is a problem, take a look at Store time derivatives, Store reaction forces, and maybe even not storing results for the whole model (Store fields in ouput)

Regards,
Henrik

-------------------
Henrik Sönnerlind
COMSOL
Hi, Maybe you can use **Maximum step constraint** = **Expression** and **Times to store** = **Steps taken by solver** As *expression* you use something related to the expression that triggers the event. A potential problem is that if the solver takes very small time steps somewhere for numerical reasons, you can get a lot of solutions stored. If the amount of data you generate is a problem, take a look at **Store time derivatives**, **Store reaction forces**, and maybe even not storing results for the whole model (**Store fields in ouput**) Regards, Henrik

Please login with a confirmed email address before reporting spam

Posted: 5 years ago Oct 7, 2019, 2:45 a.m. EDT

Thank you both,

to separate the simulation in multiple steps was not possible, because the time steps respectively the end time do not change during the step.

To use an expression as an maximum step has speeded up the simulation by a factor of 2.5. But the stored time steps is almost the same due to very small time steps when switching between the processes. My main problem here is not the memory space (the models are about 2GB large), but that the evaluation with derived values. This takes more than half an hour due to several integrations over the entire model.

Would it be possible to keep the "Steps taken by solver" setting, but to define a minimum time step to be stored?

Regards Stefanie

Thank you both, to separate the simulation in multiple steps was not possible, because the time steps respectively the end time do not change during the step. To use an expression as an maximum step has speeded up the simulation by a factor of 2.5. But the stored time steps is almost the same due to very small time steps when switching between the processes. My main problem here is not the memory space (the models are about 2GB large), but that the evaluation with derived values. This takes more than half an hour due to several integrations over the entire model. Would it be possible to keep the "Steps taken by solver" setting, but to define a minimum time step to be stored? Regards Stefanie

Henrik Sönnerlind COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 years ago Oct 7, 2019, 2:57 p.m. EDT

Hi Stefanie,

If you have a reasonable idea about when the event is triggered, you can use Times to store = Specified values and then use two range expressions for the time step, like

range(0, long_step, it_will_soon_happen) range(it_will_soon_happen + short_step, short_step, end_time)

Regards,
Henrik

-------------------
Henrik Sönnerlind
COMSOL
Hi Stefanie, If you have a reasonable idea about when the event is triggered, you can use **Times to store** = **Specified values** and then use two range expressions for the time step, like range(0, long_step, it_will_soon_happen) range(it_will_soon_happen + short_step, short_step, end_time) Regards, Henrik

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.