Diana  0.8.3
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
DianaContinuation Class Reference

#include <DianaContinuation.hpp>

Inheritance diagram for DianaContinuation:
IDianaContinuation DianaNumericSolver IDianaNumericSolver IDianaNumericSolver ICapeNumericSolver ICapeNumericSolver ICapeIdentification ICapeUtilities ICapeIdentification ICapeUtilities HopfPointContinuation SingAnalyser SteadyStateContinuation

List of all members.

Public Member Functions

 DianaContinuation (Numeric::Solvers::Model::ICapeNumericModel *_pModel)
virtual ~DianaContinuation ()
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)
Common::Types::CapeArrayDouble GetSolution () throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder)
void Destroy () throw (Common::Error::ECapeUnknown)
Numeric::Solvers::Solver::SolveReturn Solve () throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder, Common::Error::ECapeSolvingError, Common::Error::ECapeOutOfResources)
ContiReturn Continuate () throw (Common::Error::ECapeUnknown, Common::Error::ECapeSolvingError)
void AddFreeParameter (const Common::Types::CapeString &strParName, Common::Types::CapeDouble minValue=0.0, Common::Types::CapeDouble maxValue=0.0) throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument)
void RemoveFreeParameter (const Common::Types::CapeString &strParName) throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument)
Common::Types::CapeString GetVariableName (Common::Types::CapeLong index) throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument)

Protected Member Functions

void initSystemVariables ()
 initialises internal system variables for the PETSc library, such as vecY, matJacobian etc.
void destroySystemVariables ()
 destroys internal system variables for the PETSc library
ContiReturn makeContinuation (const Common::Types::CapeArrayDouble &vecYI, Common::Types::CapeDouble initialDirection) throw (Common::Error::ECapeUnknown, Common::Error::ECapeSolvingError)
Numeric::Solvers::Solver::SolveReturn doNewtonSolve (Common::Types::CapeArrayDouble &Y, int nMaxIterations, const DianaINTSignalHandler &inthandler) throw (Common::Error::ECapeUnknown, Common::Error::ECapeSolvingError)
Numeric::Solvers::Solver::SolveReturn doNewtonSolve_ (Common::Types::CapeArrayDouble &Y, int nMaxIterations, const DianaINTSignalHandler &inthandler) throw (Common::Error::ECapeUnknown, Common::Error::ECapeSolvingError)
void restoreInitialValues () throw (Common::Error::ECapeUnknown)
 Restores initial values in the continuation object.
virtual int getModelEquations ()=0
virtual int getModelVariables ()=0
virtual CapeBoolean calcTestCondition (CapeBoolean bFirstCall=false)
CapeBoolean checkIsolaCondition (const CapeArrayDouble &vecY0, const CapeArrayDouble &vecY1, const CapeArrayDouble &vecY2)
void formFunction (const Common::Types::CapeArrayDouble &Y, Common::Types::CapeArrayDouble &Res)
virtual void packModelVector (Common::Types::CapeArrayDouble &modelVector)=0
virtual void packModelBoundaries (Common::Types::CapeArrayDouble &arrMinY, Common::Types::CapeArrayDouble &arrMaxY)=0
virtual void unpackModelVector (const Common::Types::CapeArrayDouble &modelVector)=0
virtual void packModelResidual (Common::Types::CapeArrayDouble &modelResidual)=0
virtual void packModelJacobian (Diana::DianaSparseArray &Jaco)
virtual void addDerivativeByParameter (Diana::DianaSparseArray &Jaco, int nJacCol, int nParamIndex)
int checkVariableFiniteness (const Common::Types::CapeArrayDouble &Y)
void calcTangentVector (const Common::Types::CapeArrayDouble &Y, Common::Types::CapeArrayDouble &T, PredictorType type)
CapeBoolean checkVariableBoundaries (const Common::Types::CapeArrayDouble &Y)
int makeBoundaryCorrection (Common::Types::CapeArrayDouble &Y, const DianaINTSignalHandler &inthandler)
 Check variable boundaries and tries to make a correction on a boundary. If return value is 1, Y will contain corrected state vector.
