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.

Is it possible to intervene in the parameteric sweep of time-dependent solver?

Please login with a confirmed email address before reporting spam

Hi there,

I want to model the evolution of structure configuration toward its steady state under various specific parameter combinations and given initial conditions.

The problem is that the period from the initial condition to the steady state is unknown before modeling. For now, I use the parameteric sweep of time-dependent solver and specify a shared pretty long time period Ttotal to each of the time-dependent study. After a trial run, I find that for some parameter combinations, the steady state has already been reached far before Ttotal, while for some other parameter combinations, the steady state has not been reached yet.

So, I was wondering if it is possible (maybe through scripts) to intervene in the parameteric sweep of time-dependent solver, so that when a customized criterion (such as energy convergence) is satisfied, comsol can stop the calculation of current parameter combination and start to the next combination, automatically.

Best, HC L


8 Replies Last Post 02.05.2024, 22:57 GMT-4
Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 7 months ago 17.04.2024, 03:44 GMT-4

Check the options of the Events interface. You find it under Physics->Mathematics->ODE and DAE Interfaces.

Cheers Edgar

-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Check the options of the Events interface. You find it under Physics->Mathematics->ODE and DAE Interfaces. Cheers Edgar

Please login with a confirmed email address before reporting spam

Posted: 7 months ago 29.04.2024, 21:08 GMT-4

Thank you @Edgar for your suggestion.

Indeed, the Events interface provides a useful tool to solve my problem.

After check the related knowledge base, presumably, I need to drop the parametric sweep node and only use a single time dependent study step, instead. During the time-dependent modeling, the parameters, such as boundary displacement, will be changed upon the trigger of events.

Following this idea, to employ the event interface, the variance of strain energy Us is denoted by Usvary. When Usvary is smaller than a given tolerance Ustol, Us is deemed to be constant. In other words, the system converges to its steady state, and the event should be triggered. Usflag is defined as Usvary-Ustol under the 'indicator states 1' node.The table below gives the values of variables near the sign change of Usvary-Ustol. It's shown that the value of Usvary-Ustol do changes its sign from >0 to <0, but Usflag doesn't change. Therefore, the event cannot be triggered. I try to assgin 1e-8 to the 'event tolerance' under 'Solver Configurations-->Time-Dependent Solver', but it doesn't work. Moreover, I change the definition of Usflag as Usvary/Ustol-1. Similary table can be given below. It seems Usvary always takes 0 under the 'indicator states 1' node when evaluate Usflag, leaving a constant Usflag. Therefore, the event cannot be triggered. Thus, I give it another shot and directly use the expression '(Usvary/Ustol-1)<0' as the condition under the 'implicit event 1' node, instead of 'Usflag<0'. It doesn't work, neither.

Besides, How to terminate the time-dependent solver when the final event is triggered? For example, the original swept parameter is the boundary displacement ub. Every time an event is triggered, ub will increase by a prescribed step, until that ub reaches its final value, ubf. After reaches steady state under ubf, the modeling should be terminated.

Thank you so much for your reading. I would appreciate it if you could give me some hints.

Best regard

HC. Liu

Check the options of the Events interface. You find it under Physics->Mathematics->ODE and DAE Interfaces.

Cheers Edgar

