Cantera  3.0.0
Loading...
Searching...
No Matches
PDSS_IonsFromNeutral.cpp
Go to the documentation of this file.
1/**
2 * @file PDSS_IonsFromNeutral.cpp
3 * Implementation of a pressure dependent standard state
4 * virtual function.
5 */
6
7// This file is part of Cantera. See License.txt in the top-level directory or
8// at https://cantera.org/license.txt for license and copyright information.
9
13#include "cantera/base/global.h"
14
15namespace Cantera
16{
17
19{
20 warn_deprecated("class PDSS_IonsFromNeutral", "To be removed after Cantera 3.0");
21}
22
24{
25 neutralMoleculePhase_ = dynamic_cast<IonsFromNeutralVPSSTP&>(*phase).getNeutralMoleculePhase();
26}
27
28void PDSS_IonsFromNeutral::setNeutralSpeciesMultiplier(const string& species, double mult)
29{
30 neutralSpeciesMultipliers_[species] = mult;
31 numMult_++;
32}
33
34void PDSS_IonsFromNeutral::setSpecialSpecies(bool special) {
35 add2RTln2_ = !special;
36}
37
39{
40 PDSS::getParameters(eosNode);
41 eosNode["model"] = "ions-from-neutral-molecule";
42 if (!add2RTln2_) {
43 eosNode["special-species"] = true;
44 }
45 if (!neutralSpeciesMultipliers_.empty()) {
46 eosNode["multipliers"] = neutralSpeciesMultipliers_;
47 }
48}
49
51{
53 if (m_input.getBool("special-species", false)) {
54 setSpecialSpecies();
55 }
56 if (m_input.hasKey("multipliers")) {
57 for (const auto& [species, multiplier] : m_input["multipliers"].asMap<double>()) {
58 setNeutralSpeciesMultiplier(species, multiplier);
59 }
60 }
61
62 m_p0 = neutralMoleculePhase_->refPressure();
65 tmpNM.resize(neutralMoleculePhase_->nSpecies());
66 for (auto [species, multiplier] : neutralSpeciesMultipliers_) {
67 idNeutralMoleculeVec.push_back(neutralMoleculePhase_->speciesIndex(species));
68 factorVec.push_back(multiplier);
69 }
70}
71
73{
74 neutralMoleculePhase_->getEnthalpy_RT(tmpNM.data());
75 double val = 0.0;
76 for (size_t i = 0; i < numMult_; i++) {
77 size_t jNeut = idNeutralMoleculeVec[i];
78 val += factorVec[i] * tmpNM[jNeut];
79 }
80 return val;
81}
82
84{
85 return (m_h0_RT - 1.0) * GasConstant * m_temp;
86}
87
89{
90 neutralMoleculePhase_->getEntropy_R(tmpNM.data());
91 double val = 0.0;
92 for (size_t i = 0; i < numMult_; i++) {
93 size_t jNeut = idNeutralMoleculeVec[i];
94 val += factorVec[i] * tmpNM[jNeut];
95 }
96 if (add2RTln2_) {
97 val -= 2.0 * log(2.0);
98 }
99 return val;
100}
101
103{
104 neutralMoleculePhase_->getGibbs_RT(tmpNM.data());
105 double val = 0.0;
106 for (size_t i = 0; i < numMult_; i++) {
107 size_t jNeut = idNeutralMoleculeVec[i];
108 val += factorVec[i] * tmpNM[jNeut];
109 }
110 if (add2RTln2_) {
111 val += 2.0 * log(2.0);
112 }
113 return val;
114}
115
117{
118 neutralMoleculePhase_->getCp_R(tmpNM.data());
119 double val = 0.0;
120 for (size_t i = 0; i < numMult_; i++) {
121 size_t jNeut = idNeutralMoleculeVec[i];
122 val += factorVec[i] * tmpNM[jNeut];
123 }
124 return val;
125}
126
128{
129 neutralMoleculePhase_->getStandardVolumes(tmpNM.data());
130 double val = 0.0;
131 for (size_t i = 0; i < numMult_; i++) {
132 size_t jNeut = idNeutralMoleculeVec[i];
133 val += factorVec[i] * tmpNM[jNeut];
134 }
135 return val;
136}
137
139{
140 return (m_pres * m_mw / (GasConstant * m_temp));
141}
142
144{
145 neutralMoleculePhase_->getGibbs_RT_ref(tmpNM.data());
146 double val = 0.0;
147 for (size_t i = 0; i < numMult_; i++) {
148 size_t jNeut = idNeutralMoleculeVec[i];
149 val += factorVec[i] * tmpNM[jNeut];
150 }
151 if (add2RTln2_) {
152 val += 2.0 * log(2.0);
153 }
154 return val;
155}
156
158{
159 neutralMoleculePhase_->getEnthalpy_RT_ref(tmpNM.data());
160 double val = 0.0;
161 for (size_t i = 0; i < numMult_; i++) {
162 size_t jNeut = idNeutralMoleculeVec[i];
163 val += factorVec[i] * tmpNM[jNeut];
164 }
165 return val;
166}
167
169{
170 neutralMoleculePhase_->getEntropy_R_ref(tmpNM.data());
171 double val = 0.0;
172 for (size_t i = 0; i < numMult_; i++) {
173 size_t jNeut = idNeutralMoleculeVec[i];
174 val += factorVec[i] * tmpNM[jNeut];
175 }
176 if (add2RTln2_) {
177 val -= 2.0 * log(2.0);
178 }
179 return val;
180}
181
183{
184 neutralMoleculePhase_->getCp_R_ref(tmpNM.data());
185 double val = 0.0;
186 for (size_t i = 0; i < numMult_; i++) {
187 size_t jNeut = idNeutralMoleculeVec[i];
188 val += factorVec[i] * tmpNM[jNeut];
189 }
190 return val;
191}
192
194{
195 neutralMoleculePhase_->getStandardVolumes_ref(tmpNM.data());
196 double val = 0.0;
197 for (size_t i = 0; i < numMult_; i++) {
198 size_t jNeut = idNeutralMoleculeVec[i];
199 val += factorVec[i] * tmpNM[jNeut];
200 }
201 return val;
202}
203
204void PDSS_IonsFromNeutral::setState_TP(double temp, double pres)
205{
206 neutralMoleculePhase_->setState_TP(temp, pres);
207 m_pres = pres;
208 m_temp = temp;
209}
210
211}
Header for intermediate ThermoPhase object for phases which consist of ions whose thermodynamics is c...
Declarations for the class PDSS_IonsFromNeutral ( which handles calculations for a single ion in a fl...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
Definition AnyMap.cpp:1423
bool getBool(const string &key, bool default_) const
If key exists, return it as a bool, otherwise return default_.
Definition AnyMap.cpp:1515
The IonsFromNeutralVPSSTP is a derived class of ThermoPhase that handles the specification of the che...
double molarVolume() const override
Return the molar volume at standard state.
void setParent(VPStandardStateTP *phase, size_t k) override
Set the parent VPStandardStateTP object of this PDSS object.
PDSS_IonsFromNeutral()
Default constructor.
double gibbs_RT_ref() const override
Return the molar Gibbs free energy divided by RT at reference pressure.
size_t numMult_
Number of neutral molecule species that make up the stoichiometric vector for this species,...
double cp_R() const override
Return the molar const pressure heat capacity divided by RT.
void initThermo() override
Initialization routine.
vector< double > tmpNM
Vector of length equal to the number of species in the neutral molecule phase.
vector< size_t > idNeutralMoleculeVec
Vector of species indices in the neutral molecule ThermoPhase.
double entropy_R_ref() const override
Return the molar entropy divided by R at reference pressure.
double enthalpy_RT_ref() const override
Return the molar enthalpy divided by RT at reference pressure.
void getParameters(AnyMap &eosNode) const override
Store the parameters needed to reconstruct a copy of this PDSS object.
double intEnergy_mole() const override
Return the molar internal Energy in units of J kmol-1.
shared_ptr< ThermoPhase > neutralMoleculePhase_
Pointer to the Neutral Molecule ThermoPhase object.
void setState_TP(double temp, double pres) override
Set the internal temperature and pressure.
double entropy_R() const override
Return the standard state entropy divided by RT.
double enthalpy_RT() const override
Return the standard state molar enthalpy divided by RT.
double density() const override
Return the standard state density at standard state.
bool add2RTln2_
Add 2RTln2 to the entropy and Gibbs free energies for this species.
double molarVolume_ref() const override
Return the molar volume at reference pressure.
double gibbs_RT() const override
Return the molar Gibbs free energy divided by RT.
vector< double > factorVec
Stoichiometric coefficient for this species using the Neutral Molecule Species in the vector idNeutra...
double cp_R_ref() const override
Return the molar heat capacity divided by R at reference pressure.
double m_h0_RT
Reference state enthalpy divided by RT.
Definition PDSS.h:509
virtual void initThermo()
Initialization routine.
Definition PDSS.h:418
double m_p0
Reference state pressure of the species.
Definition PDSS.h:455
double m_temp
Current temperature used by the PDSS object.
Definition PDSS.h:449
double m_pres
State of the system - pressure.
Definition PDSS.h:452
double m_maxTemp
Maximum temperature.
Definition PDSS.h:461
double m_minTemp
Minimum temperature.
Definition PDSS.h:458
double m_mw
Molecular Weight of the species.
Definition PDSS.h:464
AnyMap m_input
Input data supplied via setParameters.
Definition PDSS.h:468
virtual void getParameters(AnyMap &eosNode) const
Store the parameters needed to reconstruct a copy of this PDSS object.
Definition PDSS.h:427
This is a filter class for ThermoPhase that implements some preparatory steps for efficiently handlin...
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition ct_defs.h:120
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.