Common::Types::CapeDouble vecNorm2 (const Common::Types::CapeArrayDouble &dblY)
Common::Types::CapeBoolean isZeroValue (Common::Types::CapeDouble value)
Common::Types::CapeDouble calcCosAngle (const Common::Types::CapeArrayDouble &Y1, const Common::Types::CapeArrayDouble &Y0, const Common::Types::CapeArrayDouble &Ym1)
void printVector (const Common::Types::CapeString &name, const Common::Types::CapeArrayDouble &vec)
void calcArpackSMEigenpair (Diana::DianaSparseArray &dsaA, Common::Types::CapeArrayDouble &arrEigenvector)
std::vector< std::complex
< Common::Types::CapeDouble > > 
GetEigenvalues () throw (Common::Error::ECapeUnknown)
ContiReturn init (const Common::Types::CapeArrayDouble &vecYI, Common::Types::CapeDouble initialDirection, const int nInitialCorrectionDir, const DianaINTSignalHandler &inthandler)
ContiReturn one_step (const DianaINTSignalHandler &inthandler)

Protected Attributes

Common::Types::CapeString strName
Common::Types::CapeString strDescription
Numeric::Solvers::Model::ICapeNumericModelpModel
 CapeOpen model object.
Diana::IDianaDAESOpESO
 CapeOpen model active ESO object.
Diana::DianaCollectionpESORealParameters
Diana::DianaCollection collSolverParameters
 collections of the exported solver parameters
CapeBoolean bInitialized
 flag shows that Initialize() was called
CapeBoolean bstart
CapeBoolean bintermediate
Common::Types::CapeArrayLong arrFreeParams
 array of all free parameters
Common::Types::CapeArrayDouble arrFreeParamsMin
 array of free parameters minimum values
Common::Types::CapeArrayDouble arrFreeParamsMax
 array of free parameters maximum values
Common::Types::CapeArrayDouble dblMinY
 variables lower boundaries array
Common::Types::CapeArrayDouble dblMaxY
 variables upper boundaries array
Common::Types::CapeLong nVerboseLevel
 print level 0-no output, ...
Common::Types::CapeBoolean bBidirectional
 initial direction -1.0 or 1.0
Common::Types::CapeDouble dblInitialDirection
 initial direction -1.0 or 1.0
Common::Types::CapeDouble dblStepSize
 current step size
Common::Types::CapeDouble dblInitialStepSize
 initial step size
Common::Types::CapeDouble dblFailedStepScale
 failed step size scaling
Common::Types::CapeDouble dblSucceededStepScale
 succeeded step size scaling
Common::Types::CapeDouble dblMinStepSize
 minimal continuation step size
Common::Types::CapeDouble dblMaxStepSize
 maximal continuation step size
Common::Types::CapeLong nMaxStepsAmount
 maximum amount of steps
Common::Types::CapeLong nStepNumber
 current step number
Common::Types::CapeLong nMaxNewtonIts
 maximal amount of Newton iterations
Common::Types::CapeDouble dblTol
 required relative precision in the argument space
Common::Types::CapeDouble dblTolF
 required relative precision in the function space
Common::Types::CapeLong nSuccessIts
 amount of Newton iterations of successful step
Common::Types::CapeLong nBoundaryVariableIdx
Common::Types::CapeDouble dblFDEpsilon
 epsilon value for the finite difference approximation
Common::Types::CapeDouble dblUround
 machine upper round value
Common::Types::CapeDouble dblIsolaTrustInterval
 isola trust interval
Common::Types::CapeBoolean bOrthogonalBranch
Common::Types::CapeBoolean bCheckVariablesBoundaries
 include model variables to boundary checks

Private Member Functions

