Cantera  2.1.2
RedlichKwongMFTP.h
Go to the documentation of this file.
1 /**
2  * @file RedlichKwongMFTP.h
3  * Definition file for a derived class of ThermoPhase that assumes either
4  * an ideal gas or ideal solution approximation and handles
5  * variable pressure standard state methods for calculating
6  * thermodynamic properties (see \ref thermoprops and
7  * class \link Cantera::RedlichKwongMFTP RedlichKwongMFTP\endlink).
8  */
9 /*
10  * Copyright (2005) Sandia Corporation. Under the terms of
11  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
12  * U.S. Government retains certain rights in this software.
13  */
14 
15 #ifndef CT_REDLICHKWONGMFTP_H
16 #define CT_REDLICHKWONGMFTP_H
17 
18 #include "MixtureFugacityTP.h"
19 
20 namespace Cantera
21 {
22 
23 class XML_Node;
24 
25 /**
26  * @ingroup thermoprops
27  *
28  * This class can handle either an ideal solution or an ideal gas approximation
29  * of a phase.
30  *
31  * @nosubgrouping
32  */
34 {
35 public:
36  //! @name Constructors and Duplicators
37  //! @{
38 
39  //! Base constructor.
41 
42  //! Construct and initialize a RedlichKwongMFTP object directly from an
43  //! ASCII input file
44  /*!
45  * @param infile Name of the input file containing the phase XML data
46  * to set up the object
47  * @param id ID of the phase in the input file. Defaults to the empty string.
48  */
49  RedlichKwongMFTP(const std::string& infile, std::string id="");
50 
51  //! Construct and initialize a RedlichKwongMFTP object directly from an
52  //! XML database
53  /*!
54  * @param phaseRef XML phase node containing the description of the phase
55  * @param id id attribute containing the name of the phase. (default is the empty string)
56  */
57  RedlichKwongMFTP(XML_Node& phaseRef, const std::string& id = "");
58 
59  //! This is a special constructor, used to replicate test problems
60  //! during the initial verification of the object
61  /*!
62  * test problems:
63  * 1: Pure CO2 problem
64  * input file = CO2_RedlickKwongMFTP.xml
65  *
66  * @param testProb Hard -coded test problem to instantiate.
67  * Current valid values are 1.
68  * @deprecated To be refactored into a standalone test
69  */
70  RedlichKwongMFTP(int testProb);
71 
72  //! Copy Constructor
73  /*!
74  * Copy constructor for the object. Constructed object will be a clone of this object, but will
75  * also own all of its data. This is a wrapper around the assignment operator
76  *
77  * @param right Object to be copied.
78  */
79  RedlichKwongMFTP(const RedlichKwongMFTP& right);
80 
81  //! Assignment operator
82  /*!
83  * Assignment operator for the object. Constructed object will be a clone of this object, but will
84  * also own all of its data.
85  *
86  * @param right Object to be copied.
87  */
89 
90  //! Duplicator from the ThermoPhase parent class
91  /*!
92  * Given a pointer to a ThermoPhase object, this function will
93  * duplicate the ThermoPhase object and all underlying structures.
94  * This is basically a wrapper around the copy constructor.
95  *
96  * @return returns a pointer to a ThermoPhase
97  */
98  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
99 
100  /**
101  * Equation of state type flag. The base class returns
102  * zero. Subclasses should define this to return a unique
103  * non-zero value. Constants defined for this purpose are
104  * listed in mix_defs.h.
105  */
106  virtual int eosType() const;
107 
108  //! @name Molar Thermodynamic properties
109  //! @{
110 
111  /// Molar enthalpy. Units: J/kmol.
112  virtual doublereal enthalpy_mole() const;
113 
114  /// Molar internal energy. Units: J/kmol.
115  virtual doublereal intEnergy_mole() const;
116 
117  /// Molar entropy. Units: J/kmol/K.
118  virtual doublereal entropy_mole() const;
119 
120  /// Molar Gibbs function. Units: J/kmol.
121  virtual doublereal gibbs_mole() const;
122 
123  /// Molar heat capacity at constant pressure. Units: J/kmol/K.
124  virtual doublereal cp_mole() const;
125 
126  /// Molar heat capacity at constant volume. Units: J/kmol/K.
127  virtual doublereal cv_mole() const;
128 
129  //! @}
130  //! @name Mechanical Properties
131  //! @{
132 
133  //! Return the thermodynamic pressure (Pa).
134  /*!
135  * Since the mass density, temperature, and mass fractions are stored,
136  * this method uses these values to implement the
137  * mechanical equation of state \f$ P(T, \rho, Y_1, \dots, Y_K) \f$.
138  *
139  * \f[
140  * P = \frac{RT}{v-b_{mix}} - \frac{a_{mix}}{T^{0.5} v \left( v + b_{mix} \right) }
141  * \f]
142  */
143  virtual doublereal pressure() const;
144 
145  //! Returns the isothermal compressibility. Units: 1/Pa.
146  /*!
147  * The isothermal compressibility is defined as
148  * \f[
149  * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
150  * \f]
151  */
152  virtual doublereal isothermalCompressibility() const;
153  // @}
154 
155 protected:
156  /**
157  * Calculate the density of the mixture using the partial
158  * molar volumes and mole fractions as input
159  *
160  * The formula for this is
161  *
162  * \f[
163  * \rho = \frac{\sum_k{X_k W_k}}{\sum_k{X_k V_k}}
164  * \f]
165  *
166  * where \f$X_k\f$ are the mole fractions, \f$W_k\f$ are
167  * the molecular weights, and \f$V_k\f$ are the pure species
168  * molar volumes.
169  *
170  * Note, the basis behind this formula is that in an ideal
171  * solution the partial molar volumes are equal to the
172  * species standard state molar volumes.
173  * The species molar volumes may be functions
174  * of temperature and pressure.
175  */
176  virtual void calcDensity();
177 
178 protected:
179  //! Set the temperature (K)
180  /*!
181  * Overwritten setTemperature(double) from State.h. This
182  * function sets the temperature, and makes sure that
183  * the value propagates to underlying objects
184  *
185  * @param temp Temperature in kelvin
186  */
187  virtual void setTemperature(const doublereal temp);
188 
189  //! Set the mass fractions to the specified values, and then
190  //! normalize them so that they sum to 1.0.
191  /*!
192  * @param y Array of unnormalized mass fraction values (input).
193  * Must have a length greater than or equal to the number of species.
194  */
195  virtual void setMassFractions(const doublereal* const y);
196 
197  //!Set the mass fractions to the specified values without normalizing.
198  /*!
199  * This is useful when the normalization
200  * condition is being handled by some other means, for example
201  * by a constraint equation as part of a larger set of
202  * equations.
203  *
204  * @param y Input vector of mass fractions. Length is m_kk.
205  */
206  virtual void setMassFractions_NoNorm(const doublereal* const y);
207 
208  //! Set the mole fractions to the specified values, and then
209  //! normalize them so that they sum to 1.0.
210  /*!
211  * @param x Array of unnormalized mole fraction values (input).
212  * Must have a length greater than or equal to the number of species.
213  */
214  virtual void setMoleFractions(const doublereal* const x);
215 
216  //! Set the mole fractions to the specified values without normalizing.
217  /*!
218  * This is useful when the normalization
219  * condition is being handled by some other means, for example
220  * by a constraint equation as part of a larger set ofequations.
221  *
222  * @param x Input vector of mole fractions. Length is m_kk.
223  */
224  virtual void setMoleFractions_NoNorm(const doublereal* const x);
225 
226  //! Set the concentrations to the specified values within the phase.
227  /*!
228  * @param c The input vector to this routine is in dimensional
229  * units. For volumetric phases c[k] is the
230  * concentration of the kth species in kmol/m3.
231  * For surface phases, c[k] is the concentration
232  * in kmol/m2. The length of the vector is the number
233  * of species in the phase.
234  */
235  virtual void setConcentrations(const doublereal* const c);
236 
237 public:
238  //! This method returns an array of generalized concentrations
239  /*!
240  * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k /
241  * C^0_k, \f$ where \f$ C^0_k \f$ is a standard concentration
242  * defined below and \f$ a_k \f$ are activities used in the
243  * thermodynamic functions. These activity (or generalized)
244  * concentrations are used
245  * by kinetics manager classes to compute the forward and
246  * reverse rates of elementary reactions. Note that they may
247  * or may not have units of concentration --- they might be
248  * partial pressures, mole fractions, or surface coverages,
249  * for example.
250  *
251  * @param c Output array of generalized concentrations. The
252  * units depend upon the implementation of the
253  * reaction rate expressions within the phase.
254  */
255  virtual void getActivityConcentrations(doublereal* c) const;
256 
257  //! Returns the standard concentration \f$ C^0_k \f$, which is used to normalize
258  //! the generalized concentration.
259  /*!
260  * This is defined as the concentration by which the generalized
261  * concentration is normalized to produce the activity.
262  * In many cases, this quantity will be the same for all species in a phase.
263  * Since the activity for an ideal gas mixture is
264  * simply the mole fraction, for an ideal gas \f$ C^0_k = P/\hat R T \f$.
265  *
266  * @param k Optional parameter indicating the species. The default
267  * is to assume this refers to species 0.
268  * @return
269  * Returns the standard Concentration in units of m3 kmol-1.
270  */
271  virtual doublereal standardConcentration(size_t k=0) const;
272 
273  //! Returns the natural logarithm of the standard
274  //! concentration of the kth species
275  /*!
276  * @param k index of the species. (defaults to zero)
277  */
278  virtual doublereal logStandardConc(size_t k=0) const;
279 
280  //! Returns the units of the standard and generalized concentrations.
281  /*!
282  * Note they have the same units, as their
283  * ratio is defined to be equal to the activity of the kth
284  * species in the solution, which is unitless.
285  *
286  * This routine is used in print out applications where the
287  * units are needed. Usually, MKS units are assumed throughout
288  * the program and in the XML input files.
289  *
290  * The base %ThermoPhase class assigns the default quantities
291  * of (kmol/m3) for all species.
292  * Inherited classes are responsible for overriding the default
293  * values if necessary.
294  *
295  * @param uA Output vector containing the units:
296  *
297  * uA[0] = kmol units - default = 1
298  * uA[1] = m units - default = -nDim(), the number of spatial
299  * dimensions in the Phase class.
300  * uA[2] = kg units - default = 0;
301  * uA[3] = Pa(pressure) units - default = 0;
302  * uA[4] = Temperature units - default = 0;
303  * uA[5] = time units - default = 0
304  *
305  * @param k species index. Defaults to 0.
306  * @param sizeUA output int containing the size of the vector.
307  * Currently, this is equal to 6.
308  * @deprecated
309  */
310  virtual void getUnitsStandardConc(double* uA, int k = 0, int sizeUA = 6) const;
311 
312  //! Get the array of non-dimensional activity coefficients at
313  //! the current solution temperature, pressure, and solution concentration.
314  /*!
315  * For all objects with the Mixture Fugacity approximation, we define the
316  * standard state as an ideal gas at the current temperature and pressure
317  * of the solution. The activities are based on this standard state.
318  *
319  * @param ac Output vector of activity coefficients. Length: m_kk.
320  */
321  virtual void getActivityCoefficients(doublereal* ac) const;
322 
323  /// @name Partial Molar Properties of the Solution
324  //@{
325 
326  //! Get the array of non-dimensional species chemical potentials.
327  //! These are partial molar Gibbs free energies.
328  /*!
329  * \f$ \mu_k / \hat R T \f$.
330  * Units: unitless
331  *
332  * We close the loop on this function, here, calling
333  * getChemPotentials() and then dividing by RT. No need for child
334  * classes to handle.
335  *
336  * @param mu Output vector of non-dimensional species chemical potentials
337  * Length: m_kk.
338  */
339  void getChemPotentials_RT(doublereal* mu) const;
340 
341  //! Get the species chemical potentials. Units: J/kmol.
342  /*!
343  * This function returns a vector of chemical potentials of the
344  * species in solution at the current temperature, pressure
345  * and mole fraction of the solution.
346  *
347  * @param mu Output vector of species chemical
348  * potentials. Length: m_kk. Units: J/kmol
349  */
350  virtual void getChemPotentials(doublereal* mu) const;
351 
352  //! Get the species partial molar enthalpies. Units: J/kmol.
353  /*!
354  * @param hbar Output vector of species partial molar enthalpies.
355  * Length: m_kk. units are J/kmol.
356  */
357  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
358 
359  //! Get the species partial molar entropies. Units: J/kmol/K.
360  /*!
361  * @param sbar Output vector of species partial molar entropies.
362  * Length = m_kk. units are J/kmol/K.
363  */
364  virtual void getPartialMolarEntropies(doublereal* sbar) const;
365 
366  //! Get the species partial molar enthalpies. Units: J/kmol.
367  /*!
368  * @param ubar Output vector of species partial molar internal energies.
369  * Length = m_kk. units are J/kmol.
370  */
371  virtual void getPartialMolarIntEnergies(doublereal* ubar) const;
372 
373  //! Get the partial molar heat capacities Units: J/kmol/K
374  /*!
375  * @param cpbar Output vector of species partial molar heat capacities
376  * at constant pressure.
377  * Length = m_kk. units are J/kmol/K.
378  */
379  virtual void getPartialMolarCp(doublereal* cpbar) const;
380 
381  //! Get the species partial molar volumes. Units: m^3/kmol.
382  /*!
383  * @param vbar Output vector of species partial molar volumes.
384  * Length = m_kk. units are m^3/kmol.
385  */
386  virtual void getPartialMolarVolumes(doublereal* vbar) const;
387 
388  //@}
389  /// @name Critical State Properties.
390  /// These methods are only implemented by some subclasses, and may
391  /// be moved out of ThermoPhase at a later date.
392  //@{
393 
394  /// Critical temperature (K).
395  virtual doublereal critTemperature() const;
396 
397  /// Critical pressure (Pa).
398  virtual doublereal critPressure() const;
399 
400  /// Critical density (kg/m3).
401  virtual doublereal critDensity() const;
402 
403 public:
404 
405  //@}
406  //! @name Initialization Methods - For Internal use
407  /*!
408  * The following methods are used in the process of constructing
409  * the phase and setting its parameters from a specification in an
410  * input file. They are not normally used in application programs.
411  * To see how they are used, see files importCTML.cpp and
412  * ThermoFactory.cpp.
413  */
414  //@{
415 
416  //! Set equation of state parameter values from XML entries.
417  /*!
418  * This method is called by function importPhase in
419  * file importCTML.cpp when processing a phase definition in
420  * an input file. It should be overloaded in subclasses to set
421  * any parameters that are specific to that particular phase
422  * model.
423  *
424  * @param thermoNode An XML_Node object corresponding to
425  * the "thermo" entry for this phase in the input file.
426  */
427  virtual void setParametersFromXML(const XML_Node& thermoNode);
428 
429  //! @internal Initialize the object
430  /*!
431  * This method is provided to allow
432  * subclasses to perform any initialization required after all
433  * species have been added. For example, it might be used to
434  * resize internal work arrays that must have an entry for
435  * each species. The base class implementation does nothing,
436  * and subclasses that do not require initialization do not
437  * need to overload this method. When importing a CTML phase
438  * description, this method is called just prior to returning
439  * from function importPhase().
440  *
441  * @see importCTML.cpp
442  */
443  virtual void initThermo();
444 
445  //!This method is used by the ChemEquil equilibrium solver.
446  /*!
447  * It sets the state such that the chemical potentials satisfy
448  * \f[ \frac{\mu_k}{\hat R T} = \sum_m A_{k,m}
449  * \left(\frac{\lambda_m} {\hat R T}\right) \f] where
450  * \f$ \lambda_m \f$ is the element potential of element m. The
451  * temperature is unchanged. Any phase (ideal or not) that
452  * implements this method can be equilibrated by ChemEquil.
453  *
454  * @param lambda_RT Input vector of dimensionless element potentials
455  * The length is equal to nElements().
456  */
457  void setToEquilState(const doublereal* lambda_RT);
458 
459  //! Initialize a ThermoPhase object, potentially reading activity
460  //! coefficient information from an XML database.
461  /*!
462  *
463  * This routine initializes the lengths in the current object and
464  * then calls the parent routine.
465  * This method is provided to allow
466  * subclasses to perform any initialization required after all
467  * species have been added. For example, it might be used to
468  * resize internal work arrays that must have an entry for
469  * each species. The base class implementation does nothing,
470  * and subclasses that do not require initialization do not
471  * need to overload this method. When importing a CTML phase
472  * description, this method is called just prior to returning
473  * from function importPhase().
474  *
475  * @param phaseNode This object must be the phase node of a
476  * complete XML tree
477  * description of the phase, including all of the
478  * species data. In other words while "phase" must
479  * point to an XML phase object, it must have
480  * sibling nodes "speciesData" that describe
481  * the species in the phase.
482  * @param id ID of the phase. If nonnull, a check is done
483  * to see if phaseNode is pointing to the phase
484  * with the correct id.
485  */
486  virtual void initThermoXML(XML_Node& phaseNode, const std::string& id);
487 
488 private:
489  //! Read the pure species RedlichKwong input parameters
490  /*!
491  * @param pureFluidParam XML_Node for the pure fluid parameters
492  */
493  void readXMLPureFluid(XML_Node& pureFluidParam);
494 
495  //! Apply mixing rules for a coefficients
497 
498  //! Read the cross species RedlichKwong input parameters
499  /*!
500  * @param pureFluidParam XML_Node for the cross fluid parameters
501  */
502  void readXMLCrossFluid(XML_Node& pureFluidParam);
503 
504 private:
505  //! @internal Initialize the internal lengths in this object.
506  /*!
507  * Note this is not a virtual function and only handles this object
508  */
509  void initLengths();
510  // @}
511 
512 protected:
513  // Special functions inherited from MixtureFugacityTP
514 
515  //! Calculate the deviation terms for the total entropy of the mixture from the
516  //! ideal gas mixture
517  /*!
518  * Here we use the current state conditions
519  *
520  * @return Returns the change in entropy in units of J kmol-1 K-1.
521  */
522  virtual doublereal sresid() const;
523 
524  // Calculate the deviation terms for the total enthalpy of the mixture from the
525  // ideal gas mixture
526  /*
527  * Here we use the current state conditions
528  *
529  * @return Returns the change in enthalpy in units of J kmol-1.
530  */
531  virtual doublereal hresid() const;
532 public:
533  //! Estimate for the molar volume of the liquid
534  /*!
535  * Note: this is only used as a starting guess for later routines that actually calculate an
536  * accurate value for the liquid molar volume.
537  * This routine doesn't change the state of the system.
538  *
539  * @param TKelvin temperature in kelvin
540  * @param pres Pressure in Pa. This is used as an initial guess. If the routine
541  * needs to change the pressure to find a stable liquid state, the
542  * new pressure is returned in this variable.
543  *
544  * @return Returns the estimate of the liquid volume.
545  */
546  virtual doublereal liquidVolEst(doublereal TKelvin, doublereal& pres) const;
547 
548 public:
549  //! Calculates the density given the temperature and the pressure and a guess at the density.
550  /*!
551  * Note, below T_c, this is a multivalued function. We do not cross the vapor dome in this.
552  * This is protected because it is called during setState_TP() routines. Infinite loops would result
553  * if it were not protected.
554  *
555  * -> why is this not const?
556  *
557  * parameters:
558  * @param TKelvin Temperature in Kelvin
559  * @param pressure Pressure in Pascals (Newton/m**2)
560  * @param phase int representing the phase whose density we are requesting. If we put
561  * a gas or liquid phase here, we will attempt to find a volume in that
562  * part of the volume space, only, in this routine. A value of FLUID_UNDEFINED
563  * means that we will accept anything.
564  *
565  * @param rhoguess Guessed density of the fluid. A value of -1.0 indicates that there
566  * is no guessed density
567  *
568  *
569  * @return We return the density of the fluid at the requested phase. If we have not found any
570  * acceptable density we return a -1. If we have found an acceptable density at a
571  * different phase, we return a -2.
572  */
573  virtual doublereal densityCalc(doublereal TKelvin, doublereal pressure, int phase, doublereal rhoguess);
574 
575  //! Return the value of the density at the liquid spinodal point (on the liquid side)
576  //! for the current temperature.
577  /*!
578  * @return returns the density with units of kg m-3
579  */
580  virtual doublereal densSpinodalLiquid() const;
581 
582  //! Return the value of the density at the gas spinodal point (on the gas side)
583  //! for the current temperature.
584  /*!
585  * @return returns the density with units of kg m-3
586  */
587  virtual doublereal densSpinodalGas() const;
588 
589  //! Calculate the pressure given the temperature and the molar volume
590  /*!
591  * Calculate the pressure given the temperature and the molar volume
592  *
593  * @param TKelvin temperature in kelvin
594  * @param molarVol molar volume ( m3/kmol)
595  *
596  * @return Returns the pressure.
597  */
598  virtual doublereal pressureCalc(doublereal TKelvin, doublereal molarVol) const;
599 
600  //! Calculate the pressure and the pressure derivative given the temperature and the molar volume
601  /*!
602  * Temperature and mole number are held constant
603  *
604  * @param TKelvin temperature in kelvin
605  * @param molarVol molar volume ( m3/kmol)
606  *
607  * @param presCalc Returns the pressure.
608  *
609  * @return Returns the derivative of the pressure wrt the molar volume
610  */
611  virtual doublereal dpdVCalc(doublereal TKelvin, doublereal molarVol, doublereal& presCalc) const;
612 
613  //! Calculate dpdV and dpdT at the current conditions
614  /*!
615  * These are stored internally.
616  */
617  void pressureDerivatives() const;
618 
619  virtual void updateMixingExpressions();
620 
621  //! Update the a and b parameters
622  /*!
623  * The a and the b parameters depend on the mole fraction and the temperature.
624  * This function updates the internal numbers based on the state of the object.
625  */
626  void updateAB();
627 
628  //! Calculate the a and the b parameters given the temperature
629  /*!
630  * This function doesn't change the internal state of the object, so it is a const
631  * function. It does use the stored mole fractions in the object.
632  *
633  * @param temp Temperature (TKelvin)
634  *
635  * @param aCalc (output) Returns the a value
636  * @param bCalc (output) Returns the b value.
637  */
638  void calculateAB(doublereal temp, doublereal& aCalc, doublereal& bCalc) const;
639 
640  // Special functions not inherited from MixtureFugacityTP
641 
642  doublereal da_dt() const;
643 
644  void calcCriticalConditions(doublereal a, doublereal b, doublereal a0_coeff, doublereal aT_coeff,
645  doublereal& pc, doublereal& tc, doublereal& vc) const;
646 
647  //! Solve the cubic equation of state
648  /*!
649  * The R-K equation of state may be solved via the following formula:
650  *
651  * V**3 - V**2(RT/P) - V(RTb/P - a/(P T**.5) + b*b) - (a b / (P T**.5)) = 0
652  *
653  * Returns the number of solutions found. If it only finds the liquid
654  * branch solution, it will return a -1 or a -2 instead of 1 or 2. If it
655  * returns 0, then there is an error.
656  */
657  int NicholsSolve(double TKelvin, double pres, doublereal a, doublereal b,
658  doublereal Vroot[3]) const;
659 
660 protected:
661  //! boolean indicating whether standard mixing rules are applied
662  /*!
663  * - 1 = Yes, there are standard cross terms in the a coefficient matrices.
664  * - 0 = No, there are nonstandard cross terms in the a coefficient matrices.
665  */
667 
668  //! Form of the temperature parameterization
669  /*!
670  * - 0 = There is no temperature parameterization of a or b
671  * - 1 = The a_ij parameter is a linear function of the temperature
672  */
674 
675  //! Value of b in the equation of state
676  /*!
677  * m_b is a function of the temperature and the mole fraction.
678  */
679  doublereal m_b_current;
680 
681  //! Value of a in the equation of state
682  /*!
683  * a_b is a function of the temperature and the mole fraction.
684  */
685  doublereal m_a_current;
686 
687  vector_fp a_vec_Curr_;
688  vector_fp b_vec_Curr_;
689 
690  Array2D a_coeff_vec;
691 
692  vector_fp m_pc_Species;
693  vector_fp m_tc_Species;
694  vector_fp m_vc_Species;
695 
696  int NSolns_;
697 
698  doublereal Vroot_[3];
699 
700  //! Temporary storage - length = m_kk.
701  mutable vector_fp m_pp;
702 
703  //! Temporary storage - length = m_kk.
704  mutable vector_fp m_tmpV;
705 
706  // mutable vector_fp m_tmpV2;
707 
708  // Partial molar volumes of the species
709  mutable vector_fp m_partialMolarVolumes;
710 
711  //! The derivative of the pressure wrt the volume
712  /*!
713  * Calculated at the current conditions
714  * temperature and mole number kept constant
715  */
716  mutable doublereal dpdV_;
717 
718  //! The derivative of the pressure wrt the temperature
719  /*!
720  * Calculated at the current conditions
721  * Total volume and mole number kept constant
722  */
723  mutable doublereal dpdT_;
724 
725  //! Vector of derivatives of pressure wrt mole number
726  /*!
727  * Calculated at the current conditions
728  * Total volume, temperature and other mole number kept constant
729  */
730  mutable vector_fp dpdni_;
731 
732 public:
733  //! Omega constant for a -> value of a in terms of critical properties
734  /*!
735  * this was calculated from a small nonlinear solve
736  */
737  static const doublereal omega_a;
738 
739  //! Omega constant for b
740  static const doublereal omega_b;
741 
742  //! Omega constant for the critical molar volume
743  static const doublereal omega_vc;
744 };
745 }
746 
747 #endif
int NicholsSolve(double TKelvin, double pres, doublereal a, doublereal b, doublereal Vroot[3]) const
Solve the cubic equation of state.
RedlichKwongMFTP & operator=(const RedlichKwongMFTP &right)
Assignment operator.
This class can handle either an ideal solution or an ideal gas approximation of a phase...
doublereal m_b_current
Value of b in the equation of state.
doublereal dpdV_
The derivative of the pressure wrt the volume.
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
virtual void getPartialMolarIntEnergies(doublereal *ubar) const
Get the species partial molar enthalpies. Units: J/kmol.
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
vector_fp m_tmpV
Temporary storage - length = m_kk.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
RedlichKwongMFTP()
Base constructor.
virtual doublereal densityCalc(doublereal TKelvin, doublereal pressure, int phase, doublereal rhoguess)
Calculates the density given the temperature and the pressure and a guess at the density.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
This is a filter class for ThermoPhase that implements some preparatory steps for efficiently handlin...
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplicator from the ThermoPhase parent class.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
void readXMLPureFluid(XML_Node &pureFluidParam)
Read the pure species RedlichKwong input parameters.
virtual void getPartialMolarCp(doublereal *cpbar) const
Get the partial molar heat capacities Units: J/kmol/K.
virtual int eosType() const
Equation of state type flag.
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 void getPartialMolarVolumes(doublereal *vbar) const
Get the species partial molar volumes. Units: m^3/kmol.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Initialize a ThermoPhase object, potentially reading activity coefficient information from an XML dat...
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition: Array.h:33
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
void setToEquilState(const doublereal *lambda_RT)
This method is used by the ChemEquil equilibrium solver.
int m_standardMixingRules
boolean indicating whether standard mixing rules are applied
static const doublereal omega_b
Omega constant for b.
virtual void setMoleFractions_NoNorm(const doublereal *const x)
Set the mole fractions to the specified values without normalizing.
int m_formTempParam
Form of the temperature parameterization.
Header file for a derived class of ThermoPhase that handles non-ideal mixtures based on the fugacity ...
doublereal dpdT_
The derivative of the pressure wrt the temperature.
doublereal m_a_current
Value of a in the equation of state.
virtual doublereal sresid() const
Calculate the deviation terms for the total entropy of the mixture from the ideal gas mixture...
void pressureDerivatives() const
Calculate dpdV and dpdT at the current conditions.
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...
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
virtual doublereal logStandardConc(size_t k=0) const
Returns the natural logarithm of the standard concentration of the kth species.
vector_fp m_pp
Temporary storage - length = m_kk.
virtual void setParametersFromXML(const XML_Node &thermoNode)
Set equation of state parameter values from XML entries.
virtual doublereal dpdVCalc(doublereal TKelvin, doublereal molarVol, doublereal &presCalc) const
Calculate the pressure and the pressure derivative given the temperature and the molar volume...
virtual void setMassFractions_NoNorm(const doublereal *const y)
Set the mass fractions to the specified values without normalizing.
virtual doublereal standardConcentration(size_t k=0) const
Returns the standard concentration , which is used to normalize the generalized concentration.
virtual void setConcentrations(const doublereal *const c)
Set the concentrations to the specified values within the phase.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
virtual void setTemperature(const doublereal temp)
Set the temperature (K)
virtual doublereal hresid() const
Calculate the deviation terms for the total enthalpy of the mixture from the ideal gas mixture...
virtual doublereal critDensity() const
Critical density (kg/m3).
void readXMLCrossFluid(XML_Node &pureFluidParam)
Read the cross species RedlichKwong input parameters.
virtual doublereal liquidVolEst(doublereal TKelvin, doublereal &pres) const
Estimate for the molar volume of the liquid.
virtual void calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input...
static const doublereal omega_a
Omega constant for a -> value of a in terms of critical properties.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
virtual doublereal intEnergy_mole() const
Molar internal energy. Units: J/kmol.
virtual doublereal densSpinodalGas() const
Return the value of the density at the gas spinodal point (on the gas side) for the current temperatu...
virtual doublereal critPressure() const
Critical pressure (Pa).
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 calculateAB(doublereal temp, doublereal &aCalc, doublereal &bCalc) const
Calculate the a and the b parameters given the temperature.
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Get the species partial molar enthalpies. Units: J/kmol.
static const doublereal omega_vc
Omega constant for the critical molar volume.
virtual doublereal densSpinodalLiquid() const
Return the value of the density at the liquid spinodal point (on the liquid side) for the current tem...
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
virtual void getUnitsStandardConc(double *uA, int k=0, int sizeUA=6) const
Returns the units of the standard and generalized concentrations.
void applyStandardMixingRules()
Apply mixing rules for a coefficients.
virtual doublereal pressureCalc(doublereal TKelvin, doublereal molarVol) const
Calculate the pressure given the temperature and the molar volume.
void getChemPotentials_RT(doublereal *mu) const
Get the array of non-dimensional species chemical potentials.
virtual doublereal critTemperature() const
Critical temperature (K).
virtual void getPartialMolarEntropies(doublereal *sbar) const
Get the species partial molar entropies. Units: J/kmol/K.
vector_fp dpdni_
Vector of derivatives of pressure wrt mole number.
void updateAB()
Update the a and b parameters.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional activity coefficients at the current solution temperature, pressure, and solution concentration.