Cantera  3.3.0a1
Loading...
Searching...
No Matches
vcs_VolPhase.h
Go to the documentation of this file.
1/**
2 * @file vcs_VolPhase.h
3 * Header for the object representing each phase within vcs
4 */
5
6// This file is part of Cantera. See License.txt in the top-level directory or
7// at https://cantera.org/license.txt for license and copyright information.
8
9#ifndef VCS_VOLPHASE_H
10#define VCS_VOLPHASE_H
11
12#include "vcs_defs.h"
13#include "cantera/base/Array.h"
14
15namespace Cantera
16{
17
18class ThermoPhase;
19class VCS_SOLVE;
20
21//! Phase information and Phase calculations for vcs.
22/*!
23 * Each phase in a vcs calculation has a vcs_VolPhase object associated with it.
24 * This object helps to coordinate property evaluations for species within the
25 * phase. Usually these evaluations must be carried out on a per phase basis.
26 * However, vcs frequently needs per species quantities. Therefore, we need an
27 * interface layer between vcs and Cantera's ThermoPhase.
28 *
29 * The species stay in the same ordering within this structure. The vcs
30 * algorithm will change the ordering of species in the global species list.
31 * However, the indexing of species in this list stays the same. This structure
32 * contains structures that point to the species belonging to this phase in the
33 * global vcs species list.
34 *
35 * This object is considered not to own the underlying %Cantera ThermoPhase
36 * object for the phase.
37 *
38 * This object contains an idea of the temperature and pressure. It checks to
39 * see if if the temperature and pressure has changed before calling underlying
40 * property evaluation routines.
41 *
42 * The object contains values for the electric potential of a phase. It
43 * coordinates the evaluation of properties wrt when the electric potential of a
44 * phase has changed.
45 *
46 * The object knows about the mole fractions of the phase. It controls the
47 * values of mole fractions, and coordinates the property evaluation wrt to
48 * changes in the mole fractions. It also will keep track of the likely values
49 * of mole fractions in multicomponent phases even when the phase doesn't
50 * actually exist within the thermo program.
51 *
52 * The object knows about the total moles of a phase. It checks to see if the
53 * phase currently exists or not, and modifies its behavior accordingly.
54 *
55 * Activity coefficients and volume calculations are lagged. They are only
56 * called when they are needed (and when the state has changed so that they need
57 * to be recalculated).
58 */
60{
61public:
62 vcs_VolPhase(VCS_SOLVE* owningSolverObject, ThermoPhase* thermoPhase,
63 size_t phaseNum);
64
65 vcs_VolPhase(const vcs_VolPhase& b) = delete;
66 vcs_VolPhase& operator=(const vcs_VolPhase& b) = delete;
67 ~vcs_VolPhase() = default;
68
69 //! Set the moles and/or mole fractions within the phase
70 /*!
71 * @param molNum total moles in the phase
72 * @param moleFracVec Vector of input mole fractions
73 * @param vcsStateStatus Status flag for this update
74 */
75 void setMoleFractionsState(const double molNum, const double* const moleFracVec,
76 const int vcsStateStatus);
77
78 //! Set the moles within the phase
79 /*!
80 * This function takes as input the mole numbers in vcs format, and then
81 * updates this object with their values. This is essentially a gather
82 * routine.
83 *
84 * @param stateCalc Flag indicating which mole numbers to update. Either
85 * `VCS_STATECALC_OLD` or `VCS_STATECALC_NEW`.
86 * @param molesSpeciesVCS Array of mole numbers. Note, the indices for
87 * species in this array may not be contiguous. IndSpecies[] is needed
88 * to gather the species into the local contiguous vector format.
89 */
90 void setMolesFromVCS(const int stateCalc,
91 const double* molesSpeciesVCS = 0);
92
93 //! Set the moles within the phase
94 /*!
95 * This function takes as input the mole numbers in vcs format, and then
96 * updates this object with their values. This is essentially a gather
97 * routine.
98 *
99 * Additionally it checks to see that the total moles value in
100 * TPhMoles[iplace] is equal to the internally computed value. If this isn't
101 * the case, an error exit is carried out.
102 *
103 * @param vcsStateStatus State calc value either `VCS_STATECALC_OLD` or
104 * `VCS_STATECALC_NEW`. With any other value nothing is done.
105 * @param molesSpeciesVCS array of mole numbers. Note, the indices for
106 * species in this array may not be contiguous. IndSpecies[] is needed
107 * to gather the species into the local contiguous vector format.
108 * @param TPhMoles VCS's array containing the number of moles in each phase.
109 */
110 void setMolesFromVCSCheck(const int vcsStateStatus,
111 const double* molesSpeciesVCS,
112 const double* const TPhMoles);
113
114 //! Update the moles within the phase, if necessary
115 /*!
116 * This function takes as input the stateCalc value, which determines where
117 * within VCS_SOLVE to fetch the mole numbers. It then updates this object
118 * with their values. This is essentially a gather routine.
119 *
120 * @param stateCalc State calc value either VCS_STATECALC_OLD or
121 * VCS_STATECALC_NEW. With any other value nothing is done.
122 */
123 void updateFromVCS_MoleNumbers(const int stateCalc);
124
125 //! Fill in an activity coefficients vector within a VCS_SOLVE object
126 /*!
127 * This routine will calculate the activity coefficients for the current
128 * phase, and fill in the corresponding entries in the VCS activity
129 * coefficients vector.
130 *
131 * @param stateCalc Flag indicating which mole numbers to update. Either
132 * `VCS_STATECALC_OLD` or `VCS_STATECALC_NEW`.
133 * @param AC vector of activity coefficients for all of the species in all
134 * of the phases in a VCS problem. Only the entries for the current
135 * phase are filled in.
136 */
137 void sendToVCS_ActCoeff(const int stateCalc, double* const AC);
138
139 //! set the electric potential of the phase
140 /*!
141 * @param phi electric potential (volts)
142 */
143 void setElectricPotential(const double phi);
144
145 //! Returns the electric field of the phase
146 /*!
147 * Units are potential
148 */
149 double electricPotential() const;
150
151 //! Gibbs free energy calculation for standard state of one species
152 /*!
153 * Calculate the Gibbs free energies for the standard state of the kth
154 * species. The results are held internally within the object.
155 *
156 * @param kspec Species number (within the phase)
157 * @returns the Gibbs free energy for the standard state of the kth species.
158 */
159 double GStar_calc_one(size_t kspec) const;
160
161 //! Gibbs free energy calculation at a temperature for the reference state
162 //! of a species, return a value for one species
163 /*!
164 * @param kspec species index
165 * @returns value of the Gibbs free energy
166 */
167 double G0_calc_one(size_t kspec) const;
168
169 //! Fill in the partial molar volume vector for VCS
170 /*!
171 * This routine will calculate the partial molar volumes for the current
172 * phase (if needed), and fill in the corresponding entries in the VCS
173 * partial molar volumes vector.
174 *
175 * @param[out] VolPM vector of partial molar volumes for all of the species in
176 * all of the phases in a VCS problem. Only the entries for the current
177 * phase are filled in.
178 */
179 double sendToVCS_VolPM(double* const VolPM) const;
180
181 //! Fill in the standard state Gibbs free energy vector for VCS
182 /*!
183 * This routine will calculate the standard state Gibbs free energies for the
184 * current phase (if needed), and fill in the corresponding entries in the
185 * VCS standard state gibbs free energy vector.
186 *
187 * @param[out] gstar vector of standard state Gibbs free energies for all of the
188 * species in all of the phases in a VCS problem. Only the entries for the
189 * current phase are filled in.
190 */
191 void sendToVCS_GStar(double* const gstar) const;
192
193 //! Sets the temperature and pressure in this object and underlying
194 //! ThermoPhase objects
195 /*!
196 * @param temperature_Kelvin (Kelvin)
197 * @param pressure_PA Pressure (MKS units - Pascal)
198 */
199 void setState_TP(const double temperature_Kelvin, const double pressure_PA);
200
201 //! Downloads the ln ActCoeff Jacobian into the VCS version of the
202 //! ln ActCoeff Jacobian.
203 /**
204 * This is essentially a scatter operation.
205 *
206 * @param LnACJac_VCS Jacobian parameter
207 * The Jacobians are actually d( lnActCoeff) / d (MolNumber);
208 * dLnActCoeffdMolNumber(k,j)
209 *
210 * j = id of the species mole number
211 * k = id of the species activity coefficient
212 */
213 void sendToVCS_LnActCoeffJac(Array2D& LnACJac_VCS);
214
215 //! Return the total moles in the phase
216 double totalMoles() const;
217
218 //! Returns the mole fraction of the kspec species
219 /*!
220 * @param kspec Index of the species in the phase
221 *
222 * @return Value of the mole fraction
223 */
224 double molefraction(size_t kspec) const;
225
226 //! Sets the total moles in the phase
227 /*!
228 * We don't have to flag the internal state as changing here because we have
229 * just changed the total moles.
230 *
231 * @param totalMols Total moles in the phase (kmol)
232 */
233 void setTotalMoles(const double totalMols);
234
235 //! Sets the mole flag within the object to out of date
236 /*!
237 * This will trigger the object to go get the current mole numbers when it
238 * needs it.
239 */
240 void setMolesOutOfDate(int stateCalc = -1);
241
242 //! Sets the mole flag within the object to be current
243 void setMolesCurrent(int vcsStateStatus);
244
245private:
246 void elemResize(const size_t numElemConstraints);
247
248 //! Set the mole fractions from a conventional mole fraction vector
249 /*!
250 * @param xmol Value of the mole fractions for the species in the phase.
251 * These are contiguous.
252 */
253 void setMoleFractions(const double* const xmol);
254
255public:
256 //! Return a const reference to the mole fractions stored in the object.
257 const vector<double> & moleFractions() const;
258
259 double moleFraction(size_t klocal) const;
260
261 //! Sets the creationMoleNum's within the phase object
262 /*!
263 * @param n_k Pointer to a vector of n_k's
264 * @param creationGlobalRxnNumbers Vector of global creation reaction numbers
265 */
266 void setCreationMoleNumbers(const double* const n_k, const vector<size_t> &creationGlobalRxnNumbers);
267
268 //! Return a const reference to the creationMoleNumbers stored in the object.
269 /*!
270 * @returns a const reference to the vector of creationMoleNumbers
271 */
272 const vector<double> & creationMoleNumbers(vector<size_t> &creationGlobalRxnNumbers) const;
273
274 //! Returns whether the phase is an ideal solution phase
275 bool isIdealSoln() const;
276
277 //! Return the index of the species that represents the the voltage of the
278 //! phase
279 size_t phiVarIndex() const;
280
281 void setPhiVarIndex(size_t phiVarIndex);
282
283 //! Retrieve the kth Species structure for the species belonging to this
284 //! phase
285 /*!
286 * The index into this vector is the species index within the phase.
287 *
288 * @param kindex kth species index.
289 */
290 //! int indicating whether the phase exists or not
291 /*!
292 * returns the m_existence int for the phase
293 *
294 * - VCS_PHASE_EXIST_ZEROEDPHASE = -6: Set to not exist by fiat from a
295 * higher level. This is used in phase stability boundary calculations
296 * - VCS_PHASE_EXIST_NO = 0: Doesn't exist currently
297 * - VCS_PHASE_EXIST_YES = 2 : Does exist currently
298 * - VCS_PHASE_EXIST_ALWAYS = 3: Always exists because it consists of a single
299 * species that is identified with the voltage, for example, it's an electron
300 * metal phase.
301 */
302 int exists() const;
303
304 //! Set the existence flag in the object
305 /*!
306 * Note the total moles of the phase must have been set appropriately before
307 * calling this routine.
308 *
309 * @param existence Phase existence flag
310 *
311 * @note try to eliminate this routine
312 */
313 void setExistence(const int existence);
314
315 //! Return the Global VCS index of the kth species in the phase
316 /*!
317 * @param spIndex local species index (0 to the number of species in the
318 * phase)
319 *
320 * @returns the VCS_SOLVE species index of the species. This changes as
321 * rearrangements are carried out.
322 */
323 size_t spGlobalIndexVCS(const size_t spIndex) const;
324
325
326 //! set the Global VCS index of the kth species in the phase
327 /*!
328 * @param spIndex local species index (0 to the number of species
329 * in the phase)
330 * @param spGlobalIndex Global species index (across all phases)
331 */
332 void setSpGlobalIndexVCS(const size_t spIndex, const size_t spGlobalIndex);
333
334 //! Returns the global index of the local element index for the phase
335 size_t elemGlobalIndex(const size_t e) const;
336
337 //! sets a local phase element to a global index value
338 /*!
339 * @param eLocal Local phase element index
340 * @param eGlobal Global phase element index
341 */
342 void setElemGlobalIndex(const size_t eLocal, const size_t eGlobal);
343
344 //! Returns the number of element constraints
345 size_t nElemConstraints() const;
346
347 //! Name of the element constraint with index @c e.
348 /*!
349 * @param e Element index.
350 */
351 string elementName(size_t e) const;
352
353 //! Type of the element constraint with index @c e.
354 /*!
355 * @param e Element index.
356 */
357 int elementType(const size_t e) const;
358
359 //! Transfer all of the element information from the ThermoPhase object to
360 //! the vcs_VolPhase object.
361 /*!
362 * Also decide whether we need a new charge neutrality element in the phase
363 * to enforce a charge neutrality constraint.
364 *
365 * @param tPhase Pointer to the ThermoPhase object
366 */
367 size_t transferElementsFM(const ThermoPhase* const tPhase);
368
369 //! Get a constant form of the Species Formula Matrix
370 /*!
371 * Returns a `double**` pointer such that `fm[e][f]` is the formula
372 * matrix entry for element `e` for species `k`
373 */
374 const Array2D& getFormulaMatrix() const;
375
376 //! Returns the type of the species unknown
377 /*!
378 * @param k species index
379 * @return the SpeciesUnknownType[k] = type of species
380 * - Normal -> VCS_SPECIES_TYPE_MOLUNK (unknown is the mole number in
381 * the phase)
382 * - metal electron -> VCS_SPECIES_INTERFACIALVOLTAGE (unknown is the
383 * interfacial voltage (volts))
384 */
385 int speciesUnknownType(const size_t k) const;
386
387 int elementActive(const size_t e) const;
388
389 //! Return the number of species in the phase
390 size_t nSpecies() const;
391
392 //! Return the name corresponding to the equation of state
393 string eos_name() const;
394
395private:
396 //! Evaluate the activity coefficients at the current conditions
397 /*!
398 * We carry out a calculation whenever #m_UpToDate_AC is false. Specifically
399 * whenever a phase goes zero, we do not carry out calculations on it.
400 */
401 void _updateActCoeff() const;
402
403 //! Gibbs free energy calculation for standard states
404 /*!
405 * Calculate the Gibbs free energies for the standard states The results are
406 * held internally within the object.
407 */
408 void _updateGStar() const;
409
410 //! Gibbs free energy calculation at a temperature for the reference state
411 //! of each species
412 void _updateG0() const;
413
414 //! Molar volume calculation for standard states
415 /*!
416 * Calculate the molar volume for the standard states. The results are held
417 * internally within the object. Units are in m**3/kmol.
418 */
419 void _updateVolStar() const;
420
421 //! Calculate the partial molar volumes of all species and return the
422 //! total volume
423 /*!
424 * Calculates these quantities internally and then stores them
425 *
426 * @return total volume [m^3]
427 */
428 double _updateVolPM() const;
429
430 //! Evaluation of Activity Coefficient Jacobians
431 /*!
432 * This is the derivative of the ln of the activity coefficient with respect
433 * to mole number of jth species. (temp, pressure, and other mole numbers
434 * held constant)
435 *
436 * We employ a finite difference derivative approach here. Because we have
437 * to change the mole numbers, this is not a const function, even though the
438 * paradigm would say that it should be.
439 */
441
442 //! Updates the mole fraction dependencies
443 /*!
444 * Whenever the mole fractions change, this routine should be called.
445 */
447
448private:
449 //! Backtrack value of VCS_SOLVE *
451
452public:
453 //! Original ID of the phase in the problem.
454 /*!
455 * If a non-ideal phase splits into two due to a miscibility gap, these
456 * numbers will stay the same after the split.
457 */
458 size_t VP_ID_ = npos;
459
460 //! If true, this phase consists of a single species
461 bool m_singleSpecies = true;
462
463 //! This is the element number for the charge neutrality condition of the
464 //! phase
465 /*!
466 * If it has one. If it does not have a charge neutrality
467 * constraint, then this value is equal to -1
468 */
470
471 //! Convention for the activity formulation
472 /*!
473 * * 0 = molar based activities (default)
474 * * 1 = Molality based activities, mu = mu_0 + ln a_molality. Standard
475 * state is based on unity molality
476 */
478
479private:
480 //! Number of element constraints within the problem
481 /*!
482 * This is usually equal to the number of elements.
483 */
485
486 //! vector of strings containing the element constraint names
487 /*!
488 * Length = nElemConstraints
489 */
490 vector<string> m_elementNames;
491
492 //! boolean indicating whether an element constraint is active
493 //! for the current problem
494 vector<int> m_elementActive;
495
496 //! Type of the element constraint
497 /*!
498 * m_elType[j] = type of the element:
499 * * 0 VCS_ELEM_TYPE_ABSPOS Normal element that is positive or zero in
500 * all species.
501 * * 1 VCS_ELEM_TYPE_ELECTRONCHARGE element dof that corresponds to the
502 * charge DOF.
503 */
504 vector<int> m_elementType;
505
506 //! Formula Matrix for the phase
507 /*!
508 * FormulaMatrix(kspec,j) = Formula Matrix for the species
509 * Number of elements, j, in the kspec species
510 */
512
513 //! Type of the species unknown
514 /*!
515 * SpeciesUnknownType[k] = type of species
516 * - Normal -> VCS_SPECIES_TYPE_MOLUNK.
517 * (unknown is the mole number in the phase)
518 * - metal electron -> VCS_SPECIES_INTERFACIALVOLTAGE.
519 * (unknown is the interfacial voltage (volts))
520 */
522
523 //! Index of the element number in the global list of elements stored in VCS_SOLVE
524 vector<size_t> m_elemGlobalIndex;
525
526 //! Number of species in the phase
527 size_t m_numSpecies = 0;
528
529public:
530 //! String name for the phase
531 string PhaseName;
532
533private:
534 //! Boolean indicating whether the phase is an ideal solution
535 //! and therefore its molar-based activity coefficients are
536 //! uniformly equal to one.
537 bool m_isIdealSoln = false;
538
539 //! Current state of existence:
540 /*!
541 * - VCS_PHASE_EXIST_ZEROEDPHASE = -6: Set to not exist by fiat from a
542 * higher level. This is used in phase stability boundary calculations
543 * - VCS_PHASE_EXIST_NO = 0: Doesn't exist currently
544 * - VCS_PHASE_EXIST_YES = 2 : Does exist currently
545 * - VCS_PHASE_EXIST_ALWAYS = 3: Always exists because it contains inerts
546 * which can't exist in any other phase. Or, the phase exists always
547 * because it consists of a single species, which is identified with the
548 * voltage, for example, its an electron metal phase.
549 */
551
552 // Index of the first MF species in the list of unknowns for this phase
553 /*!
554 * This is always equal to zero.
555 * Am anticipating the case where the phase potential is species # 0,
556 * for multiphase phases. Right now we have the phase potential equal
557 * to 0 for single species phases, where we set by hand the mole fraction
558 * of species 0 to one.
559 */
561
562 //! Index into the species vectors
563 /*!
564 * Maps the phase species number into the global species number.
565 * Note, as part of the vcs algorithm, the order of the species
566 * vector is changed during the algorithm
567 */
568 vector<size_t> IndSpecies;
569
570 //! Vector of Species structures for the species belonging to this phase
571 /*!
572 * The index into this vector is the species index within the phase.
573 */
574 /**
575 * If we are using Cantera, this is the pointer to the ThermoPhase
576 * object. If not, this is null.
577 */
578 ThermoPhase* TP_ptr = nullptr;
579
580 //! Total mols in the phase. units are kmol
581 double v_totalMoles = 0.0;
582
583 //! Vector of the current mole fractions for species in the phase
584 vector<double> Xmol_;
585
586 //! Vector of current creationMoleNumbers_
587 /*!
588 * These are the actual unknowns in the phase stability problem
589 */
590 vector<double> creationMoleNumbers_;
591
592 //! Vector of creation global reaction numbers for the phase stability problem
593 /*!
594 * The phase stability problem requires a global reaction number for each
595 * species in the phase. Usually this is the krxn = kglob - M for species in
596 * the phase that are not components. For component species, the choice of
597 * the reaction is one which maximizes the chance that the phase pops into
598 * (or remains in) existence.
599 *
600 * The index here is the local phase species index. the value of the
601 * variable is the global vcs reaction number. Note, that the global
602 * reaction number will go out of order when the species positions are
603 * swapped. So, this number has to be recalculated.
604 *
605 * Length = number of species in phase
606 */
608
609 //! If the potential is a solution variable in VCS, it acts as a species.
610 //! This is the species index in the phase for the potential
612
613 //! Total Volume of the phase. Units are m**3.
614 mutable double m_totalVol = 0.0;
615
616 //! Vector of calculated SS0 chemical potentials for the
617 //! current Temperature.
618 /*!
619 * Note, This is the chemical potential derived strictly from the polynomial
620 * in temperature. Pressure effects have to be added in to get to the
621 * standard state. Units are J/kmol.
622 */
623 mutable vector<double> SS0ChemicalPotential;
624
625 //! Vector of calculated Star chemical potentials for the
626 //! current Temperature and pressure.
627 /*!
628 * Note, This is the chemical potential at unit activity. Thus, we can call
629 * it the standard state chemical potential as well. Units are J/kmol.
630 */
631 mutable vector<double> StarChemicalPotential;
632
633 //! Vector of the Star molar Volumes of the species. units m3 / kmol
634 mutable vector<double> StarMolarVol;
635
636 //! Vector of the Partial molar Volumes of the species. units m3 / kmol
637 mutable vector<double> PartialMolarVol;
638
639 //! Vector of calculated activity coefficients for the current state
640 /*!
641 * Whether or not this vector is current is determined by the bool
642 * #m_UpToDate_AC.
643 */
644 mutable vector<double> ActCoeff;
645
646 //! Vector of the derivatives of the ln activity coefficient wrt to the
647 //! current mole number multiplied by the current phase moles
648 /*!
649 * np_dLnActCoeffdMolNumber(k,j);
650 * - j = id of the species mole number
651 * - k = id of the species activity coefficient
652 */
654
655 //! Status
656 /*!
657 * valid values are
658 * - VCS_STATECALC_OLD
659 * - VCS_STATECALC_NEW
660 * - VCS_STATECALC_TMP
661 */
663
664 //! Value of the potential for the phase (Volts)
665 double m_phi = 0.0;
666
667 //! Boolean indicating whether the object has an up-to-date mole number vector
668 //! and potential with respect to the current vcs state calc status
669 bool m_UpToDate = false;
670
671 //! Boolean indicating whether activity coefficients are up to date.
672 /*!
673 * Activity coefficients and volume calculations are lagged. They are only
674 * called when they are needed (and when the state has changed so that they
675 * need to be recalculated).
676 */
677 mutable bool m_UpToDate_AC = false;
678
679 //! Boolean indicating whether Star volumes are up to date.
680 /*!
681 * Activity coefficients and volume calculations are lagged. They are only
682 * called when they are needed (and when the state has changed so that they
683 * need to be recalculated). Star volumes are sensitive to temperature and
684 * pressure
685 */
686 mutable bool m_UpToDate_VolStar = false;
687
688 //! Boolean indicating whether partial molar volumes are up to date.
689 /*!
690 * Activity coefficients and volume calculations are lagged. They are only
691 * called when they are needed (and when the state has changed so that they
692 * need to be recalculated). partial molar volumes are sensitive to
693 * everything
694 */
695 mutable bool m_UpToDate_VolPM = false;
696
697 //! Boolean indicating whether GStar is up to date.
698 /*!
699 * GStar is sensitive to the temperature and the pressure, only
700 */
701 mutable bool m_UpToDate_GStar = false;
702
703 //! Boolean indicating whether G0 is up to date.
704 /*!
705 * G0 is sensitive to the temperature and the pressure, only
706 */
707 mutable bool m_UpToDate_G0 = false;
708
709 //! Current value of the temperature for this object, and underlying objects
710 double Temp_ = 273.15;
711
712 //! Current value of the pressure for this object, and underlying objects
713 double Pres_ = OneAtm;
714};
715
716}
717
718#endif
Header file for class Cantera::Array2D.
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition Array.h:32
Base class for a phase with thermodynamic properties.
This is the main structure used to hold the internal data used in vcs_solve_TP(), and to solve TP sys...
Definition vcs_solve.h:44
Phase information and Phase calculations for vcs.
vector< double > StarChemicalPotential
Vector of calculated Star chemical potentials for the current Temperature and pressure.
void setCreationMoleNumbers(const double *const n_k, const vector< size_t > &creationGlobalRxnNumbers)
Sets the creationMoleNum's within the phase object.
void setElectricPotential(const double phi)
set the electric potential of the phase
bool m_UpToDate_GStar
Boolean indicating whether GStar is up to date.
double electricPotential() const
Returns the electric field of the phase.
size_t m_phiVarIndex
If the potential is a solution variable in VCS, it acts as a species.
vector< double > Xmol_
Vector of the current mole fractions for species in the phase.
double Temp_
Current value of the temperature for this object, and underlying objects.
int speciesUnknownType(const size_t k) const
Returns the type of the species unknown.
size_t elemGlobalIndex(const size_t e) const
Returns the global index of the local element index for the phase.
void _updateGStar() const
Gibbs free energy calculation for standard states.
vector< double > SS0ChemicalPotential
Vector of calculated SS0 chemical potentials for the current Temperature.
size_t nSpecies() const
Return the number of species in the phase.
string PhaseName
String name for the phase.
void setMolesFromVCSCheck(const int vcsStateStatus, const double *molesSpeciesVCS, const double *const TPhMoles)
Set the moles within the phase.
void setMoleFractionsState(const double molNum, const double *const moleFracVec, const int vcsStateStatus)
Set the moles and/or mole fractions within the phase.
void setMolesOutOfDate(int stateCalc=-1)
Sets the mole flag within the object to out of date.
vector< string > m_elementNames
vector of strings containing the element constraint names
vector< int > m_elementActive
boolean indicating whether an element constraint is active for the current problem
vector< double > creationMoleNumbers_
Vector of current creationMoleNumbers_.
double _updateVolPM() const
Calculate the partial molar volumes of all species and return the total volume.
double m_totalVol
Total Volume of the phase. Units are m**3.
size_t ChargeNeutralityElement
This is the element number for the charge neutrality condition of the phase.
vector< size_t > m_elemGlobalIndex
Index of the element number in the global list of elements stored in VCS_SOLVE.
size_t VP_ID_
Original ID of the phase in the problem.
Array2D np_dLnActCoeffdMolNumber
Vector of the derivatives of the ln activity coefficient wrt to the current mole number multiplied by...
const Array2D & getFormulaMatrix() const
Get a constant form of the Species Formula Matrix.
vector< int > m_speciesUnknownType
Type of the species unknown.
bool m_UpToDate_VolStar
Boolean indicating whether Star volumes are up to date.
void updateFromVCS_MoleNumbers(const int stateCalc)
Update the moles within the phase, if necessary.
size_t phiVarIndex() const
Return the index of the species that represents the the voltage of the phase.
double v_totalMoles
Total mols in the phase. units are kmol.
bool m_singleSpecies
If true, this phase consists of a single species.
void setMolesFromVCS(const int stateCalc, const double *molesSpeciesVCS=0)
Set the moles within the phase.
void setElemGlobalIndex(const size_t eLocal, const size_t eGlobal)
sets a local phase element to a global index value
int m_MFStartIndex
This is always equal to zero.
bool m_isIdealSoln
Boolean indicating whether the phase is an ideal solution and therefore its molar-based activity coef...
vector< double > ActCoeff
Vector of calculated activity coefficients for the current state.
int exists() const
Retrieve the kth Species structure for the species belonging to this phase.
vector< size_t > IndSpecies
Index into the species vectors.
const vector< double > & moleFractions() const
Return a const reference to the mole fractions stored in the object.
size_t nElemConstraints() const
Returns the number of element constraints.
double m_phi
Value of the potential for the phase (Volts)
size_t spGlobalIndexVCS(const size_t spIndex) const
Return the Global VCS index of the kth species in the phase.
size_t transferElementsFM(const ThermoPhase *const tPhase)
Transfer all of the element information from the ThermoPhase object to the vcs_VolPhase object.
vector< int > m_elementType
Type of the element constraint.
double GStar_calc_one(size_t kspec) const
Gibbs free energy calculation for standard state of one species.
void _updateVolStar() const
Molar volume calculation for standard states.
int m_vcsStateStatus
Status.
bool m_UpToDate_G0
Boolean indicating whether G0 is up to date.
void _updateG0() const
Gibbs free energy calculation at a temperature for the reference state of each species.
double Pres_
Current value of the pressure for this object, and underlying objects.
vector< double > PartialMolarVol
Vector of the Partial molar Volumes of the species. units m3 / kmol.
double molefraction(size_t kspec) const
Returns the mole fraction of the kspec species.
Array2D m_formulaMatrix
Formula Matrix for the phase.
void _updateLnActCoeffJac()
Evaluation of Activity Coefficient Jacobians.
string elementName(size_t e) const
Name of the element constraint with index e.
void setTotalMoles(const double totalMols)
Sets the total moles in the phase.
int p_activityConvention
Convention for the activity formulation.
void setMolesCurrent(int vcsStateStatus)
Sets the mole flag within the object to be current.
void sendToVCS_GStar(double *const gstar) const
Fill in the standard state Gibbs free energy vector for VCS.
void sendToVCS_ActCoeff(const int stateCalc, double *const AC)
Fill in an activity coefficients vector within a VCS_SOLVE object.
size_t m_numElemConstraints
Number of element constraints within the problem.
vector< double > StarMolarVol
Vector of the Star molar Volumes of the species. units m3 / kmol.
double sendToVCS_VolPM(double *const VolPM) const
Fill in the partial molar volume vector for VCS.
void sendToVCS_LnActCoeffJac(Array2D &LnACJac_VCS)
Downloads the ln ActCoeff Jacobian into the VCS version of the ln ActCoeff Jacobian.
double G0_calc_one(size_t kspec) const
Gibbs free energy calculation at a temperature for the reference state of a species,...
void _updateActCoeff() const
Evaluate the activity coefficients at the current conditions.
void setState_TP(const double temperature_Kelvin, const double pressure_PA)
Sets the temperature and pressure in this object and underlying ThermoPhase objects.
int m_existence
Current state of existence:
string eos_name() const
Return the name corresponding to the equation of state.
bool m_UpToDate_AC
Boolean indicating whether activity coefficients are up to date.
VCS_SOLVE * m_owningSolverObject
Backtrack value of VCS_SOLVE *.
ThermoPhase * TP_ptr
Vector of Species structures for the species belonging to this phase.
void _updateMoleFractionDependencies()
Updates the mole fraction dependencies.
int elementType(const size_t e) const
Type of the element constraint with index e.
vector< size_t > creationGlobalRxnNumbers_
Vector of creation global reaction numbers for the phase stability problem.
void setSpGlobalIndexVCS(const size_t spIndex, const size_t spGlobalIndex)
set the Global VCS index of the kth species in the phase
size_t m_numSpecies
Number of species in the phase.
void setExistence(const int existence)
Set the existence flag in the object.
void setMoleFractions(const double *const xmol)
Set the mole fractions from a conventional mole fraction vector.
bool m_UpToDate
Boolean indicating whether the object has an up-to-date mole number vector and potential with respect...
const vector< double > & creationMoleNumbers(vector< size_t > &creationGlobalRxnNumbers) const
Return a const reference to the creationMoleNumbers stored in the object.
bool m_UpToDate_VolPM
Boolean indicating whether partial molar volumes are up to date.
bool isIdealSoln() const
Returns whether the phase is an ideal solution phase.
double totalMoles() const
Return the total moles in the phase.
const double OneAtm
One atmosphere [Pa].
Definition ct_defs.h:96
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
const size_t npos
index returned by functions to indicate "no position"
Definition ct_defs.h:180
Defines and definitions within the vcs package.
#define VCS_STATECALC_OLD
State Calculation based on the old or base mole numbers.
Definition vcs_defs.h:206
#define VCS_PHASE_EXIST_NO
Phase doesn't currently exist in the mixture.
Definition vcs_defs.h:147