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 Attributes | List of all members
FuelCell::ApplicationCore::DAEWrapper Class Referenceabstract

This class is to be used as a wrapper for the functions needed in the DAESolver. More...

#include <DAE_wrapper.h>

Inheritance diagram for FuelCell::ApplicationCore::DAEWrapper:
Inheritance graph
[legend]
Collaboration diagram for FuelCell::ApplicationCore::DAEWrapper:
Collaboration graph
[legend]

Public Member Functions

 DAEWrapper ()
 Constructor. More...
 
 ~DAEWrapper ()
 Destructor. More...
 
double integrate (double lb, double ub, std::vector< double > &W, std::vector< double > &F)
 Member function that integrates a solution between a lower and upper bound. More...
 
void get_quadrature_points (double lb, double ub, std::vector< double > &X, std::vector< double > &W, FuelCell::ApplicationCore::DAESolver *prob)
 Function that obtains the gaussian quadrature points and weights. More...
 
virtual void setup_DAE_solver ()=0
 Setup the variables in the problem required by the DAE Solver. More...
 
virtual void fsub (double &, double[], double[], double[])=0
 Define the DAE function. More...
 
virtual void dfsub (double &, double[], double[], double[])=0
 The Jacobian of fsub. More...
 
virtual void gsub (int &, double[], double &)=0
 Define the boundary conditions. More...
 
virtual void dgsub (int &, double[], double[])=0
 The derivatives of the boundary conditions. More...
 
virtual void guess (double &, double[], double[], double[])=0
 The initial guess. More...
 
void verbosity (int i)
 Set the verbosity variable (controls output to screen) More...
 
void DAE_Error (int flag)
 Indicates error in the solve function. More...
 
void clear_memory ()
 

Protected Attributes

int n_mesh
 Number of mesh points. More...
 
double * mesh
 Array of mesh points. More...
 
int n_colloc
 Number of collocation points. More...
 
int n_output
 Output integer variable. More...
 
int n_comp
 number of PDEs More...
 
int n_y
 number of Algebraic constraints More...
 
int * mm
 array of integers storing the order of each PDE More...
 
int m_star
 Integer representing the total number of variables given by $ \sum mm[i] $. More...
 
double boundary_0
 Left boundary point. More...
 
double boundary_1
 Right boundary point. More...
 
double * zeta
 Array of boundary points. More...
 
FuelCell::ApplicationCore::DAESolverprob
 DAE problem solver object. More...
 
double * fixpnt
 Array of fixed points on the mesh. More...
 
int * ltol
 
double * tol
 
double cm_to_m
 Convert from centimetres to metres. More...
 
double cm2_to_m2
 Convert from centimetres squared to metres squared. More...
 
double cm3_to_m3
 Convert from centimetres cubed to metres cubed. More...
 

Detailed Description

This class is to be used as a wrapper for the functions needed in the DAESolver.

All the functions defined within this class are pure and therefore must be reimplemented in a derived class. The functions here are define a Differential Algebraic Equation, more specifically in this case, a system of ODE's.

The derived classes must have the specific implementation of the functions and static wrapper functions that point to the implementation. This is so that the DAESolver can be used in a generic form and interface with COLDAE.

The static wrapper functions should take the form:

static void fsub_wrapper (double &, double [], double [], double [])
* DerivedClass *ptr_to_class = (DerivedClass*) ptr_DAE_object;
* ptr_to_class->fsub(x, z, y, f);
*

where ptr_DAE_object is a void globally defined variable that can take any form. This must be used with caution.

Author
Peter Dobson

Constructor & Destructor Documentation

FuelCell::ApplicationCore::DAEWrapper::DAEWrapper ( )

Constructor.

FuelCell::ApplicationCore::DAEWrapper::~DAEWrapper ( )
inline

Destructor.

Member Function Documentation

void FuelCell::ApplicationCore::DAEWrapper::clear_memory ( )
inline
void FuelCell::ApplicationCore::DAEWrapper::DAE_Error ( int  flag)

Indicates error in the solve function.

Prints error message and aborts the program.

virtual void FuelCell::ApplicationCore::DAEWrapper::dfsub ( double &  ,
double  [],
double  [],
double  [] 
)
pure virtual

The Jacobian of fsub.

Until we decide on how to get AD support in FCST, we must enter the Jacobian in manually. Note that a one-dimensional array must be passed back to COLDAE. However, it is easier to define a two-dimensional array as the matrix (see COLDAE.f). After, use c_to_for_matrix to convert it to the correct one-dimensional array.

Implemented in FuelCellShop::MicroScale::WaterAgglomerate, FuelCellShop::MicroScale::HybridAgglomerate, and FuelCellShop::MicroScale::IonomerAgglomerate.

virtual void FuelCell::ApplicationCore::DAEWrapper::dgsub ( int &  ,
double  [],
double  [] 
)
pure virtual

