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.

Model Inconsistencies post and replies

Return to the Model Inconsistencies thread
Login to post to this thread

Uploaded Model
Emma Osborne
4 Posts

Hi Paco,

The file should be attached. The problem is worse for the Sun model.

Thanks

Emma

Attached File: TheGravitationalLensingEffect.jar.zip


Replies to Uploaded Model

Re: Uploaded Model -
Francisco Esquembre
237 Posts

Emma,

Sorry for the delay, I've been very busy.

Here is what happens.

You misunderstood the meaning of "Prelim Code" in an ODE page. And also the need to correctly initialise the model variables either in Variables or in Initialization.

You MUST give correct initial values to the variables as a result of one of these:
- the Value cell in the table of variables
- code in one of the Initialization pages
- code in one of the Fixed relations.

If not, the variables can have ANY random value. Typically, Java gives them an initial value of 0. But when you click _reset(), they 'probably' will keep the value they had in the last run. Hence, the different runs you are seeing.

Now to the Prelim Code. This is not code that is run once before the ODEs are solved. Nope. This is a placeholder for lengthy code that you need to do to evaluate the Rate values of an ODE. It is run, probably many times, before evaluating whatever you write in the Rate cells of the ODE.

Therefore, it is NOT a place to locate your initial values for the variable, as it seems to me you are doing.

I suggest that you clean your code. Move all the initial code (now in Prelim Code) to one Initialization page and keep the Prelim Code to its minimum. In your case, maybe empty, since the ODE is rather simple.

Hope this helps.

Paco



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