Cantera  3.1.0a1
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
96bool GibbsExcessVPSSTP::addSpecies(shared_ptr<Species> spec)
97{
98 bool added = VPStandardStateTP::addSpecies(spec);
99 if (added) {
100 if (m_kk == 1) {
101 moleFractions_.push_back(1.0);
102 } else {
103 moleFractions_.push_back(0.0);
104 }
105 lnActCoeff_Scaled_.push_back(0.0);
106 dlnActCoeffdT_Scaled_.push_back(0.0);
107 d2lnActCoeffdT2_Scaled_.push_back(0.0);
108 dlnActCoeffdlnX_diag_.push_back(0.0);
109 dlnActCoeffdlnN_diag_.push_back(0.0);
111 }
112 return added;
113}
114
115} // 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
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...
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:597
size_t m_kk
Number of species in the phase.
Definition Phase.h:842
double meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
Definition Phase.h:655
void getMoleFractions(double *const x) const
Get the species mole fraction vector.
Definition Phase.cpp:434
virtual void compositionChanged()
Apply changes to the state which are needed after the composition changes.
Definition Phase.cpp:905
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
Contains declarations for string manipulation functions within Cantera.