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::ParametricStudy< dim > Class Template Reference

This application is used to perform a parametric study for a given fuel cell model. More...

#include <parametric_study.h>

Inheritance diagram for FuelCell::ParametricStudy< dim >:
Inheritance graph
[legend]

Public Member Functions

 ParametricStudy ()
 Constructor. More...
 
 ~ParametricStudy ()
 
void declare_parameters (ParameterHandler &) const
 
void initialize (ParameterHandler &)
 Read parameters from file. More...
 
void run (ParameterHandler &param, std::string simulator_parameter_file_name, boost::shared_ptr< SimulationSelector< dim > > sim_selector)
 Run a full polarization curve run. More...
 

Protected Member Functions

virtual void set_parameters (ParameterHandler &param, const shared_ptr< FuelCell::ApplicationCore::AdaptiveRefinement< dim > > &solver, const int iteration, const std::vector< std::string > parameter_name, const std::vector< double > param_value)
 Modify cell voltage and any other parameters that you would like to modify with respect to the inital input file. More...
 
void run_point (ParameterHandler &param, const std::string simulator_parameter_file_name, const boost::shared_ptr< SimulationSelector< dim > > sim_selector, const int iteration, const std::vector< std::string > parameter_name, const std::vector< double > param_value, std::map< std::string, double > &functionals)
 Run a single point in the polarization curve and return the current density and any other data. More...
 
void print_iteration_info (const unsigned int iteration, const double param_value) const
 
void print_iteration_info (const unsigned int iteration, const std::vector< double > param_value) const
 
virtual void print_parameters () const
 Print parameters: More...
 
virtual void print_parameteric_study_header ()
 Print parameteric study header into a file. More...
 
void register_data (const double, std::map< std::string, double > &functionals)
 Store the value of the current density in the solution. More...
 

Protected Attributes

std::string parameter_filename
 Variable where the output file to store parameteric study results is stored. More...
 
std::vector< std::string > parameter_name
 String that defines the parameter that we would like to modify The parameter should be of the from. More...
 
double p_init
 Initial value to run the parametric study, in the units specified for the value. More...
 
double p_end
 Final parameter value used in the parameteric study. More...
 
double dp
 Spacing between points in the parameteric study. More...
 
std::vector< std::vector
< double > > 
p_values
 Another way to define the sequence of parameter values is to use the vector p_values instead of variables p_init, p_end, and dp. More...
 
bool adaptive
 Set to true if you would like to reduce the voltage increment adaptively if convergence could not be achieved with the larger value. More...
 
double min_dp
 
int n_dpPts
 
bool convergence
 Convergence of the solution. More...
 
std::vector< std::vector
< double > > 
curve
 Map used to store the parametric study data. More...
 
std::ofstream myfile
 File object for output logging. More...
 
std::vector< std::string > name_responses
 
int n_resp
 
const unsigned int max_num_parameters = 10
 Set the maximum number of parameters that you can alter in a Parametric Study. More...
 
FuelCell::ApplicationCore::FEVector coarse_solution
 Vector used to store the solution from the previous iteration if convergence has been achieved. More...
 

Detailed Description

template<int dim>
class FuelCell::ParametricStudy< dim >

This application is used to perform a parametric study for a given fuel cell model.

This class reads the linear and a nonlinear applications to be used from the parameter file and uses them in order to obtain a parameteric study for the given application.

Usage

This class is used in SimulationBuilder to run a complete parameteric study. All parameters for this application should be defined in the main parameter file. There are two methods for running a parametric study. The first involves specifying multiple parameters (up to 10) and a respective list that these parameters values will be set to. An example of this is:

