OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
FuelCell::ApplicationCore::DAESolver Class Reference

This class provides an interface to the Fortran 77 code COLDAE. More...

#include <DAE_solver.h>

Public Member Functions

 DAESolver (int m_comp, int ny, int m[], double a, double b, double zeta[], void(*fsub)(double &, double[], double[], double[]), void(*dfsub)(double &, double[], double[], double[]), void(*gsub)(int &, double[], double &), void(*dgsub)(int &, double[], double[]), void(*guess)(double &, double[], double[], double[])=NULL)
 Constructor. More...
 
 ~DAESolver ()
 Destructor - clear all data. More...
 
void set_tolerance (int ltol_size=0, int *ltol=NULL, double *tol=NULL)
 Set tolerances for solution components. More...
 
void set_linear (void)
 Indicate if the problem is linear. More...
 
void set_collocation_points (int pnts)
 Sets number of collocation points to be used in each subinterval. More...
 
void set_initial_mesh_size (int pnts)
 Sets the initial mesh size. More...
 
void set_integer_space (int ispace_size=0)
 Sets the size of the integer array used by COLDAE. More...
 
void set_float_space (int fspace_size=0, double *fspace=NULL)
 Sets the size and location of double array used by COLDAE. More...
 
void set_output (int level)
 Set output level for COLDAE. More...
 
void set_fixpnts (int fixpnt_size=1, double *fixpnt=NULL)
 Set the fixed points in the mesh. More...
 
void set_solver_control (int control)
 Set the solver control parameter. More...
 
void set_DAE_index (int index)
 Set index of DAE. More...
 
void use_simple_cont (void)
 Allows for simple continuation. More...
 
int get_ODE_order (void)
 Get the order of ODE's. More...
 
int DAE_solve (void)
 Solves the DAE. More...
 
void DAE_solution (double x, double z[], double y[])
 Return a solution for the DAE at point x. More...
 
int * return_integer_space (void)
 Gets the integer array used by COLDAE. More...
 
double * return_float_space (void)
 Gets the double array used by COLDAE. More...
 
int get_size_final_mesh (void)
 Get the number of mesh points in the final mesh. More...
 
void get_copy_final_mesh (double *mesh)
 Returns a copy of the final mesh. More...
 
void use_sol_as_guess ()
 Overloads delete operator. More...
 

Protected Member Functions

void set_fsub (void(*fsub)(double &, double[], double[], double[]))
 Set the ODE function. More...
 
void set_dfsub (void(*dfsub)(double &, double[], double[], double[]))
 Sets the Jacobian of the ODE function. More...
 
void set_gsub (void(*)(int &, double[], double &))
 Sets the boundary condition function. More...
 
void set_dgsub (void(*)(int &, double[], double[]))
 Sets the partial derivative of the boundary condition function. More...
 
void set_guess (void(*)(double &, double[], double[], double[]))
 Sets the initial-guess function. More...
 
void set_prob_size (int num_ODEs, int num_Alg_Const, int *ODEs_Orders)
 Sets the problem size. More...
 
void set_boundary_points (int a, int b)
 Sets the left and right-most boundary points. More...
 
void set_side_conditions (int zeta_size, double *zeta)
 Sets additional boundary points. More...
 
void set_ipar (void)
 Creates an array that contains various information about how to solve the DAE. More...
 
void clear_mem (void)
 Deletes dynamic memory. More...
 

Protected Attributes

void(* DAE_fsub )(double &, double[], double[], double[])
 
void(* DAE_dfsub )(double &, double[], double[], double[])
 Pointer to wrapper for jacobian of fsub. More...
 
void(* DAE_gsub )(int &, double[], double &)
 Pointer to boundary condition function. More...
 
void(* DAE_dgsub )(int &, double[], double[])
 
void(* DAE_guess )(double &, double[], double[], double[])
 Pointer to geuss function. More...
 
bool have_fsub
 Boolian for DAE function. More...
 
bool have_dfsub
 Boolian for jacobian of fsub wrapper function. More...
 
bool have_gsub
 Boolian for boundary condition function. More...
 
bool have_dgsub
 Boolian for jacobian of boundary condition function. More...
 
bool have_guess
 Boolian for guess function. More...
 
double * zeta
 Array of boundary locations. More...
 
