ptolemy.domains.ct.kernel.solver
Class BackwardEulerSolver

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.BackwardEulerSolver
All Implemented Interfaces:
Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable
Direct Known Subclasses:
ImpulseBESolver

public class BackwardEulerSolver
extends FixedStepSolver

The backward Euler ODE solver. For an ODE

   x' = f(x, t), x(0) = x0
   
This solver uses the following formula to solve it:
   x(t+h) = x(t) + h*x'(t+h)
   
where x(t) is the current state, x(t+h) is the next state, h is the step size, and x'(t+h) is the derivative of x at t+h. The formula above is an algebraic equation, and this method uses fixed point iteration to solve it.

This method does not perform step size control other than reducing the step sizes when the fixed-point iteration does not converge.

Since:
Ptolemy II 0.2
Version:
$Id: BackwardEulerSolver.java,v 1.52 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
BackwardEulerSolver()
          Construct a solver in the default workspace with the name "CT_Backward_Euler_Solver".
BackwardEulerSolver(Workspace workspace)
          Construct a solver in the given workspace with the name "CT_Backward_Euler_Solver".
 
Method Summary
protected  boolean _isConverged()
          Return true if all integrators agree that the fixed-point iteration has converged.
protected  void _setConvergence(boolean converge)
          Set the convergence flag.
protected  void _voteForConvergence(boolean converge)
          Vote on whether a fixed point has reached.
 int getHistoryCapacityRequirement()
          Return 0 to indicate that no history information is needed by this solver.
 int getIntegratorAuxVariableCount()
          Return 1 to indicate that an integrator under this solver needs one auxiliary variable.
 void integratorFire(CTBaseIntegrator integrator)
          Provide the fire() method for the integrator under this solver.
 boolean resolveStates()
          Advance time by the current step size and return true if the state of the integrators are resolved accurately at that time.
 
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

BackwardEulerSolver

public BackwardEulerSolver()
Construct a solver in the default workspace with the name "CT_Backward_Euler_Solver". The solver is added to the list of objects in the workspace. Increment the version number of the workspace.


BackwardEulerSolver

public BackwardEulerSolver(Workspace workspace)
Construct a solver in the given workspace with the name "CT_Backward_Euler_Solver". If the workspace argument is null, use the default workspace. The solver is added to the list of objects in the workspace. 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 no history information is needed by this solver.

Specified by:
getHistoryCapacityRequirement in class ODESolver
Returns:
0.

getIntegratorAuxVariableCount

public int getIntegratorAuxVariableCount()
Return 1 to indicate that an integrator under this solver needs one auxiliary variable.

Specified by:
getIntegratorAuxVariableCount in class ODESolver
Returns:
1.

integratorFire

public void integratorFire(CTBaseIntegrator integrator)
                    throws IllegalActionException
Provide the fire() method for the integrator under this solver. For the given integrator, do x(n+1) = x(n)+h*x'(n+1) and test whether this calculation converges.

Specified by:
integratorFire in class ODESolver
Parameters:
integrator - The integrator that uses the fire() method.
Throws:
IllegalActionException - If there is no director.

resolveStates

public boolean resolveStates()
                      throws IllegalActionException
Advance time by the current step size and return true if the state of the integrators are resolved accurately at that time. It resolves the states by getting the state transition schedule from the scheduler and trying to iteration until the fixed point is reached. Return false if the fixed point is not reached after maxIterations number of iterations. This method only resoles the tentative state. It is the director's job to update the states.

Specified by:
resolveStates in class ODESolver
Throws:
IllegalActionException - If there is no director or no scheduler.

_isConverged

protected boolean _isConverged()
Return true if all integrators agree that the fixed-point iteration has converged. Integrators vote for convergence by calling the _voteForConvergence() with a true arguments. And the value returned here is the AND of all votes.

Returns:
True if all the votes are true.

_setConvergence

protected void _setConvergence(boolean converge)
Set the convergence flag.

Parameters:
converge - The flag setting.

_voteForConvergence

protected void _voteForConvergence(boolean converge)
Vote on whether a fixed point has reached.

Parameters:
converge - True if vote for convergence.