Diana  0.8.3
Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Attributes
IDASolver Class Reference

#include <IDASolver.hpp>

Inheritance diagram for IDASolver:
IDianaNumericDAESolver DianaNumericSolver ICapeNumericDAESolver IDianaNumericSolver IDianaNumericSolver ICapeNumericSolver ICapeNumericSolver ICapeNumericSolver ICapeIdentification ICapeUtilities ICapeIdentification ICapeUtilities ICapeIdentification ICapeUtilities

List of all members.

Classes

struct  IDALASolverMemRec

Public Member Functions

 IDASolver (Numeric::Solvers::Model::ICapeNumericModel *model) throw (Common::Error::ECapeUnknown)
const Common::Types::CapeStringGetComponentName () const throw (Common::Error::ECapeUnknown)
void SetComponentName (const Common::Types::CapeString &_name) throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument)
const Common::Types::CapeStringGetComponentDescription () const throw (Common::Error::ECapeUnknown)
void SetComponentDescription (const Common::Types::CapeString &_description) throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument)
Common::Collection::ICapeCollectionGetParameters () throw (Common::Error::ECapeUnknown, Common::Error::ECapeFailedInitialisation, Common::Error::ECapeNoImpl)
void SetSimulationContext (Common::Identification::ICapeIdentification *simContextManager) throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, Common::Error::ECapeFailedInitialisation, Common::Error::ECapeNoImpl)
void Initialize () throw (Common::Error::ECapeUnknown, Common::Error::ECapeFailedInitialisation, Common::Error::ECapeOutOfResources, Common::Error::ECapeLicenceError, Common::Error::ECapeBadInvOrder)
void Terminate () throw (Common::Error::ECapeUnknown, Common::Error::ECapeOutOfResources, Common::Error::ECapeBadInvOrder)
Numeric::Solvers::Solver::SolveReturn Solve () throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder, Common::Error::ECapeSolvingError, Common::Error::ECapeOutOfResources)
Common::Types::CapeArrayDouble GetSolution () throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder)
void Destroy () throw (Common::Error::ECapeUnknown)
void SetRelTolerance (const Common::Types::CapeArrayDouble &relTolValue) throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, Common::Error::ECapeOutOfBounds)
Common::Types::CapeArrayDouble GetRelTolerance () throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder)
void SetAbsTolerance (const Common::Types::CapeArrayDouble &absTolValues) throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, Common::Error::ECapeOutOfBounds)
Common::Types::CapeArrayDouble GetAbsTolerance () throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder)
Numeric::Solvers::Model::CapeArrayNumericEventInfoAdvanceToNextEvent (Numeric::Solvers::Model::CapeArrayNumericEventInfo endConditions, Common::Types::CapeDouble &timeBefore, Common::Types::CapeDouble &timeAfter) throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, Common::Error::ECapeOutOfBounds, Common::Error::ECapeBadInvOrder, Common::Error::ECapeSolvingError, Common::Error::ECapeOutOfResources, Common::Error::ECapeNoImpl)

Protected Member Functions

int calculateStructuralRank (const Diana::DianaSparseArray &dsa)
void setValuesFromESO (bool bUpdateAbsTol=true)
void startIntegrator ()
void printStep ()

Static Protected Member Functions