void packVector (Common::Types::CapeArrayDouble &work_vector)
void unpackVector (const Common::Types::CapeArrayDouble &work_vector)
void packFreeParameters (int nFreeParamsPos, Common::Types::CapeArrayDouble &modelVector)
void unpackFreeParameters (int nFreeParamsPos, const Common::Types::CapeArrayDouble &modelVector)
void getParameterBoundaries (Common::Parameter::ICapeParameter *param, Common::Types::CapeDouble &dblMin, Common::Types::CapeDouble &dblMax)
void setNoneParameterisation ()
 prepare system to solve without parameterisation
void setLocalParameterisation (CapeLong idx, CapeDouble val, CapeDouble sign)
 prepare system to solve with local parameterisation
Common::Types::CapeDouble calcLocalParameterisation (const Common::Types::CapeArrayDouble &dblY)
 calculate residual entries for the local parameterisation of the system
void addLocalParameterisationJacRow (Diana::DianaSparseArray &Jaco, int nRow)
 add Jacobian entries for the local parameterisation of the system
void setPseudoParameterisation ()
 prepare system to solve with pseudo-arclength parameterisation
Common::Types::CapeDouble calcPseudoParameterisation (const Common::Types::CapeArrayDouble &dblY)
 calculate residual entries for the pseudo-arclength parameterisation of the system
void addPseudoParameterisationJacRow (Diana::DianaSparseArray &Jaco, int nRow)
 calculate residual entries for the pseudo-arclength parameterisation of the system
void formJacobianMatrix (const Common::Types::CapeArrayDouble &Y)

Private Attributes

Common::Types::CapeArrayDouble dblScaleY
 variables scaling array
int nVars
 number of variables in the whole system
int nModelVars
 number of variables in the subclass system
int nModelEqns
 number of equations in the subclass system
Common::Types::CapeArrayDouble vecY
 total state variables vector Y
Common::Types::CapeArrayDouble vecYBC
 currently accepted state vector for the boundary correction
Common::Types::CapeArrayDouble vecRes
 total residual vector
Common::Types::CapeArrayDouble vecEye
 auxiliary eye vector of type [0..0 1]
Common::Types::CapeArrayDouble vecY0
 currently accepted state vector
Common::Types::CapeArrayDouble vecT0
 tangent at point Y0
Common::Types::CapeArrayDouble vecYm1
 state vector on the prevoius step
Common::Types::CapeArrayDouble vecYStart
 state vector at the first point
Diana::DianaSparseArray matJacobian
 total Jacobi matrix
Diana::DianaSparseSolver spmNewton
ResidualType nResidualType
Common::Types::CapeLong nParameterisationType
 specified type of the parameterisation
Common::Types::CapeLong nPredictorType
 specified type of the predictor
Common::Parameter::ICapeParameterprmParameterisationType
Common::Parameter::ICapeParameterprmPredictorType
Common::Parameter::ICapeParameterprmInitialCorrection
CapeDouble dblLocalXk
 value of the fixed variable
CapeLong indLocalXk
 index of the fixed variable in the vector Y

Detailed Description

Continuation class definition

Author:
Michael Krasnyk

Constructor & Destructor Documentation

~DianaContinuation ( ) [virtual]

Destructor

References DianaContinuation::Terminate().


Member Function Documentation

void addDerivativeByParameter ( Diana::DianaSparseArray Jaco,
int  nJacCol,
int  nParamIndex 
) [protected, virtual]

Adds derivative by the parameter to the Jacobi matrix

Parameters:
nJacColcolumn where to place derivative vector.
paramparameter pointer.

Reimplemented in SingAnalyser.

References sparray::append(), CapeVariant::asDouble(), ICapeParameter::GetValue(), and ICapeParameter::SetValue().

Adds "free" parameter (the possible variants are continuation parameter, unfolding parameters, etc). Such parameters are sused as state variables in the continuation.

Parameters:
strParNameis the name of the continuation parameter.
maxValueparameter maximum value.
minValueparameter minimum value.
Note:
if minValue and maxValue equals 0.0 then will be used values defined in the model.

