• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

step/stepcore

  • StepCore
  • Solver
Public Types | Public Member Functions | Protected Attributes | List of all members
StepCore::Solver Class Referenceabstract
ODE Solvers

#include <solver.h>

Inheritance diagram for StepCore::Solver:
Inheritance graph
[legend]

Public Types

enum  {
  OK = 0, ToleranceError = 2048, InternalError = 2049, CollisionDetected = 4096,
  IntersectionDetected = 4097, Aborted = 8192, CollisionError = 16384, ConstraintError = 32768
}
 
typedef int(* Function )(double t, const double *y, const double *yvar, double *f, double *fvar, void *params)
 

Public Member Functions

 Solver (int dimension=0, Function function=NULL, void *params=NULL, double stepSize=0.001)
 
 Solver (double stepSize)
 
virtual ~Solver ()
 
int dimension () const
 
virtual int doCalcFn (double *t, const VectorXd *y, const VectorXd *yvar=0, VectorXd *f=0, VectorXd *fvar=0)=0
 
virtual int doEvolve (double *t, double t1, VectorXd *y, VectorXd *yvar)=0
 
Function function () const
 
double localError () const
 
double localErrorRatio () const
 
void * params () const
 
virtual void setDimension (int dimension)
 
virtual void setFunction (Function function)
 
virtual void setParams (void *params)
 
virtual void setStepSize (double stepSize)
 
virtual void setToleranceAbs (double toleranceAbs)
 
virtual void setToleranceRel (double toleranceRel)
 
QString solverType () const
 
double stepSize () const
 
double toleranceAbs () const
 
double toleranceRel () const
 
- Public Member Functions inherited from StepCore::Object
 Object (const QString &name=QString())
 
virtual ~Object ()
 
const QString & name () const
 
void setName (const QString &name)
 

Protected Attributes

int _dimension
 
Function _function
 
double _localError
 
double _localErrorRatio
 
void * _params
 
double _stepSize
 
double _toleranceAbs
 
double _toleranceRel
 
- Protected Attributes inherited from StepCore::Object
QString _name
 

Detailed Description

Generic Solver interface.

Provides generic interface suitable for large variety of ordinaty differential equations integration algorithms.

It solves system of the first order differential equations:

\begin{eqnarray*} \frac{dy_i(t)}{dt} &=& f(y_i(t), t) \\ y_i(t_0) &=& y^0_i \end{eqnarray*}

Dimension of system is provided via setDimension(), function $f$ is provided via setFunction().

It also provides interface for setting allowed local tolerance. It can be defined using two properties: toleranceAbs and toleranceRel.

On each step solver calculates local error estimation (which depends on used integration method) and local error ratio for each variable using the following formula:

\[ \mbox{localErrorRatio}_i = \frac{|\mbox{localError}_i|} {\mbox{toleranceAbs} + \mbox{toleranceRel} \cdot | y_i |} \]

Non-adaptive solvers cancel current step if maximal local error ratio is bigger than 1.1 (exact value depends on solver) and doEvolve() function returns false.

Adaptive solvers use maximal local error ratio to change time step until the ratio becomes almost equal 1. If it can't be made smaller than 1.1 (exact value depends on solver), solvers cancel current step and doEvolve() function returns false.

Maximal (over all variables) error estimation and error ratio from last time step can be obtained using localError() and localErrorRatio() methods.

Definition at line 70 of file solver.h.

Member Typedef Documentation

typedef int(* StepCore::Solver::Function)(double t, const double *y, const double *yvar, double *f, double *fvar, void *params)

Callback function type.

Definition at line 77 of file solver.h.

Member Enumeration Documentation

anonymous enum

Status codes for doCalcFn and doEvolve.

Enumerator
OK 
ToleranceError 
InternalError 
CollisionDetected 
IntersectionDetected 
Aborted 
CollisionError 
ConstraintError 

Definition at line 142 of file solver.h.

Constructor & Destructor Documentation

StepCore::Solver::Solver ( int  dimension = 0,
Function  function = NULL,
void *  params = NULL,
double  stepSize = 0.001 
)
inlineexplicit

