OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
parametric_study.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2009-13 by Energy Systems Design Laboratory, University of Alberta
6 //
7 // This software is distributed under the MIT License.
8 // For more information, see the README file in /doc/LICENSE
9 //
10 // - Class: parametric_study.h
11 // - Description: Application used to perform parameteric studies on a given application.
12 // - Developers: M. Secanell
13 // - $Id$
14 //
15 //---------------------------------------------------------------------------
16 
17 #ifndef _FUELCELL__PARAMETRIC_STUDY_H_
18 #define _FUELCELL__PARAMETRIC_STUDY_H_
19 
20 // OpenFCST
23 #include <utils/fcst_utilities.h>
24 
25 // STD include files
26 #include <string>
27 #include <vector>
28 #include <iostream>
29 #include <fstream>
30 
31 #include <stdio.h>
32 #include <stdlib.h>
33 
34 namespace FuelCell
35 {
77  template <int dim>
79  {
80  public:
85 
90 
94  void declare_parameters (ParameterHandler& ) const;
95 
99  void initialize (ParameterHandler& );
100 
104  void run (ParameterHandler& param,
105  std::string simulator_parameter_file_name,
106  boost::shared_ptr<SimulationSelector<dim> > sim_selector);
107 
108  protected:
114  virtual void set_parameters(ParameterHandler& param,
115  const shared_ptr<FuelCell::ApplicationCore::AdaptiveRefinement<dim> >& solver,
116  const int iteration,
117  const std::string parameter_name,
118  double param_value);
119 
123  void run_point (ParameterHandler& param,
124  const std::string simulator_parameter_file_name,
125  const boost::shared_ptr<SimulationSelector<dim> > sim_selector,
126  const int iteration,
127  const std::string parameter_name,
128  const double param_value,
129  std::map<std::string, double>& functionals);
130 
134  inline void print_iteration_info(const unsigned int iteration,
135  const double param_value) const
136  {
137  FcstUtilities::log<<"============================================================================="<<std::endl;
138  FcstUtilities::log<<"Iteration : "<<iteration<<std::endl;
139  FcstUtilities::log<<"Solving for..."<<std::endl;
140  FcstUtilities::log<<"Parameter name: "<<parameter_name<<std::endl;
141  FcstUtilities::log<<"Cell param_value: "<<param_value<<std::endl;
142  FcstUtilities::log<<"======"<<std::endl;
143  }
144 
148  virtual void print_parameters() const;
149 
153  virtual void print_parameteric_study(const std::vector<std::vector<double> >& curve) const;
154 
158  void register_data(const double ,
159  std::map<std::string, double>& functionals);
160 
164  std::string parameter_filename;
171  std::string parameter_name;
172 
185  double p_init;
186 
199  double p_end;
200 
213  double dp;
214 
229  std::vector<double> p_values;
230 
244  bool adaptive;
245 
257  double min_dp;
258 
259  int n_dpPts;
260 
266 
270  std::vector<std::vector<double> > curve;
271 
277  };
278 }
279 
280 #endif
int n_dpPts
Definition: parametric_study.h:259
void print_iteration_info(const unsigned int iteration, const double param_value) const
Definition: parametric_study.h:134
std::vector< double > p_values
Another way to define the sequence of parameter values is to use the vector p_values instead of varia...
Definition: parametric_study.h:229
This class selects an openFCST application which will run.
Definition: simulation_selector.h:68
virtual void set_parameters(ParameterHandler &param, const shared_ptr< FuelCell::ApplicationCore::AdaptiveRefinement< dim > > &solver, const int iteration, const std::string parameter_name, double param_value)
Modify cell voltage and any other parameters that you would like to modify with respect to the inital...
This application is used to perform a parametric study for a given fuel cell model.
Definition: parametric_study.h:78
bool adaptive
Set to true if you would like to reduce the voltage increment adaptively if convergence could not be ...
Definition: parametric_study.h:244
void declare_parameters(ParameterHandler &) const
This class is initialized with an application that describes the linearization of the problem that we...
Definition: adaptive_refinement.h:54
double p_end
Final parameter value used in the parameteric study.
Definition: parametric_study.h:199
void register_data(const double, std::map< std::string, double > &functionals)
Store the value of the current density in the solution.
FCSTLogStream log
Object used to output data to file and, if file attached recorded to a file as well.
FuelCell::ApplicationCore::FEVector coarse_solution
Vector used to store the solution from the previous iteration if convergence has been achieved...
Definition: parametric_study.h:276
void run(ParameterHandler &param, std::string simulator_parameter_file_name, boost::shared_ptr< SimulationSelector< dim > > sim_selector)
Run a full polarization curve run.
std::string parameter_name
String that defines the parameter that we would like to modify The parameter should be of the from...
Definition: parametric_study.h:171
ParametricStudy()
Constructor.
void initialize(ParameterHandler &)
Read parameters from file.
bool convergence
Convergence of the solution.
Definition: parametric_study.h:265
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::string parameter_name, const 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...
std::string parameter_filename
Variable where the output file to store parameteric study results is stored.
Definition: parametric_study.h:164
BlockVector< double > FEVector
The vector class used by applications.
Definition: application_data.h:39
double p_init
Initial value to run the parametric study, in the units specified for the value.
Definition: parametric_study.h:185
virtual void print_parameters() const
Print parameters:
double min_dp
Definition: parametric_study.h:257
double dp
Spacing between points in the parameteric study.
Definition: parametric_study.h:213
std::vector< std::vector< double > > curve
Map used to store the parametric study data.
Definition: parametric_study.h:270
virtual void print_parameteric_study(const std::vector< std::vector< double > > &curve) const
Print parameteric study results into a file.