OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dakota_direct_interface.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 //
3 // C++ Implementation: dakota_application
4 //
5 // Description: Used to read in an array of experimental data with column headers.
6 // For use with parameter estimation or generating polarization curves.
7 //
8 // Author: Malte Krack, Peter Dobson <pdobson@ualberta.ca>, Marc Secanell <secanell@ualberta.ca>, (C) 2009,2010
9 //
10 // Copyright: See COPYING file that comes with this distribution
11 //
12 // Created by: Malte Krack, Peter Dobson (August 2009)
13 // Last updated: January, 2010
14 //
15 //---------------------------------------------------------------------------
16 #ifndef dakota_direct_interface_h
17 #define dakota_direct_interface_h
18 
19 //STL libraries:
20 #include<string>
21 #include<fstream>
22 #include<iostream>
23 #include<vector>
24 #include<ctime>
25 
26 //deal.II:
27 #include<base/parameter_handler.h>
28 #include <base/timer.h>
29 
30 // Fuel Cells:
32 #include "experimental_data.h"
33 #include "simulation_selector.h"
34 #include "adaptive_refinement.h"
35 #include "dakota_application.h"
36 
37 #ifdef _WITH_DAKOTA
38 
39 //DAKOTA libraries:
40 #include "DirectApplicInterface.H"
41 #include "ApplicationInterface.H"
42 
43 
44 
45 
52 namespace SIM
53 {
54 
70  template <int dim>
71  class DakotaDirectInterface : public Dakota::DirectApplicInterface
72  {
73  public:
74 
78  DakotaDirectInterface(boost::shared_ptr<const Dakota::ProblemDescDB > problem_db);
79 
85  DakotaDirectInterface(DakotaApplication &fcst_interface,
86  boost::shared_ptr<const Dakota::ProblemDescDB > problem_db,
87  ParameterHandler& param,
88  boost::shared_ptr<SimulationSelector<dim> > sim_selector,
89  std::string &param_file);
90 
92  ~DakotaDirectInterface()
93  {
94  };
95 
96 
97  protected:
102  int derived_map_ac(const Dakota::String& ac_name);
103 
109  void dakota_adopt_parameters(boost::shared_ptr<AppFrame::OptimizationBlockMatrixApplication<dim> > app_linear);
110 
115  void dakota_assign_results(const std::vector<double>& responses,
116  const std::vector<std::vector<double> >& dresponses_dl);
121  void dakota_assign_results(const std::vector<double>& responses);
122 
126  ParameterHandler* param;
127 
134  boost::shared_ptr<SimulationSelector<deal_II_dimension> > sim_selector;
135 
140  DakotaApplication* fcst_interface;
141 
145  boost::shared_ptr<const Dakota::ProblemDescDB> problem_db;
146 
147  std::string simulator_parameter_file_name;
148 
152  Timer eval_timer;
153 
157  unsigned int n_dvar;
161  unsigned int n_resp;
165  std::vector<std::string> name_design_var;
169  std::vector<std::string> name_responses;
170 
171 
172  };
173 
174 
175  // Least-Squares Interface
182  template <int dim>
183  class DakotaLeastSquaresInterface : public DakotaDirectInterface<dim>
184  {
185  public:
189  DakotaLeastSquaresInterface(DakotaApplication &fcst_interface,
190  boost::shared_ptr<const Dakota::ProblemDescDB > problem_db,
191  ParameterHandler& param,
192  boost::shared_ptr<SimulationSelector<dim> > sim_selector,
193  std::string &param_file);
194 
198  ~DakotaLeastSquaresInterface()
199  {
200  };
201 
205  void _initialize(ParameterHandler& param);
206 
207  protected:
212  int derived_map_ac(const Dakota::String& ac_name);
213 
214  private:
215 
219  std::string NLS_data_file;
224  std::vector<double> NLS_residual;
228  std::string NLS_residual_option;
232  std::string NLS_residual_value;
236  std::vector<double> experimental_current;
240  std::vector<std::string> OC_names;
244  std::vector<std::vector<double> > OC_values;
248  std::vector<std::string> param_names;
252  std::vector<double> param_values;
253 
255  Timer nls_timer;
256  };
257 
258 }
259 
260 #endif //Dakota
261 
262 
263 #endif