Cantera  3.0.0
Loading...
Searching...
No Matches
GibbsExcessVPSSTP.cpp
Go to the documentation of this file.
1/**
2 * @file GibbsExcessVPSSTP.cpp
3 * Definitions for intermediate ThermoPhase object for phases which
4 * employ excess Gibbs free energy formulations
5 * (see @ref thermoprops and class @link Cantera::GibbsExcessVPSSTP GibbsExcessVPSSTP@endlink).
6 *
7 * Header file for a derived class of ThermoPhase that handles variable pressure
8 * standard state methods for calculating thermodynamic properties that are
9 * further based upon expressions for the excess Gibbs free energy expressed as
10 * a function of the mole fractions.
11 */
12
13// This file is part of Cantera. See License.txt in the top-level directory or
14// at https://cantera.org/license.txt for license and copyright information.
15
18#include "cantera/base/global.h"
19#include <numeric>
20
21namespace Cantera
22{
23
25{
28}
29
30// ------------ Mechanical Properties ------------------------------
31
33{
34 const vector<double>& vbar = getStandardVolumes();
35 double vtotal = 0.0;
36 for (size_t i = 0; i < m_kk; i++) {
37 vtotal += vbar[i] * moleFractions_[i];
38 }
39 double dd = meanMolecularWeight() / vtotal;
41}
42
43// - Activities, Standard States, Activity Concentrations -----------
44
46{
47 return Units(1.0); // dimensionless
48}
49
51{
53}
54
56{
57 return 1.0;
58}
59
61{
62 return 0.0;
63}
64
66{
69 for (size_t k = 0; k < m_kk; k++) {
70 ac[k] *= moleFractions_[k];
71 }
72}
73
75{
77 for (size_t k = 0; k < m_kk; k++) {
78 if (ac[k] > 700.) {
79 ac[k] = exp(700.0);
80 } else if (ac[k] < -700.) {
81 ac[k] = exp(-700.0);
82 } else {
83 ac[k] = exp(ac[k]);
84 }
85 }
86}
87
88// ------------ Partial Molar Properties of the Solution ------------
89
91{
92 // Get the standard state values in m^3 kmol-1
94}
95
97{
98 warn_deprecated("GibbsExcessVPSSTP::getPartialMolarVolumesVector",
99 "Unused. To be removed after Cantera 3.0.");
100 return getStandardVolumes();
101}
102
103double GibbsExcessVPSSTP::checkMFSum(const double* const x) const
104{
105 warn_deprecated("GibbsExcessVPSSTP::checkMFSum",
106 "Unused. To be removed after Cantera 3.0");
107 double norm = std::accumulate(x, x + m_kk, 0.0);
108 if (fabs(norm - 1.0) > 1.0E-9) {
109 throw CanteraError("GibbsExcessVPSSTP::checkMFSum",
110 "(MF sum - 1) exceeded tolerance of 1.0E-9: {}", norm);
111 }
112 return norm;
113}
114
115bool GibbsExcessVPSSTP::addSpecies(shared_ptr<Species> spec)
116{
117 bool added = VPStandardStateTP::addSpecies(spec);
118 if (added) {
119 if (m_kk == 1) {
120 moleFractions_.push_back(1.0);
121 } else {
122 moleFractions_.push_back(0.0);
123 }
124 lnActCoeff_Scaled_.push_back(0.0);
125 dlnActCoeffdT_Scaled_.push_back(0.0);
126 d2lnActCoeffdT2_Scaled_.push_back(0.0);
127 dlnActCoeffdlnX_diag_.push_back(0.0);
128 dlnActCoeffdlnN_diag_.push_back(0.0);
130 }
131 return added;
132}
133
134} // end of namespace Cantera
Header for intermediate ThermoPhase object for phases which employ Gibbs excess free energy based for...
virtual void resize(size_t n, size_t m, double v=0.0)
Resize the array, and fill the new entries with 'v'.
Definition Array.cpp:47
Base class for exceptions thrown by Cantera classes.
vector< double > d2lnActCoeffdT2_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
double logStandardConc(size_t k=0) const override
Natural logarithm of the standard concentration of the kth species.
Array2D dlnActCoeffdlnN_
Storage for the current derivative values of the gradients with respect to logarithm of the species m...
virtual const vector< double > & getPartialMolarVolumesVector() const
double checkMFSum(const double *const x) const
utility routine to check mole fraction sum
vector< double > lnActCoeff_Scaled_
Storage for the current values of the activity coefficients of the species.
void getActivityConcentrations(double *c) const override
This method returns an array of generalized concentrations.
void getPartialMolarVolumes(double *vbar) const override
Return an array of partial molar volumes for the species in the mixture.
vector< double > dlnActCoeffdlnX_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
vector< double > moleFractions_
Storage for the current values of the mole fractions of the species.
vector< double > dlnActCoeffdT_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
void calcDensity() override
Calculate the density of the mixture using the partial molar volumes and mole fractions as input.
void getActivities(double *ac) const override
Get the array of non-dimensional activities (molality based for this class and classes that derive fr...
Units standardConcentrationUnits() const override
Returns the units of the "standard concentration" for this phase.
void compositionChanged() override
Apply changes to the state which are needed after the composition changes.
double standardConcentration(size_t k=0) const override
The standard concentration used to normalize the generalized concentration.
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
void getActivityCoefficients(double *ac) const override
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
vector< double > dlnActCoeffdlnN_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
void assignDensity(const double density_)
Set the internally stored constant density (kg/m^3) of the phase.
Definition Phase.cpp:718
size_t m_kk
Number of species in the phase.
Definition Phase.h:947
double meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
Definition Phase.h:760
void getMoleFractions(double *const x) const
Get the species mole fraction vector.
Definition Phase.cpp:540
virtual void compositionChanged()
Apply changes to the state which are needed after the composition changes.
Definition Phase.cpp:1026
virtual void getLnActivityCoefficients(double *lnac) const
Get the array of non-dimensional molar-based ln activity coefficients at the current solution tempera...
A representation of the units associated with a dimensional quantity.
Definition Units.h:35
void getStandardVolumes(double *vol) const override
Get the molar volumes of the species standard states at the current T and P of the solution.
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Definition AnyMap.cpp:1926
Contains declarations for string manipulation functions within Cantera.