Cantera  2.1.2
ImplicitSurfChem.h
Go to the documentation of this file.
1 /**
2  * @file ImplicitSurfChem.h
3  * Declarations for the implicit integration of surface site density equations
4  * (see \ref kineticsmgr and class
6  */
7 // Copyright 2001 California Institute of Technology
8
9 #ifndef CT_IMPSURFCHEM_H
10 #define CT_IMPSURFCHEM_H
11
16 #include "solveSP.h"
17
18 namespace Cantera
19 {
20 class solveSP;
21
22 //! Advances the surface coverages of the associated set of SurfacePhase
23 //! objects in time
24 /*!
25  * This function advances a set of SurfPhase objects, each associated with one
26  * InterfaceKinetics object, in time. The following equation is used for each
27  * surface phase, *i*.
28  *
29  * \f[
30  * \dot \theta_k = \dot s_k (\sigma_k / s_0)
31  * \f]
32  *
33  * In this equation,
34  * - \f$\theta_k \f$ is the site coverage for the kth species.
35  * - \f$\dot s_k \f$ is the source term for the kth species
36  * - \f$\sigma_k \f$ is the number of surface sites covered by each species k.
37  * - \f$s_0 \f$ is the total site density of the interfacial phase.
38  *
40  * alternate equation is solved for
41  *
42  * \f[
43  * \sum_{k=0}^{N-1} \dot \theta_k = 0
44  * \f]
45  *
46  * This last equation serves to ensure that sum of the \f$\theta_k \f$ values
47  * stays constant.
48  *
49  * The object uses the CVODE software to advance the surface equations.
50  *
51  * The solution vector used by this object is as follows: For each surface
52  * phase with \f$N_s \f$ surface sites, it consists of the surface coverages
53  * \f$\theta_k \f$ for \f$k = 0, N_s - 1 \f$
54  *
55  * @ingroup kineticsmgr
56  */
57 class ImplicitSurfChem : public FuncEval
58 {
59 public:
60  //! Constructor for multiple surfaces.
61  /*!
62  * @param k Vector of pointers to InterfaceKinetics objects
63  * Each object consists of a surface or an edge containing
64  * internal degrees of freedom representing the concentration
66  */
67  ImplicitSurfChem(std::vector<InterfaceKinetics*> k);
68
69  /**
70  * Destructor. Deletes the integrator.
71  */
72  virtual ~ImplicitSurfChem();
73
74  /*!
75  * Must be called before calling method 'advance'
76  */
77  virtual void initialize(doublereal t0 = 0.0);
78
79  //! Integrate from t0 to t1. The integrator is reinitialized first.
80  /*!
81  * This routine does a time accurate solve from t = t0 to t = t1.
82  * of the surface problem.
83  *
84  * @param t0 Initial Time -> this is an input
85  * @param t1 Final Time -> This is an input
86  */
87  void integrate(doublereal t0, doublereal t1);
88
89  //! Integrate from t0 to t1 without reinitializing the integrator.
90  /*!
91  * Use when the coverages have not changed from their values on return
92  * from the last call to integrate or integrate0.
93  *
94  * @param t0 Initial Time -> this is an input
95  * @param t1 Final Time -> This is an input
96  */
97  void integrate0(doublereal t0, doublereal t1);
98
99  //! Solve for the pseudo steady-state of the surface problem
100  /*!
101  * Solve for the steady state of the surface problem.
102  * This is the same thing as the advanceCoverages() function,
103  * but at infinite times.
104  *
105  * Note, a direct solve is carried out under the hood here,
106  * to reduce the computational time.
107  *
108  * @param ifuncOverride One of the values defined in @ref solvesp_methods.
109  * The default is -1, which means that the program will decide.
110  *
111  * @param timeScaleOverride When a pseudo transient is
112  * selected this value can be used to override
113  * the default time scale for integration which
114  * is one.
115  * When SFLUX_TRANSIENT is used, this is equal to the
116  * time over which the equations are integrated.
117  * When SFLUX_INITIALIZE is used, this is equal to the
118  * time used in the initial transient algorithm,
119  * before the equation system is solved directly.
120  */
121  void solvePseudoSteadyStateProblem(int ifuncOverride = -1,
122  doublereal timeScaleOverride = 1.0);
123
124  // overloaded methods of class FuncEval
125
126  //! Return the number of equations
127  virtual size_t neq() {
128  return m_nv;
129  }
130
131  //! Evaluate the value of ydot[k] at the current conditions
132  /*!
133  * @param t Time (seconds)
134  * @param y Vector containing the current solution vector
135  * @param ydot Output vector containing the value of the
136  * derivative of the surface coverages.
137  * @param p Unused parameter pass-through parameter vector
138  */
139  virtual void eval(doublereal t, doublereal* y, doublereal* ydot,
140  doublereal* p);
141
142  //! Set the initial conditions for the solution vector
143  /*!
144  * @param t0 Initial time
145  * @param leny Length of the solution vector
146  * @param y Value of the solution vector to be used.
147  * On output, this contains the initial value
148  * of the solution.
149  */
150  virtual void getInitialConditions(doublereal t0,
151  size_t leny, doublereal* y);
152
153  /*!
154  * Get the specifications for the problem from the values
155  * in the ThermoPhase objects for all phases.
156  *
157  * 1. concentrations of all species in all phases, #m_concSpecies
158  * 2. Temperature and pressure
159  *
160  * @param vecConcSpecies Vector of concentrations. The phase
161  * concentration vectors are contiguous within the
162  * object, in the same order as the unknown vector.
163  */
164  void getConcSpecies(doublereal* const vecConcSpecies) const;
165
166  //! Sets the concentrations within phases that are unknowns in
167  //! the surface problem
168  /*!
169  * Fills the local concentration vector for all of the species in all of
170  * the phases that are unknowns in the surface problem.
171  *
172  * @param vecConcSpecies Vector of concentrations. The
173  * phase concentration vectors are contiguous
174  * within the object, in the same order as the
175  * unknown vector.
176  */
177  void setConcSpecies(const doublereal* const vecConcSpecies);
178
179  //! Sets the state variable in all thermodynamic phases (surface and
180  //! surrounding bulk phases) to the input temperature and pressure
181  /*!
182  * @param TKelvin input temperature (kelvin)
183  * @param PresPa input pressure in pascal.
184  */
185  void setCommonState_TP(doublereal TKelvin, doublereal PresPa);
186
187  //! Returns a reference to the vector of pointers to the
188  //! InterfaceKinetics objects
189  /*!
190  * This should probably go away in the future, as it opens up the class.
191  */
192  std::vector<InterfaceKinetics*> & getObjects() {
193  return m_vecKinPtrs;
194  }
195
196  int checkMatch(std::vector<ThermoPhase*> m_vec, ThermoPhase* thPtr);
197
198  void setIOFlag(int ioFlag) {
199  m_ioFlag = ioFlag;
200  }
201
202 protected:
203  //! Set the mixture to a state consistent with solution
204  //! vector y.
205  /*!
206  * This function will set the surface site factions in the underlying
207  * SurfPhase objects to the current value of the solution vector.
208  *
209  * @param y Current value of the solution vector. The lenth is equal to
210  * the sum of the number of surface sites in all the surface phases.
211  */
213
214  //! vector of pointers to surface phases.
215  std::vector<SurfPhase*> m_surf;
216
217  //! Vector of pointers to bulk phases
218  std::vector<ThermoPhase*> m_bulkPhases;
219
220  //! vector of pointers to InterfaceKinetics objects
221  std::vector<InterfaceKinetics*> m_vecKinPtrs;
222
223  //! Vector of number of species in each Surface Phase
224  std::vector<size_t> m_nsp;
225
226  //! index of the surface phase in each InterfaceKinetics object
227  std::vector<size_t> m_surfindex;
228
229  std::vector<size_t> m_specStartIndex;
230
231  //! Total number of surface phases.
232  /*!
233  * This is also equal to the number of InterfaceKinetics objects
234  * as there is a 1-1 correspondence between InterfaceKinetics objects
235  * and surface phases.
236  */
237  size_t m_nsurf;
238
239  //! Total number of surface species in all surface phases
240  /*!
241  * This is the total number of unknowns in m_mode 0 problem
242  */
243  size_t m_nv;
244
245  size_t m_numBulkPhases;
246  std::vector<size_t> m_nspBulkPhases;
247  size_t m_numTotalBulkSpecies;
248  size_t m_numTotalSpecies;
249
250  std::vector<vector_int> pLocVec;
251  //! Pointer to the cvode integrator
253  doublereal m_atol, m_rtol; // tolerances
254  doublereal m_maxstep; //!< max step size
255  vector_fp m_work;
256
257  /**
258  * Temporary vector - length num species in the Kinetics object. This is
259  * the sum of the number of species in each phase included in the kinetics
260  * object.
261  */
263  vector_fp m_concSpeciesSave;
264
265  //std::vector<vector_fp> m_vectorConcKinSpecies;
266  //std::vector<vector_fp> m_vectorNetSpeciesProdRate;
267  /**
268  * Index into the species vector of the kinetics manager,
269  * pointing to the first species from the surrounding medium.
270  */
272  /**
273  * Index into the species vector of the kinetics manager,
274  * pointing to the first species from the condensed phase
275  * of the particles.
276  */
278  /**
279  * Index into the species vector of the kinetics manager,
280  * pointing to the first species from the surface
281  * of the particles
282  */
284  /**
285  * Pointer to the helper method, Placid, which solves the
286  * surface problem.
287  */
289
290  //! If true, a common temperature and pressure for all
291  //! surface and bulk phases associated with the surface problem
292  //! is imposed
294
295  //! We make the solveSS class a friend because we need
296  //! to access all of the above information directly.
297  //! Adding the members into the class is also a possibility.
298  friend class solveSS;
299
300 private:
301  //! Controls the amount of printing from this routine
302  //! and underlying routines.
303  int m_ioFlag;
304 };
305 }
306
307 #endif
Integrator * m_integ
Pointer to the cvode integrator.
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase, assuming an ideal solution model (see Thermodynamic Properties and class SurfPhase).
std::vector< size_t > m_surfindex
index of the surface phase in each InterfaceKinetics object
int m_mediumSpeciesStart
Index into the species vector of the kinetics manager, pointing to the first species from the surroun...
Solve for the pseudo steady-state of the surface problem.
std::vector< ThermoPhase * > m_bulkPhases
Vector of pointers to bulk phases.
Method to solve a pseudo steady state surface problem.
Definition: solveSP.h:145
doublereal m_maxstep
max step size
std::vector< size_t > m_nsp
Vector of number of species in each Surface Phase.
friend class solveSS
We make the solveSS class a friend because we need to access all of the above information directly...
int m_surfSpeciesStart
Index into the species vector of the kinetics manager, pointing to the first species from the surface...
solveSP * m_surfSolver
Pointer to the helper method, Placid, which solves the surface problem.
virtual size_t neq()
Return the number of equations.
std::vector< SurfPhase * > m_surf
vector of pointers to surface phases.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
int m_ioFlag
Controls the amount of printing from this routine and underlying routines.
int m_bulkSpeciesStart
Index into the species vector of the kinetics manager, pointing to the first species from the condens...
bool m_commonTempPressForPhases
If true, a common temperature and pressure for all surface and bulk phases associated with the surfac...
virtual ~ImplicitSurfChem()
Destructor.
Abstract base class for ODE system integrators.
Definition: Integrator.h:53
virtual void getInitialConditions(doublereal t0, size_t leny, doublereal *y)
Set the initial conditions for the solution vector.
size_t m_nv
Total number of surface species in all surface phases.
virtual void eval(doublereal t, doublereal *y, doublereal *ydot, doublereal *p)
Evaluate the value of ydot[k] at the current conditions.
void integrate0(doublereal t0, doublereal t1)
Integrate from t0 to t1 without reinitializing the integrator.
void setConcSpecies(const doublereal *const vecConcSpecies)
Sets the concentrations within phases that are unknowns in the surface problem.
std::vector< InterfaceKinetics * > & getObjects()
Returns a reference to the vector of pointers to the InterfaceKinetics objects.
Advances the surface coverages of the associated set of SurfacePhase objects in time.
ImplicitSurfChem(std::vector< InterfaceKinetics * > k)
Constructor for multiple surfaces.
void getConcSpecies(doublereal *const vecConcSpecies) const
virtual void initialize(doublereal t0=0.0)
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:165
void setCommonState_TP(doublereal TKelvin, doublereal PresPa)
Sets the state variable in all thermodynamic phases (surface and surrounding bulk phases) to the inpu...