Cantera  4.0.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, span<const double> 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 span<const double> molesSpeciesVCS = {});
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 span<const double> molesSpeciesVCS,
112 span<const double> 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, span<double> 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(span<double> 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(span<double> 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(span<const double> xmol);
254
255public:
256 //! Return a const reference to the mole fractions stored in the object.
257 span<const 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(span<const double> n_k,
267 span<const size_t> creationGlobalRxnNumbers);
268
269 //! Return a const reference to the creationMoleNumbers stored in the object.
270 /*!
271 * @returns a const reference to the vector of creationMoleNumbers
272 */
273 span<const double> creationMoleNumbers(span<size_t> creationGlobalRxnNumbers) const;
274
275 //! Returns whether the phase is an ideal solution phase
276 bool isIdealSoln() const;
277
278 //! Return the index of the species that represents the the voltage of the
279 //! phase
280 size_t phiVarIndex() const;
281
282 void setPhiVarIndex(size_t phiVarIndex);
283
284 //! Retrieve the kth Species structure for the species belonging to this
285 //! phase
286 /*!
287 * The index into this vector is the species index within the phase.
288 *
289 * @param kindex kth species index.
290 */
291 //! int indicating whether the phase exists or not
292 /*!
293 * returns the m_existence int for the phase
294 *
295 * - VCS_PHASE_EXIST_ZEROEDPHASE = -6: Set to not exist by fiat from a
296 * higher level. This is used in phase stability boundary calculations
297 * - VCS_PHASE_EXIST_NO = 0: Doesn't exist currently
298 * - VCS_PHASE_EXIST_YES = 2 : Does exist currently
299 * - VCS_PHASE_EXIST_ALWAYS = 3: Always exists because it consists of a single
300 * species that is identified with the voltage, for example, it's an electron
301 * metal phase.
302 */
303 int exists() const;
304
305 //! Set the existence flag in the object
306 /*!
307 * Note the total moles of the phase must have been set appropriately before
308 * calling this routine.
309 *
310 * @param existence Phase existence flag
311 *
312 * @note try to eliminate this routine
313 */
314 void setExistence(const int existence);
315
316 //! Return the Global VCS index of the kth species in the phase
317 /*!
318 * @param spIndex local species index (0 to the number of species in the
319 * phase)
320 *
321 * @returns the VCS_SOLVE species index of the species. This changes as
322 * rearrangements are carried out.
323 */
324 size_t spGlobalIndexVCS(const size_t spIndex) const;
325
326
327 //! set the Global VCS index of the kth species in the phase
328 /*!
329 * @param spIndex local species index (0 to the number of species
330 * in the phase)
331 * @param spGlobalIndex Global species index (across all phases)
332 */
333 void setSpGlobalIndexVCS(const size_t spIndex, const size_t spGlobalIndex);
334
335 //! Returns the global index of the local element index for the phase
336 size_t elemGlobalIndex(const size_t e) const;
337
338 //! sets a local phase element to a global index value
339 /*!
340 * @param eLocal Local phase element index
341 * @param eGlobal Global phase element index
342 */
343 void setElemGlobalIndex(const size_t eLocal, const size_t eGlobal);
344
345 //! Returns the number of element constraints
346 size_t nElemConstraints() const;
347
348 //! Name of the element constraint with index @c e.
349 /*!
350 * @param e Element index.
351 */
352 string elementName(size_t e) const;
353
354 //! Type of the element constraint with index @c e.
355 /*!
356 * @param e Element index.
357 */
358 int elementType(const size_t e) const;
359
360 //! Transfer all of the element information from the ThermoPhase object to
361 //! the vcs_VolPhase object.
362 /*!
363 * Also decide whether we need a new charge neutrality element in the phase
364 * to enforce a charge neutrality constraint.
365 *
366 * @param tPhase Pointer to the ThermoPhase object
367 */
368 size_t transferElementsFM(const ThermoPhase* const tPhase);
369
370 //! Get a constant form of the Species Formula Matrix
371 /*!
372 * Returns a matrix `M` where `M(k, e)` is the entry for element `e` and
373 * species `k`.
374 */
375 const Array2D& getFormulaMatrix() const;
376
377 //! Returns the type of the species unknown
378 /*!
379 * @param k species index
380 * @return the SpeciesUnknownType[k] = type of species
381 * - Normal -> VCS_SPECIES_TYPE_MOLUNK (unknown is the mole number in
382 * the phase)
383 * - metal electron -> VCS_SPECIES_INTERFACIALVOLTAGE (unknown is the
384 * interfacial voltage (volts))
385 */
386 int speciesUnknownType(const size_t k) const;
387
388 int elementActive(const size_t e) const;
389
390 //! Return the number of species in the phase
391 size_t nSpecies() const;
392
393 //! Return the name corresponding to the equation of state
394 string eos_name() const;
395
396private:
397 //! Evaluate the activity coefficients at the current conditions
398 /*!
399 * We carry out a calculation whenever #m_UpToDate_AC is false. Specifically
400 * whenever a phase goes zero, we do not carry out calculations on it.
401 */
402 void _updateActCoeff() const;
403
404 //! Gibbs free energy calculation for standard states
405 /*!
406 * Calculate the Gibbs free energies for the standard states The results are
407 * held internally within the object.
408 */
409 void _updateGStar() const;
410
411 //! Gibbs free energy calculation at a temperature for the reference state
412 //! of each species
413 void _updateG0() const;
414
415 //! Molar volume calculation for standard states
416 /*!
417 * Calculate the molar volume for the standard states. The results are held
418 * internally within the object. Units are in m**3/kmol.
419 */
420 void _updateVolStar() const;
421
422 //! Calculate the partial molar volumes of all species and return the
423 //! total volume
424 /*!
425 * Calculates these quantities internally and then stores them
426 *
427 * @return total volume [m^3]
428 */
429 double _updateVolPM() const;
430
431 //! Evaluation of Activity Coefficient Jacobians
432 /*!
433 * This is the derivative of the ln of the activity coefficient with respect
434 * to mole number of jth species. (temp, pressure, and other mole numbers
435 * held constant)
436 *
437 * We employ a finite difference derivative approach here. Because we have
438 * to change the mole numbers, this is not a const function, even though the
439 * paradigm would say that it should be.
440 */
442
443 //! Updates the mole fraction dependencies
444 /*!
445 * Whenever the mole fractions change, this routine should be called.
446 */
448
449private:
450 //! Backtrack value of VCS_SOLVE *
452
453public:
454 //! Original ID of the phase in the problem.
455 /*!
456 * If a non-ideal phase splits into two due to a miscibility gap, these
457 * numbers will stay the same after the split.
458 */
459 size_t VP_ID_ = npos;
460
461 //! If true, this phase consists of a single species
462 bool m_singleSpecies = true;
463
464 //! This is the element number for the charge neutrality condition of the
465 //! phase
466 /*!
467 * If it has one. If it does not have a charge neutrality
468 * constraint, then this value is equal to -1
469 */
471
472 //! Convention for the activity formulation
473 /*!
474 * * 0 = molar based activities (default)
475 * * 1 = Molality based activities, mu = mu_0 + ln a_molality. Standard
476 * state is based on unity molality
477 */
479
480private:
481 //! Number of element constraints within the problem
482 /*!
483 * This is usually equal to the number of elements.
484 */
486
487 //! vector of strings containing the element constraint names
488 /*!
489 * Length = nElemConstraints
490 */
491 vector<string> m_elementNames;
492
493 //! boolean indicating whether an element constraint is active
494 //! for the current problem
495 vector<int> m_elementActive;
496
497 //! Type of the element constraint
498 /*!
499 * m_elType[j] = type of the element:
500 * * 0 VCS_ELEM_TYPE_ABSPOS Normal element that is positive or zero in
501 * all species.
502 * * 1 VCS_ELEM_TYPE_ELECTRONCHARGE element dof that corresponds to the
503 * charge DOF.
504 */
505 vector<int> m_elementType;
506
507 //! Formula Matrix for the phase
508 /*!
509 * FormulaMatrix(kspec,j) = Formula Matrix for the species
510 * Number of elements, j, in the kspec species
511 */
513
514 //! Type of the species unknown
515 /*!
516 * SpeciesUnknownType[k] = type of species
517 * - Normal -> VCS_SPECIES_TYPE_MOLUNK.
518 * (unknown is the mole number in the phase)
519 * - metal electron -> VCS_SPECIES_INTERFACIALVOLTAGE.
520 * (unknown is the interfacial voltage (volts))
521 */
523
524 //! Index of the element number in the global list of elements stored in VCS_SOLVE
525 vector<size_t> m_elemGlobalIndex;
526
527 //! Number of species in the phase
528 size_t m_numSpecies = 0;
529
530public:
531 //! String name for the phase
532 string PhaseName;
533
534private:
535 //! Boolean indicating whether the phase is an ideal solution
536 //! and therefore its molar-based activity coefficients are
537 //! uniformly equal to one.
538 bool m_isIdealSoln = false;
539
540 //! Current state of existence:
541 /*!
542 * - VCS_PHASE_EXIST_ZEROEDPHASE = -6: Set to not exist by fiat from a
543 * higher level. This is used in phase stability boundary calculations
544 * - VCS_PHASE_EXIST_NO = 0: Doesn't exist currently
545 * - VCS_PHASE_EXIST_YES = 2 : Does exist currently
546 * - VCS_PHASE_EXIST_ALWAYS = 3: Always exists because it contains inerts
547 * which can't exist in any other phase. Or, the phase exists always
548 * because it consists of a single species, which is identified with the
549 * voltage, for example, its an electron metal phase.
550 */
552
553 // Index of the first MF species in the list of unknowns for this phase
554 /*!
555 * This is always equal to zero.
556 * Am anticipating the case where the phase potential is species # 0,
557 * for multiphase phases. Right now we have the phase potential equal
558 * to 0 for single species phases, where we set by hand the mole fraction
559 * of species 0 to one.
560 */
562
563 //! Index into the species vectors
564 /*!
565 * Maps the phase species number into the global species number.
566 * Note, as part of the vcs algorithm, the order of the species
567 * vector is changed during the algorithm
568 */
569 vector<size_t> IndSpecies;
570
571 //! Vector of Species structures for the species belonging to this phase
572 /*!
573 * The index into this vector is the species index within the phase.
574 */
575 /**
576 * If we are using Cantera, this is the pointer to the ThermoPhase
577 * object. If not, this is null.
578 */
579 ThermoPhase* TP_ptr = nullptr;
580
581 //! Total mols in the phase. units are kmol
582 double v_totalMoles = 0.0;
583
584 //! Vector of the current mole fractions for species in the phase
585 vector<double> Xmol_;
586
587 //! Vector of current creationMoleNumbers_
588 /*!
589 * These are the actual unknowns in the phase stability problem
590 */
591 vector<double> creationMoleNumbers_;
592
593 //! Vector of creation global reaction numbers for the phase stability problem
594 /*!
595 * The phase stability problem requires a global reaction number for each
596 * species in the phase. Usually this is the krxn = kglob - M for species in
597 * the phase that are not components. For component species, the choice of
598 * the reaction is one which maximizes the chance that the phase pops into
599 * (or remains in) existence.
600 *
601 * The index here is the local phase species index. the value of the
602 * variable is the global vcs reaction number. Note, that the global
603 * reaction number will go out of order when the species positions are
604 * swapped. So, this number has to be recalculated.
605 *
606 * Length = number of species in phase
607 */
609
610 //! If the potential is a solution variable in VCS, it acts as a species.
611 //! This is the species index in the phase for the potential
613
614 //! Total Volume of the phase. Units are m**3.
615 mutable double m_totalVol = 0.0;
616
617 //! Vector of calculated SS0 chemical potentials for the
618 //! current Temperature.
619 /*!
620 * Note, This is the chemical potential derived strictly from the polynomial
621 * in temperature. Pressure effects have to be added in to get to the
622 * standard state. Units are J/kmol.
623 */
624 mutable vector<double> SS0ChemicalPotential;
625
626 //! Vector of calculated Star chemical potentials for the
627 //! current Temperature and pressure.
628 /*!
629 * Note, This is the chemical potential at unit activity. Thus, we can call
630 * it the standard state chemical potential as well. Units are J/kmol.
631 */
632 mutable vector<double> StarChemicalPotential;
633
634 //! Vector of the Star molar Volumes of the species. units m3 / kmol
635 mutable vector<double> StarMolarVol;
636
637 //! Vector of the Partial molar Volumes of the species. units m3 / kmol
638 mutable vector<double> PartialMolarVol;
639
640 //! Vector of calculated activity coefficients for the current state
641 /*!
642 * Whether or not this vector is current is determined by the bool
643 * #m_UpToDate_AC.
644 */
645 mutable vector<double> ActCoeff;
646
647 //! Vector of the derivatives of the ln activity coefficient wrt to the
648 //! current mole number multiplied by the current phase moles
649 /*!
650 * np_dLnActCoeffdMolNumber(k,j);
651 * - j = id of the species mole number
652 * - k = id of the species activity coefficient
653 */
655
656 //! Status
657 /*!
658 * valid values are
659 * - VCS_STATECALC_OLD
660 * - VCS_STATECALC_NEW
661 * - VCS_STATECALC_TMP
662 */
664
665 //! Value of the potential for the phase (Volts)
666 double m_phi = 0.0;
667
668 //! Boolean indicating whether the object has an up-to-date mole number vector
669 //! and potential with respect to the current vcs state calc status
670 bool m_UpToDate = false;
671
672 //! Boolean indicating whether activity coefficients are up to date.
673 /*!
674 * Activity coefficients and volume calculations are lagged. They are only
675 * called when they are needed (and when the state has changed so that they
676 * need to be recalculated).
677 */
678 mutable bool m_UpToDate_AC = false;
679
680 //! Boolean indicating whether Star volumes are up to date.
681 /*!
682 * Activity coefficients and volume calculations are lagged. They are only
683 * called when they are needed (and when the state has changed so that they
684 * need to be recalculated). Star volumes are sensitive to temperature and
685 * pressure
686 */
687 mutable bool m_UpToDate_VolStar = false;
688
689 //! Boolean indicating whether partial molar volumes are up to date.
690 /*!
691 * Activity coefficients and volume calculations are lagged. They are only
692 * called when they are needed (and when the state has changed so that they
693 * need to be recalculated). partial molar volumes are sensitive to
694 * everything
695 */
696 mutable bool m_UpToDate_VolPM = false;
697
698 //! Boolean indicating whether GStar is up to date.
699 /*!
700 * GStar is sensitive to the temperature and the pressure, only
701 */
702 mutable bool m_UpToDate_GStar = false;
703
704 //! Boolean indicating whether G0 is up to date.
705 /*!
706 * G0 is sensitive to the temperature and the pressure, only
707 */
708 mutable bool m_UpToDate_G0 = false;
709
710 //! Current value of the temperature for this object, and underlying objects
711 double Temp_ = 273.15;
712
713 //! Current value of the pressure for this object, and underlying objects
714 double Pres_ = OneAtm;
715};
716
717}
718
719#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.
void setMoleFractions(span< const double > xmol)
Set the mole fractions from a conventional mole fraction vector.
vector< double > StarChemicalPotential
Vector of calculated Star chemical potentials for the current Temperature and pressure.
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.
void setMolesFromVCS(const int stateCalc, span< const double > molesSpeciesVCS={})
Set the moles within the phase.
size_t nSpecies() const
Return the number of species in the phase.
string PhaseName
String name for 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.
void sendToVCS_ActCoeff(const int stateCalc, span< double > AC)
Fill in an activity coefficients vector within a VCS_SOLVE object.
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 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.
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.
span< const double > moleFractions() const
Return a const reference to the mole fractions stored in the object.
double GStar_calc_one(size_t kspec) const
Gibbs free energy calculation for standard state of one species.
void setMolesFromVCSCheck(const int vcsStateStatus, span< const double > molesSpeciesVCS, span< const double > TPhMoles)
Set the moles within the phase.
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 setCreationMoleNumbers(span< const double > n_k, span< const size_t > creationGlobalRxnNumbers)
Sets the creationMoleNum's within the phase object.
void setMolesCurrent(int vcsStateStatus)
Sets the mole flag within the object to be current.
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.
void sendToVCS_LnActCoeffJac(Array2D &LnACJac_VCS)
Downloads the ln ActCoeff Jacobian into the VCS version of the ln ActCoeff Jacobian.
span< const double > creationMoleNumbers(span< size_t > creationGlobalRxnNumbers) const
Return a const reference to the creationMoleNumbers stored in the object.
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 *.
void setMoleFractionsState(const double molNum, span< const double > moleFracVec, const int vcsStateStatus)
Set the moles and/or mole fractions within the phase.
ThermoPhase * TP_ptr
Vector of Species structures for the species belonging to this phase.
void _updateMoleFractionDependencies()
Updates the mole fraction dependencies.
double sendToVCS_VolPM(span< double > VolPM) const
Fill in the partial molar volume vector for VCS.
void sendToVCS_GStar(span< double > gstar) const
Fill in the standard state Gibbs free energy vector for VCS.
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.
bool m_UpToDate
Boolean indicating whether the object has an up-to-date mole number vector and potential with respect...
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:99
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:183
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