Diana
0.8.3
|
#include <IDASolver.hpp>
Classes | |
struct | IDALASolverMemRec |
Public Member Functions | |
IDASolver (Numeric::Solvers::Model::ICapeNumericModel *model) throw (Common::Error::ECapeUnknown) | |
const Common::Types::CapeString & | GetComponentName () const throw (Common::Error::ECapeUnknown) |
void | SetComponentName (const Common::Types::CapeString &_name) throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument) |
const Common::Types::CapeString & | GetComponentDescription () const throw (Common::Error::ECapeUnknown) |
void | SetComponentDescription (const Common::Types::CapeString &_description) throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument) |
Common::Collection::ICapeCollection * | GetParameters () 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::CapeArrayNumericEventInfo * | AdvanceToNextEvent (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::ICapeNumericModel * | pModel |
simulated model | |
Numeric::Solvers::Eso::ICapeNumericDAESO * | pESO |
current model ESO | |
Diana::DianaCollection | collParameters |
collections of the exported parameters | |
Common::Parameter::ICapeParameter * | prmLASolver |
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 |
IDASolver | ( | Numeric::Solvers::Model::ICapeNumericModel * | model | ) | throw (Common::Error::ECapeUnknown) |
Main constructor.
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.
endConditions | the list of stopping conditions for this call |
timeBefore | the independent variable value at the beginning of the internal step |
timeAfter | the 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 .
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 .
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
Common::Types::CapeArrayDouble GetAbsTolerance | ( | ) | throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) [virtual] |
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.
const Common::Types::CapeString& GetComponentDescription | ( | ) | const throw (Common::Error::ECapeUnknown) [virtual] |
gets the description of the component.
Implements ICapeIdentification.
const Common::Types::CapeString& GetComponentName | ( | ) | const throw (Common::Error::ECapeUnknown) [virtual] |
gets the name of the component.
Implements ICapeIdentification.
Common::Collection::ICapeCollection* GetParameters | ( | ) | throw (Common::Error::ECapeUnknown, Common::Error::ECapeFailedInitialisation, Common::Error::ECapeNoImpl) [virtual] |
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.
Common::Types::CapeArrayDouble GetRelTolerance | ( | ) | throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) [virtual] |
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.
Common::Types::CapeArrayDouble GetSolution | ( | ) | throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) [virtual] |
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.
void SetAbsTolerance | ( | const Common::Types::CapeArrayDouble & | absTolValues | ) | throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, Common::Error::ECapeOutOfBounds) [virtual] |
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.
void SetComponentDescription | ( | const Common::Types::CapeString & | _description | ) | throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument) [virtual] |
sets the description of the component.
_description | the description of the component |
Implements ICapeIdentification.
void SetComponentName | ( | const Common::Types::CapeString & | _name | ) | throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument) [virtual] |
sets the name of the component.
_name | the name of the component |
Implements ICapeIdentification.
void SetRelTolerance | ( | const Common::Types::CapeArrayDouble & | relTolValue | ) | throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, Common::Error::ECapeOutOfBounds) [virtual] |
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.
relTolValue | the relative tolerance values. |
Implements ICapeNumericDAESolver.
void SetSimulationContext | ( | Common::Identification::ICapeIdentification * | simContextManager | ) | throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, Common::Error::ECapeFailedInitialisation, Common::Error::ECapeNoImpl) [virtual] |
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.
simContextManager | the 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.
Numeric::Solvers::Solver::SolveReturn Solve | ( | ) | throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder, Common::Error::ECapeSolvingError, Common::Error::ECapeOutOfResources) [virtual] |
Attempts to solve the system of equations defined within the Model associated with this solver instance. Return will occur in different circumstances:
Notes:The initial guesses for this solution will be the current variable values of the Model.
Implements ICapeNumericSolver.
void startIntegrator | ( | ) | [protected] |
Restarts integrator.
void Terminate | ( | ) | throw (Common::Error::ECapeUnknown, Common::Error::ECapeOutOfResources, Common::Error::ECapeBadInvOrder) [virtual] |
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.
Common::Types::CapeBoolean bCalculateConsistentIC [protected] |
flag, indicates whether it is necessary to evaluate consistent initial values
Common::Types::CapeBoolean bStartSimulation [protected] |
flag, indicates whether it is necessary to restart integration
Common::Types::CapeDouble dblMaxStepSize [protected] |
specifies the maximum absolute value of the step size (0 corresponds to the infinity value)
Common::Types::CapeLong nMaxInternalSteps [protected] |
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.