Implements IDianaContinuation.

References Common::Error::ECodeNone.

void calcTangentVector ( const Common::Types::CapeArrayDouble Y,
Common::Types::CapeArrayDouble T,
PredictorType  type 
) [protected]

Function calcTangentVector calculates tangent T for the point Y

  • type=TangentPredictor, than $T=J(Y)^{-1}*[0...0 +/-1]$
  • type=ChordPredictor, than $T=Y-Y0$ Tangent vector normalised, so $||T||_2=1.0$.

References ECapeUser::code, ECapeUser::description, Common::Error::ECodeNone, ECapeUser::interfaceName, ECapeUser::moreInfo, ECapeUser::operation, and ECapeUser::scope.

CapeBoolean calcTestCondition ( CapeBoolean  bFirstCall = false) [protected, virtual]

Evaluates specified test conditions during continuation.

Returns:
true if the condition occurs.

Dummy function, returns false

Reimplemented in SingAnalyser, and SteadyStateContinuation.

CapeBoolean checkVariableBoundaries ( const Common::Types::CapeArrayDouble Y) [protected]

Check variable boundaries.

Parameters:
Ycurrent state vector
Returns:
true if all variables are in bounds.

Function checkVariableFiniteness checks input vector Y for finite values

Returns:
index of the first NaN, Inf or -Inf component

Main continuation method.

Returns:
Continuation return code ContiReturn

Implements IDianaContinuation.

Reimplemented in SingAnalyser, and HopfPointContinuation.

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

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

Implements ICapeNumericSolver.

References DianaContinuation::Terminate().

Solves nonlinear system with help of the Newton method, uses static members formFunction and formJacobian to generate residual vector and Jacobi matrix of the system.

Parameters:
Yinitial vector for the solution iterations. If the Newton iterations will be succeeded, then this vector will contain result of the iterations.
bCheckIterationsif this flag is equal true, then nSuccessIts used to check success of the iterations. If total number more then nSuccessIts, will be returned error SolveTooManyIterations, even if the method successfully converged.
Returns:
SolveReturn
void formFunction ( const Common::Types::CapeArrayDouble Y,
Common::Types::CapeArrayDouble Res 
) [protected]

Function fills vector Res with a residual of the current system

Parameters:
Ycurrent state vector of the system.
Resresidual vector.

References Common::Error::ECodeNone.

gets the description of the component.

Implements ICapeIdentification.

returns the name of the component.

Implements ICapeIdentification.

std::vector< std::complex< Common::Types::CapeDouble > > GetEigenvalues ( ) throw (Common::Error::ECapeUnknown) [protected, virtual]

Returns eigenvalues of the generalized eigenvalues problem (PhD thesis, section 2.3) or Floquet multipliers (PhD thesis, section 3.2 )

Implements IDianaContinuation.

Reimplemented in SteadyStateContinuation.

References Common::Error::ECodeNone.

virtual int getModelEquations ( ) [protected, pure virtual]

Returns size of the problem residual vector.

Implemented in SingAnalyser, HopfPointContinuation, and SteadyStateContinuation.

Referenced by DianaContinuation::initSystemVariables().

virtual int getModelVariables ( ) [protected, pure virtual]

Returns size of the problem variables subvector.

Implemented in SingAnalyser, HopfPointContinuation, and SteadyStateContinuation.

Referenced by DianaContinuation::initSystemVariables().

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.

Returns the current solution point. Size of the vector depends on the solver parameters such as ParameterisationType etc.

Implements ICapeNumericSolver.

References Common::Error::ECodeNone.

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.

References DianaContinuation::bInitialized, DianaContinuation::initSystemVariables(), DianaContinuation::packVector(), and DianaContinuation::vecY.

int makeBoundaryCorrection ( Common::Types::CapeArrayDouble Y,
const DianaINTSignalHandler inthandler 
) [protected]

Check variable boundaries and tries to make a correction on a boundary. If return value is 1, Y will contain corrected state vector.

