Recent Changes - Search:

Information

Installation

Documentation

ModelPrelim

In some symmetrical cases, the ODEs have elements in common. One such example is the case of a force that depends on the distance to some point of origin. Then, in the differential equations, you would need to compute the distance to the origin twice to calculate both the rate of vx and of vy. The Preliminary code editor allows to avoid duplicating computations by specifying elements of calculation (in code that complies with Java syntax) that several differential equations have in common.


The variable 'rd' that is declared in the preliminary panel can be invoked in the ODE editor

This preliminary code is executed (as its name suggests) always before the rate of the equations are computed. Hence, you can use whatever computation you write in this page. Notice that you can also declare and use local variables (i.e. variables that are not declared in the Variables panel). This is why, in the example of the image, the line of code starts with 'double'. (In java code when a variable is created its type must be specified explicitly.) This code declares a local double variable and uses it to compute the required distance. This variable can now be used in the rate equations to compute the x and y forces.

Note that specifying these calculations in the Fixed relations panel is not an option. The algorithm that computes a new state of the state variables calculates a weighed average of states at intermediate points in time. For the example of the distance to the origin, this means that for every intermediate point in time there is a different distance to the origin. Using the value from the Fixed Relations would mean that, at every intermediate step, the same distance to the origin was used, which would be incorrect.

Edit - History - Print - Recent Changes - Search
Page last modified on April 29, 2009, at 12:11 AM