* subsection Simulator
* subsection Parametric study
* set Parameter 1 name = subsection>>subsection>>name1
* set Parameter 1 values = 0.1, 0.2, 0.3 #Solves for value 0.1 first then sequentially moves through list
*
* set Parameter 2 name = subsection>>subsection>>name2
* set Parameter 2 values = 1.0, 0.9, 0.8
* ...
* end
* end
*
Note
: On the first iteration it will solve the problem with name1 set to 0.1 and name2 set to 1.0. On the next iteration it will solve with name1 set to 0.2 and name2 set to 0.9, ...
: If you wish to change a value at a boundary or material ID then when specifying name1 add ":#" where # is the boundary/material ID number, e.g. Boundary data>>density_species_1 [g/cm^3]:2
: If you want to alter more than 10 parameters at a time, change max_num_parameters in parametric_study.h file and recompile OpenFCST.

The second method only allows for one parameter to be changed but it has the ease that you do not need to specify all the values that you wish to run the simulation at. Instead you enter an upper and lower bounds and the step size. An example of this is:

* subsection Simulator
* subsection Parametric study
* set Parameter 1 name = subsection>>subsection>>name
* set Initial value = 0.5 #Enter the value you would like to start the parameteric study from.
* set Final value = 1.0 #Enter the final value for the parameteric study.
* set Increment = 0.1 #Spacing between points in the parameteric study
* set Adaptive Increment = false #Set to true if you would like to reduce the voltage increment adaptively if convergence could not be achieved with the larger value
* set Min. Increment = 0.1 #If Adaptive Increment is set to true, this value controls the
* #minimum change in cell voltage before the parameter study gives up
* #and the voltage is updated again. Note that this value has to be more
* #than 0.01 V as a value of zero would lead to an infinite loop.
* end
* end
*

To use the class, imply create an object, declare the parameters, read the file, initialize and run

* ParameterHandler param;
* curve.declare_parameters(param);
* std::string simulator_parameter_file_name = "input_file.prm";
* param.read_input(simulator_parameter_file_name,
* true);
* curve.initialize(param);
* curve.run(param, simulator_parameter_file_name, sim_selector);
*
Author
M. Secanell, 2014

Constructor & Destructor Documentation

template<int dim>
FuelCell::ParametricStudy< dim >::ParametricStudy ( )

Constructor.

template<int dim>
FuelCell::ParametricStudy< dim >::~ParametricStudy ( )

Member Function Documentation

template<int dim>
void FuelCell::ParametricStudy< dim >::declare_parameters ( ParameterHandler &  ) const
template<int dim>
void FuelCell::ParametricStudy< dim >::initialize ( ParameterHandler &  )

Read parameters from file.

template<int dim>
void FuelCell::ParametricStudy< dim >::print_iteration_info ( const unsigned int  iteration,
const double  param_value 
) const
inlineprotected

References FcstUtilities::log.

template<int dim>
void FuelCell::ParametricStudy< dim >::print_iteration_info ( const unsigned int  iteration,
const std::vector< double >  param_value 
) const
inlineprotected

References FcstUtilities::log.

template<int dim>
virtual void FuelCell::ParametricStudy< dim >::print_parameteric_study_header ( )
protectedvirtual

Print parameteric study header into a file.

Reimplemented in FuelCell::PolarizationCurve< dim >.

template<int dim>
virtual void FuelCell::ParametricStudy< dim >::print_parameters ( ) const
protectedvirtual

Print parameters:

Reimplemented in FuelCell::PolarizationCurve< dim >.

template<int dim>
void FuelCell::ParametricStudy< dim >::register_data ( const double  ,
std::map< std::string, double > &  functionals 
)
protected

Store the value of the current density in the solution.

template<int dim>
void FuelCell::ParametricStudy< dim >::run ( ParameterHandler &  param,
std::string  simulator_parameter_file_name,
boost::shared_ptr< SimulationSelector< dim > >  sim_selector 
)

Run a full polarization curve run.

template<int dim>
void FuelCell::ParametricStudy< dim >::run_point ( ParameterHandler &  param,
const std::string  simulator_parameter_file_name,
const boost::shared_ptr< SimulationSelector< dim > >  sim_selector,
const int  iteration,
const std::vector< std::string >  parameter_name,
const std::vector< double >  param_value,
std::map< std::string, double > &  functionals 
)
protected

