| 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
10#include "cantera/thermo/PDSS_IonsFromNeutral.h"
11#include "cantera/thermo/IonsFromNeutralVPSSTP.h"
12#include "cantera/base/stringUtils.h"
13#include "cantera/base/global.h"
14
15 namespace Cantera
16{
17
18 PDSS_IonsFromNeutral::PDSS_IonsFromNeutral()
19{
20 warn_deprecated("class PDSS_IonsFromNeutral", "To be removed after Cantera 3.0");
21}
22
23 void PDSS_IonsFromNeutral::setParent(VPStandardStateTP* phase, size_t k)
24{
25 neutralMoleculePhase_ = dynamic_cast<IonsFromNeutralVPSSTP&>(*phase).getNeutralMoleculePhase();
26}
27
28 void PDSS_IonsFromNeutral::setNeutralSpeciesMultiplier(const string& species, double mult)
29{
30 neutralSpeciesMultipliers_[species] = mult;
31 numMult_++;
32}
33
34 void PDSS_IonsFromNeutral::setSpecialSpecies(bool special) {
35 add2RTln2_ = !special;
36}
37
38 void PDSS_IonsFromNeutral::getParameters(AnyMap& eosNode) const
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
50 void PDSS_IonsFromNeutral::initThermo()
51{
52 PDSS::initThermo();
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();
63 m_minTemp = neutralMoleculePhase_->minTemp();
64 m_maxTemp = neutralMoleculePhase_->maxTemp();
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
72 double PDSS_IonsFromNeutral::enthalpy_RT() const
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
83 double PDSS_IonsFromNeutral::intEnergy_mole() const
84{
85 return (m_h0_RT - 1.0) * GasConstant * m_temp;
86}
87
88 double PDSS_IonsFromNeutral::entropy_R() const
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
102 double PDSS_IonsFromNeutral::gibbs_RT() const
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
116 double PDSS_IonsFromNeutral::cp_R() const
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
127 double PDSS_IonsFromNeutral::molarVolume() const
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
138 double PDSS_IonsFromNeutral::density() const
139{
140 return (m_pres * m_mw / (GasConstant * m_temp));
141}
142
143 double PDSS_IonsFromNeutral::gibbs_RT_ref() const
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
157 double PDSS_IonsFromNeutral::enthalpy_RT_ref() const
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
168 double PDSS_IonsFromNeutral::entropy_R_ref() const
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
182 double PDSS_IonsFromNeutral::cp_R_ref() const
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
193 double PDSS_IonsFromNeutral::molarVolume_ref() const
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
204 void 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}
IonsFromNeutralVPSSTP.h
Header for intermediate ThermoPhase object for phases which consist of ions whose thermodynamics is c...
PDSS_IonsFromNeutral.h
Declarations for the class PDSS_IonsFromNeutral ( which handles calculations for a single ion in a fl...
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
Cantera::AnyMap::hasKey
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
Definition AnyMap.cpp:1423
Cantera::AnyMap::getBool
bool getBool(const string &key, bool default_) const
If key exists, return it as a bool, otherwise return default_.
Definition AnyMap.cpp:1515
Cantera::IonsFromNeutralVPSSTP
The IonsFromNeutralVPSSTP is a derived class of ThermoPhase that handles the specification of the che...
Definition IonsFromNeutralVPSSTP.h:70
Cantera::PDSS_IonsFromNeutral::molarVolume
double molarVolume() const override
Return the molar volume at standard state.
Definition PDSS_IonsFromNeutral.cpp:127
Cantera::PDSS_IonsFromNeutral::setParent
void setParent(VPStandardStateTP *phase, size_t k) override
Set the parent VPStandardStateTP object of this PDSS object.
Definition PDSS_IonsFromNeutral.cpp:23
Cantera::PDSS_IonsFromNeutral::PDSS_IonsFromNeutral
PDSS_IonsFromNeutral()
Default constructor.
Definition PDSS_IonsFromNeutral.cpp:18
Cantera::PDSS_IonsFromNeutral::gibbs_RT_ref
double gibbs_RT_ref() const override
Return the molar Gibbs free energy divided by RT at reference pressure.
Definition PDSS_IonsFromNeutral.cpp:143
Cantera::PDSS_IonsFromNeutral::numMult_
size_t numMult_
Number of neutral molecule species that make up the stoichiometric vector for this species,...
Definition PDSS_IonsFromNeutral.h:106
Cantera::PDSS_IonsFromNeutral::cp_R
double cp_R() const override
Return the molar const pressure heat capacity divided by RT.
Definition PDSS_IonsFromNeutral.cpp:116
Cantera::PDSS_IonsFromNeutral::initThermo
void initThermo() override
Initialization routine.
Definition PDSS_IonsFromNeutral.cpp:50
Cantera::PDSS_IonsFromNeutral::tmpNM
vector< double > tmpNM
Vector of length equal to the number of species in the neutral molecule phase.
Definition PDSS_IonsFromNeutral.h:122
Cantera::PDSS_IonsFromNeutral::idNeutralMoleculeVec
vector< size_t > idNeutralMoleculeVec
Vector of species indices in the neutral molecule ThermoPhase.
Definition PDSS_IonsFromNeutral.h:109
Cantera::PDSS_IonsFromNeutral::entropy_R_ref
double entropy_R_ref() const override
Return the molar entropy divided by R at reference pressure.
Definition PDSS_IonsFromNeutral.cpp:168
Cantera::PDSS_IonsFromNeutral::enthalpy_RT_ref
double enthalpy_RT_ref() const override
Return the molar enthalpy divided by RT at reference pressure.
Definition PDSS_IonsFromNeutral.cpp:157
Cantera::PDSS_IonsFromNeutral::getParameters
void getParameters(AnyMap &eosNode) const override
Store the parameters needed to reconstruct a copy of this PDSS object.
Definition PDSS_IonsFromNeutral.cpp:38
Cantera::PDSS_IonsFromNeutral::intEnergy_mole
double intEnergy_mole() const override
Return the molar internal Energy in units of J kmol-1.
Definition PDSS_IonsFromNeutral.cpp:83
Cantera::PDSS_IonsFromNeutral::neutralMoleculePhase_
shared_ptr< ThermoPhase > neutralMoleculePhase_
Pointer to the Neutral Molecule ThermoPhase object.
Definition PDSS_IonsFromNeutral.h:100
Cantera::PDSS_IonsFromNeutral::setState_TP
void setState_TP(double temp, double pres) override
Set the internal temperature and pressure.
Definition PDSS_IonsFromNeutral.cpp:204
Cantera::PDSS_IonsFromNeutral::entropy_R
double entropy_R() const override
Return the standard state entropy divided by RT.
Definition PDSS_IonsFromNeutral.cpp:88
Cantera::PDSS_IonsFromNeutral::enthalpy_RT
double enthalpy_RT() const override
Return the standard state molar enthalpy divided by RT.
Definition PDSS_IonsFromNeutral.cpp:72
Cantera::PDSS_IonsFromNeutral::density
double density() const override
Return the standard state density at standard state.
Definition PDSS_IonsFromNeutral.cpp:138
Cantera::PDSS_IonsFromNeutral::add2RTln2_
bool add2RTln2_
Add 2RTln2 to the entropy and Gibbs free energies for this species.
Definition PDSS_IonsFromNeutral.h:119
Cantera::PDSS_IonsFromNeutral::molarVolume_ref
double molarVolume_ref() const override
Return the molar volume at reference pressure.
Definition PDSS_IonsFromNeutral.cpp:193
Cantera::PDSS_IonsFromNeutral::gibbs_RT
double gibbs_RT() const override
Return the molar Gibbs free energy divided by RT.
Definition PDSS_IonsFromNeutral.cpp:102
Cantera::PDSS_IonsFromNeutral::factorVec
vector< double > factorVec
Stoichiometric coefficient for this species using the Neutral Molecule Species in the vector idNeutra...
Definition PDSS_IonsFromNeutral.h:113
Cantera::PDSS_IonsFromNeutral::cp_R_ref
double cp_R_ref() const override
Return the molar heat capacity divided by R at reference pressure.
Definition PDSS_IonsFromNeutral.cpp:182
Cantera::PDSS_Nondimensional::m_h0_RT
double m_h0_RT
Reference state enthalpy divided by RT.
Definition PDSS.h:509
Cantera::PDSS::initThermo
virtual void initThermo()
Initialization routine.
Definition PDSS.h:418
Cantera::PDSS::m_p0
double m_p0
Reference state pressure of the species.
Definition PDSS.h:455
Cantera::PDSS::m_temp
double m_temp
Current temperature used by the PDSS object.
Definition PDSS.h:449
Cantera::PDSS::m_pres
double m_pres
State of the system - pressure.
Definition PDSS.h:452
Cantera::PDSS::m_maxTemp
double m_maxTemp
Maximum temperature.
Definition PDSS.h:461
Cantera::PDSS::m_minTemp
double m_minTemp
Minimum temperature.
Definition PDSS.h:458
Cantera::PDSS::m_mw
double m_mw
Molecular Weight of the species.
Definition PDSS.h:464
Cantera::PDSS::m_input
AnyMap m_input
Input data supplied via setParameters.
Definition PDSS.h:468
Cantera::PDSS::getParameters
virtual void getParameters(AnyMap &eosNode) const
Store the parameters needed to reconstruct a copy of this PDSS object.
Definition PDSS.h:427
Cantera::VPStandardStateTP
This is a filter class for ThermoPhase that implements some preparatory steps for efficiently handlin...
Definition VPStandardStateTP.h:44
global.h
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
Cantera::GasConstant
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition ct_defs.h:120
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
Cantera::warn_deprecated
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
stringUtils.h
Contains declarations for string manipulation functions within Cantera.