APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Code Pages and ODE Pages together post and replies

Return to the Code Pages and ODE Pages together thread
Login to post to this thread

Code Pages and ODE Pages working together
praveen
7 Posts

EJS allows creating multiple code pages and ODE pages, so I have a basic question.

I would like to understand how they would interact:

[1]  If a code page is followed immediately by an ODE page, would the code page work exactly the same as a "Preliminary" code-block attached to the ODE?

[2]   If the above is not true, then what kind of physical problem would be modeled by a code page followed by an ODE? Or a sequence like code-ODE-code-ODE?

Thanks and Best Regards,
Praveen


Replies to Code Pages and ODE Pages working together

Re: Code Pages and ODE Pages working together -
Francisco Esquembre
228 Posts

Praveen,

1) each page is execute after the previous one. From left to right. As if they were successive routines. A normal page is just this, a routine. AnODE page steps the ODE solution by the increment.
No. The code page does not work exactly as a preliminary page. except if you use Euler method.

In all other methods, the solver calls the rate functions more than once, with intermediate steps. What you write in Prelim Code is 'magically' called at each intermediate step to provide the right approximation. If you write the code in a previous normal code page, this is allied only once BEFORE the solving step starts.

2) Well, suppose you have a problem that you can solve both analytically and numerically. You would do the analytic part in a normal code page, the numeric part using the ODE editor. Or you may have two phenomena coexisting in a problem (maybe one continuous, on discrete). For the continuous you can use an ODE, for the discrete you can provide your own algorithm.

Having two ODE pages in the same model is unusual. But having something like code-ODE-code is possible. You may want to do some pre-ode code, and post-ode code.

Paco



Re: Re: Code Pages and ODE Pages working together -
praveen
7 Posts

OK, I think I got it..  thank you!



OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book