Run a single point in the polarization curve and return the current density and any other data.

template<int dim>
virtual void FuelCell::ParametricStudy< dim >::set_parameters ( ParameterHandler &  param,
const shared_ptr< FuelCell::ApplicationCore::AdaptiveRefinement< dim > > &  solver,
const int  iteration,
const std::vector< std::string >  parameter_name,
const std::vector< double >  param_value 
)
protectedvirtual

Modify cell voltage and any other parameters that you would like to modify with respect to the inital input file.

Reimplemented in FuelCell::PolarizationCurve< dim >.

Member Data Documentation

template<int dim>
bool FuelCell::ParametricStudy< dim >::adaptive
protected

Set to true if you would like to reduce the voltage increment adaptively if convergence could not be achieved with the larger value.

Note
This vaule is set via input file using the following section
* subsection Simulator
* subsection Parametric study
* set Adaptive Increment? = true (or false)
* end
* end
*
template<int dim>
FuelCell::ApplicationCore::FEVector FuelCell::ParametricStudy< dim >::coarse_solution
protected

Vector used to store the solution from the previous iteration if convergence has been achieved.

template<int dim>
bool FuelCell::ParametricStudy< dim >::convergence
protected

Convergence of the solution.

True if the adaptive loop was able to provide a solution.

template<int dim>
std::vector<std::vector<double> > FuelCell::ParametricStudy< dim >::curve
protected

Map used to store the parametric study data.

template<int dim>
double FuelCell::ParametricStudy< dim >::dp
protected

Spacing between points in the parameteric study.

Note
This vaule is set via input file using the following section
* subsection Simulator
* subsection Parameteric study
* set Increment
* end
* end
*
template<int dim>
const unsigned int FuelCell::ParametricStudy< dim >::max_num_parameters = 10
protected

Set the maximum number of parameters that you can alter in a Parametric Study.

template<int dim>
double FuelCell::ParametricStudy< dim >::min_dp
protected
Note
This vaule is set via input file using the following section
* subsection Simulator
* subsection Parametric study
* set Min. Increment
* end
* end
*
template<int dim>
std::ofstream FuelCell::ParametricStudy< dim >::myfile
protected

File object for output logging.

template<int dim>
int FuelCell::ParametricStudy< dim >::n_dpPts
protected
template<int dim>
int FuelCell::ParametricStudy< dim >::n_resp
protected
template<int dim>
std::vector<std::string> FuelCell::ParametricStudy< dim >::name_responses
protected
template<int dim>
double FuelCell::ParametricStudy< dim >::p_end
protected

Final parameter value used in the parameteric study.

Note
This vaule is set via input file using the following section
* subsection Simulator
* subsection Parametric study
* set Final Value
* end
* end
*
template<int dim>
double FuelCell::ParametricStudy< dim >::p_init
protected

Initial value to run the parametric study, in the units specified for the value.

Note
This vaule is set via input file using the following section
* subsection Simulator
* subsection Parametric study
* set Initial Value =
* end
* end
*
template<int dim>
std::vector< std::vector<double> > FuelCell::ParametricStudy< dim >::p_values
protected

Another way to define the sequence of parameter values is to use the vector p_values instead of variables p_init, p_end, and dp.

This vector contains the discrete values of a parameter of study.

Note
This vector is set via input file using the following section
* subsection Simulator
* subsection Parameteric study
* set Parameter 1 values = v1, v2, v3, ..., vN
* end
* end
*
template<int dim>
std::string FuelCell::ParametricStudy< dim >::parameter_filename
protected

Variable where the output file to store parameteric study results is stored.

template<int dim>
std::vector<std::string> FuelCell::ParametricStudy< dim >::parameter_name
protected

String that defines the parameter that we would like to modify The parameter should be of the from.

  • For normal parameter: Subsection_1>>Subsection_2>>Value
  • For boundary value or graded: Subsection_1>>Subsection_2>>Material_id:Value

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