Parameters:
Ycurrent state vector
Returns:
on of this values:
  • 0 all variables are in bounds
  • 1 was reached boundary by the nVarIdx variable, and correction was succesful.
  • -1 was reached boundary by the nVarIdx variable, and correction was unsuccesful
void packFreeParameters ( int  nFreeParamsPos,
Common::Types::CapeArrayDouble modelVector 
) [private]
virtual void packModelBoundaries ( Common::Types::CapeArrayDouble arrMinY,
Common::Types::CapeArrayDouble arrMaxY 
) [protected, pure virtual]

Update boundary arrays dblMinY, dblMaxY. Before call of this function this array this array should have size at least getModelVariables() entries.

Implemented in SingAnalyser, HopfPointContinuation, and SteadyStateContinuation.

Referenced by DianaContinuation::initSystemVariables().

void packModelJacobian ( Diana::DianaSparseArray Jaco) [protected, virtual]

Calculate Jacobian and set data to the matrix with help of addJacobianEntry function.

Reimplemented in SingAnalyser, HopfPointContinuation, and SteadyStateContinuation.

References sparray::append(), and sparray::clear().

virtual void packModelResidual ( Common::Types::CapeArrayDouble modelResidual) [protected, pure virtual]

Calculate residual and copy data to the pVector (ESO.Residual -> pVector).

Implemented in SingAnalyser, HopfPointContinuation, and SteadyStateContinuation.

virtual void packModelVector ( Common::Types::CapeArrayDouble modelVector) [protected, pure virtual]

Copy data from the subclass to the pVector (ESO -> pVector).

Implemented in SingAnalyser, HopfPointContinuation, and SteadyStateContinuation.

Referenced by DianaContinuation::packVector().

void packVector ( Common::Types::CapeArrayDouble work_vector) [private]

Removes "free" parameter.

Parameters:
strParNameis the name of the parameter

Implements IDianaContinuation.

References Common::Error::ECodeNone.

sets the description of the component.

Parameters:
_descriptionthe description of the component

Implements ICapeIdentification.

References Common::Error::ECodeNone.

sets the name of the component.

Parameters:
_namethe name of the component

Implements ICapeIdentification.

References Common::Error::ECodeNone.

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.

References Common::Error::ECodeNone.

Method solves system of nonlinear equations $G(x,0,0)=0$ contained in CAPE-ESO model. Initial values from the pESO state vector. If it succeeds, vecY and pESO will contain found point, otherwise it will be initial point

Returns:
Solve return code SolveReturn

Implements ICapeNumericSolver.

Reimplemented in SingAnalyser, and HopfPointContinuation.

References Common::Error::ECodeError, and Common::Error::ECodeNone.

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.

References DianaContinuation::destroySystemVariables().

Referenced by DianaContinuation::Destroy(), and DianaContinuation::~DianaContinuation().

void unpackFreeParameters ( int  nFreeParamsPos,
const Common::Types::CapeArrayDouble modelVector 
) [private]

Copy continuation parameters from the the pVector to ESO data structures.

References DianaContinuation::arrFreeParams, Common::Error::ECodeNone, DianaCollection::ItemByIndex(), and ICapeParameter::SetValue().

Referenced by DianaContinuation::unpackVector().

virtual void unpackModelVector ( const Common::Types::CapeArrayDouble modelVector) [protected, pure virtual]

Copy data from the the pVector to subclass data structures (pVector -> ESO).

Implemented in SingAnalyser, HopfPointContinuation, and SteadyStateContinuation.

Referenced by DianaContinuation::unpackVector().

void unpackVector ( const Common::Types::CapeArrayDouble work_vector) [private]

Member Data Documentation

if exit code Continuate is OkAchievedBoundary, InitialPointNaN or InitialPointNotInRange variable nBoundaryVariableIdx contains index of the variable.

Referenced by DianaContinuation::DianaContinuation().

ResidualType nResidualType [private]

type of the residual, for internal use in formFunction and formJacobian


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