Cantera  2.0
IonsFromNeutralVPSSTP.h
Go to the documentation of this file.
1 /**
2  * @file IonsFromNeutralVPSSTP.h
3  * Header for intermediate ThermoPhase object for phases which
4  * consist of ions whose thermodynamics is calculated from neutral molecule thermodynamics.
5  * (see \ref thermoprops
6  * and class \link Cantera::IonsFromNeutralVPSSTP IonsFromNeutralVPSSTP\endlink).
7  *
8  * Header file for a derived class of %ThermoPhase that handles
9  * variable pressure standard state methods for calculating
10  * thermodynamic properties that are further based upon activities
11  * based on the molality scale. These include most of the methods for
12  * calculating liquid electrolyte thermodynamics.
13  */
14 /*
15  * Copyright (2006) Sandia Corporation. Under the terms of
16  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
17  * U.S. Government retains certain rights in this software.
18  */
19 #ifndef CT_IONSFROMNEUTRALVPSSTP_H
20 #define CT_IONSFROMNEUTRALVPSSTP_H
21 
22 #include "GibbsExcessVPSSTP.h"
23 
24 namespace Cantera
25 {
26 
27 //! enums for molten salt ion solution types
28 /*!
29  * Types identify how complicated the solution is. If there
30  * is just mixing on one of the sublattices but not the other,
31  * then the math is considerably simpler.
32  */
34  cIonSolnType_PASSTHROUGH = 2000 ,
35  cIonSolnType_SINGLEANION ,
36  cIonSolnType_SINGLECATION ,
37  cIonSolnType_MULTICATIONANION
38 };
39 
40 /*!
41  * The IonsFromNeutralVPSSTP is a derived class of ThermoPhase
42  * that handles the specification of the chemical potentials for
43  * ionic species, given a specification of the chemical potentials
44  * for the same phase expressed in terms of combinations of the
45  * ionic species that represent neutral molecules. It's expected
46  * that the neutral molecules will be represented in terms of
47  * an excess gibbs free energy approximation that is a derivative
48  * of the GbbsExcessVPSSTP object. All of the e Excess Gibbs free
49  * energy formulations in this area employ
50  * symmetrical formulations.
51  *
52  * This class is used for molten salts.
53  *
54  * This object actually employs 4 different mole fraction types.
55  *
56  * 1) There is a mole fraction associated the the cations and
57  * anions and neutrals from this ThermoPhase object. This
58  * is the normal mole fraction vector for this object.
59  * Note, however, it isn't the appropriate mole fraction
60  * vector to use even for obtaining the correct ideal
61  * free energies of mixing.
62  * 2) There is a mole fraction vector associated with the
63  * neutral molecule ThermoPhase object.
64  * 3) There is a mole fraction vector associated with the
65  * cation lattice.
66  * 4) There is a mole fraction vector associated with the
67  * anion lattice
68  *
69  * This object can translate between any of the four mole
70  * fraction representations.
71  *
72  *
73  */
75 {
76 
77 public:
78 
79  /// Constructors
80  /*!
81  * Default constructor
82  */
84 
85  //! Construct and initialize an IonsFromNeutralVPSSTP object
86  //! directly from an ASCII input file
87  /*!
88  * Working constructors
89  *
90  * The two constructors below are the normal way
91  * the phase initializes itself. They are shells that call
92  * the routine initThermo(), with a reference to the
93  * XML database to get the info for the phase.
94  *
95  * @param inputFile Name of the input file containing the phase XML data
96  * to set up the object
97  * @param id ID of the phase in the input file. Defaults to the
98  * empty string.
99  * @param neutralPhase The object takes a neutralPhase ThermoPhase
100  * object as input. It can either take a pointer
101  * to an existing object in the parameter list,
102  * in which case it does not own the object, or
103  * it can construct a neutral Phase as a slave
104  * object, in which case, it does own the slave
105  * object, for purposes of who gets to destroy
106  * the object.
107  * If this parameter is zero, then a slave
108  * neutral phase object is created and used.
109  */
110  IonsFromNeutralVPSSTP(std::string inputFile, std::string id = "",
111  ThermoPhase* neutralPhase = 0);
112 
113  //! Construct and initialize an IonsFromNeutralVPSSTP object
114  //! directly from an XML database
115  /*!
116  * @param phaseRoot XML phase node containing the description of the phase
117  * @param id id attribute containing the name of the phase.
118  * (default is the empty string)
119  * @param neutralPhase The object takes a neutralPhase ThermoPhase
120  * object as input. It can either take a pointer
121  * to an existing object in the parameter list,
122  * in which case it does not own the object, or
123  * it can construct a neutral Phase as a slave
124  * object, in which case, it does own the slave
125  * object, for purposes of who gets to destroy
126  * the object.
127  * If this parameter is zero, then a slave
128  * neutral phase object is created and used.
129  */
130  IonsFromNeutralVPSSTP(XML_Node& phaseRoot, std::string id = "",
131  ThermoPhase* neutralPhase = 0);
132 
133 
134  //! Copy constructor
135  /*!
136  * Note this stuff will not work until the underlying phase
137  * has a working copy constructor
138  *
139  * @param b class to be copied
140  */
142 
143  /// Assignment operator
144  /*!
145  *
146  * @param b class to be copied.
147  */
149 
150  /// Destructor.
151  virtual ~IonsFromNeutralVPSSTP();
152 
153  //! Duplication routine for objects which inherit from ThermoPhase.
154  /*!
155  * This virtual routine can be used to duplicate ThermoPhase objects
156  * inherited from ThermoPhase even if the application only has
157  * a pointer to ThermoPhase to work with.
158  */
159  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
160 
161  /**
162  *
163  * @name Utilities
164  * @{
165  */
166 
167 
168  //! Equation of state type flag.
169  /*!
170  * The ThermoPhase base class returns
171  * zero. Subclasses should define this to return a unique
172  * non-zero value. Known constants defined for this purpose are
173  * listed in mix_defs.h. The MolalityVPSSTP class also returns
174  * zero, as it is a non-complete class.
175  */
176  virtual int eosType() const;
177 
178 
179 
180  /**
181  * @}
182  * @name Molar Thermodynamic Properties
183  * @{
184  */
185 
186  //! Return the Molar enthalpy. Units: J/kmol.
187  /*!
188  * This is calculated from the partial molar enthalpies of the species
189  */
190  virtual doublereal enthalpy_mole() const;
191 
192  /**
193  * Molar internal energy. J/kmol.
194  * *
195  * This is calculated from the soln enthalpy and then
196  * subtracting pV.
197  */
198  virtual doublereal intEnergy_mole() const;
199 
200  /**
201  * Molar entropy. Units: J/kmol/K.
202  *
203  *
204  */
205  virtual doublereal entropy_mole() const;
206 
207  /**
208  * Molar Gibbs free Energy for an ideal gas.
209  * Units = J/kmol.
210  */
211  virtual doublereal gibbs_mole() const;
212 
213  /**
214  * Molar heat capacity at constant pressure. Units: J/kmol/K.
215  * For an ideal gas mixture,
216  *
217  */
218  virtual doublereal cp_mole() const;
219 
220  /**
221  * Molar heat capacity at constant volume. Units: J/kmol/K.
222  *
223  */
224  virtual doublereal cv_mole() const;
225 
226 
227  /**
228  * @}
229  * @name Utilities
230  * @{
231  */
232 
233 
234 
235 
236  /**
237  * @}
238  * @name Mechanical Properties
239  * @{
240  */
241 
242  /**
243  * @}
244  * @name Potential Energy
245  *
246  * Species may have an additional potential energy due to the
247  * presence of external gravitation or electric fields. These
248  * methods allow specifying a potential energy for individual
249  * species.
250  * @{
251  */
252 
253  /**
254  * @}
255  * @name Activities, Standard States, and Activity Concentrations
256  *
257  * The activity \f$a_k\f$ of a species in solution is
258  * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
259  * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
260  * the chemical potential at unit activity, which depends only
261  * on temperature and pressure.
262  * @{
263  */
264 
265  //! Get the array of non-dimensional molar-based activity coefficients at
266  //! the current solution temperature, pressure, and solution concentration.
267  /*!
268  * @param ac Output vector of activity coefficients. Length: m_kk.
269  */
270  virtual void getActivityCoefficients(doublereal* ac) const;
271 
272 
273  //@}
274  /// @name Partial Molar Properties of the Solution
275  //@{
276 
277  //! Get the species chemical potentials. Units: J/kmol.
278  /*!
279  * This function returns a vector of chemical potentials of the
280  * species in solution at the current temperature, pressure
281  * and mole fraction of the solution.
282  *
283  * @param mu Output vector of species chemical
284  * potentials. Length: m_kk. Units: J/kmol
285  */
286  virtual void getChemPotentials(doublereal* mu) const;
287 
288 
289  //! Returns an array of partial molar enthalpies for the species
290  //! in the mixture.
291  /*!
292  * Units (J/kmol)
293  *
294  * For this phase, the partial molar enthalpies are equal to the
295  * standard state enthalpies modified by the derivative of the
296  * molality-based activity coefficient wrt temperature
297  *
298  * \f[
299  * \bar h_k(T,P) = h^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
300  * \f]
301  *
302  * @param hbar Output vector of species partial molar enthalpies.
303  * Length: m_kk. Units: J/kmol
304  */
305  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
306 
307  //! Returns an array of partial molar entropies for the species
308  //! in the mixture.
309  /*!
310  * Units (J/kmol)
311  *
312  * For this phase, the partial molar enthalpies are equal to the
313  * standard state enthalpies modified by the derivative of the
314  * activity coefficient wrt temperature
315  *
316  * \f[
317  * \bar s_k(T,P) = s^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
318  * - R \ln( \gamma_k X_k)
319  * - R T \frac{d \ln(\gamma_k) }{dT}
320  * \f]
321  *
322  *
323  * @param sbar Output vector of species partial molar entropies.
324  * Length: m_kk. Units: J/kmol/K
325  */
326  virtual void getPartialMolarEntropies(doublereal* sbar) const;
327 
328 
329  //! Get the change in activity coefficients w.r.t. change in state (temp, mole fraction, etc.) along
330  //! a line in parameter space or along a line in physical space
331  /*!
332  *
333  * @param dTds Input of temperature change along the path
334  * @param dXds Input vector of changes in mole fraction along the path. length = m_kk
335  * Along the path length it must be the case that the mole fractions sum to one.
336  * @param dlnActCoeffds Output vector of the directional derivatives of the
337  * log Activity Coefficients along the path. length = m_kk
338  */
339  virtual void getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds,
340  doublereal* dlnActCoeffds) const;
341 
342  //! Get the array of log concentration-like derivatives of the
343  //! log activity coefficients - diagonal component
344  /*!
345  * This function is a virtual method. For ideal mixtures
346  * (unity activity coefficients), this can return zero.
347  * Implementations should take the derivative of the
348  * logarithm of the activity coefficient with respect to the
349  * logarithm of the mole fraction.
350  *
351  * units = dimensionless
352  *
353  * @param dlnActCoeffdlnX_diag Output vector of log(mole fraction)
354  * derivatives of the log Activity Coefficients.
355  * length = m_kk
356  */
357  virtual void getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const;
358 
359  //! Get the array of log concentration-like derivatives of the
360  //! log activity coefficients - diagonal components
361  /*!
362  * This function is a virtual method. For ideal mixtures
363  * (unity activity coefficients), this can return zero.
364  * Implementations should take the derivative of the
365  * logarithm of the activity coefficient with respect to the
366  * logarithm of the species mole numbe. This routine just does the diagonal entries.
367  *
368  * units = dimensionless
369  *
370  * @param dlnActCoeffdlnN_diag Output vector of diagonal components of the log(mole fraction)
371  * derivatives of the log Activity Coefficients.
372  * length = m_kk
373  */
374  virtual void getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const;
375 
376  //! Get the array of derivatives of the ln activity coefficients with respect to the ln species mole numbers
377  /*!
378  * Implementations should take the derivative of the logarithm of the activity coefficient with respect to a
379  * log of a species mole number (with all other species mole numbers held constant)
380  *
381  * units = 1 / kmol
382  *
383  * dlnActCoeffdlnN[ ld * k + m] will contain the derivative of log act_coeff for the <I>m</I><SUP>th</SUP>
384  * species with respect to the number of moles of the <I>k</I><SUP>th</SUP> species.
385  *
386  * \f[
387  * \frac{d \ln(\gamma_m) }{d \ln( n_k ) }\Bigg|_{n_i}
388  * \f]
389  *
390  * @param ld Number of rows in the matrix
391  * @param dlnActCoeffdlnN Output vector of derivatives of the
392  * log Activity Coefficients. length = m_kk * m_kk
393  */
394  virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN) ;
395 
396 
397  //! Get the Salt Dissociation Coefficients
398  //! Returns the vector of dissociation coefficients and vector of charges
399  /*!
400  * @param fm_neutralMolec_ions Returns the formula matrix for the composition of neutral molecules
401  * in terms of the ions.
402  * @param charges Returns a vector containing the charges of all species in this phase
403  * @param neutMolIndex Returns the vector fm_invert_ionForNeutral
404  * This is the mapping between ion species and neutral molecule for quick invert.
405  */
406  void getDissociationCoeffs(vector_fp& fm_neutralMolec_ions, vector_fp& charges, std::vector<size_t>& neutMolIndex) const;
407 
408 
409  //! Return the current value of the neutral mole fraction vector
410  /*!
411  * @param neutralMoleculeMoleFractions Vector of neutral molecule mole fractions.
412  */
413  void getNeutralMolecMoleFractions(vector_fp& neutralMoleculeMoleFractions) const {
414  neutralMoleculeMoleFractions = NeutralMolecMoleFractions_;
415  }
416 
417  //! Calculate neutral molecule mole fractions
418  /*!
419  * This routine calculates the neutral molecule mole
420  * fraction given the vector of ion mole fractions,
421  * i.e., the mole fractions from this ThermoPhase.
422  * Note, this routine basically assumes that there
423  * is charge neutrality. If there isn't, then it wouldn't
424  * make much sense.
425  *
426  * for the case of cIonSolnType_SINGLEANION, some slough
427  * in the charge neutrality is allowed. The cation number
428  * is followed, while the difference in charge neutrality
429  * is dumped into the anion mole number to fix the imbalance.
430  *
431  * @param dx input vector of ion mole fraction gradients
432  * @param dy output Vector of neutral molecule mole fraction gradients
433  */
434  void getNeutralMoleculeMoleGrads(const doublereal* const dx, doublereal* const dy) const;
435 
436  //! Get the list of cations in this object
437  /*!
438  * @param cation List of cations
439  */
440  void getCationList(std::vector<size_t>& cation) const {
441  cation=cationList_;
442  }
443 
444  //! Get the list of anions in this object
445  /*!
446  * @param anion List of anions
447  */
448  void getAnionList(std::vector<size_t>& anion) const {
449  anion=anionList_;
450  }
451 
452 
453  //@}
454  /// @name Properties of the Standard State of the Species in the Solution
455  //@{
456 
457 
458 
459  //@}
460  /// @name Thermodynamic Values for the Species Reference States
461  //@{
462 
463 
464  ///////////////////////////////////////////////////////
465  //
466  // The methods below are not virtual, and should not
467  // be overloaded.
468  //
469  //////////////////////////////////////////////////////
470 
471  /**
472  * @name Specific Properties
473  * @{
474  */
475 
476 
477  /**
478  * @name Setting the State
479  *
480  * These methods set all or part of the thermodynamic
481  * state.
482  * @{
483  */
484 
485  virtual void setTemperature(const doublereal t);
486  virtual void setPressure(doublereal p);
487 
488  //! Set the temperature (K) and pressure (Pa)
489  /*!
490  * Setting the pressure may involve the solution of a nonlinear equation.
491  *
492  * @param t Temperature (K)
493  * @param p Pressure (Pa)
494  */
495  virtual void setState_TP(doublereal t, doublereal p);
496 
497 
498  //! Calculate ion mole fractions from neutral molecule
499  //! mole fractions.
500  /*!
501  * @param mf Dump the mole fractions into this vector.
502  */
503  virtual void calcIonMoleFractions(doublereal* const mf) const;
504 
505  //! Calculate neutral molecule mole fractions
506  /*!
507  * This routine calculates the neutral molecule mole
508  * fraction given the vector of ion mole fractions,
509  * i.e., the mole fractions from this ThermoPhase.
510  * Note, this routine basically assumes that there
511  * is charge neutrality. If there isn't, then it wouldn't
512  * make much sense.
513  *
514  * for the case of cIonSolnType_SINGLEANION, some slough
515  * in the charge neutrality is allowed. The cation number
516  * is followed, while the difference in charge neutrality
517  * is dumped into the anion mole number to fix the imbalance.
518  */
519  virtual void calcNeutralMoleculeMoleFractions() const;
520 
521  /**
522  * Set the mass fractions to the specified values, and then
523  * normalize them so that they sum to 1.0.
524  * @param y Array of unnormalized mass fraction values (input).
525  * Must have a length greater than or equal to the number of
526  * species.
527  *
528  * @param y Input vector of mass fractions.
529  * Length is m_kk.
530  */
531  virtual void setMassFractions(const doublereal* const y);
532 
533  /**
534  * Set the mass fractions to the specified values without
535  * normalizing. This is useful when the normalization
536  * condition is being handled by some other means, for example
537  * by a constraint equation as part of a larger set of
538  * equations.
539  *
540  * @param y Input vector of mass fractions.
541  * Length is m_kk.
542  */
543  virtual void setMassFractions_NoNorm(const doublereal* const y);
544 
545  /**
546  * Set the mole fractions to the specified values, and then
547  * normalize them so that they sum to 1.0.
548  * @param x Array of unnormalized mole fraction values (input).
549  * Must have a length greater than or equal to the number of
550  * species.
551  *
552  * @param x Input vector of mole fractions.
553  * Length is m_kk.
554  */
555  virtual void setMoleFractions(const doublereal* const x);
556 
557  /**
558  * Set the mole fractions to the specified values without
559  * normalizing. This is useful when the normalization
560  * condition is being handled by some other means, for example
561  * by a constraint equation as part of a larger set of
562  * equations.
563  *
564  * @param x Input vector of mole fractions.
565  * Length is m_kk.
566  */
567  virtual void setMoleFractions_NoNorm(const doublereal* const x);
568 
569  /**
570  * Set the concentrations to the specified values within the
571  * phase.
572  *
573  * @param c The input vector to this routine is in dimensional
574  * units. For volumetric phases c[k] is the
575  * concentration of the kth species in kmol/m3.
576  * For surface phases, c[k] is the concentration
577  * in kmol/m2. The length of the vector is the number
578  * of species in the phase.
579  */
580  virtual void setConcentrations(const doublereal* const c);
581 
582  //@}
583 
584  /**
585  * @name Chemical Equilibrium
586  * Routines that implement the Chemical equilibrium capability
587  * for a single phase, based on the element-potential method.
588  * @{
589  */
590 
591 
592 
593  //@}
594 
595 
596 
597  /// The following methods are used in the process of constructing
598  /// the phase and setting its parameters from a specification in an
599  /// input file. They are not normally used in application programs.
600  /// To see how they are used, see files importCTML.cpp and
601  /// ThermoFactory.cpp.
602 
603  //! Initialization of an IonsFromNeutralVPSSTP phase using an xml file
604  /*!
605  * This routine is a precursor to initThermo(XML_Node*)
606  * routine, which does most of the work.
607  *
608  * @param inputFile XML file containing the description of the
609  * phase
610  *
611  * @param id Optional parameter identifying the name of the
612  * phase. If none is given, the first XML
613  * phase element will be used.
614  */
615  void constructPhaseFile(std::string inputFile, std::string id);
616 
617  //! Import and initialize an IonsFromNeutralVPSSTP phase
618  //! specification in an XML tree into the current object.
619  /*!
620  * Here we read an XML description of the phase.
621  * We import descriptions of the elements that make up the
622  * species in a phase.
623  * We import information about the species, including their
624  * reference state thermodynamic polynomials. We then freeze
625  * the state of the species.
626  *
627  * Then, we read the species molar volumes from the xml
628  * tree to finish the initialization.
629  *
630  * @param phaseNode This object must be the phase node of a
631  * complete XML tree
632  * description of the phase, including all of the
633  * species data. In other words while "phase" must
634  * point to an XML phase object, it must have
635  * sibling nodes "speciesData" that describe
636  * the species in the phase.
637  *
638  * @param id ID of the phase. If nonnull, a check is done
639  * to see if phaseNode is pointing to the phase
640  * with the correct id.
641  */
642  void constructPhaseXML(XML_Node& phaseNode, std::string id);
643 
644 
645  /*!
646  * @internal Initialize. This method is provided to allow
647  * subclasses to perform any initialization required after all
648  * species have been added. For example, it might be used to
649  * resize internal work arrays that must have an entry for
650  * each species. The base class implementation does nothing,
651  * and subclasses that do not require initialization do not
652  * need to overload this method. When importing a CTML phase
653  * description, this method is called just prior to returning
654  * from function importPhase.
655  *
656  * @see importCTML.cpp
657  */
658  virtual void initThermo();
659 
660 
661  /**
662  * Import and initialize a ThermoPhase object
663  *
664  * @param phaseNode This object must be the phase node of a
665  * complete XML tree
666  * description of the phase, including all of the
667  * species data. In other words while "phase" must
668  * point to an XML phase object, it must have
669  * sibling nodes "speciesData" that describe
670  * the species in the phase.
671  * @param id ID of the phase. If nonnull, a check is done
672  * to see if phaseNode is pointing to the phase
673  * with the correct id.
674  */
675  void initThermoXML(XML_Node& phaseNode, std::string id);
676 
677 
678 private:
679 
680 
681  //! Initialize lengths of local variables after all species have
682  //! been identified.
683  void initLengths();
684 
685  //! Update the activity coefficients
686  /*!
687  * This function will be called to update the internally stored
688  * natural logarithm of the activity coefficients
689  */
690  void s_update_lnActCoeff() const;
691 
692  //! Update the temperature derivative of the ln activity coefficients
693  /*!
694  * This function will be called to update the internally stored
695  * temperature derivative of the natural logarithm of the activity coefficients
696  */
697  void s_update_dlnActCoeffdT() const;
698 
699  //! Update the change in the ln activity coefficients
700  /*!
701  * This function will be called to update the internally stored
702  * change of the natural logarithm of the activity coefficients
703  * w.r.t a change in state (temp, mole fraction, etc)
704  */
705  void s_update_dlnActCoeff() const;
706 
707  //! Update the derivative of the log of the activity coefficients
708  //! wrt log(mole fraction)
709  /*!
710  * This function will be called to update the internally stored
711  * derivative of the natural logarithm of the activity coefficients
712  * wrt logarithm of the mole fractions.
713  */
714  void s_update_dlnActCoeff_dlnX_diag() const;
715 
716  //! Update the derivative of the log of the activity coefficients
717  //! wrt log(number of moles) - diagonal components
718  /*!
719  * This function will be called to update the internally stored
720  * derivative of the natural logarithm of the activity coefficients
721  * wrt logarithm of the number of moles of given species.
722  */
723  void s_update_dlnActCoeff_dlnN_diag() const;
724 
725  //! Update the derivative of the log of the activity coefficients
726  //! wrt log(number of moles) - diagonal components
727  /*!
728  * This function will be called to update the internally stored
729  * derivative of the natural logarithm of the activity coefficients
730  * wrt logarithm of the number of moles of given species.
731  */
732  void s_update_dlnActCoeff_dlnN() const;
733 
734 
735 private:
736  //! Error function
737  /*!
738  * Print an error string and exit
739  *
740  * @param msg Message to be printed
741  */
742  doublereal err(std::string msg) const;
743 
744 protected:
745 
746  //! Ion solution type
747  /*!
748  * There is either mixing on the anion, cation, or both lattices.
749  * There is also a passthrough option
750  *
751  * Defaults to cIonSolnType_SINGLEANION, so that LiKCl can be hardwired
752  */
754 
755  //! Number of neutral molecule species
756  /*!
757  * This is equal to the number of species in the
758  * neutralMoleculePhase_ ThermoPhase.
759  */
761 
762  //! Index of special species
764 
765  //! Index of special species
767 
768  //! Formula Matrix for composition of neutral molecules
769  //! in terms of the molecules in this ThermoPhase
770  /*!
771  * fm_neutralMolec_ions[ i + jNeut * m_kk ]
772  *
773  * This is the number of ions of type i in the neutral
774  * molecule jNeut.
775  */
776  std::vector<double> fm_neutralMolec_ions_;
777 
778  //! Mapping between ion species and neutral molecule for quick invert.
779  /*!
780  *
781  * fm_invert_ionForNeutral returns vector of int. Each element represents
782  * an ionic species and stores the value of the corresponding neutral
783  * molecule
784  *
785  * For the case of fm_invert_simple_ = true, we assume that there
786  * is a quick way to invert the formula matrix so that we can
787  * quickly calculate the neutral molecule mole fraction
788  * given the ion mole fraction vector.
789  *
790  * We assume that for a selected set of ion species, that that
791  * ion is only in the neutral molecule, jNeut.
792  *
793  * therefore,
794  *
795  * NeutralMolecMoleFractions_[jNeut] += moleFractions_[i_ion] / fmij;
796  *
797  * where fmij is the number of ions in neutral molecule jNeut.
798  *
799  * Thus, we formulate the neutral molecule mole fraction NeutralMolecMoleFractions_[]
800  * vector from this association. We further assume that there are
801  * no other associations. If fm_invert_simple_ is not true,
802  * then we need to do a formal inversion which takes a great
803  * deal of time and is not currently implemented.
804  */
805  std::vector<size_t> fm_invert_ionForNeutral;
806 
807  //! Mole fractions using the Neutral Molecule Mole fraction basis
808  mutable std::vector<doublereal> NeutralMolecMoleFractions_;
809 
810 
811  //! List of the species in this ThermoPhase which are cation species
812  std::vector<size_t> cationList_;
813 
814  //! Number of cation species
816 
817  //! List of the species in this ThermoPhase which are anion species
818  std::vector<size_t> anionList_;
819 
820  //! Number of anion species
822 
823  //! List of the species in this ThermoPhase which are passed
824  //! through to the neutralMoleculePhase ThermoPhase.
825  /*!
826  * These have neutral charges.
827  */
828  std::vector<size_t> passThroughList_;
829 
830  //! Number of the species in this ThermoPhase which are passed
831  //! through to the neutralMoleculePhase ThermoPhase
833 
834 public:
835  //! This is a pointer to the neutral Molecule Phase
836  /*!
837  * If the variable, IOwnNThermoPhase_ is true, then we own
838  * the pointer. If not, then this is considered a shallow pointer.
839  */
841 
842 private:
843 
844  //! If true then we own the underlying neutral Molecule Phase
845  /*!
846  * If this is false, then the neutral molecule phase is considered
847  * as a shallow pointer.
848  */
850 
851  //! Temporary mole fraction vector
852  mutable std::vector<doublereal> moleFractionsTmp_;
853 
854  //! Storage vector for the neutral molecule chemical potentials
855  /*!
856  * This vector is used as a temporary storage area when calculating the ion chemical
857  * potentials.
858  *
859  * Units = Joules/kmol
860  * Length = numNeutralMoleculeSpecies_
861  */
862  mutable std::vector<doublereal> muNeutralMolecule_;
863 
864  //! Storage vector for the neutral molecule ln activity coefficients
865  /*!
866  * This vector is used as a temporary storage area when calculating the ion chemical
867  * potentials and activity coefficients
868  *
869  * Units = none
870  * Length = numNeutralMoleculeSpecies_
871  */
872  mutable std::vector<doublereal> lnActCoeff_NeutralMolecule_;
873 
874  //! Storage vector for the neutral molecule d ln activity coefficients dT
875  /*!
876  * This vector is used as a temporary storage area when calculating the ion derivatives
877 
878  *
879  * Units = 1/Kelvin
880  * Length = numNeutralMoleculeSpecies_
881  */
882  mutable std::vector<doublereal> dlnActCoeffdT_NeutralMolecule_;
883 
884  //! Storage vector for the neutral molecule d ln activity coefficients dX - diagonal component
885  /*!
886  * This vector is used as a temporary storage area when calculating the ion derivatives
887  *
888  * Units = none
889  * Length = numNeutralMoleculeSpecies_
890  */
891  mutable std::vector<doublereal> dlnActCoeffdlnX_diag_NeutralMolecule_;
892 
893  //! Storage vector for the neutral molecule d ln activity coefficients dlnN - diagonal component
894  /*!
895  * This vector is used as a temporary storage area when calculating the ion derivatives
896  *
897  * Units = none
898  * Length = numNeutralMoleculeSpecies_
899  */
900  mutable std::vector<doublereal> dlnActCoeffdlnN_diag_NeutralMolecule_;
901 
902  //! Storage vector for the neutral molecule d ln activity coefficients dlnN
903  /*!
904  * This vector is used as a temporary storage area when calculating the ion derivatives
905  *
906  * Units = none
907  * Length = numNeutralMoleculeSpecies_
908  */
910 
911 };
912 
913 
914 
915 
916 
917 }
918 
919 #endif