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 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2006-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: dakota_direct_interface.h
11 // - Description: Class used to create an interface between FCST and DAKOTA
12 // - Developers: Malte Krack, Peter Dobson, Marc Secanell <secanell@ualberta.ca>
13 //
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 <deal.II/base/parameter_handler.h>
28 #include <deal.II/base/timer.h>
29 
30 // Fuel Cells:
36 #include <utils/fcst_utilities.h>
38 
39 
40 #ifdef _WITH_DAKOTA
41 
42 #include <DirectApplicInterface.hpp>
43 #include <ApplicationInterface.hpp>
44 
51 namespace SIM
52 {
53 
69  template <int dim>
70  class DakotaDirectInterface : public Dakota::DirectApplicInterface
71  {
72  public:
73 
77  //DakotaDirectInterface(boost::shared_ptr<const Dakota::ProblemDescDB > problem_db);
78 
85  boost::shared_ptr<const Dakota::ProblemDescDB > problem_db,
86  ParameterHandler& param,
87  boost::shared_ptr <FuelCell::ApplicationCore::ApplicationData> data,
88  boost::shared_ptr<SimulationSelector<dim> > sim_selector,
89  std::string &param_file);
90 
93  {
94  };
95 
96 
97  protected:
102  int derived_map_ac(const Dakota::String& ac_name);
103 
109 
114  void dakota_assign_results(const std::vector<double>& responses,
115  const std::vector<std::vector<double> >& dresponses_dl);
120  void dakota_assign_results(const std::vector<double>& responses);
121 
125  ParameterHandler* param;
126 
133  boost::shared_ptr<SimulationSelector<deal_II_dimension> > sim_selector;
134 
140 
144  boost::shared_ptr<const Dakota::ProblemDescDB> problem_db;
145 
150 
154  Timer eval_timer;
155 
159  unsigned int n_dvar;
160 
164  unsigned int n_resp;
165 
169  std::vector<std::string> name_design_var;
170 
174  std::vector<std::string> name_responses;
175 
179  boost::shared_ptr <FuelCell::ApplicationCore::ApplicationData> data;
180 
181  };
182 
183 
184  // Least-Squares Interface
191  template <int dim>
193  {
194  public:
199  boost::shared_ptr<const Dakota::ProblemDescDB > problem_db,
200  ParameterHandler& param,
201  boost::shared_ptr <FuelCell::ApplicationCore::ApplicationData> data,
202  boost::shared_ptr<SimulationSelector<dim> > sim_selector,
203  std::string &param_file);
204 
209  {
210  };
211 
215  void _initialize(ParameterHandler& param);
216 
217  protected:
222  int derived_map_ac(const Dakota::String& ac_name);
223 
224  private:
225 
229  std::string NLS_data_file;
234  std::vector<double> NLS_residual;
238  std::string NLS_residual_option;
242  std::string NLS_residual_value;
246  std::vector<double> experimental_current;
250  std::vector<std::string> OC_names;
254  std::vector<std::vector<double> > OC_values;
258  std::vector<std::string> param_names;
262  std::vector<double> param_values;
263 
265  Timer nls_timer;
266 
270  boost::shared_ptr <FuelCell::ApplicationCore::ApplicationData> data;
271  };
272 
273 }
274 
275 #endif //Dakota
276 
277 
278 #endif
std::string NLS_residual_option
String storing the option of absolute, weighted, or no residuals (for sensitivity) ...
Definition: dakota_direct_interface.h:238
std::vector< double > param_values
Vector to store the parameter values to set.
Definition: dakota_direct_interface.h:262
unsigned int n_resp
Number of responses.
Definition: dakota_direct_interface.h:164
std::vector< std::vector< double > > OC_values
Array to store Operating Condition values (set in NLS_data_file)
Definition: dakota_direct_interface.h:254
unsigned int n_dvar
Number of design variables.
Definition: dakota_direct_interface.h:159
This class selects an openFCST application which will run.
Definition: simulation_selector.h:70
std::string NLS_residual_value
String storing the choice of returning the residual vector (for NLS methods) or the L2 norm (for all ...
Definition: dakota_direct_interface.h:242
void dakota_adopt_parameters(boost::shared_ptr< FuelCell::ApplicationCore::OptimizationBlockMatrixApplication< dim > > app_linear)
Member function that is used to get the design variable names and values and assigns the values to th...
void _initialize(ParameterHandler &param)
Local initialize function for this class.
std::string simulator_parameter_file_name
Definition: dakota_direct_interface.h:149
ParameterHandler * param
Pointer to the Parameter Handler object.
Definition: dakota_direct_interface.h:125
This class is used to solve a least-squares parameter estimation problem.
Definition: dakota_direct_interface.h:192
Timer eval_timer
Object used to calculate the CPU and Run time for the optimization evaluation.
Definition: dakota_direct_interface.h:154
boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData > data
Data structure storing information to be shared between applications.
Definition: dakota_direct_interface.h:270
boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData > data
Data structure storing information to be shared between applications.
Definition: dakota_direct_interface.h:179
std::vector< double > NLS_residual
Output vector storing residuals from experimental data and output.
Definition: dakota_direct_interface.h:234
int derived_map_ac(const Dakota::String &ac_name)
Function called by DAKOTA&#39;s iterators in order to run the simulation code and assign the correspondin...
boost::shared_ptr< SimulationSelector< deal_II_dimension > > sim_selector
Pointer to the SimulationSelector object which gives access to the file names and selector functions ...
Definition: dakota_direct_interface.h:133
DakotaApplication * fcst_interface
Pointer to the DakotaApplication object, so that the design variables can be accessed with synchroniz...
Definition: dakota_direct_interface.h:139
std::vector< std::string > OC_names
Vector to store Operating Condition names (set in NLS_data_file)
Definition: dakota_direct_interface.h:250
boost::shared_ptr< const Dakota::ProblemDescDB > problem_db
Pointer to the problem description data base.
Definition: dakota_direct_interface.h:144
This class is used to read the input file from Dakota in its original format, use this inforamtion to...
Definition: dakota_direct_interface.h:70
std::string NLS_data_file
Experimental data file for NLS parameter estimation - Operating Conditions &amp; output.
Definition: dakota_direct_interface.h:229
~DakotaLeastSquaresInterface()
Destructor.
Definition: dakota_direct_interface.h:208
std::vector< std::string > name_responses
Member that stores the name of the responses.
Definition: dakota_direct_interface.h:174
std::vector< double > experimental_current
Vector to store experimental current density output values.
Definition: dakota_direct_interface.h:246
int derived_map_ac(const Dakota::String &ac_name)
Function called by DAKOTA&#39;s iterators in order to run the simulation code and assign the correspondin...
Timer nls_timer
Object used to calculate the CPU and Run time for the NLS loop.
Definition: dakota_direct_interface.h:265
void dakota_assign_results(const std::vector< double > &responses, const std::vector< std::vector< double > > &dresponses_dl)
Member function that is used to assign the application responses and gradients to the result variable...
std::vector< std::string > param_names
Vector to store the parameter names to set.
Definition: dakota_direct_interface.h:258
This class is used to interface with DAKOTA as an algorithm library.
Definition: dakota_application.h:76
DakotaLeastSquaresInterface(DakotaApplication &fcst_interface, boost::shared_ptr< const Dakota::ProblemDescDB > problem_db, ParameterHandler &param, boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData > data, boost::shared_ptr< SimulationSelector< dim > > sim_selector, std::string &param_file)
Constructor.
~DakotaDirectInterface()
Destructor.
Definition: dakota_direct_interface.h:92
Application handling matrices and assembling the linear system to solve the sensitivity equations...
Definition: optimization_block_matrix_application.h:49
std::vector< std::string > name_design_var
Member that stores the name of the design variables.
Definition: dakota_direct_interface.h:169
DakotaDirectInterface(DakotaApplication &fcst_interface, boost::shared_ptr< const Dakota::ProblemDescDB > problem_db, ParameterHandler &param, boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData > data, boost::shared_ptr< SimulationSelector< dim > > sim_selector, std::string &param_file)
Default constructor for an object of this class.