int zeta_size
 Size of zeta array. More...
 
bool set_zeta
 Set zeta flag. More...
 
int * ltol
 Array used to hold location of tolerances. More...
 
bool set_ltol
 Set ltol flag. More...
 
int ltol_size
 Size of ltol array. More...
 
double * tol
 Array of tolerances. More...
 
bool set_tol
 tol flag More...
 
int * ipar
 Array of info passed to COLDAE. More...
 
bool linear
 Linear flag. More...
 
int collpnts
 Number of collocation points. More...
 
bool set_collpnts
 Set collocation flag. More...
 
int intialmeshsize
 Size of initial mesh. More...
 
bool set_intialmeshsize
 Set initial mesh flag. More...
 
int * ispace
 Integer array used by COLDAE. More...
 
int ispace_size
 size of ispace More...
 
bool set_ispace
 ispace flag More...
 
double * fspace
 Double array used by COLDAE. More...
 
int fspace_size
 Size of fspace. More...
 
bool set_fspace
 Set fspace flag. More...
 
bool use_old_fspace
 USer old fspace for continuation. More...
 
int output_level
 Output level. More...
 
double * fixpnt
 Array of fixed points. More...
 
bool set_fixpnt
 fixpnt flag More...
 
int fixpnt_size
 Size of fixpnt array. More...
 
bool set_solvercontrol
 solver control flag More...
 
int solvercontrol
 solver control parameter (see ipar(10)) More...
 
int DAE_index
 DAE index. More...
 
int num_ODEs
 Number of ODEs. More...
 
int num_Alg_Const
 Number of algebraic constants. More...
 
int * ODEs_Orders
 A pointer to an array that contains the orders of each of the ODEs. More...
 
double a
 Leftmost boundary point. More...
 
double b
 Rightmost boundary point. More...
 
bool use_cont
 use simple continuation More...
 

Detailed Description

This class provides an interface to the Fortran 77 code COLDAE.

COLDAE solves multi-point boundary-value DAEs for a system of mixed-order ODEs

\[ u_{i}^{(m_{i})} = f_{i} ( x; z(u(x)), y(x) ), \quad i = 1, ... ,\tt{m\_comp}, \]

and algebraic constraints

\[ 0 = f_{i}( x; z(u(x)), y(x) ), \quad i = \tt{m\_comp}+1,...,\tt{m\_comp}+\tt{ny}, \]

for

\[ a < x < b. \]

The DAE is subjected to the boundary conditions

\[ g_{j} ( \zeta_{j}; z(u(\zeta_{j})) ) = 0, \quad j = 1, ... ,m^{*}, \]

where

\[ a \leq \zeta_{1} \leq \zeta_{2} \leq \dots \leq \zeta_{m^{*}} \leq b, \]

\[ m^{*} = \sum^{\tt{m\_comp}}_{i=1} m_{i}. \]

The exact solution is represented by

