Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  */
73 {
74 public:
75 
76  //! @name Constructors
77  //! @{
78 
79  /*!
80  * Default constructor
81  */
83 
84  //! Construct and initialize an IonsFromNeutralVPSSTP object
85  //! directly from an ASCII input file
86  /*!
87  * This constructor is a shell around the routine initThermo(), with a
88  * reference to the XML database to get the info for the phase.
89  *
90  * @param inputFile Name of the input file containing the phase XML data
91  * to set up the object
92  * @param id ID of the phase in the input file. Defaults to the
93  * empty string.
94  * @param neutralPhase The object takes a neutralPhase ThermoPhase
95  * object as input. It can either take a pointer
96  * to an existing object in the parameter list,
97  * in which case it does not own the object, or
98  * it can construct a neutral Phase as a slave
99  * object, in which case, it does own the slave
100  * object, for purposes of who gets to destroy
101  * the object.
102  * If this parameter is zero, then a slave
103  * neutral phase object is created and used.
104  */
105  IonsFromNeutralVPSSTP(const std::string& inputFile,
106  const std::string& id = "",
107  ThermoPhase* neutralPhase = 0);
108 
109  //! Construct and initialize an IonsFromNeutralVPSSTP object
110  //! directly from an XML database
111  /*!
112  * @param phaseRoot XML phase node containing the description of the phase
113  * @param id id attribute containing the name of the phase.
114  * (default is the empty string)
115  * @param neutralPhase The object takes a neutralPhase ThermoPhase
116  * object as input. It can either take a pointer
117  * to an existing object in the parameter list,
118  * in which case it does not own the object, or
119  * it can construct a neutral Phase as a slave
120  * object, in which case, it does own the slave
121  * object, for purposes of who gets to destroy
122  * the object.
123  * If this parameter is zero, then a slave
124  * neutral phase object is created and used.
125  */
126  IonsFromNeutralVPSSTP(XML_Node& phaseRoot, const std::string& id = "",
127  ThermoPhase* neutralPhase = 0);
128 
129 
130  //! Copy constructor
131  /*!
132  * @param b class to be copied
133  */
135 
136  /// Assignment operator
137  /*!
138  * @param b class to be copied.
139  */
141 
142  /// Destructor.
143  virtual ~IonsFromNeutralVPSSTP();
144 
145  //! Duplication routine for objects which inherit from ThermoPhase.
146  /*!
147  * This virtual routine can be used to duplicate ThermoPhase objects
148  * inherited from ThermoPhase even if the application only has
149  * a pointer to ThermoPhase to work with.
150  */
151  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
152 
153  // @}
154 
155  /// The following methods are used in the process of constructing
156  /// the phase and setting its parameters from a specification in an
157  /// input file.
158 
159  //! Initialization of an IonsFromNeutralVPSSTP phase using an XML file
160  /*!
161  * This routine is a precursor to initThermo(XML_Node*)
162  * routine, which does most of the work.
163  *
164  * @param inputFile XML file containing the description of the phase
165  *
166  * @param id Optional parameter identifying the name of the
167  * phase. If none is given, the first XML
168  * phase element will be used.
169  */
170  void constructPhaseFile(std::string inputFile, std::string id);
171 
172  //! Import and initialize an IonsFromNeutralVPSSTP phase
173  //! specification in an XML tree into the current object.
174  /*!
175  * Here we read an XML description of the phase.
176  * We import descriptions of the elements that make up the
177  * species in a phase.
178  * We import information about the species, including their
179  * reference state thermodynamic polynomials. We then freeze
180  * the state of the species.
181  *
182  * Then, we read the species molar volumes from the XML
183  * tree to finish the initialization.
184  *
185  * @param phaseNode This object must be the phase node of a complete XML tree
186  * description of the phase, including all of the
187  * species data. In other words while "phase" must
188  * point to an XML phase object, it must have
189  * sibling nodes "speciesData" that describe
190  * the species in the phase.
191  *
192  * @param id ID of the phase. If nonnull, a check is done
193  * to see if phaseNode is pointing to the phase
194  * with the correct id.
195  */
196  void constructPhaseXML(XML_Node& phaseNode, std::string id);
197 
198  //! @name Utilities
199  //! @{
200 
201  //! Equation of state type flag.
202  /*!
203  * The ThermoPhase base class returns
204  * zero. Subclasses should define this to return a unique
205  * non-zero value. Known constants defined for this purpose are
206  * listed in mix_defs.h. The MolalityVPSSTP class also returns
207  * zero, as it is a non-complete class.
208  */
209  virtual int eosType() const;
210 
211  //! @}
212  //! @name Molar Thermodynamic Properties
213  //! @{
214 
215  //! Return the Molar enthalpy. Units: J/kmol.
216  /*!
217  * This is calculated from the partial molar enthalpies of the species.
218  */
219  virtual doublereal enthalpy_mole() const;
220 
221  //! Molar entropy. Units: J/kmol/K.
222  virtual doublereal entropy_mole() const;
223 
224  //! Molar Gibbs free Energy for an ideal gas. Units = J/kmol.
225  virtual doublereal gibbs_mole() const;
226 
227  //! Molar heat capacity at constant pressure. Units: J/kmol/K.
228  virtual doublereal cp_mole() const;
229 
230  //! Molar heat capacity at constant volume. Units: J/kmol/K.
231  virtual doublereal cv_mole() const;
232 
233  /**
234  * @}
235  * @name Activities, Standard States, and Activity Concentrations
236  *
237  * The activity \f$a_k\f$ of a species in solution is
238  * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
239  * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
240  * the chemical potential at unit activity, which depends only
241  * on temperature and pressure.
242  * @{
243  */
244 
245  //! Get the array of non-dimensional molar-based activity coefficients at
246  //! the current solution temperature, pressure, and solution concentration.
247  /*!
248  * @param ac Output vector of activity coefficients. Length: m_kk.
249  */
250  virtual void getActivityCoefficients(doublereal* ac) const;
251 
252  //@}
253  /// @name Partial Molar Properties of the Solution
254  //@{
255 
256  //! Get the species chemical potentials. Units: J/kmol.
257  /*!
258  * This function returns a vector of chemical potentials of the
259  * species in solution at the current temperature, pressure
260  * and mole fraction of the solution.
261  *
262  * @param mu Output vector of species chemical
263  * potentials. Length: m_kk. Units: J/kmol
264  */
265  virtual void getChemPotentials(doublereal* mu) const;
266 
267  //! Returns an array of partial molar enthalpies for the species
268  //! in the mixture.
269  /*!
270  * Units (J/kmol)
271  *
272  * For this phase, the partial molar enthalpies are equal to the
273  * standard state enthalpies modified by the derivative of the
274  * molality-based activity coefficient wrt temperature
275  *
276  * \f[
277  * \bar h_k(T,P) = h^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
278  * \f]
279  *
280  * @param hbar Output vector of species partial molar enthalpies.
281  * Length: m_kk. Units: J/kmol
282  */
283  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
284 
285  //! Returns an array of partial molar entropies for the species
286  //! in the mixture.
287  /*!
288  * Units (J/kmol)
289  *
290  * For this phase, the partial molar enthalpies are equal to the
291  * standard state enthalpies modified by the derivative of the
292  * activity coefficient wrt temperature
293  *
294  * \f[
295  * \bar s_k(T,P) = s^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
296  * - R \ln( \gamma_k X_k)
297  * - R T \frac{d \ln(\gamma_k) }{dT}
298  * \f]
299  *
300  *
301  * @param sbar Output vector of species partial molar entropies.
302  * Length: m_kk. Units: J/kmol/K
303  */
304  virtual void getPartialMolarEntropies(doublereal* sbar) const;
305 
306 
307  //! Get the change in activity coefficients w.r.t. change in state (temp, mole fraction, etc.) along
308  //! a line in parameter space or along a line in physical space
309  /*!
310  *
311  * @param dTds Input of temperature change along the path
312  * @param dXds Input vector of changes in mole fraction along the path. length = m_kk
313  * Along the path length it must be the case that the mole fractions sum to one.
314  * @param dlnActCoeffds Output vector of the directional derivatives of the
315  * log Activity Coefficients along the path. length = m_kk
316  */
317  virtual void getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds,
318  doublereal* dlnActCoeffds) const;
319 
320  //! Get the array of log concentration-like derivatives of the
321  //! log activity coefficients - diagonal component
322  /*!
323  * For ideal mixtures (unity activity coefficients), this can return zero.
324  * Implementations should take the derivative of the logarithm of the
325  * activity coefficient with respect to the logarithm of the mole
326  * fraction. This quantity is to be used in conjunction with derivatives
327  * of that concentration-like variable when the derivative of the chemical
328  * potential is taken.
329  *
330  * units = dimensionless
331  *
332  * @param dlnActCoeffdlnX_diag Output vector of log(mole fraction)
333  * derivatives of the log Activity Coefficients.
334  * length = m_kk
335  */
336  virtual void getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const;
337 
338  //! Get the array of log concentration-like derivatives of the
339  //! log activity coefficients - diagonal components
340  /*!
341  * For ideal mixtures (unity activity coefficients), this can return zero.
342  * Implementations should take the derivative of the logarithm of the
343  * activity coefficient with respect to the logarithm of the species mole
344  * numbe. This routine just does the diagonal entries.
345  *
346  * units = dimensionless
347  *
348  * @param dlnActCoeffdlnN_diag Output vector of diagonal components of the log(mole fraction)
349  * derivatives of the log Activity Coefficients.
350  * length = m_kk
351  */
352  virtual void getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const;
353 
354  //! Get the array of derivatives of the ln activity coefficients with respect to the ln species mole numbers
355  /*!
356  * Implementations should take the derivative of the logarithm of the activity coefficient with respect to a
357  * log of a species mole number (with all other species mole numbers held constant)
358  *
359  * units = 1 / kmol
360  *
361  * dlnActCoeffdlnN[ ld * k + m] will contain the derivative of log act_coeff for the <I>m</I><SUP>th</SUP>
362  * species with respect to the number of moles of the <I>k</I><SUP>th</SUP> species.
363  *
364  * \f[
365  * \frac{d \ln(\gamma_m) }{d \ln( n_k ) }\Bigg|_{n_i}
366  * \f]
367  *
368  * @param ld Number of rows in the matrix
369  * @param dlnActCoeffdlnN Output vector of derivatives of the
370  * log Activity Coefficients. length = m_kk * m_kk
371  */
372  virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN) ;
373  //! @}
374 
375  //! Get the Salt Dissociation Coefficients
376  //! Returns the vector of dissociation coefficients and vector of charges
377  /*!
378  * @param fm_neutralMolec_ions Returns the formula matrix for the composition of neutral molecules
379  * in terms of the ions.
380  * @param charges Returns a vector containing the charges of all species in this phase
381  * @param neutMolIndex Returns the vector fm_invert_ionForNeutral
382  * This is the mapping between ion species and neutral molecule for quick invert.
383  */
384  void getDissociationCoeffs(vector_fp& fm_neutralMolec_ions, vector_fp& charges, std::vector<size_t>& neutMolIndex) const;
385 
386  //! Return the current value of the neutral mole fraction vector
387  /*!
388  * @param neutralMoleculeMoleFractions Vector of neutral molecule mole fractions.
389  */
390  void getNeutralMolecMoleFractions(vector_fp& neutralMoleculeMoleFractions) const {
391  neutralMoleculeMoleFractions = NeutralMolecMoleFractions_;
392  }
393 
394  //! Calculate neutral molecule mole fractions
395  /*!
396  * This routine calculates the neutral molecule mole
397  * fraction given the vector of ion mole fractions,
398  * i.e., the mole fractions from this ThermoPhase.
399  * Note, this routine basically assumes that there
400  * is charge neutrality. If there isn't, then it wouldn't
401  * make much sense.
402  *
403  * for the case of cIonSolnType_SINGLEANION, some slough
404  * in the charge neutrality is allowed. The cation number
405  * is followed, while the difference in charge neutrality
406  * is dumped into the anion mole number to fix the imbalance.
407  *
408  * @param dx input vector of ion mole fraction gradients
409  * @param dy output Vector of neutral molecule mole fraction gradients
410  */
411  void getNeutralMoleculeMoleGrads(const doublereal* const dx, doublereal* const dy) const;
412 
413  //! Get the list of cations in this object
414  /*!
415  * @param cation List of cations
416  */
417  void getCationList(std::vector<size_t>& cation) const {
418  cation=cationList_;
419  }
420 
421  //! Get the list of anions in this object
422  /*!
423  * @param anion List of anions
424  */
425  void getAnionList(std::vector<size_t>& anion) const {
426  anion=anionList_;
427  }
428 
429  /**
430  * @name Setting the State
431  * These methods set all or part of the thermodynamic state.
432  * @{
433  */
434 
435  virtual void setTemperature(const doublereal t);
436  virtual void setPressure(doublereal p);
437 
438  //! Set the temperature (K) and pressure (Pa)
439  /*!
440  * Setting the pressure may involve the solution of a nonlinear equation.
441  *
442  * @param t Temperature (K)
443  * @param p Pressure (Pa)
444  */
445  virtual void setState_TP(doublereal t, doublereal p);
446 
447 
448  //! Calculate ion mole fractions from neutral molecule mole fractions.
449  /*!
450  * @param mf Dump the mole fractions into this vector.
451  */
452  virtual void calcIonMoleFractions(doublereal* const mf) const;
453 
454  //! Calculate neutral molecule mole fractions
455  /*!
456  * This routine calculates the neutral molecule mole
457  * fraction given the vector of ion mole fractions,
458  * i.e., the mole fractions from this ThermoPhase.
459  * Note, this routine basically assumes that there
460  * is charge neutrality. If there isn't, then it wouldn't
461  * make much sense.
462  *
463  * for the case of cIonSolnType_SINGLEANION, some slough
464  * in the charge neutrality is allowed. The cation number
465  * is followed, while the difference in charge neutrality
466  * is dumped into the anion mole number to fix the imbalance.
467  */
468  virtual void calcNeutralMoleculeMoleFractions() const;
469 
470  /**
471  * Set the mass fractions to the specified values, and then
472  * normalize them so that they sum to 1.0.
473  * @param y Array of unnormalized mass fraction values (input).
474  * Must have a length greater than or equal to the number of
475  * species.
476  *
477  * @param y Input vector of mass fractions.
478  * Length is m_kk.
479  */
480  virtual void setMassFractions(const doublereal* const y);
481 
482  /**
483  * Set the mass fractions to the specified values without
484  * normalizing. This is useful when the normalization
485  * condition is being handled by some other means, for example
486  * by a constraint equation as part of a larger set of
487  * equations.
488  *
489  * @param y Input vector of mass fractions.
490  * Length is m_kk.
491  */
492  virtual void setMassFractions_NoNorm(const doublereal* const y);
493 
494  /**
495  * Set the mole fractions to the specified values, and then
496  * normalize them so that they sum to 1.0.
497  * @param x Array of unnormalized mole fraction values (input).
498  * Must have a length greater than or equal to the number of
499  * species.
500  *
501  * @param x Input vector of mole fractions.
502  * Length is m_kk.
503  */
504  virtual void setMoleFractions(const doublereal* const x);
505 
506  /**
507  * Set the mole fractions to the specified values without
508  * normalizing. This is useful when the normalization
509  * condition is being handled by some other means, for example
510  * by a constraint equation as part of a larger set of
511  * equations.
512  *
513  * @param x Input vector of mole fractions.
514  * Length is m_kk.
515  */
516  virtual void setMoleFractions_NoNorm(const doublereal* const x);
517 
518  /**
519  * Set the concentrations to the specified values within the phase.
520  *
521  * @param c The input vector to this routine is in dimensional
522  * units. For volumetric phases c[k] is the
523  * concentration of the kth species in kmol/m3.
524  * For surface phases, c[k] is the concentration
525  * in kmol/m2. The length of the vector is the number
526  * of species in the phase.
527  */
528  virtual void setConcentrations(const doublereal* const c);
529 
530  //@}
531 
532  /*!
533  * @internal Initialize. This method is provided to allow
534  * subclasses to perform any initialization required after all
535  * species have been added. For example, it might be used to
536  * resize internal work arrays that must have an entry for
537  * each species. The base class implementation does nothing,
538  * and subclasses that do not require initialization do not
539  * need to overload this method. When importing a CTML phase
540  * description, this method is called just prior to returning
541  * from function importPhase().
542  */
543  virtual void initThermo();
544 
545  /**
546  * Import and initialize a ThermoPhase object
547  *
548  * @param phaseNode This object must be the phase node of a
549  * complete XML tree
550  * description of the phase, including all of the
551  * species data. In other words while "phase" must
552  * point to an XML phase object, it must have
553  * sibling nodes "speciesData" that describe
554  * the species in the phase.
555  * @param id ID of the phase. If nonnull, a check is done
556  * to see if phaseNode is pointing to the phase
557  * with the correct id.
558  */
559  void initThermoXML(XML_Node& phaseNode, const std::string& id);
560 
561 
562 private:
563  //! Initialize lengths of local variables after all species have
564  //! been identified.
565  void initLengths();
566 
567  //! Update the activity coefficients
568  /*!
569  * This function will be called to update the internally stored
570  * natural logarithm of the activity coefficients
571  */
572  void s_update_lnActCoeff() const;
573 
574  //! Update the temperature derivative of the ln activity coefficients
575  /*!
576  * This function will be called to update the internally stored
577  * temperature derivative of the natural logarithm of the activity coefficients
578  */
579  void s_update_dlnActCoeffdT() const;
580 
581  //! Update the change in the ln activity coefficients
582  /*!
583  * This function will be called to update the internally stored
584  * change of the natural logarithm of the activity coefficients
585  * w.r.t a change in state (temp, mole fraction, etc)
586  */
587  void s_update_dlnActCoeff() const;
588 
589  //! Update the derivative of the log of the activity coefficients
590  //! wrt log(mole fraction)
591  /*!
592  * This function will be called to update the internally stored
593  * derivative of the natural logarithm of the activity coefficients
594  * wrt logarithm of the mole fractions.
595  */
596  void s_update_dlnActCoeff_dlnX_diag() const;
597 
598  //! Update the derivative of the log of the activity coefficients
599  //! wrt log(number of moles) - diagonal components
600  /*!
601  * This function will be called to update the internally stored
602  * derivative of the natural logarithm of the activity coefficients
603  * wrt logarithm of the number of moles of given species.
604  */
605  void s_update_dlnActCoeff_dlnN_diag() const;
606 
607  //! Update the derivative of the log of the activity coefficients
608  //! wrt log(number of moles) - diagonal components
609  /*!
610  * This function will be called to update the internally stored
611  * derivative of the natural logarithm of the activity coefficients
612  * wrt logarithm of the number of moles of given species.
613  */
614  void s_update_dlnActCoeff_dlnN() const;
615 
616 protected:
617  //! Ion solution type
618  /*!
619  * There is either mixing on the anion, cation, or both lattices.
620  * There is also a passthrough option
621  *
622  * Defaults to cIonSolnType_SINGLEANION, so that LiKCl can be hardwired
623  */
625 
626  //! Number of neutral molecule species
627  /*!
628  * This is equal to the number of species in the
629  * neutralMoleculePhase_ ThermoPhase.
630  */
632 
633  //! Index of special species
635 
636  //! Index of special species
638 
639  //! Formula Matrix for composition of neutral molecules
640  //! in terms of the molecules in this ThermoPhase
641  /*!
642  * fm_neutralMolec_ions[ i + jNeut * m_kk ]
643  *
644  * This is the number of ions of type i in the neutral
645  * molecule jNeut.
646  */
647  std::vector<double> fm_neutralMolec_ions_;
648 
649  //! Mapping between ion species and neutral molecule for quick invert.
650  /*!
651  * fm_invert_ionForNeutral returns vector of int. Each element represents
652  * an ionic species and stores the value of the corresponding neutral
653  * molecule
654  *
655  * For the case of fm_invert_simple_ = true, we assume that there
656  * is a quick way to invert the formula matrix so that we can
657  * quickly calculate the neutral molecule mole fraction
658  * given the ion mole fraction vector.
659  *
660  * We assume that for a selected set of ion species, that that
661  * ion is only in the neutral molecule, jNeut.
662  *
663  * therefore,
664  *
665  * NeutralMolecMoleFractions_[jNeut] += moleFractions_[i_ion] / fmij;
666  *
667  * where fmij is the number of ions in neutral molecule jNeut.
668  *
669  * Thus, we formulate the neutral molecule mole fraction NeutralMolecMoleFractions_[]
670  * vector from this association. We further assume that there are
671  * no other associations. If fm_invert_simple_ is not true,
672  * then we need to do a formal inversion which takes a great
673  * deal of time and is not currently implemented.
674  */
675  std::vector<size_t> fm_invert_ionForNeutral;
676 
677  //! Mole fractions using the Neutral Molecule Mole fraction basis
678  mutable std::vector<doublereal> NeutralMolecMoleFractions_;
679 
680  //! List of the species in this ThermoPhase which are cation species
681  std::vector<size_t> cationList_;
682 
683  //! List of the species in this ThermoPhase which are anion species
684  std::vector<size_t> anionList_;
685 
686  //! List of the species in this ThermoPhase which are passed
687  //! through to the neutralMoleculePhase ThermoPhase.
688  /*!
689  * These have neutral charges.
690  */
691  std::vector<size_t> passThroughList_;
692 
693 public:
694  //! This is a pointer to the neutral Molecule Phase
695  /*!
696  * If the variable, IOwnNThermoPhase_ is true, then we own
697  * the pointer. If not, then this is considered a shallow pointer.
698  */
700 
701 private:
702  GibbsExcessVPSSTP* geThermo;
703  // Temporary vectors that I don't want to allocate every time the function is called
704  mutable vector_fp y_;
705  mutable vector_fp dlnActCoeff_NeutralMolecule_;
706  mutable vector_fp dX_NeutralMolecule_;
707 
708  //! If true then we own the underlying neutral Molecule Phase
709  /*!
710  * If this is false, then the neutral molecule phase is considered
711  * as a shallow pointer.
712  */
714 
715  //! Temporary mole fraction vector
716  mutable std::vector<doublereal> moleFractionsTmp_;
717 
718  //! Storage vector for the neutral molecule chemical potentials
719  /*!
720  * This vector is used as a temporary storage area when calculating the ion chemical
721  * potentials.
722  *
723  * - Units = Joules/kmol
724  * - Length = numNeutralMoleculeSpecies_
725  */
726  mutable std::vector<doublereal> muNeutralMolecule_;
727 
728  //! Storage vector for the neutral molecule ln activity coefficients
729  /*!
730  * This vector is used as a temporary storage area when calculating the ion chemical
731  * potentials and activity coefficients
732  *
733  * - Units = none
734  * - Length = numNeutralMoleculeSpecies_
735  */
736  mutable std::vector<doublereal> lnActCoeff_NeutralMolecule_;
737 
738  //! Storage vector for the neutral molecule d ln activity coefficients dT
739  /*!
740  * This vector is used as a temporary storage area when calculating the ion derivatives
741  *
742  * - Units = 1/Kelvin
743  * - Length = numNeutralMoleculeSpecies_
744  */
745  mutable std::vector<doublereal> dlnActCoeffdT_NeutralMolecule_;
746 
747  //! Storage vector for the neutral molecule d ln activity coefficients dX - diagonal component
748  /*!
749  * This vector is used as a temporary storage area when calculating the ion derivatives
750  *
751  * - Units = none
752  * - Length = numNeutralMoleculeSpecies_
753  */
754  mutable std::vector<doublereal> dlnActCoeffdlnX_diag_NeutralMolecule_;
755 
756  //! Storage vector for the neutral molecule d ln activity coefficients dlnN - diagonal component
757  /*!
758  * This vector is used as a temporary storage area when calculating the ion derivatives
759  *
760  * - Units = none
761  * - Length = numNeutralMoleculeSpecies_
762  */
763  mutable std::vector<doublereal> dlnActCoeffdlnN_diag_NeutralMolecule_;
764 
765  //! Storage vector for the neutral molecule d ln activity coefficients dlnN
766  /*!
767  * This vector is used as a temporary storage area when calculating the ion derivatives
768  *
769  * - Units = none
770  * - Length = numNeutralMoleculeSpecies_
771  */
773 };
774 
775 }
776 
777 #endif
virtual void setMassFractions(const doublereal *const y)
Set the mass fractions to the specified values, and then normalize them so that they sum to 1...
virtual ~IonsFromNeutralVPSSTP()
Destructor.
void s_update_dlnActCoeff() const
Update the change in the ln activity coefficients.
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
virtual void setConcentrations(const doublereal *const c)
Set the concentrations to the specified values within the phase.
virtual void setState_TP(doublereal t, doublereal p)
Set the temperature (K) and pressure (Pa)
void getNeutralMolecMoleFractions(vector_fp &neutralMoleculeMoleFractions) const
Return the current value of the neutral mole fraction vector.
IonsFromNeutralVPSSTP & operator=(const IonsFromNeutralVPSSTP &b)
Assignment operator.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
std::vector< double > fm_neutralMolec_ions_
Formula Matrix for composition of neutral molecules in terms of the molecules in this ThermoPhase...
size_t indexSpecialSpecies_
Index of special species.
virtual void calcNeutralMoleculeMoleFractions() const
Calculate neutral molecule mole fractions.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
virtual void calcIonMoleFractions(doublereal *const mf) const
Calculate ion mole fractions from neutral molecule mole fractions.
void constructPhaseFile(std::string inputFile, std::string id)
The following methods are used in the process of constructing the phase and setting its parameters fr...
void s_update_dlnActCoeff_dlnN_diag() const
Update the derivative of the log of the activity coefficients wrt log(number of moles) - diagonal com...
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
bool IOwnNThermoPhase_
If true then we own the underlying neutral Molecule Phase.
void getDissociationCoeffs(vector_fp &fm_neutralMolec_ions, vector_fp &charges, std::vector< size_t > &neutMolIndex) const
Get the Salt Dissociation Coefficients Returns the vector of dissociation coefficients and vector of ...
void constructPhaseXML(XML_Node &phaseNode, std::string id)
Import and initialize an IonsFromNeutralVPSSTP phase specification in an XML tree into the current ob...
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition: Array.h:29
virtual int eosType() const
Equation of state type flag.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of log concentration-like derivatives of the log activity coefficients - diagonal compo...
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
virtual doublereal enthalpy_mole() const
Return the Molar enthalpy. Units: J/kmol.
virtual void setTemperature(const doublereal t)
Set the temperature of the phase.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
void getCationList(std::vector< size_t > &cation) const
Get the list of cations in this object.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies for the species in the mixture.
IonSolnType_enumType ionSolnType_
Ion solution type.
virtual void getdlnActCoeffdlnN(const size_t ld, doublereal *const dlnActCoeffdlnN)
Get the array of derivatives of the ln activity coefficients with respect to the ln species mole numb...
Array2D dlnActCoeffdlnN_NeutralMolecule_
Storage vector for the neutral molecule d ln activity coefficients dlnN.
Header for intermediate ThermoPhase object for phases which employ Gibbs excess free energy based for...
std::vector< doublereal > dlnActCoeffdT_NeutralMolecule_
Storage vector for the neutral molecule d ln activity coefficients dT.
void initLengths()
Initialize lengths of local variables after all species have been identified.
virtual void setMoleFractions(const doublereal *const x)
Set the mole fractions to the specified values, and then normalize them so that they sum to 1...
std::vector< doublereal > muNeutralMolecule_
Storage vector for the neutral molecule chemical potentials.
void s_update_dlnActCoeffdT() const
Update the temperature derivative of the ln activity coefficients.
void s_update_dlnActCoeff_dlnX_diag() const
Update the derivative of the log of the activity coefficients wrt log(mole fraction) ...
std::vector< size_t > anionList_
List of the species in this ThermoPhase which are anion species.
std::vector< size_t > passThroughList_
List of the species in this ThermoPhase which are passed through to the neutralMoleculePhase ThermoPh...
void s_update_dlnActCoeff_dlnN() const
Update the derivative of the log of the activity coefficients wrt log(number of moles) - diagonal com...
std::vector< doublereal > lnActCoeff_NeutralMolecule_
Storage vector for the neutral molecule ln activity coefficients.
void getNeutralMoleculeMoleGrads(const doublereal *const dx, doublereal *const dy) const
Calculate neutral molecule mole fractions.
void getAnionList(std::vector< size_t > &anion) const
Get the list of anions in this object.
virtual void getdlnActCoeffdlnX_diag(doublereal *dlnActCoeffdlnX_diag) const
Get the array of log concentration-like derivatives of the log activity coefficients - diagonal compo...
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:157
std::vector< size_t > fm_invert_ionForNeutral
Mapping between ion species and neutral molecule for quick invert.
virtual void setMoleFractions_NoNorm(const doublereal *const x)
Set the mole fractions to the specified values without normalizing.
std::vector< doublereal > dlnActCoeffdlnN_diag_NeutralMolecule_
Storage vector for the neutral molecule d ln activity coefficients dlnN - diagonal component...
std::vector< size_t > cationList_
List of the species in this ThermoPhase which are cation species.
virtual doublereal gibbs_mole() const
Molar Gibbs free Energy for an ideal gas. Units = J/kmol.
void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object.
std::vector< doublereal > dlnActCoeffdlnX_diag_NeutralMolecule_
Storage vector for the neutral molecule d ln activity coefficients dX - diagonal component.
virtual void getdlnActCoeffds(const doublereal dTds, const doublereal *const dXds, doublereal *dlnActCoeffds) const
Get the change in activity coefficients w.r.t.
std::vector< doublereal > NeutralMolecMoleFractions_
Mole fractions using the Neutral Molecule Mole fraction basis.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual void setMassFractions_NoNorm(const doublereal *const y)
Set the mass fractions to the specified values without normalizing.
size_t indexSecondSpecialSpecies_
Index of special species.
size_t numNeutralMoleculeSpecies_
Number of neutral molecule species.
ThermoPhase * neutralMoleculePhase_
This is a pointer to the neutral Molecule Phase.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
void s_update_lnActCoeff() const
Update the activity coefficients.
std::vector< doublereal > moleFractionsTmp_
Temporary mole fraction vector.
IonSolnType_enumType
enums for molten salt ion solution types
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.