Cunstructs a solver.

Definition at line 164 of file solver.h.

StepCore::Solver::Solver ( double  stepSize)
inline

Cunstructs a solver.

Definition at line 170 of file solver.h.

virtual StepCore::Solver::~Solver ( )
inlinevirtual

Definition at line 86 of file solver.h.

Member Function Documentation

int StepCore::Solver::dimension ( ) const
inline

Get ODE dimension.

Definition at line 92 of file solver.h.

virtual int StepCore::Solver::doCalcFn ( double *  t,
const VectorXd *  y,
const VectorXd *  yvar = 0,
VectorXd *  f = 0,
VectorXd *  fvar = 0 
)
pure virtual

Calculate function value.

Implemented in StepCore::GenericEulerSolver.

virtual int StepCore::Solver::doEvolve ( double *  t,
double  t1,
VectorXd *  y,
VectorXd *  yvar 
)
pure virtual

Integrate.

Parameters
tCurrent time (will be updated by the new value)
t1Target time
yFunction value
yvarFunction variance
Returns
Solver::OK on success, error status on failure
Todo:
Provide error message

Implemented in StepCore::GenericEulerSolver.

Function StepCore::Solver::function ( ) const
inline

Get callback function.

Definition at line 97 of file solver.h.

double StepCore::Solver::localError ( ) const
inline

Get error estimation from last step.

Definition at line 122 of file solver.h.

double StepCore::Solver::localErrorRatio ( ) const
inline

Get local tolerance calculated at last step.

Definition at line 124 of file solver.h.

void* StepCore::Solver::params ( ) const
inline

Get callback function params.

Definition at line 102 of file solver.h.

virtual void StepCore::Solver::setDimension ( int  dimension)
inlinevirtual

Set ODE dimension.

Reimplemented in StepCore::GenericEulerSolver.

Definition at line 94 of file solver.h.

virtual void StepCore::Solver::setFunction ( Function  function)
inlinevirtual

Set callback function.

Definition at line 99 of file solver.h.

virtual void StepCore::Solver::setParams ( void *  params)
inlinevirtual

Set callback function params.

Definition at line 104 of file solver.h.

virtual void StepCore::Solver::setStepSize ( double  stepSize)
inlinevirtual

Set step size (solver can adjust it later)

Definition at line 109 of file solver.h.

virtual void StepCore::Solver::setToleranceAbs ( double  toleranceAbs)
inlinevirtual

Set absolute allowed local tolerance.

Definition at line 114 of file solver.h.

virtual void StepCore::Solver::setToleranceRel ( double  toleranceRel)
inlinevirtual

Set relative allowed local tolerance.

Definition at line 119 of file solver.h.

QString StepCore::Solver::solverType ( ) const
inline

Get solver type.

Definition at line 89 of file solver.h.

double StepCore::Solver::stepSize ( ) const
inline

Get step size.

Definition at line 107 of file solver.h.

double StepCore::Solver::toleranceAbs ( ) const
inline

Get absolute allowed local tolerance.

Definition at line 112 of file solver.h.

double StepCore::Solver::toleranceRel ( ) const
inline

Get relative allowed local tolerance.

Definition at line 117 of file solver.h.

Member Data Documentation

int StepCore::Solver::_dimension
protected

Definition at line 153 of file solver.h.

Function StepCore::Solver::_function
protected

Definition at line 154 of file solver.h.

double StepCore::Solver::_localError
protected

Definition at line 160 of file solver.h.

double StepCore::Solver::_localErrorRatio
protected

Definition at line 161 of file solver.h.

void* StepCore::Solver::_params
protected

Definition at line 155 of file solver.h.

double StepCore::Solver::_stepSize
protected

Definition at line 157 of file solver.h.

double StepCore::Solver::_toleranceAbs
protected

Definition at line 158 of file solver.h.

double StepCore::Solver::_toleranceRel
protected

Definition at line 159 of file solver.h.


The documentation for this class was generated from the following file:
  • solver.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:43:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

step/stepcore

Skip menu "step/stepcore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal