OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
numerical_agglomerate_base.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2006-2013 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: Micro Scale Initial Solution
11 // - Description: INSERT SHORT DEFINITION HERE
12 // - Developers: Philip Wardlaw, University of Alberta
13 // - $Id: numerical_agglomerate_base.h 2605 2014-08-15 03:36:44Z secanell $
14 //
15 // ----------------------------------------------------------------------------
16 
17 #include<agglomerate_base.h>
18 #include <fcst_db.h>
19 
20 
21 #ifndef NUMERICAL_AGGLOMERATE_BASE_H_
22 #define NUMERICAL_AGGLOMERATE_BASE_H_
23 
24 
25 //Friend class for testing
26 class NumericalAgglomerateBaseTest;
27 
28 namespace FuelCellShop
29 {
30  namespace MicroScale
31  {
60  {
61  public:
62  friend class::NumericalAgglomerateBaseTest;
63 
64  //Nothing public
65  protected:
66 
67 
68  //Set AV function Just for testing purposes
69  inline void setAV(double newAV){
70  AV = newAV;
71  }
72 
75 
78 
79  /*
80  * Protected member function for updating initial solution.
81  * Function will determine if initial solution should be updated or not.
82  *
83  * <h3> Usage </h3>
84  * Should be called before solving for current density.
85  */
87 
88  /*
89  * Protected member function for saving an initial solution.
90  * Function will determine if initial solution should be saved or not.
91  *
92  * <h3> Usage </h3>
93  * Should be called after successfully solving system of equations.
94  */
95  void save_initial_solution();
96 
97  /*
98  * Protected virtual member function for declaring parameters,
99  * calls parent class (AgglomerateBase).
100  */
101  virtual void declare_parameters (ParameterHandler &param) const;
102 
103  /*
104  * Protected virtual member function for initializing parameters,
105  * calls parent class (AgglomerateBase).
106  */
107  virtual void initialize(ParameterHandler &param);
108 
109  /*
110  * Protected member function for obtaining active area at
111  * a given location in domain. Active area may vary depending on
112  * loading profile
113  *
114  * \param location The current location in the agglomerate domain
115  * from 1.0 to 0.0 (dimensionless linear coordinates)
116  *
117  * Units [cm^2 of pt surface per /cm^3 of solid CL micro structure]
118  */
119  double getAV(double location);
120 
121  /*
122  * Function to be called by COLDAE guess function to get initial solution at point x
123  *
124 
125  */
126  bool use_initial_data(double z[], const double &x);
127 
128  /*
129  * 2d Solutions
130  */
131  std::vector<std::vector<double>> final_results;
132  std::vector<std::vector<double>> initial_solution;
133 
134  /*
135  * Names of columns for solution data
136  * <b>Important:</b> Should be implemented by child.
137  */
138  std::vector<std::string> column_names;
139 
140 
141  /*
142  * Absolute tolerance in reactant concentration
143  */
144  double R_tol;
145 
146 
147  virtual void make_thread_safe(ParameterHandler &param, unsigned int thread_index);
148 
149  private:
150 
151  /*
152  * Private function to set up the active area loading profiles depending on user input from user.
153  *
154  * Active area is conserved.
155  *
156  * See section 2.4.2.3 of Philip Wardlaw's thesis
157  */
158 
159  void setUpLoadings();
160 
161  /*
162  * Private member function for creating a snapshot if current operating conditions
163  * so that we can query database.
164  */
166 
167  /*
168  * Private to check if current initial solution is still valid given a set of operating conditions.
169  */
171 
172  /*
173  * Private for interpolating initial solution.
174  */
175  void interpolate_initial_data(double z[], const double &x, const double& left_pos, const double& right_pos,
176  const std::vector<double>& left_data, const std::vector<double>& right_data);
177 
178  /*
179  * Database variables
180  */
182  std::string db_address;
184 
185  /*
186  * Bool determining if we should push data on next call to save_initial_solution();
187  */
188  bool push_next;
189 
190  /*
191  * Tolerance determining how often we update/save initial solutions.
192  */
193  double tolerance;
194 
195  /*
196  * Parameters for variable active area profile
197  */
199  std::vector<double> loadingWeigths;
200  std::vector<double> actualLoadings;
201  std::vector<double> loadingRadii;
202 
203  unsigned int thread_id;
204 
205  }; //class
206  }
207 } //namespace
208 
209 #endif
std::vector< std::vector< double > > final_results
Definition: numerical_agglomerate_base.h:131
unsigned int thread_id
Definition: numerical_agglomerate_base.h:203
This class is for storing a list of up to 10 parameters and is used as a way of informing the FCSTdat...
Definition: fcst_db.h:368
Base class for numerical agglomerates.
Definition: numerical_agglomerate_base.h:59
The base class for agglomerate objects in OpenFCST.
Definition: agglomerate_base.h:70
std::vector< double > loadingWeigths
Definition: numerical_agglomerate_base.h:199
virtual void initialize(ParameterHandler &param)
bool push_next
Definition: numerical_agglomerate_base.h:188
virtual void declare_parameters(ParameterHandler &param) const
double maxRadialDimension
Definition: numerical_agglomerate_base.h:198
~NumericalAgglomerateBase()
Destructor.
Definition: numerical_agglomerate_base.h:77
void interpolate_initial_data(double z[], const double &x, const double &left_pos, const double &right_pos, const std::vector< double > &left_data, const std::vector< double > &right_data)
std::vector< std::string > column_names
Definition: numerical_agglomerate_base.h:138
void setAV(double newAV)
Definition: numerical_agglomerate_base.h:69
std::vector< std::vector< double > > initial_solution
Definition: numerical_agglomerate_base.h:132
std::vector< double > loadingRadii
Definition: numerical_agglomerate_base.h:201
double R_tol
Definition: numerical_agglomerate_base.h:144
virtual void make_thread_safe(ParameterHandler &param, unsigned int thread_index)
bool use_initial_data(double z[], const double &x)
double AV
Definition: agglomerate_base.h:355
FcstUtilities::DatabaseOC database_OC
Definition: numerical_agglomerate_base.h:183
bool guess_no_longer_valid(const FcstUtilities::DatabaseOC &OC)
std::vector< double > actualLoadings
Definition: numerical_agglomerate_base.h:200
This class is for interfacing with SQL databases, for the purpose of accessing and storing simulation...
Definition: fcst_db.h:134
std::string db_address
Definition: numerical_agglomerate_base.h:182
FcstUtilities::FCSTdatabase db
Definition: numerical_agglomerate_base.h:181
double tolerance
Definition: numerical_agglomerate_base.h:193