OpenFCST: The open-source Fuel Cell Simulation Toolbox
|
This class is to be used as a wrapper for the functions needed in the DAESolver. More...
#include <DAE_wrapper.h>
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 . More... | |
double | boundary_0 |
Left boundary point. More... | |
double | boundary_1 |
Right boundary point. More... | |
double * | zeta |
Array of boundary points. More... | |
FuelCell::ApplicationCore::DAESolver * | prob |
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... | |
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:
where ptr_DAE_object is a void globally defined variable that can take any form. This must be used with caution.
FuelCell::ApplicationCore::DAEWrapper::DAEWrapper | ( | ) |
Constructor.
|
inline |
Destructor.
|
inline |
References omp_get_thread_num, and ptr_DAE_object.
void FuelCell::ApplicationCore::DAEWrapper::DAE_Error | ( | int | flag | ) |
Indicates error in the solve function.
Prints error message and aborts the program.
|
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.
|
pure virtual |
The derivatives of the boundary conditions.
See COLDAE.f
Implemented in FuelCellShop::MicroScale::WaterAgglomerate, and FuelCellShop::MicroScale::IonomerAgglomerate.
|
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
X | are transformed to be points between |
lb | and |
ub. |
|
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.
|
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.
|
pure virtual |
Setup the variables in the problem required by the DAE Solver.
Implemented in FuelCellShop::MicroScale::WaterAgglomerate, and FuelCellShop::MicroScale::IonomerAgglomerate.
|
inline |
Set the verbosity variable (controls output to screen)
|
protected |
Left boundary point.
|
protected |
Right boundary point.
|
protected |
Convert from centimetres squared to metres squared.
|
protected |
Convert from centimetres cubed to metres cubed.
|
protected |
Convert from centimetres to metres.
|
protected |
Array of fixed points on the mesh.
|
protected |
|
protected |
Integer representing the total number of variables given by .
|
protected |
Array of mesh points.
|
protected |
array of integers storing the order of each PDE
|
protected |
Number of collocation points.
|
protected |
number of PDEs
|
protected |
Number of mesh points.
|
protected |
Output integer variable.
|
protected |
number of Algebraic constraints
|
protected |
DAE problem solver object.
|
protected |
|
protected |
Array of boundary points.