Thank you @Edgar for your suggestion. Indeed, the Events interface provides a useful tool to solve my problem. After check the related [knowledge base](https://www.comsol.com/support/knowledgebase/1245), presumably, I need to drop the parametric sweep node and only use a single time dependent study step, instead. During the time-dependent modeling, the parameters, such as boundary displacement, will be changed upon the trigger of events. Following this idea, to employ the event interface, the variance of strain energy Us is denoted by Usvary. When Usvary is smaller than a given tolerance Ustol, Us is deemed to be constant. In other words, the system converges to its steady state, and the event should be triggered. **Usflag is defined as Usvary-Ustol under the 'indicator states 1' node**.The table below gives the values of variables near the sign change of Usvary-Ustol. It's shown that **the value of Usvary-Ustol do changes its sign from >0 to Time-Dependent Solver', but it doesn't work. ![](https://img.chkaja.com/898e69a5e3fe5740.jpg) Moreover, I change the definition of Usflag as Usvary/Ustol-1. Similary table can be given below. It seems **Usvary always takes 0 under the 'indicator states 1' node when evaluate Usflag, leaving a constant Usflag.** Therefore, the event cannot be triggered. Thus, I give it another shot and directly use the expression '(Usvary/Ustol-1)Mathematics->ODE and DAE Interfaces. > >Cheers >Edgar

Please login with a confirmed email address before reporting spam

Posted: 7 months ago 30.04.2024, 06:11 GMT-4

Check the options of the Events interface. You find it under Physics->Mathematics->ODE and DAE Interfaces.

Cheers Edgar

Thank you @Edgar for your advice.

I think event interface could be the solution. Some questions (posted in this thread) are encountered when using event interface.

I would appreciate it if you could give some more hints.

Best regards,

HC Liu

>Check the options of the Events interface. You find it under Physics->Mathematics->ODE and DAE Interfaces. > >Cheers >Edgar Thank you @Edgar for your advice. I think event interface could be the solution. Some questions (posted in [this thread](https://www.comsol.com/forum/thread/338851/how-to-define-indicator-states-in-event-interface-using-solution-of-previous-ste)) are encountered when using event interface. I would appreciate it if you could give some more hints. Best regards, HC Liu

Henrik Sönnerlind COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 months ago 30.04.2024, 08:25 GMT-4

A possible simpler solution could be to add a Stop Condition node under Time-Dependent Solver. Then, you could use a stop criterion based on the time derivative of something, like

(t>1E-3)&&(abs(d(comp1.solid.Ws_tot,t))<200)

-------------------
Henrik Sönnerlind
COMSOL
A possible simpler solution could be to add a **Stop Condition** node under **Time-Dependent Solver**. Then, you could use a stop criterion based on the time derivative of something, like (t>1E-3)&&(abs(d(comp1.solid.Ws_tot,t))

Please login with a confirmed email address before reporting spam

Posted: 7 months ago 30.04.2024, 11:01 GMT-4

A possible simpler solution could be to add a Stop Condition node under Time-Dependent Solver. Then, you could use a stop criterion based on the time derivative of something, like

(t>1E-3)&&(abs(d(comp1.solid.Ws_tot,t))

Thank you so much @Henrik. 'Stop condition' exactly solves the problem.

>A possible simpler solution could be to add a **Stop Condition** node under **Time-Dependent Solver**. Then, you could use a stop criterion based on the time derivative of something, like > >(t>1E-3)&&(abs(d(comp1.solid.Ws_tot,t)) Thank you so much @Henrik. 'Stop condition' exactly solves the problem.

Please login with a confirmed email address before reporting spam

Posted: 7 months ago 01.05.2024, 04:17 GMT-4
Updated: 7 months ago 01.05.2024, 08:30 GMT-4

A possible simpler solution could be to add a Stop Condition node under Time-Dependent Solver. Then, you could use a stop criterion based on the time derivative of something, like

(t>1E-3)&&(abs(d(comp1.solid.Ws_tot,t))

Hi Henrik,

Another question occurs. After the parametric sweep, I try to access the results of the last timestep under each parameter value through matlab commands like 'strain=mphevalpoint(model,{'ee'},"dataset","dset2",'outersolnum','all','selection',2,'t',Trelax)', where Trelax is the end step time at each parameter value.

'Stop Condition' makes Trelax an unknow variable. I try to use commands like 'strain=mphevalpoint(model,{'ee'},"dataset","dset2",'outersolnum','all','selection',2,'solnum','end')'. It causes error like

Invalid property value. - Property: solnum (Time)

'Time' is an array of integers. - : "1", "2", "3", "4"

Is there any way to circumvent?

Best regards,

HCL

>A possible simpler solution could be to add a **Stop Condition** node under **Time-Dependent Solver**. Then, you could use a stop criterion based on the time derivative of something, like > >(t>1E-3)&&(abs(d(comp1.solid.Ws_tot,t)) Hi Henrik, Another question occurs. After the parametric sweep, I try to access the results of the last timestep under each parameter value through matlab commands like 'strain=mphevalpoint(model,{'ee'},"dataset","dset2",'outersolnum','all','selection',2,**'t',Trelax**)', where Trelax is the end step time at each parameter value. **'Stop Condition' makes Trelax an unknow variable**. I try to use commands like 'strain=mphevalpoint(model,{'ee'},"dataset","dset2",'outersolnum','all','selection',2,**'solnum','end'**)'. It causes error like > Invalid property value. > - Property: solnum (Time) > 'Time' is an array of integers. > - : "1", "2", "3", "4" Is there any way to circumvent? Best regards, HCL

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 months ago 02.05.2024, 08:10 GMT-4

Hi HCL

I can't find a model that reproduces your problem. Some of our wrapper functions do not work well with parametric sweeps where the number of returned values (e.g. times or solnum) vary accross the parametric sweep.

Try this: for i=1:number_of_outer_solnums strain(i)=mphevalpoint(model,{'ee'},"dataset","dset2",'outersolnum',i,'selection',2,'solnum','end') end

If that doesn't work for you send please send your model to support@comsol.com and mention my name.

-------------------
Lars Gregersen
Comsol Denmark
Hi HCL I can't find a model that reproduces your problem. Some of our wrapper functions do not work well with parametric sweeps where the number of returned values (e.g. times or solnum) vary accross the parametric sweep. Try this: for i=1:number_of_outer_solnums strain(i)=mphevalpoint(model,{'ee'},"dataset","dset2",'outersolnum',i,'selection',2,'solnum','end') end If that doesn't work for you send please send your model to support@comsol.com and mention my name.

Please login with a confirmed email address before reporting spam

Posted: 7 months ago 02.05.2024, 22:57 GMT-4

Hi HCL

I can't find a model that reproduces your problem. Some of our wrapper functions do not work well with parametric sweeps where the number of returned values (e.g. times or solnum) vary accross the parametric sweep.

Try this: for i=1:number_of_outer_solnums strain(i)=mphevalpoint(model,{'ee'},"dataset","dset2",'outersolnum',i,'selection',2,'solnum','end') end

If that doesn't work for you send please send your model to support@comsol.com and mention my name.

Thank you @Lars for your advice! It works!

Best regards,

HCL

>Hi HCL > >I can't find a model that reproduces your problem. Some of our wrapper functions do not work well with parametric sweeps where the number of returned values (e.g. times or solnum) vary accross the parametric sweep. > >Try this: >for i=1:number_of_outer_solnums >strain(i)=mphevalpoint(model,{'ee'},"dataset","dset2",'outersolnum',i,'selection',2,'solnum','end') >end > >If that doesn't work for you send please send your model to support@comsol.com and mention my name. Thank you @Lars for your advice! It works! Best regards, HCL

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.