
Science SPORE Prize
November 2011

The Open Source Physics Project is supported by NSF DUE-0442581.
|
Modeling Tips & Help
post and replies
Return to the Modeling Tips & Help thread
Login to post to this thread
|
automatically stop a simulation
- Feb 2, 2012 at 11:10PM
|
mos
1 Posts
|
Hi,
Is there any way to define a final time for automatically stop a simulation when the simulation time reaches it?
Thank you in advance
|
|
Re: automatically stop a simulation - Feb 03 2012 6:45AM
|
Francisco Esquembre
72 Posts
|
Hi Mos,
If the model is based on an differential equation, then add an event with Zero condition: return t - yourLimit;
where t is the time variable and yourLimit the maximum you want.
As action, enter: _pause();
This will stop (_pause()) your simulation exactly at that time.
Notice that, if the event is of the "State event" type, you should not continue playing it. If you want to allow the user to continue playing, set the event type to be "Zero crossing".
If the model is not based on an ODE, then you need to add to your Evolution page the code if (t>=yourLimit) _pause();
This will pause your simulation whenever t reaches or exceeds yourLimit. (numerical round errors permit).
Cheers,
Paco
|
|