Recent Changes - Search:





Direct control of ODE solvers

An EJS evolution step with an ODE page in it can consist of multiple ODE solver steps if the requested tolerance cannot be achieved using the requested stepsize.  Conversely, a single ODE solver step can be interpolated to produce multiple evolution steps if the tolerance is low and the solution is slowly varying.   An evolution step and a solver step are, of course, equal for fixed stepsize algorithms.


This process of stepping the solver is done automatically at each evolution step. There are, however, situations in which you may want to step the solver ‘by hand’. For this purpose, EJS allows direct access to the numerical algorithms underlying an ODE Evolution page.


The predefined method _getODE (String _odeName) returns an object of the class org.opensourcephysics.numerics.EJSODE for the ODE page with the given name (same as its page title).


This object has the following public methods, that you can use to control how the solver behaves:


Public methods of an org.opensourcephysics.numerics.EJSODE object

org.opensourcephysics.numerics.ODEInterpolatorEventSolver getEventSolver()
Returns the actual event solver method

String setSolverClass (String _solverName)
Allows changing the solver in run-time. The parameter must be the name of a valid method. Valid names are: BogakiShampine, CashKarp45, Dopri5, Dopri853, Euler, EulerRichardson, Fehlberg78, Fehlberg8, Radau5, and RungeKutta4 (or simply RK4). The method returns the fully qualified name of the corresponding class or null if not valid. (By the way, this string is of no real use, but just to satisfy your curiosity.)
Note: The model method _setSolver(String _odeName, String _solverName) is a short-cut for _getODE(String _odeName).setSolverClass(String _solverName).

void initializeSolver ()
Initializes the solver. This is done autommatically at the end of the EJS initialization, but the user may require to do it explicitly if she want to step the solver before the initialization completes

double step ()
Steps the ODE solution as much as the ODE Evolution page increment indicates. If an event is found and the “End step at event” checkbox is checked, the step is interrupted at the event. Returns the step actually taken.

double solverStep ()
Steps the ODE solution as much as the given tolerance allows. If a fixed-step method is used, this step equals the internal step (or the increment, if the internal step is not set). The step is interrupted if an event is found. Returns the step actually taken.

void setEnabled (boolean _enabled)
Whether the ODE page is enabled. True by default for EJS enabled pages.

double getIndependentVariableValue ()
Returns the current value  of the independent variable

double getInternalStepSize ()
Returns the value of the internal step size of the solver

Edit - History - Print - Recent Changes - Search
Page last modified on June 19, 2011, at 01:00 PM