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 // - $Id: dakota_direct_interface.h 2616 2014-08-15 22:57:14Z secanell $
14 //
15 //---------------------------------------------------------------------------
16 
17 #ifndef dakota_direct_interface_h
18 #define dakota_direct_interface_h
19 
20 //STL libraries:
21 #include<string>
22 #include<fstream>
23 #include<iostream>
24 #include<vector>
25 #include<ctime>
26 
27 //deal.II:
28 #include<base/parameter_handler.h>
29 #include <base/timer.h>
30 
31 // Fuel Cells:
33 #include "experimental_data.h"
34 #include "simulation_selector.h"
35 #include "adaptive_refinement.h"
36 #include "dakota_application.h"
37 #include <utils/fcst_utilities.h>
38 
39 #ifdef _WITH_DAKOTA
40 
41 #include <DirectApplicInterface.hpp>
42 #include <ApplicationInterface.hpp>
43 
50 namespace SIM
51 {
52 
68  template <int dim>
69  class DakotaDirectInterface : public Dakota::DirectApplicInterface
70  {
71  public:
72 
76  DakotaDirectInterface(boost::shared_ptr<const Dakota::ProblemDescDB > problem_db);
77 
84  boost::shared_ptr<const Dakota::ProblemDescDB > problem_db,
85  ParameterHandler& param,
86  boost::shared_ptr<SimulationSelector<dim> > sim_selector,
87  std::string &param_file);
88 
91  {
92  };
93 
94 
95  protected:
100  int derived_map_ac(const Dakota::String& ac_name);
101 
107 
112  void dakota_assign_results(const std::vector<double>& responses,
113  const std::vector<std::vector<double> >& dresponses_dl);
118  void dakota_assign_results(const std::vector<double>& responses);
119 
123  ParameterHandler* param;
124 
131  boost::shared_ptr<SimulationSelector<deal_II_dimension> > sim_selector;
132 
138 
142  boost::shared_ptr<const Dakota::ProblemDescDB> problem_db;
143 
148 
152  Timer eval_timer;
153 
157  unsigned int n_dvar;
158 
162  unsigned int n_resp;
163 
167  std::vector<std::string> name_design_var;
168 
172  std::vector<std::string> name_responses;
173 
174  };
175 
176 
177  // Least-Squares Interface
184  template <int dim>
186  {
187  public:
192  boost::shared_ptr<const Dakota::ProblemDescDB > problem_db,
193  ParameterHandler& param,
194  boost::shared_ptr<SimulationSelector<dim> > sim_selector,
195  std::string &param_file);
196 
201  {
202  };
203 
207  void _initialize(ParameterHandler& param);
208 
209  protected:
214  int derived_map_ac(const Dakota::String& ac_name);
215 
216  private:
217 
221  std::string NLS_data_file;
226  std::vector<double> NLS_residual;
230  std::string NLS_residual_option;
234  std::string NLS_residual_value;
238  std::vector<double> experimental_current;
242  std::vector<std::string> OC_names;
246  std::vector<std::vector<double> > OC_values;
250  std::vector<std::string> param_names;
254  std::vector<double> param_values;
255 
257  Timer nls_timer;
258  };
259 
260 }
261 
262 #endif //Dakota
263 
264 
265 #endif
DakotaLeastSquaresInterface(DakotaApplication &fcst_interface, boost::shared_ptr< const Dakota::ProblemDescDB > problem_db, ParameterHandler &param, boost::shared_ptr< SimulationSelector< dim > > sim_selector, std::string &param_file)
Constructor.
std::string NLS_residual_option
String storing the option of absolute, weighted, or no residuals (for sensitivity) ...
Definition: dakota_direct_interface.h:230
std::vector< double > param_values
Vector to store the parameter values to set.
Definition: dakota_direct_interface.h:254
unsigned int n_resp
Number of responses.
Definition: dakota_direct_interface.h:162
std::vector< std::vector< double > > OC_values
Array to store Operating Condition values (set in NLS_data_file)
Definition: dakota_direct_interface.h:246
unsigned int n_dvar
Number of design variables.
Definition: dakota_direct_interface.h:157
This class selects an openFCST application which will run.
Definition: simulation_selector.h:68
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:234
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:147
ParameterHandler * param
Pointer to the Parameter Handler object.
Definition: dakota_direct_interface.h:123
This class is used to solve a least-squares parameter estimation problem.
Definition: dakota_direct_interface.h:185
Timer eval_timer
Object used to calculate the CPU and Run time for the optimization evaluation.
Definition: dakota_direct_interface.h:152
std::vector< double > NLS_residual
Output vector storing residuals from experimental data and output.
Definition: dakota_direct_interface.h:226
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:131
DakotaApplication * fcst_interface
Pointer to the DakotaApplication object, so that the design variables can be accessed with synchroniz...
Definition: dakota_direct_interface.h:137
std::vector< std::string > OC_names
Vector to store Operating Condition names (set in NLS_data_file)
Definition: dakota_direct_interface.h:242
boost::shared_ptr< const Dakota::ProblemDescDB > problem_db
Pointer to the problem description data base.
Definition: dakota_direct_interface.h:142
This class is used to read the input file from Dakota in its original format, use this inforamtion to...
Definition: dakota_direct_interface.h:69
std::string NLS_data_file
Experimental data file for NLS parameter estimation - Operating Conditions &amp; output.
Definition: dakota_direct_interface.h:221
~DakotaLeastSquaresInterface()
Destructor.
Definition: dakota_direct_interface.h:200
std::vector< std::string > name_responses
Member that stores the name of the responses.
Definition: dakota_direct_interface.h:172
std::vector< double > experimental_current
Vector to store experimental current density output values.
Definition: dakota_direct_interface.h:238
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:257
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:250
This class is used to interface with DAKOTA as an algorithm library.
Definition: dakota_application.h:76
~DakotaDirectInterface()
Destructor.
Definition: dakota_direct_interface.h:90
Application handling matrices and assembling the linear system to solve the sensitivity equations...
Definition: optimization_block_matrix_application.h:62
std::vector< std::string > name_design_var
Member that stores the name of the design variables.
Definition: dakota_direct_interface.h:167
DakotaDirectInterface(boost::shared_ptr< const Dakota::ProblemDescDB > problem_db)
Default constructor for an object of this class.