\[ z(u(x)) = ( u_{1}^{(1)}(x), u_{1}^{(m_{1}-1)}(x), \dots, u_{\tt{m\_comp}}^{m_{(\tt{m\_comp}-1)}}(x), \]

where

\[ u_{i}^{(m_{i})} \]

is the ith derivative of

\[ u_{i}. \]

Constructor & Destructor Documentation

FuelCell::ApplicationCore::DAESolver::DAESolver ( int  m_comp,
int  ny,
int  m[],
double  a,
double  b,
double  zeta[],
void(*)(double &, double[], double[], double[])  fsub,
void(*)(double &, double[], double[], double[])  dfsub,
void(*)(int &, double[], double &)  gsub,
void(*)(int &, double[], double[])  dgsub,
void(*)(double &, double[], double[], double[])  guess = NULL 
)

Constructor.

Parameters
m_compis the number of ODEs defined in fsub.
nyis the number of algebraic constraints defined in fsub.
mis an array of size m_comp that contains the orders for each ODE defined in fsub.
ais the left-most boundary condition.
bis the right-most boundary condition.
zetais an array that holds the location, in the problem domain, of each of the boundary conditions defined in gsub. The ith element in zeta is associated with the ith boundary condition defined in gsub.
fsubis a user-supplied function that defines the ODEs and algebraic constraints.
dfsubis a user-supplied function that defines the Jacobian matrix of fsub.
gsubis a user-supplied function that defines the boundary conditions.
dgsubis a user-supplied function that defines the partial derivatives of gsub.
guessis a optional user-supplied function that defines an initial guess.
Note
ny should equal zero if solving a boundary-value ODE.
FuelCell::ApplicationCore::DAESolver::~DAESolver ( )
inline

Destructor - clear all data.

References clear_mem().

Here is the call graph for this function:

Member Function Documentation

void FuelCell::ApplicationCore::DAESolver::clear_mem ( void  )
protected

Deletes dynamic memory.

Referenced by ~DAESolver().

Here is the caller graph for this function:

void FuelCell::ApplicationCore::DAESolver::DAE_solution ( double  x,
double  z[],
double  y[] 
)

Return a solution for the DAE at point x.

Parameters
xis a value between a <= x <= b.
zis an array that contains the solution z(u(z)).
yis an array that contains the solution y(x).
int FuelCell::ApplicationCore::DAESolver::DAE_solve ( void  )

Solves the DAE.

Returns
A flag indicating success is returned where 1 indicates a normal return, 0 indicates the collocation matrix is singular, -1 indicates the expected number of subintervals exceeds storage specifications, -2 indicates the nonlinear iteration has not converged, and -3 indicates there is an input data error.
void FuelCell::ApplicationCore::DAESolver::get_copy_final_mesh ( double *  mesh)

Returns a copy of the final mesh.

Parameters
meshis a pointer to an array used to store a copy of the mesh.
Note
This function should only be used after a call to DAE_solve().
int FuelCell::ApplicationCore::DAESolver::get_ODE_order ( void  )
inline

Get the order of ODE's.

References ODEs_Orders.

int FuelCell::ApplicationCore::DAESolver::get_size_final_mesh ( void  )
inline

Get the number of mesh points in the final mesh.

Returns
The size of the final mesh is returned.
Note
This function should only be used after a call to DAE_solve().

References ispace.

double* FuelCell::ApplicationCore::DAESolver::return_float_space ( void  )

Gets the double array used by COLDAE.

Returns
A pointer to the double array used by COLDAE is returned.
int* FuelCell::ApplicationCore::DAESolver::return_integer_space ( void  )

Gets the integer array used by COLDAE.

Returns
A pointer to the integer array used by COLDAE is is returned.
void FuelCell::ApplicationCore::DAESolver::set_boundary_points ( int  a,
int  b 
)
protected

Sets the left and right-most boundary points.

Parameters
ais the left-most boundary point.
bis the right-most boundary point.
void FuelCell::ApplicationCore::DAESolver::set_collocation_points ( int  pnts)

Sets number of collocation points to be used in each subinterval.

Parameters
pntsis the number of collocation points to be used in each subinterval.
Note
Must be used before a call to DAE_solve().
void FuelCell::ApplicationCore::DAESolver::set_DAE_index ( int  index)

Set index of DAE.

Parameters
indexis the index value of the DAE such that index =0,1,2.
Note
Must be used before a call to DAE_solve().
void FuelCell::ApplicationCore::DAESolver::set_dfsub ( void(*)(double &, double[], double[], double[])  dfsub)
protected

Sets the Jacobian of the ODE function.

Parameters
dfsubis a user-supplied function that defines the Jacobian matrix of fsub.
void FuelCell::ApplicationCore::DAESolver::set_dgsub ( void(*)(int &, double[], double[])  )
protected

Sets the partial derivative of the boundary condition function.

Parameters
dgsubis a user-supplied function that defines the partial derivatives of gsub.
void FuelCell::ApplicationCore::DAESolver::set_fixpnts ( int  fixpnt_size = 1,
double *  fixpnt = NULL 
)

Set the fixed points in the mesh.

Parameters
fixpnt_sizeis the number of fixed points. is an array that contains the location of the fixed points.
Note
Must be used before a call to DAE_solve().
void FuelCell::ApplicationCore::DAESolver::set_float_space ( int  fspace_size = 0,
double *  fspace = NULL 
)

Sets the size and location of double array used by COLDAE.

Parameters
fspace_sizeis the size of double array.
fspaceis an optional parameter to pass a double array from a previous run.
Note
Must be used before a call to DAE_solve().
void FuelCell::ApplicationCore::DAESolver::set_fsub ( void(*)(double &, double[], double[], double[])  fsub)
protected

Set the ODE function.

Parameters
fsubis a user-supplied function that defines the ODEs and algebraic constraints.
void FuelCell::ApplicationCore::DAESolver::set_gsub ( void(*)(int &, double[], double &)  )
protected

Sets the boundary condition function.

Parameters
gsubis a user-supplied function that defines the boundary conditions.
void FuelCell::ApplicationCore::DAESolver::set_guess ( void(*)(double &, double[], double[], double[])  )
protected

Sets the initial-guess function.

Parameters
guessis a optional user-supplied function that defines an initial guess.
void FuelCell::ApplicationCore::DAESolver::set_initial_mesh_size ( int  pnts)

Sets the initial mesh size.

Parameters
pntsis the initial mesh size.
Note
Must be used before a call to DAE_solve().
void FuelCell::ApplicationCore::DAESolver::set_integer_space ( int  ispace_size = 0)

Sets the size of the integer array used by COLDAE.

Parameters
ispace_sizeis the size of integer array.
Note
Must be used before a call to DAE_solve().
void FuelCell::ApplicationCore::DAESolver::set_ipar ( void  )
protected

Creates an array that contains various information about how to solve the DAE.

void FuelCell::ApplicationCore::DAESolver::set_linear ( void  )

Indicate if the problem is linear.

Note
Must be used before a call to DAE_solve(). If not, COLDAE treats the problem as a nonlinear problem.
void FuelCell::ApplicationCore::DAESolver::set_output ( int  level)

Set output level for COLDAE.

Parameters
levelis the desired output level where level = -1 is for full output, level = 0 is for selected output, and level=1 is for no output.
Note
Must be used before a call to DAE_solve().
void FuelCell::ApplicationCore::DAESolver::set_prob_size ( int  num_ODEs,
int  num_Alg_Const,
int *  ODEs_Orders 
)
protected

Sets the problem size.

Parameters
num_ODEsis the number of ODE.
num_Alg_Constis the number of algebraic constraints.
ODEs_Ordersis an array that contains the orders of each of the ODEs defined in fsub.
void FuelCell::ApplicationCore::DAESolver::set_side_conditions ( int  zeta_size,
double *  zeta 
)
protected

Sets additional boundary points.

Parameters
zeta_sizeis the size of the array zeta.
zetais an array that holds boundary points other than a and b.
void FuelCell::ApplicationCore::DAESolver::set_solver_control ( int  control)

Set the solver control parameter.

Parameters
controlis the integer defined in ipar(10) -1 if the first relax factor is RSTART 0 if the problem is regular 1 if the newton iterations are not to be damped 2 if we are to return immediately upon (a) two successive nonconvergences, or (b) after obtaining error estimate for the first time.
void FuelCell::ApplicationCore::DAESolver::set_tolerance ( int  ltol_size = 0,
int *  ltol = NULL,
double *  tol = NULL 
)

Set tolerances for solution components.

Parameters
ltol_sizeis the size of both arrays ltol and tol.
ltolis an array such that the ltol[i]=l specifies that tol[i] is assigned to the lth component of z(u).
tolis an array of tolerances.
Note
Must be used before a call to DAE_solve().
void FuelCell::ApplicationCore::DAESolver::use_simple_cont ( void  )

Allows for simple continuation.

Note
Should only be ran after atleast one use of DAE_solve
void FuelCell::ApplicationCore::DAESolver::use_sol_as_guess ( )
inline

Overloads delete operator.

References ispace.

Member Data Documentation

double FuelCell::ApplicationCore::DAESolver::a
protected

Leftmost boundary point.

double FuelCell::ApplicationCore::DAESolver::b
protected

Rightmost boundary point.

int FuelCell::ApplicationCore::DAESolver::collpnts
protected

Number of collocation points.

void(* FuelCell::ApplicationCore::DAESolver::DAE_dfsub)(double &, double[], double[], double[])
protected

Pointer to wrapper for jacobian of fsub.

void(* FuelCell::ApplicationCore::DAESolver::DAE_dgsub)(int &, double[], double[])
protected
  • Pointer to jacobian of boundary condition function
void(* FuelCell::ApplicationCore::DAESolver::DAE_fsub)(double &, double[], double[], double[])
protected
  • Pointer to DAE function
void(* FuelCell::ApplicationCore::DAESolver::DAE_gsub)(int &, double[], double &)
protected

Pointer to boundary condition function.

void(* FuelCell::ApplicationCore::DAESolver::DAE_guess)(double &, double[], double[], double[])
protected

Pointer to geuss function.

int FuelCell::ApplicationCore::DAESolver::DAE_index
protected

DAE index.

double* FuelCell::ApplicationCore::DAESolver::fixpnt
protected

Array of fixed points.

int FuelCell::ApplicationCore::DAESolver::fixpnt_size
protected

Size of fixpnt array.

double* FuelCell::ApplicationCore::DAESolver::fspace
protected

Double array used by COLDAE.

int FuelCell::ApplicationCore::DAESolver::fspace_size
protected

Size of fspace.

bool FuelCell::ApplicationCore::DAESolver::have_dfsub
protected

Boolian for jacobian of fsub wrapper function.

bool FuelCell::ApplicationCore::DAESolver::have_dgsub
protected

Boolian for jacobian of boundary condition function.

bool FuelCell::ApplicationCore::DAESolver::have_fsub
protected

Boolian for DAE function.

bool FuelCell::ApplicationCore::DAESolver::have_gsub
protected

Boolian for boundary condition function.

bool FuelCell::ApplicationCore::DAESolver::have_guess
protected

Boolian for guess function.

int FuelCell::ApplicationCore::DAESolver::intialmeshsize
protected

Size of initial mesh.

int* FuelCell::ApplicationCore::DAESolver::ipar
protected

Array of info passed to COLDAE.

int* FuelCell::ApplicationCore::DAESolver::ispace
protected

Integer array used by COLDAE.

Referenced by get_size_final_mesh(), and use_sol_as_guess().

int FuelCell::ApplicationCore::DAESolver::ispace_size
protected

size of ispace

bool FuelCell::ApplicationCore::DAESolver::linear
protected

Linear flag.

int* FuelCell::ApplicationCore::DAESolver::ltol
protected

Array used to hold location of tolerances.

int FuelCell::ApplicationCore::DAESolver::ltol_size
protected

Size of ltol array.

int FuelCell::ApplicationCore::DAESolver::num_Alg_Const
protected

Number of algebraic constants.

int FuelCell::ApplicationCore::DAESolver::num_ODEs
protected

Number of ODEs.

int* FuelCell::ApplicationCore::DAESolver::ODEs_Orders
protected

A pointer to an array that contains the orders of each of the ODEs.

Referenced by get_ODE_order().

int FuelCell::ApplicationCore::DAESolver::output_level
protected

Output level.

bool FuelCell::ApplicationCore::DAESolver::set_collpnts
protected

Set collocation flag.

bool FuelCell::ApplicationCore::DAESolver::set_fixpnt
protected

fixpnt flag

bool FuelCell::ApplicationCore::DAESolver::set_fspace
protected

Set fspace flag.

bool FuelCell::ApplicationCore::DAESolver::set_intialmeshsize
protected

Set initial mesh flag.

bool FuelCell::ApplicationCore::DAESolver::set_ispace
protected

ispace flag

bool FuelCell::ApplicationCore::DAESolver::set_ltol
protected

Set ltol flag.

bool FuelCell::ApplicationCore::DAESolver::set_solvercontrol
protected

solver control flag

bool FuelCell::ApplicationCore::DAESolver::set_tol
protected

tol flag

bool FuelCell::ApplicationCore::DAESolver::set_zeta
protected

Set zeta flag.

int FuelCell::ApplicationCore::DAESolver::solvercontrol
protected

solver control parameter (see ipar(10))

double* FuelCell::ApplicationCore::DAESolver::tol
protected

Array of tolerances.

bool FuelCell::ApplicationCore::DAESolver::use_cont
protected

use simple continuation

bool FuelCell::ApplicationCore::DAESolver::use_old_fspace
protected

USer old fspace for continuation.

double* FuelCell::ApplicationCore::DAESolver::zeta
protected

Array of boundary locations.

int FuelCell::ApplicationCore::DAESolver::zeta_size
protected

Size of zeta array.


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