ptolemy.domains.ct.kernel.solver
Class ForwardEulerSolver

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.domains.ct.kernel.ODESolver
          extended byptolemy.domains.ct.kernel.solver.FixedStepSolver
              extended byptolemy.domains.ct.kernel.solver.ForwardEulerSolver
All Implemented Interfaces:
Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable

public class ForwardEulerSolver
extends FixedStepSolver

The Forward Euler(FE) ODE solver. For ODE

   dx/dt = f(x, u, t), x(0) = x0;
   
The FE method approximate the x(t+h) as:
   x(t+h) =  x(t) + h * f(x(t), u(t), t)
   
No error control and step size control is performed. This is the simplest algorithm for solving an ODE. It is a first order method, and has stability problem for some systems.

Since:
Ptolemy II 0.2
Version:
$Id: ForwardEulerSolver.java,v 1.47 2004/04/13 05:12:51 cxh Exp $
Author:
Jie Liu
See Also:
Serialized Form
Accepted Rating:
Yellow (liuxj)
Proposed Rating:
Yellow (liuj)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
ForwardEulerSolver()
          Construct a solver in the default workspace with an empty string as name.
ForwardEulerSolver(Workspace workspace)
          Construct a solver in the given workspace.
 
Method Summary
 int getHistoryCapacityRequirement()
          Return 0 to indicate that this solver needs no history information.
 int getIntegratorAuxVariableCount()
          Return 1 to indicate that this solver needs one auxiliary variable from each integrator when solving the ODE.
 void integratorFire(CTBaseIntegrator integrator)
          Perform the fire() method for the argument integrator.
 boolean resolveStates()
          Advance the current time by the current step size and resolve the state of the system.
 
Methods inherited from class ptolemy.domains.ct.kernel.solver.FixedStepSolver
integratorIsAccurate, integratorPredictedStepSize
 
Methods inherited from class ptolemy.domains.ct.kernel.ODESolver
_makeSolverOf, _prefireIfNecessary, getContainer, getRound, incrementRound, resetRound
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getContainedObject, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateExistence, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setName, setPersistent, setSource, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ForwardEulerSolver

public ForwardEulerSolver()
Construct a solver in the default workspace with an empty string as name. The solver is added to the list of objects in the workspace. Increment the version number of the workspace. The name of the solver is set to "CT_Forward_Euler_Solver".


ForwardEulerSolver

public ForwardEulerSolver(Workspace workspace)
Construct a solver in the given workspace. If the workspace argument is null, use the default workspace. The director is added to the list of objects in the workspace. The name of the solver is set to "CT_Forward_Euler_Solver". Increment the version number of the workspace.

Parameters:
workspace - Object for synchronization and version tracking
Method Detail

getHistoryCapacityRequirement

public int getHistoryCapacityRequirement()
Return 0 to indicate that this solver needs no history information.

Specified by:
getHistoryCapacityRequirement in class ODESolver
Returns:
0.

getIntegratorAuxVariableCount

public int getIntegratorAuxVariableCount()
Return 1 to indicate that this solver needs one auxiliary variable from each integrator when solving the ODE.

Specified by:
getIntegratorAuxVariableCount in class ODESolver
Returns:
1.

integratorFire

public void integratorFire(CTBaseIntegrator integrator)
                    throws IllegalActionException
Perform the fire() method for the argument integrator. This implements the ODE solving algorithm as shown in the class comment.

Specified by:
integratorFire in class ODESolver
Parameters:
integrator - The integrator that calls this method.
Throws:
IllegalActionException - If there is no director.

resolveStates

public boolean resolveStates()
                      throws IllegalActionException
Advance the current time by the current step size and resolve the state of the system. This method always returns true to indicate that the state is found accurately. This gets the state transition schedule from the scheduler and fire for one iteration (which consists of 1 round). This method only resoles the tentative state. It is the director's job to update the states.

Specified by:
resolveStates in class ODESolver
Returns:
True.
Throws:
IllegalActionException - If the firing of some actors throw it.