static int errHandler (int error_code, const char *module, const char *function, char *msg, IDASolver *rdata)
static int calculateResiduals (Common::Types::CapeDouble Tres, N_Vector Y, N_Vector Yp, N_Vector R, IDASolver *solver)
static int calculateJacobainDense (Common::Types::CapeLong Neq, Common::Types::CapeDouble T, N_Vector Y, N_Vector Yp, N_Vector Res, Common::Types::CapeDouble cj, IDASolver *solver, DenseMat JJ, N_Vector tempv1, N_Vector tempv2, N_Vector tempv3)
static int IDASparseSetup (IDAMem IDA_mem, N_Vector yyp, N_Vector ypp, N_Vector rrp, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
static int IDASparseSolve (IDAMem IDA_mem, N_Vector b, N_Vector weight, N_Vector ycur, N_Vector ypcur, N_Vector rrcur)

Protected Attributes

Common::Types::CapeString strName
Common::Types::CapeString strDescription
Numeric::Solvers::Model::ICapeNumericModelpModel
 simulated model
Numeric::Solvers::Eso::ICapeNumericDAESOpESO
 current model ESO
Diana::DianaCollection collParameters
 collections of the exported parameters
Common::Parameter::ICapeParameterprmLASolver
void * memIDA
 ida memory context
Common::Types::CapeBoolean bStartSimulation
Common::Types::CapeBoolean bIntermediateResults
Common::Types::CapeBoolean bCalculateConsistentIC
Common::Types::CapeLong nVerboseLevel
Common::Types::CapeLong nParamVisual
 maximum number of values on the screen
Common::Types::CapeLong nStructRankLHS
 LHS matrix structural rank.
Common::Types::CapeLong nVars
 current number of the state variables
Common::Types::CapeLong nEqns
 current number of the equations
N_Vector vecStates
 state vector
N_Vector vecDerivs
 derivatives vector
N_Vector vecId
N_Vector vecAbsTol
 the absolute error tolerance vector
Common::Types::CapeDouble dblT
 is the current value of the independent variable
Common::Types::CapeDouble dblT0
 is the initial value of the independent variable
Common::Types::CapeDouble dblTend
 the final value of the independent variable
Common::Types::CapeDouble dblTout
 time interval for equidistant output mode
Common::Types::CapeDouble dblRTol
 the relative error tolerance
Common::Types::CapeLong nMaxInternalSteps
Common::Types::CapeBoolean bSingleStepping
 flag, indicates whether solver runs in single stepping mode
Common::Types::CapeDouble dblMaxStepSize
Common::Types::CapeLong nMaxOrd
 specifies the maximum order of the linear multistep method

Private Attributes

Common::Types::CapeBoolean bIDAInitialized
 flag, indicates that IDA solver initialised
Common::Types::CapeBoolean bIDAInterruption
 flag, indicates that integration process can be terminated
Diana::DianaSparseArray dsaJacoDiff
Diana::DianaSparseSolver dssJacoDiff
IDALASolverMemRec stIDALASolverMem

Detailed Description

IDASolver.


Constructor & Destructor Documentation

Main constructor.


Member Function Documentation

Advances the solution of the DAESO with respect to its independent variable until some Event(s) occurs, or an error occurs in the solution process.

Note:For dynamic problems, we cannot be certain that the Solver will be able to identify precisely the single Event which causes termination. Thus we allow it to provide a list of Event objects, together with independent variable values which "bracket" the termination point.

Parameters:
endConditionsthe list of stopping conditions for this call
timeBeforethe independent variable value at the beginning of the internal step
timeAfterthe independent variable value at the end of the internal step

Implements ICapeNumericDAESolver.

static int calculateJacobainDense ( Common::Types::CapeLong  Neq,
Common::Types::CapeDouble  T,
N_Vector  Y,
N_Vector  Yp,
N_Vector  Res,
Common::Types::CapeDouble  cj,
IDASolver solver,
DenseMat  JJ,
N_Vector  tempv1,
N_Vector  tempv2,
N_Vector  tempv3 
) [static, protected]

Static callback function, which calculates dense matrix $\partial G/\partial x+cj \partial G/\partial x'$.

static int calculateResiduals ( Common::Types::CapeDouble  Tres,
N_Vector  Y,
N_Vector  Yp,
N_Vector  R,
IDASolver solver 
) [static, protected]

Static callback function, which calculates residuals $G(t,x,x')$.

int calculateStructuralRank ( const Diana::DianaSparseArray dsa) [protected]

Calculates structural rank of the matrix by given pattern. Idea is quite simple, so let's do the Gaussian elimination with pivoting. With without values it is means that column rank will be amount of the non zero columns and row rank will be amount of the non zero rows. Structural rank than is equal minimum value of that values. Please, if you find counterexample, send it to miha@mpi-magdeburg.mpg.de.

void Destroy ( ) throw (Common::Error::ECapeUnknown) [virtual]

Deletes the Solver Component and all the objects associated to this particular Solver Component.

Implements ICapeNumericSolver.

static int errHandler ( int  error_code,
const char *  module,
const char *  function,
char *  msg,
IDASolver rdata 
) [static, protected]

Static error handler

Gets information on the absolute tolerance to be used in performing local error tests while solving the DAE system. The precise interpretation of this parameter will depend on individual implementations; the exact nature of the error measure used (e.g. local truncation error, local error etc.), and the way in which this is estimated, are not defined by CAPE-OPEN.

Implements ICapeNumericDAESolver.

gets the description of the component.

Implements ICapeIdentification.

gets the name of the component.

Implements ICapeIdentification.

Returns an ICapeCollection interface. This interface will contain a collection of ICapeParameter interfaces. This method allows any client to access all the Cape Open Parameters exposed by a model component. If the model component does not support exposing its parameters, it should raise the ECapeNoImpl error, instead of returning a NULL reference or an empty Collection. But if the PMC supports parameters but has for this call no parameters, it should return a valid ICapeCollection reference exposing zero parameters.

Implements ICapeUtilities.

Gets information on the relative tolerance to be used in performing local error tests while solving a DAE system, as well as its current value. The precise interpretation of this parameter will depend on individual implementations; the exact nature of the error measure used (e.g. local truncation error, local error etc.), and the way in which this is estimated, are not defined by CAPE-OPEN.

Implements ICapeNumericDAESolver.

Gets all the values of the variables that solve this System.

Implements ICapeNumericSolver.

The environment will order the component to get initialised through this method. Any initialisation that could fail must be placed here. Initialise is guaranteed to be the first method called by the client (except low level methods such as class constructors or initialisation persistence methods). Initialise has to be called once when the component is instantiated in a particular flowsheet. When the initialisation fails, before signalling an error, the component must free all the resources that were allocated before the failure occurred. When the environment receives this error, it may not use the component anymore. The method terminate of the current interface must not either be called. Hence, the environment may only release the component through the middleware native mechanisms.

Implements ICapeUtilities.

Sets the absolute tolerance to be used in performing local error tests while solving the DAE system. The precise interpretation of this parameter will depend on individual implementations; the exact nature of the error measure used (e.g. local truncation error, local error etc.), and the way in which this is estimated, are not defined by CAPE-OPEN.

Implements ICapeNumericDAESolver.

sets the description of the component.

Parameters:
_descriptionthe description of the component

Implements ICapeIdentification.

sets the name of the component.

Parameters:
_namethe name of the component

Implements ICapeIdentification.

Sets the relative tolerance values to be used in performing local error tests while solving a DAE system. The precise interpretation of this parameter will depend on individual implementations; the exact nature of the error measure used (e.g. local truncation error, local error etc.) and the way in which this is estimated are not defined by CAPE-OPEN.

Parameters:
relTolValuethe relative tolerance values.

Implements ICapeNumericDAESolver.

Allows the environment to convey the component a reference to the formers simulation context. The simulation context will be environment objects which will expose a given set of Cape Open interfaces. Each of these interfaces will allow the component to call back the environment in order to benefit from its exposed services (such as creation of material templates, diagnostics or measurement unit conversion). If the component does not support accessing the simulation context, it is recommended to raise the ECapeNoImpl error.

Parameters:
simContextManagerthe reference to the environment's simulation context class. For the component to use this class, this reference will have to be converted to each of the defined Cape Open Simulation Context interfaces.

Implements ICapeUtilities.

void setValuesFromESO ( bool  bUpdateAbsTol = true) [protected]

Copies values from the ESO into internal arrays.

Attempts to solve the system of equations defined within the Model associated with this solver instance. Return will occur in different circumstances:

  • The attempt succeeds.
  • The solver gives up.
  • An unexpected problem ("exception") arises.
    If the underlying Model contains one or more STNs, the Solver may consider a switch to a different set of active states necessary to finding a solution. In this case, it may use the MoveToNextState method of one or more of the Model's STNs during the computation. The numerical values held in the model on return should be consistent with the set of states which are active on return.

Notes:The initial guesses for this solution will be the current variable values of the Model.

Implements ICapeNumericSolver.

void startIntegrator ( ) [protected]

Restarts integrator.

The environment will order the component to get destroyed through this method. Any uninitialisation that could fail must be placed here. Terminate is guaranteed to be the last method called by the client (except low level methods such as class destructors). Terminate may be called at any time, but may be only called once. When this method returns an error, the environment should report the user. However, after that the environment is not allowed to use the component anymore.

Implements ICapeUtilities.


Member Data Documentation

flag, indicates whether it is necessary to evaluate consistent initial values

flag, indicates whether it is necessary to restart integration

specifies the maximum absolute value of the step size (0 corresponds to the infinity value)

the maximum number of steps to be taken by the solver in its attempt to reach the next output time.

N_Vector vecId [protected]

specifies algebraic/differential components in the state vector. A value of 1.0 indicates a differential variable, while 0.0 indicates an algebraic variable.


The documentation for this class was generated from the following file: