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 //
14 //---------------------------------------------------------------------------
15 
16 #ifndef _FUELCELL__PARAMETRIC_STUDY_H_
17 #define _FUELCELL__PARAMETRIC_STUDY_H_
18 
19 // OpenFCST
22 #include <utils/fcst_utilities.h>
23 
24 // STD include files
25 #include <string>
26 #include <vector>
27 #include <iostream>
28 #include <fstream>
29 
30 #include <stdio.h>
31 #include <stdlib.h>
32 
33 namespace FuelCell
34 {
95  template <int dim>
97  {
98  public:
102  ParametricStudy();
103 
108 
112  void declare_parameters (ParameterHandler& ) const;
113 
117  void initialize (ParameterHandler& );
118 
122  void run (ParameterHandler& param,
123  std::string simulator_parameter_file_name,
124  boost::shared_ptr<SimulationSelector<dim> > sim_selector);
125 
126  protected:
132  virtual void set_parameters(ParameterHandler& param,
133  const shared_ptr<FuelCell::ApplicationCore::AdaptiveRefinement<dim> >& solver,
134  const int iteration,
135  const std::vector<std::string> parameter_name,
136  const std::vector<double> param_value);
137 
141  void run_point (ParameterHandler& param,
142  const std::string simulator_parameter_file_name,
143  const boost::shared_ptr<SimulationSelector<dim> > sim_selector,
144  const int iteration,
145  const std::vector<std::string> parameter_name,
146  const std::vector<double> param_value,
147  std::map<std::string, double>& functionals);
148 
152  inline void print_iteration_info(const unsigned int iteration,
153  const double param_value) const
154  {
155  FcstUtilities::log<<"============================================================================="<<std::endl;
156  FcstUtilities::log<<"Iteration : "<<iteration<<std::endl;
157  FcstUtilities::log<<"Solving for..."<<std::endl;
158  FcstUtilities::log<<"Parameter name: ";
159  if(!parameter_name.empty())
160  FcstUtilities::log<<parameter_name[0];
161  FcstUtilities::log<<std::endl;
162  FcstUtilities::log<<"Cell param_value: "<<param_value<<std::endl;
163  FcstUtilities::log<<"======"<<std::endl;
164  }
165 
166  inline void print_iteration_info(const unsigned int iteration,
167  const std::vector<double> param_value) const
168  {
169  FcstUtilities::log<<"============================================================================="<<std::endl;
170  FcstUtilities::log<<"Iteration : "<<iteration<<std::endl;
171  FcstUtilities::log<<"Solving for..."<<std::endl;
172  for(unsigned int i = 0; i < parameter_name.size(); ++i)
173  {
174  FcstUtilities::log<<"Parameter " << i+1 << " name: "<<parameter_name[i]<<std::endl;
175  FcstUtilities::log<<"Parameter " << i+1 << " value: "<<param_value[i]<<std::endl;
176  }
177  FcstUtilities::log<<"======"<<std::endl;
178  }
179 
183  virtual void print_parameters() const;
184 
188  virtual void print_parameteric_study_header() ;
189 
193  void register_data(const double ,
194  std::map<std::string, double>& functionals);
195 
199  std::string parameter_filename;
200 
207  std::vector<std::string> parameter_name;
208 
221  double p_init;
222 
235  double p_end;
236 
249  double dp;
250 
265  std::vector< std::vector<double> > p_values;
266 
280  bool adaptive;
281 
293  double min_dp;
294 
295  int n_dpPts;
296 
302 
306  std::vector<std::vector<double> > curve;
307 
311  std::ofstream myfile;
312 
313  std::vector<std::string> name_responses;
314 
315  int n_resp;
316 
320  const unsigned int max_num_parameters = 10;
321 
327  };
328 }
329 
330 #endif
int n_resp
Definition: parametric_study.h:315
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 varia...
Definition: parametric_study.h:265
virtual void print_parameteric_study_header()
Print parameteric study header into a file.
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...
int n_dpPts
Definition: parametric_study.h:295
void print_iteration_info(const unsigned int iteration, const double param_value) const
Definition: parametric_study.h:152
std::ofstream myfile
File object for output logging.
Definition: parametric_study.h:311
This class selects an openFCST application which will run.
Definition: simulation_selector.h:70
const unsigned int max_num_parameters
Set the maximum number of parameters that you can alter in a Parametric Study.
Definition: parametric_study.h:320
This application is used to perform a parametric study for a given fuel cell model.
Definition: parametric_study.h:96
void print_iteration_info(const unsigned int iteration, const std::vector< double > param_value) const
Definition: parametric_study.h:166
bool adaptive
Set to true if you would like to reduce the voltage increment adaptively if convergence could not be ...
Definition: parametric_study.h:280
void declare_parameters(ParameterHandler &) const
std::vector< std::string > name_responses
Definition: parametric_study.h:313
This class is initialized with an application that describes the linearization of the problem that we...
Definition: adaptive_refinement.h:52
double p_end
Final parameter value used in the parameteric study.
Definition: parametric_study.h:235
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:326
void run(ParameterHandler &param, std::string simulator_parameter_file_name, boost::shared_ptr< SimulationSelector< dim > > sim_selector)
Run a full polarization curve run.
ParametricStudy()
Constructor.
void initialize(ParameterHandler &)
Read parameters from file.
bool convergence
Convergence of the solution.
Definition: parametric_study.h:301
std::string parameter_filename
Variable where the output file to store parameteric study results is stored.
Definition: parametric_study.h:199
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...
BlockVector< double > FEVector
The vector class used by applications.
Definition: application_data.h:46
double p_init
Initial value to run the parametric study, in the units specified for the value.
Definition: parametric_study.h:221
virtual void print_parameters() const
Print parameters:
std::vector< 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:207
double min_dp
Definition: parametric_study.h:293
double dp
Spacing between points in the parameteric study.
Definition: parametric_study.h:249
std::vector< std::vector< double > > curve
Map used to store the parametric study data.
Definition: parametric_study.h:306