*** empty log message ***
This commit is contained in:
parent
33b114b178
commit
1023b2bbcb
7 changed files with 164 additions and 186 deletions
127
Cantera/src/LatticePhase.cpp
Normal file
127
Cantera/src/LatticePhase.cpp
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/**
|
||||
*
|
||||
* @file LatticePhase.cpp
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#pragma warning(disable:4503)
|
||||
#endif
|
||||
|
||||
#include "ct_defs.h"
|
||||
#include "mix_defs.h"
|
||||
#include "LatticePhase.h"
|
||||
#include "SpeciesThermo.h"
|
||||
|
||||
namespace Cantera {
|
||||
|
||||
doublereal LatticePhase::
|
||||
enthalpy_mole() const {
|
||||
doublereal p0 = m_spthermo->refPressure();
|
||||
return GasConstant * temperature() *
|
||||
mean_X(&enthalpy_RT()[0])
|
||||
+ (pressure() - p0)/molarDensity();
|
||||
}
|
||||
|
||||
doublereal LatticePhase::intEnergy_mole() const {
|
||||
doublereal p0 = m_spthermo->refPressure();
|
||||
return GasConstant * temperature() *
|
||||
mean_X(&enthalpy_RT()[0])
|
||||
- p0/molarDensity();
|
||||
}
|
||||
|
||||
doublereal LatticePhase::entropy_mole() const {
|
||||
return GasConstant * (mean_X(&entropy_R()[0]) -
|
||||
sum_xlogx());
|
||||
}
|
||||
|
||||
doublereal LatticePhase::gibbs_mole() const {
|
||||
return enthalpy_mole() - temperature() * entropy_mole();
|
||||
}
|
||||
|
||||
doublereal LatticePhase::cp_mole() const {
|
||||
return GasConstant * mean_X(&cp_R()[0]);
|
||||
}
|
||||
|
||||
void LatticePhase::getActivityConcentrations(doublereal* c) const {
|
||||
getMoleFractions(c);
|
||||
}
|
||||
|
||||
void LatticePhase::getActivityCoefficients(doublereal* ac) const {
|
||||
for (int k = 0; k < m_kk; k++) {
|
||||
ac[k] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
doublereal LatticePhase::standardConcentration(int k) const {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
doublereal LatticePhase::logStandardConc(int k) const {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void LatticePhase::getChemPotentials(doublereal* mu) const {
|
||||
doublereal vdp = (pressure() - m_spthermo->refPressure())/
|
||||
molarDensity();
|
||||
doublereal xx;
|
||||
doublereal rt = temperature() * GasConstant;
|
||||
const array_fp& g_RT = gibbs_RT();
|
||||
for (int k = 0; k < m_kk; k++) {
|
||||
xx = fmaxx(SmallNumber, moleFraction(k));
|
||||
mu[k] = rt*(g_RT[k] + log(xx)) + vdp;
|
||||
}
|
||||
}
|
||||
|
||||
void LatticePhase::getStandardChemPotentials(doublereal* mu0) const {
|
||||
getPureGibbs(mu0);
|
||||
}
|
||||
|
||||
void LatticePhase::initThermo() {
|
||||
m_kk = nSpecies();
|
||||
m_mm = nElements();
|
||||
doublereal tmin = m_spthermo->minTemp();
|
||||
doublereal tmax = m_spthermo->maxTemp();
|
||||
if (tmin > 0.0) m_tmin = tmin;
|
||||
if (tmax > 0.0) m_tmax = tmax;
|
||||
m_p0 = refPressure();
|
||||
|
||||
int leng = m_kk;
|
||||
m_h0_RT.resize(leng);
|
||||
m_g0_RT.resize(leng);
|
||||
m_cp0_R.resize(leng);
|
||||
m_s0_R.resize(leng);
|
||||
setMolarDensity(m_molar_density);
|
||||
}
|
||||
|
||||
|
||||
void LatticePhase::_updateThermo() const {
|
||||
doublereal tnow = temperature();
|
||||
if (fabs(molarDensity() - m_molar_density)/m_molar_density > 0.0001) {
|
||||
throw CanteraError("_updateThermo","molar density changed from "
|
||||
+fp2str(m_molar_density)+" to "+fp2str(molarDensity()));
|
||||
}
|
||||
if (m_tlast != tnow) {
|
||||
m_spthermo->update(tnow, &m_cp0_R[0], &m_h0_RT[0],
|
||||
&m_s0_R[0]);
|
||||
m_tlast = tnow;
|
||||
int k;
|
||||
for (k = 0; k < m_kk; k++) {
|
||||
m_g0_RT[k] = m_h0_RT[k] - m_s0_R[k];
|
||||
}
|
||||
m_tlast = tnow;
|
||||
}
|
||||
}
|
||||
|
||||
void LatticePhase::setParametersFromXML(const XML_Node& eosdata) {
|
||||
eosdata._require("model","Lattice");
|
||||
m_molar_density = getFloat(i, "site_density", "-");
|
||||
m_vacancy = getString(i, "vacancy_species");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,176 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* @file LatticeSolidPhase.cpp
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#pragma warning(disable:4503)
|
||||
#endif
|
||||
|
||||
#include "ct_defs.h"
|
||||
#include "mix_defs.h"
|
||||
#include "LatticeSolidPhase.h"
|
||||
#include "SpeciesThermo.h"
|
||||
|
||||
namespace Cantera {
|
||||
|
||||
doublereal LatticeSolidPhase::
|
||||
enthalpy_mole() const {
|
||||
doublereal p0 = m_spthermo->refPressure();
|
||||
return GasConstant * temperature() *
|
||||
mean_X(&enthalpy_RT()[0])
|
||||
+ (pressure() - p0)/molarDensity();
|
||||
}
|
||||
|
||||
doublereal LatticeSolidPhase::intEnergy_mole() const {
|
||||
doublereal p0 = m_spthermo->refPressure();
|
||||
return GasConstant * temperature() *
|
||||
mean_X(&enthalpy_RT()[0])
|
||||
- p0/molarDensity();
|
||||
}
|
||||
|
||||
doublereal LatticeSolidPhase::entropy_mole() const {
|
||||
return GasConstant * (mean_X(&entropy_R()[0]) -
|
||||
sum_xlogx());
|
||||
}
|
||||
|
||||
doublereal LatticeSolidPhase::gibbs_mole() const {
|
||||
return enthalpy_mole() - temperature() * entropy_mole();
|
||||
}
|
||||
|
||||
doublereal LatticeSolidPhase::cp_mole() const {
|
||||
return GasConstant * mean_X(&cp_R()[0]);
|
||||
}
|
||||
|
||||
void LatticeSolidPhase::getActivityConcentrations(doublereal* c) const {
|
||||
getMoleFractions(c);
|
||||
}
|
||||
|
||||
void LatticeSolidPhase::getActivityCoefficients(doublereal* ac) const {
|
||||
for (int k = 0; k < m_kk; k++) {
|
||||
ac[k] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
doublereal LatticeSolidPhase::standardConcentration(int k) const {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
doublereal LatticeSolidPhase::logStandardConc(int k) const {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void LatticeSolidPhase::getChemPotentials(doublereal* mu) const {
|
||||
doublereal vdp = (pressure() - m_spthermo->refPressure())/
|
||||
molarDensity();
|
||||
doublereal xx;
|
||||
doublereal rt = temperature() * GasConstant;
|
||||
const array_fp& g_RT = gibbs_RT();
|
||||
for (int k = 0; k < m_kk; k++) {
|
||||
xx = fmaxx(SmallNumber, moleFraction(k));
|
||||
mu[k] = rt*(g_RT[k] + log(xx)) + vdp;
|
||||
}
|
||||
}
|
||||
|
||||
void LatticeSolidPhase::getStandardChemPotentials(doublereal* mu0) const {
|
||||
getPureGibbs(mu0);
|
||||
}
|
||||
|
||||
void LatticeSolidPhase::initThermo() {
|
||||
m_kk = nSpecies();
|
||||
m_mm = nElements();
|
||||
doublereal tmin = m_spthermo->minTemp();
|
||||
doublereal tmax = m_spthermo->maxTemp();
|
||||
if (tmin > 0.0) m_tmin = tmin;
|
||||
if (tmax > 0.0) m_tmax = tmax;
|
||||
m_p0 = refPressure();
|
||||
|
||||
int leng = m_kk;
|
||||
m_h0_RT.resize(leng);
|
||||
m_g0_RT.resize(leng);
|
||||
m_cp0_R.resize(leng);
|
||||
m_s0_R.resize(leng);
|
||||
setMolarDensity(m_molar_density);
|
||||
|
||||
const vector<string>& spnames = speciesNames();
|
||||
int n, k, kl, namesize;
|
||||
int nl = m_sitedens.size();
|
||||
string s;
|
||||
m_lattice.resize(m_kk,-1);
|
||||
vector_fp conc(m_kk, 0.0);
|
||||
|
||||
compositionMap xx;
|
||||
for (n = 0; n < nl; n++) {
|
||||
for (k = 0; k < m_kk; k++) {
|
||||
xx[speciesName(k)] = -1.0;
|
||||
}
|
||||
parseCompString(m_sp[n], xx);
|
||||
for (k = 0; k < m_kk; k++) {
|
||||
if (xx[speciesName(k)] != -1.0) {
|
||||
conc[k] = m_sitedens[n]*xx[speciesName(k)];
|
||||
m_lattice[k] = n;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for (k = 0; k < m_kk; k++) {
|
||||
if (m_lattice[k] == -1) {
|
||||
throw CanteraError("LatticeSolidPhase::"
|
||||
"setParametersFromXML","Species "+speciesName(k)
|
||||
+" not a member of any lattice.");
|
||||
}
|
||||
}
|
||||
setMoleFractions(DATA_PTR(conc));
|
||||
}
|
||||
|
||||
|
||||
void LatticeSolidPhase::_updateThermo() const {
|
||||
doublereal tnow = temperature();
|
||||
if (fabs(molarDensity() - m_molar_density)/m_molar_density > 0.0001) {
|
||||
throw CanteraError("_updateThermo","molar density changed from "
|
||||
+fp2str(m_molar_density)+" to "+fp2str(molarDensity()));
|
||||
}
|
||||
if (m_tlast != tnow) {
|
||||
m_spthermo->update(tnow, &m_cp0_R[0], &m_h0_RT[0],
|
||||
&m_s0_R[0]);
|
||||
m_tlast = tnow;
|
||||
int k;
|
||||
for (k = 0; k < m_kk; k++) {
|
||||
m_g0_RT[k] = m_h0_RT[k] - m_s0_R[k];
|
||||
}
|
||||
m_tlast = tnow;
|
||||
}
|
||||
}
|
||||
|
||||
void LatticeSolidPhase::setParametersFromXML(const XML_Node& eosdata) {
|
||||
eosdata._require("model","LatticeSolid");
|
||||
XML_Node& la = eosdata.child("LatticeArray");
|
||||
vector<XML_Node*> lattices;
|
||||
la.getChildren("Lattice",lattices);
|
||||
int n;
|
||||
int nl = lattices.size();
|
||||
doublereal site_density;
|
||||
string vacancy;
|
||||
doublereal sum = 0.0;
|
||||
string s;
|
||||
for (n = 0; n < nl; n++) {
|
||||
XML_Node& i = *lattices[n];
|
||||
site_density = getFloat(i, "site_density", "-");
|
||||
vacancy = getString(i, "vacancy_species");
|
||||
s = getString(i, "species");
|
||||
m_sp.push_back(s);
|
||||
m_vac.push_back(vacancy);
|
||||
m_sitedens.push_back(site_density);
|
||||
sum += site_density;
|
||||
}
|
||||
m_molar_density = sum;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* @file LatticeSolidPhase.h
|
||||
* @file LatticePhase.h
|
||||
*/
|
||||
|
||||
/* $Author$
|
||||
|
|
@ -11,8 +11,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef CT_LATTICESOLID_H
|
||||
#define CT_LATTICESOLID_H
|
||||
#ifndef CT_LATTICE_H
|
||||
#define CT_LATTICE_H
|
||||
|
||||
#include "ct_defs.h"
|
||||
#include "mix_defs.h"
|
||||
|
|
@ -23,18 +23,16 @@
|
|||
namespace Cantera {
|
||||
|
||||
/**
|
||||
* Overloads the virtual methods of class Thermo to implement the
|
||||
* incompressible equation of state.
|
||||
*/
|
||||
class LatticeSolidPhase : public ThermoPhase {
|
||||
class LatticePhase : public ThermoPhase {
|
||||
|
||||
public:
|
||||
|
||||
LatticeSolidPhase() : m_tlast(0.0) {}
|
||||
LatticePhase() : m_tlast(0.0) {}
|
||||
|
||||
virtual ~LatticeSolidPhase() {}
|
||||
virtual ~LatticePhase() {}
|
||||
|
||||
virtual int eosType() const { return cLatticeSolid; }
|
||||
virtual int eosType() const { return cLattice; }
|
||||
|
||||
virtual doublereal enthalpy_mole() const;
|
||||
|
||||
|
|
@ -42,6 +42,7 @@ namespace Cantera {
|
|||
const int cStoichSubstance = 5; // StoichSubstance.h
|
||||
|
||||
const int cLatticeSolid = 20; // LatticeSolidPhase.h
|
||||
const int cLattice = 21;
|
||||
|
||||
// pure fluids with liquid/vapor eqs of state
|
||||
const int cPureFluid = 10;
|
||||
|
|
|
|||
|
|
@ -124,6 +124,33 @@ namespace Cantera {
|
|||
while (s != "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse a composition string.
|
||||
*/
|
||||
void split(const string ss, vector<string>& w) {
|
||||
string s = ss;
|
||||
string::size_type icolon, ibegin, iend;
|
||||
string name, num, nm;
|
||||
do {
|
||||
ibegin = s.find_first_not_of(", ;\n\t");
|
||||
if (ibegin != string::npos) {
|
||||
s = s.substr(ibegin,s.size());
|
||||
iend = s.find_first_of(", ;\n\t");
|
||||
if (iend != string::npos) {
|
||||
w.push_back(s.substr(0, iend));
|
||||
s = s.substr(iend+1, s.size());
|
||||
}
|
||||
else {
|
||||
w.push_back(s.substr(0, s.size()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (s != "");
|
||||
}
|
||||
|
||||
int fillArrayFromString(const string& str, doublereal* a, char delim) {
|
||||
string::size_type iloc;
|
||||
int count = 0;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ namespace Cantera {
|
|||
string stripnonprint(string s);
|
||||
string lowercase(string s);
|
||||
void parseCompString(const string ss, compositionMap& x);
|
||||
void split(const string ss, vector<string>& w);
|
||||
int fillArrayFromString(const string& str, doublereal* a, char delim = ' ');
|
||||
string report(const ThermoPhase& th, bool show_thermo = true);
|
||||
string formatCompList(const Phase& mix, int xyc);
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ namespace Cantera {
|
|||
* and
|
||||
* \f[
|
||||
* \Phi_{k,j} = \frac{\left[1
|
||||
* + \sqrt\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_k}}\right)\right]^2}
|
||||
* + \sqrt{\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_k}}\right)}\right]^2}
|
||||
* {\sqrt{8}\sqrt{1 + M_k/M_j}}
|
||||
* \f]
|
||||
* @see updateViscosity_T();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue