OpenFCST: The open-source Fuel Cell Simulation Toolbox
|
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... | |
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
and algebraic constraints
for
The DAE is subjected to the boundary conditions
where
The exact solution is represented by
where
is the ith derivative of
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.
m_comp | is the number of ODEs defined in fsub. |
ny | is the number of algebraic constraints defined in fsub. |
m | is an array of size m_comp that contains the orders for each ODE defined in fsub. |
a | is the left-most boundary condition. |
b | is the right-most boundary condition. |
zeta | is 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. |
fsub | is a user-supplied function that defines the ODEs and algebraic constraints. |
dfsub | is a user-supplied function that defines the Jacobian matrix of fsub. |
gsub | is a user-supplied function that defines the boundary conditions. |
dgsub | is a user-supplied function that defines the partial derivatives of gsub. |
guess | is a optional user-supplied function that defines an initial guess. |
|
inline |
|
protected |
void FuelCell::ApplicationCore::DAESolver::DAE_solution | ( | double | x, |
double | z[], | ||
double | y[] | ||
) |
Return a solution for the DAE at point x.
x | is a value between a <= x <= b. |
z | is an array that contains the solution z(u(z)). |
y | is an array that contains the solution y(x). |
int FuelCell::ApplicationCore::DAESolver::DAE_solve | ( | void | ) |
Solves the DAE.
void FuelCell::ApplicationCore::DAESolver::get_copy_final_mesh | ( | double * | mesh | ) |
Returns a copy of the final mesh.
mesh | is a pointer to an array used to store a copy of the mesh. |
|
inline |
Get the order of ODE's.
References ODEs_Orders.
|
inline |
Get the number of mesh points in the final mesh.
References ispace.
double* FuelCell::ApplicationCore::DAESolver::return_float_space | ( | void | ) |
Gets the double array used by COLDAE.
int* FuelCell::ApplicationCore::DAESolver::return_integer_space | ( | void | ) |
Gets the integer array used by COLDAE.
|
protected |
Sets the left and right-most boundary points.
a | is the left-most boundary point. |
b | is 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.
pnts | is the number of collocation points to be used in each subinterval. |
void FuelCell::ApplicationCore::DAESolver::set_DAE_index | ( | int | index | ) |
Set index of DAE.
index | is the index value of the DAE such that index =0,1,2. |
|
protected |
Sets the Jacobian of the ODE function.
dfsub | is a user-supplied function that defines the Jacobian matrix of fsub. |
|
protected |
Sets the partial derivative of the boundary condition function.
dgsub | is 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.
fixpnt_size | is the number of fixed points. is an array that contains the location of the fixed points. |
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.
fspace_size | is the size of double array. |
fspace | is an optional parameter to pass a double array from a previous run. |
|
protected |
Set the ODE function.
fsub | is a user-supplied function that defines the ODEs and algebraic constraints. |
|
protected |
Sets the boundary condition function.
gsub | is a user-supplied function that defines the boundary conditions. |
|
protected |
Sets the initial-guess function.
guess | is 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.
pnts | is the initial mesh size. |
void FuelCell::ApplicationCore::DAESolver::set_integer_space | ( | int | ispace_size = 0 | ) |
Sets the size of the integer array used by COLDAE.
ispace_size | is the size of integer array. |
|
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.
void FuelCell::ApplicationCore::DAESolver::set_output | ( | int | level | ) |
Set output level for COLDAE.
level | is the desired output level where level = -1 is for full output, level = 0 is for selected output, and level=1 is for no output. |
|
protected |
Sets the problem size.
num_ODEs | is the number of ODE. |
num_Alg_Const | is the number of algebraic constraints. |
ODEs_Orders | is an array that contains the orders of each of the ODEs defined in fsub. |
|
protected |
Sets additional boundary points.
zeta_size | is the size of the array zeta. |
zeta | is 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.
control | is 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.
ltol_size | is the size of both arrays ltol and tol. |
ltol | is an array such that the ltol[i]=l specifies that tol[i] is assigned to the lth component of z(u). |
tol | is an array of tolerances. |
void FuelCell::ApplicationCore::DAESolver::use_simple_cont | ( | void | ) |
Allows for simple continuation.
|
inline |
Overloads delete operator.
References ispace.
|
protected |
Leftmost boundary point.
|
protected |
Rightmost boundary point.
|
protected |
Number of collocation points.
|
protected |
Pointer to wrapper for jacobian of fsub.
|
protected |
|
protected |
|
protected |
Pointer to boundary condition function.
|
protected |
Pointer to geuss function.
|
protected |
DAE index.
|
protected |
Array of fixed points.
|
protected |
Size of fixpnt array.
|
protected |
Double array used by COLDAE.
|
protected |
Size of fspace.
|
protected |
Boolian for jacobian of fsub wrapper function.
|
protected |
Boolian for jacobian of boundary condition function.
|
protected |
Boolian for DAE function.
|
protected |
Boolian for boundary condition function.
|
protected |
Boolian for guess function.
|
protected |
Size of initial mesh.
|
protected |
Array of info passed to COLDAE.
|
protected |
Integer array used by COLDAE.
Referenced by get_size_final_mesh(), and use_sol_as_guess().
|
protected |
size of ispace
|
protected |
Linear flag.
|
protected |
Array used to hold location of tolerances.
|
protected |
Size of ltol array.
|
protected |
Number of algebraic constants.
|
protected |
Number of ODEs.
|
protected |
A pointer to an array that contains the orders of each of the ODEs.
Referenced by get_ODE_order().
|
protected |
Output level.
|
protected |
Set collocation flag.
|
protected |
fixpnt flag
|
protected |
Set fspace flag.
|
protected |
Set initial mesh flag.
|
protected |
ispace flag
|
protected |
Set ltol flag.
|
protected |
solver control flag
|
protected |
tol flag
|
protected |
Set zeta flag.
|
protected |
solver control parameter (see ipar(10))
|
protected |
Array of tolerances.
|
protected |
use simple continuation
|
protected |
USer old fspace for continuation.
|
protected |
Array of boundary locations.
|
protected |
Size of zeta array.