The derivatives of the boundary conditions.

See COLDAE.f

Implemented in FuelCellShop::MicroScale::WaterAgglomerate, and FuelCellShop::MicroScale::IonomerAgglomerate.

virtual void FuelCell::ApplicationCore::DAEWrapper::fsub ( double &  ,
double  [],
double  [],
double  [] 
)
pure virtual

Define the DAE function.

In this case,it is simply a system of ODES. COLDAE allows for the system to be defined as a system of 2 mixed-order ODEs. See COLDAE.f for additional information about how to define fsub. In particular, see COLDAE.f for the meaning of z and y. Note that because a BVP is solved, y is not used.

Implemented in FuelCellShop::MicroScale::WaterAgglomerate, FuelCellShop::MicroScale::HybridAgglomerate, and FuelCellShop::MicroScale::IonomerAgglomerate.

void FuelCell::ApplicationCore::DAEWrapper::get_quadrature_points ( double  lb,
double  ub,
std::vector< double > &  X,
std::vector< double > &  W,
FuelCell::ApplicationCore::DAESolver prob 
)

Function that obtains the gaussian quadrature points and weights.

Number of points and weights based on based on the order of the polynomial, given by n_colloc + mm[i].

The points returned in

Parameters
Xare transformed to be points between
lband
ub.
virtual void FuelCell::ApplicationCore::DAEWrapper::gsub ( int &  ,
double  [],
double &   
)
pure virtual

Define the boundary conditions.

There are 4 boundary conditions. Note that i refers to the ith boundary condition. See COLDAE.f

Implemented in FuelCellShop::MicroScale::WaterAgglomerate, and FuelCellShop::MicroScale::IonomerAgglomerate.

virtual void FuelCell::ApplicationCore::DAEWrapper::guess ( double &  ,
double  [],
double  [],
double  [] 
)
pure virtual

The initial guess.

This is optional, but a good idea for this problem. If we do not provide this, CODAE will use a constant of 0.0 for an initial guess.

Implemented in FuelCellShop::MicroScale::WaterAgglomerate, and FuelCellShop::MicroScale::IonomerAgglomerate.

double FuelCell::ApplicationCore::DAEWrapper::integrate ( double  lb,
double  ub,
std::vector< double > &  W,
std::vector< double > &  F 
)

Member function that integrates a solution between a lower and upper bound.

The function takes the values of the bounds, and the function evaluated at the quadrature points

The integral is computed using gauss quadrature.

virtual void FuelCell::ApplicationCore::DAEWrapper::setup_DAE_solver ( )
pure virtual

Setup the variables in the problem required by the DAE Solver.

Implemented in FuelCellShop::MicroScale::WaterAgglomerate, and FuelCellShop::MicroScale::IonomerAgglomerate.

void FuelCell::ApplicationCore::DAEWrapper::verbosity ( int  i)
inline

Set the verbosity variable (controls output to screen)

Member Data Documentation

double FuelCell::ApplicationCore::DAEWrapper::boundary_0
protected

Left boundary point.

double FuelCell::ApplicationCore::DAEWrapper::boundary_1
protected

Right boundary point.

double FuelCell::ApplicationCore::DAEWrapper::cm2_to_m2
protected

Convert from centimetres squared to metres squared.

double FuelCell::ApplicationCore::DAEWrapper::cm3_to_m3
protected

Convert from centimetres cubed to metres cubed.

double FuelCell::ApplicationCore::DAEWrapper::cm_to_m
protected

Convert from centimetres to metres.

double* FuelCell::ApplicationCore::DAEWrapper::fixpnt
protected

Array of fixed points on the mesh.

int* FuelCell::ApplicationCore::DAEWrapper::ltol
protected
int FuelCell::ApplicationCore::DAEWrapper::m_star
protected

Integer representing the total number of variables given by $ \sum mm[i] $.

double* FuelCell::ApplicationCore::DAEWrapper::mesh
protected

Array of mesh points.

int* FuelCell::ApplicationCore::DAEWrapper::mm
protected

array of integers storing the order of each PDE

int FuelCell::ApplicationCore::DAEWrapper::n_colloc
protected

Number of collocation points.

int FuelCell::ApplicationCore::DAEWrapper::n_comp
protected

number of PDEs

int FuelCell::ApplicationCore::DAEWrapper::n_mesh
protected

Number of mesh points.

int FuelCell::ApplicationCore::DAEWrapper::n_output
protected

Output integer variable.

int FuelCell::ApplicationCore::DAEWrapper::n_y
protected

number of Algebraic constraints

FuelCell::ApplicationCore::DAESolver* FuelCell::ApplicationCore::DAEWrapper::prob
protected

DAE problem solver object.

double* FuelCell::ApplicationCore::DAEWrapper::tol
protected
double* FuelCell::ApplicationCore::DAEWrapper::zeta
protected

Array of boundary points.


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