merged changes from branch

This commit is contained in:
Dave Goodwin 2005-01-07 10:26:43 +00:00
parent 41a7a55a24
commit cb27d211e3
28 changed files with 684 additions and 395 deletions

View file

@ -35,14 +35,14 @@ inline XML_Node* _xml(int i) {
#ifdef INCL_PURE_FLUID
static PureFluid* purefluid(int n) {
static PureFluidPhase* purefluid(int n) {
try {
ThermoPhase* tp = th(n);
if (tp->eosType() == cPureFluid) {
return (PureFluid*)tp;
return (PureFluidPhase*)tp;
}
else {
throw CanteraError("purefluid","object is not a PureFluid object");
throw CanteraError("purefluid","object is not a PureFluidPhase object");
}
}
catch (CanteraError) {
@ -744,6 +744,46 @@ extern "C" {
}
int DLL_EXPORT kin_getDelta(int n, int job, int len, double* delta) {
try {
Kinetics* k = kin(n);
if (len < k->nReactions()) return ERR;
switch (job) {
case 0:
k->getDeltaEnthalpy(delta); break;
case 1:
k->getDeltaGibbs(delta); break;
case 2:
k->getDeltaEntropy(delta); break;
case 3:
k->getDeltaSSEnthalpy(delta); break;
case 4:
k->getDeltaSSGibbs(delta); break;
case 5:
k->getDeltaSSEntropy(delta); break;
default:
return ERR;
}
return 0;
}
catch (CanteraError) {return -1;}
}
int DLL_EXPORT kin_getDeltaEntropy(int n, int len, double* deltaS) {
try {
Kinetics* k = kin(n);
if (len >= k->nReactions()) {
k->getDeltaEntropy(deltaS);
return 0;
}
else
return ERR;
}
catch (CanteraError) {return -1;}
}
int DLL_EXPORT kin_getCreationRates(int n, int len, double* cdot) {
try {
Kinetics* k = kin(n);

View file

@ -106,7 +106,7 @@ extern "C" {
int DLL_IMPORT kin_getFwdRateConstants(int n, int len, double* kfwd);
int DLL_IMPORT kin_getRevRateConstants(int n, int doIrreversible, int len, double* krev);
int DLL_IMPORT kin_getActivationEnergies(int n, int len, double* E);
int DLL_IMPORT kin_getDelta(int n, int job, int len, double* delta);
int DLL_IMPORT kin_getCreationRates(int n, int len, double* cdot);
int DLL_IMPORT kin_getDestructionRates(int n, int len, double* ddot);
int DLL_IMPORT kin_getNetProductionRates(int n, int len, double* wdot);

View file

@ -8,7 +8,7 @@ CTNEW = ctnew
.SUFFIXES :
.SUFFIXES : .mak
SRCS = kinetics1.cpp flamespeed.cpp
SRCS = kinetics1.cpp flamespeed.cpp rankine.cpp
OBJS = $(SRCS:.cpp=.o)
EXES = $(SRCS:.cpp=.x)

View file

@ -0,0 +1,89 @@
// An open Rankine cycle
#include <string>
#include <map>
#include <cantera/Cantera.h>
#include <cantera/PureFluid.h> // defines class Water
using namespace Cantera;
map<string,double> h;
map<string,double> s;
map<string,double> T;
map<string,double> P;
map<string,double> x;
vector<string> states;
template<class F>
void saveState(F& fluid, string name) {
h[name] = fluid.enthalpy_mass();
s[name] = fluid.entropy_mass();
T[name] = fluid.temperature();
P[name] = fluid.pressure();
x[name] = fluid.vaporFraction();
states.push_back(name);
}
void printStates() {
string name;
int n;
int nStates = states.size();
for (n = 0; n < nStates; n++) {
name = states[n];
printf(" %5s %10.6g %10.6g %12.6g %12.6g %5.2g \n",
name.c_str(), T[name], P[name], h[name], s[name], x[name]);
}
}
void openRankine() {
double etap = 0.6; // pump isentropic efficiency
double etat = 0.8; // turbine isentropic efficiency
double phigh = 8.0e5; // high pressure
Water w;
// begin with water at 300 K, 1 atm
w.setState_TP(300.0, OneAtm);
saveState(w,"1");
// pump water to 0.8 MPa
w.setState_SP(s["1"], phigh);
saveState(w,"2s");
double h2 = (h["2s"] - h["1"])/etap + h["1"];
w.setState_HP(h2, phigh);
saveState(w,"2");
// heat to saturated vapor
w.setState_Psat(phigh, 1.0);
saveState(w,"3");
// expand to 1 atm
w.setState_SP(s["3"], OneAtm);
saveState(w,"4s");
double work_s = h["3"] - h["4s"];
double work = etat*work_s;
w.setState_HP(h["3"] - work, OneAtm);
saveState(w,"4");
printStates();
double heat_in = h["3"] - h["2"];
double efficiency = work/heat_in;
cout << "efficiency = " << efficiency << endl;
}
int main() {
try {
openRankine();
}
catch (CanteraError) {
showErrors(cout);
}
}

View file

@ -1,5 +1,5 @@
/**
* @file writelog.cpp
* @file cxx/src/writelog.cpp
*/
/*

View file

@ -1,5 +1,5 @@
/**
* @file Constituents.cpp.
* @file Constituents.cpp
* Implementation file for class Constituents
*/

View file

@ -112,10 +112,6 @@ namespace Cantera {
}
#endif
/**
* Multiply \c A*b and return the result in \c prod. Uses BLAS
* routine DGEMV.
*/
void multiply(const DenseMatrix& A, const double* b, double* prod) {
ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose,
static_cast<int>(A.nRows()), static_cast<int>(A.nColumns()), 1.0,
@ -129,10 +125,6 @@ namespace Cantera {
A.begin(), static_cast<int>(A.nRows()), b, 1, 1.0, prod, 1);
}
/**
* invert A. A is overwritten with A^-1.
*/
int invert(DenseMatrix& A, int nn) {
integer n = (nn > 0 ? nn : static_cast<int>(A.nRows()));
int info=0;

View file

@ -1,5 +1,5 @@
/**
* @file Reactor.cpp
* @file ImplicitChem.cpp
*/
/* $Author$

View file

@ -384,6 +384,188 @@ namespace Cantera {
}
/**
*
* getDeltaGibbs():
*
* Return the vector of values for the reaction gibbs free energy
* change
* These values depend upon the concentration
* of the ideal gas.
*
* units = J kmol-1
*/
void InterfaceKinetics::getDeltaGibbs(doublereal* deltaG) {
/*
* Get the chemical potentials of the species in the
* ideal gas solution.
*/
int np = nPhases();
int n;
for (n = 0; n < np; n++) {
thermo(n).getChemPotentials(m_grt.begin() + m_start[n]);
}
/*
* Use the stoichiometric manager to find deltaG for each
* reaction.
*/
m_rxnstoich.getReactionDelta(m_ii, m_grt.begin(), deltaG);
}
/**
*
* getDeltaEnthalpy():
*
* Return the vector of values for the reactions change in
* enthalpy.
* These values depend upon the concentration
* of the solution.
*
* units = J kmol-1
*/
void InterfaceKinetics::getDeltaEnthalpy(doublereal* deltaH) {
/*
* Get the partial molar enthalpy of all species in the
* ideal gas.
*/
int np = nPhases();
int n;
for (n = 0; n < np; n++) {
thermo(n).getPartialMolarEnthalpies(m_grt.begin() + m_start[n]);
}
/*
* Use the stoichiometric manager to find deltaG for each
* reaction.
*/
m_rxnstoich.getReactionDelta(m_ii, m_grt.begin(), deltaH);
}
/************************************************************************
*
* getDeltaEntropy():
*
* Return the vector of values for the reactions change in
* entropy.
* These values depend upon the concentration
* of the solution.
*
* units = J kmol-1 Kelvin-1
*/
void InterfaceKinetics::getDeltaEntropy( doublereal* deltaS) {
/*
* Get the partial molar entropy of all species in the
* solid solution.
*/
int np = nPhases();
int n;
for (n = 0; n < np; n++) {
thermo(n).getPartialMolarEntropies(m_grt.begin() + m_start[n]);
}
/*
* Use the stoichiometric manager to find deltaS for each
* reaction.
*/
m_rxnstoich.getReactionDelta(m_ii, m_grt.begin(), deltaS);
}
/**
*
* getDeltaSSGibbs():
*
* Return the vector of values for the reaction
* standard state gibbs free energy change.
* These values don't depend upon the concentration
* of the solution.
*
* units = J kmol-1
*/
void InterfaceKinetics::getDeltaSSGibbs(doublereal* deltaG) {
/*
* Get the standard state chemical potentials of the species.
* This is the array of chemical potentials at unit activity
* We define these here as the chemical potentials of the pure
* species at the temperature and pressure of the solution.
*/
int np = nPhases();
int n;
for (n = 0; n < np; n++) {
thermo(n).getStandardChemPotentials(m_grt.begin() + m_start[n]);
}
/*
* Use the stoichiometric manager to find deltaG for each
* reaction.
*/
m_rxnstoich.getReactionDelta(m_ii, m_grt.begin(), deltaG);
}
/**
*
* getDeltaSSEnthalpy():
*
* Return the vector of values for the change in the
* standard state enthalpies of reaction.
* These values don't depend upon the concentration
* of the solution.
*
* units = J kmol-1
*/
void InterfaceKinetics::getDeltaSSEnthalpy(doublereal* deltaH) {
/*
* Get the standard state enthalpies of the species.
* This is the array of chemical potentials at unit activity
* We define these here as the enthalpies of the pure
* species at the temperature and pressure of the solution.
*/
int np = nPhases();
int n;
for (n = 0; n < np; n++) {
thermo(n).getEnthalpy_RT(m_grt.begin() + m_start[n]);
}
doublereal RT = thermo().temperature() * GasConstant;
for (int k = 0; k < m_kk; k++) {
m_grt[k] *= RT;
}
/*
* Use the stoichiometric manager to find deltaG for each
* reaction.
*/
m_rxnstoich.getReactionDelta(m_ii, m_grt.begin(), deltaH);
}
/*********************************************************************
*
* getDeltaSSEntropy():
*
* Return the vector of values for the change in the
* standard state entropies for each reaction.
* These values don't depend upon the concentration
* of the solution.
*
* units = J kmol-1 Kelvin-1
*/
void InterfaceKinetics::getDeltaSSEntropy(doublereal* deltaS) {
/*
* Get the standard state entropy of the species.
* We define these here as the entropies of the pure
* species at the temperature and pressure of the solution.
*/
int np = nPhases();
int n;
for (n = 0; n < np; n++) {
thermo(n).getEntropy_R(m_grt.begin() + m_start[n]);
}
doublereal R = GasConstant;
for (int k = 0; k < m_kk; k++) {
m_grt[k] *= R;
}
/*
* Use the stoichiometric manager to find deltaS for each
* reaction.
*/
m_rxnstoich.getReactionDelta(m_ii, m_grt.begin(), deltaS);
}
/**
* Add a single reaction to the mechanism. This routine
* must be called after init() and before finalize().
@ -608,6 +790,7 @@ namespace Cantera {
m_prxn.resize(m_kk);
m_conc.resize(m_kk);
m_mu0.resize(m_kk);
m_grt.resize(m_kk);
m_pot.resize(m_kk, 0.0);
m_phi.resize(np, 0.0);
}

View file

@ -157,6 +157,59 @@ namespace Cantera {
virtual void getEquilibriumConstants(doublereal* kc);
virtual void getDeltaGibbs( doublereal* deltaG);
/**
* Return the vector of values for the reactions change in
* enthalpy.
* These values depend upon the concentration
* of the solution.
*
* units = J kmol-1
*/
virtual void getDeltaEnthalpy( doublereal* deltaH);
/**
* Return the vector of values for the reactions change in
* entropy.
* These values depend upon the concentration
* of the solution.
*
* units = J kmol-1 Kelvin-1
*/
virtual void getDeltaEntropy(doublereal* deltaS);
/**
* Return the vector of values for the reaction
* standard state gibbs free energy change.
* These values don't depend upon the concentration
* of the solution.
*
* units = J kmol-1
*/
virtual void getDeltaSSGibbs(doublereal* deltaG);
/**
* Return the vector of values for the change in the
* standard state enthalpies of reaction.
* These values don't depend upon the concentration
* of the solution.
*
* units = J kmol-1
*/
virtual void getDeltaSSEnthalpy(doublereal* deltaH);
/**
* Return the vector of values for the change in the
* standard state entropies for each reaction.
* These values don't depend upon the concentration
* of the solution.
*
* units = J kmol-1 Kelvin-1
*/
virtual void getDeltaSSEntropy(doublereal* deltaS);
//@}
/**
* @name Species Production Rates
@ -323,6 +376,7 @@ namespace Cantera {
void advanceCoverages(doublereal tstep);
void checkPartialEquil();
vector_fp m_grt;
protected:
/**

View file

@ -1,15 +1,19 @@
#include "xml.h"
#include "PureFluidPhase.h"
#include "../../ext/tpx/Sub.h"
#include "../../ext/tpx/utils.h"
namespace Cantera {
void PureFluid::
PureFluidPhase::~PureFluidPhase() { delete m_sub; }
void PureFluidPhase::
initThermo() {
if (m_sub) delete m_sub;
m_sub = tpx::GetSub(m_subflag);
if (m_sub == 0) {
throw CanteraError("PureFluid::initThermo",
throw CanteraError("PureFluidPhase::initThermo",
"could not create new substance object.");
}
m_mw = m_sub->MolWt();
@ -33,21 +37,21 @@ namespace Cantera {
m_sub->setStdState(h0_RT*GasConstant*298.15/m_mw,
s_R*GasConstant/m_mw, T0, p);
if (m_verbose) {
writelog("PureFluid::initThermo: initialized phase "
writelog("PureFluidPhase::initThermo: initialized phase "
+id()+"\n");
}
}
void PureFluid::
void PureFluidPhase::
setParametersFromXML(const XML_Node& eosdata) {
eosdata.require("model","PureFluid");
m_subflag = atoi(eosdata["fluid_type"].c_str());
if (m_subflag < 0)
throw CanteraError("PureFluid::setParametersFromXML",
throw CanteraError("PureFluidPhase::setParametersFromXML",
"missing or negative substance flag");
}
doublereal PureFluid::
doublereal PureFluidPhase::
enthalpy_mole() const {
setTPXState();
doublereal h = m_sub->h() * m_mw;
@ -55,7 +59,7 @@ namespace Cantera {
return h;
}
doublereal PureFluid::
doublereal PureFluidPhase::
intEnergy_mole() const {
setTPXState();
doublereal u = m_sub->u() * m_mw;
@ -63,7 +67,7 @@ namespace Cantera {
return u;
}
doublereal PureFluid::
doublereal PureFluidPhase::
entropy_mole() const {
setTPXState();
doublereal s = m_sub->s() * m_mw;
@ -71,7 +75,7 @@ namespace Cantera {
return s;
}
doublereal PureFluid::
doublereal PureFluidPhase::
gibbs_mole() const {
setTPXState();
doublereal g = m_sub->g() * m_mw;
@ -79,7 +83,7 @@ namespace Cantera {
return g;
}
doublereal PureFluid::
doublereal PureFluidPhase::
cp_mole() const {
setTPXState();
doublereal cp = m_sub->cp() * m_mw;
@ -87,7 +91,7 @@ namespace Cantera {
return cp;
}
doublereal PureFluid::
doublereal PureFluidPhase::
cv_mole() const {
setTPXState();
doublereal cv = m_sub->cv() * m_mw;
@ -95,7 +99,7 @@ namespace Cantera {
return cv;
}
doublereal PureFluid::
doublereal PureFluidPhase::
pressure() const {
setTPXState();
doublereal p = m_sub->P();
@ -103,14 +107,14 @@ namespace Cantera {
return p;
}
void PureFluid::
void PureFluidPhase::
setPressure(doublereal p) {
Set(tpx::TP, temperature(), p);
setDensity(1.0/m_sub->v());
check();
}
void PureFluid::Set(int n, double x, double y) const {
void PureFluidPhase::Set(int n, double x, double y) const {
try {
m_sub->Set(n, x, y);
}
@ -119,21 +123,119 @@ namespace Cantera {
}
}
void PureFluid::setTPXState() const {
void PureFluidPhase::setTPXState() const {
Set(tpx::TV, temperature(), 1.0/density());
}
void PureFluid::check(doublereal v) const {
void PureFluidPhase::check(doublereal v) const {
if (m_sub->Error() || v == tpx::Undef) {
throw CanteraError("PureFluidPhase",string(tpx::errorMsg(
m_sub->Error())));
}
}
void PureFluid::reportTPXError() const {
void PureFluidPhase::reportTPXError() const {
string msg = tpx::TPX_Error::ErrorMessage;
string proc = "tpx::"+tpx::TPX_Error::ErrorProcedure;
throw CanteraError(proc,msg);
}
doublereal PureFluidPhase::isothermalCompressibility() {
return m_sub->isothermalCompressibility();
}
doublereal PureFluidPhase::thermalExpansionCoeff() {
return m_sub->thermalExpansionCoeff();
}
tpx::Substance& PureFluidPhase::TPX_Substance() { return *m_sub; }
/// critical temperature
doublereal PureFluidPhase::critTemperature() const { return m_sub->Tcrit(); }
/// critical pressure
doublereal PureFluidPhase::critPressure() const { return m_sub->Pcrit(); }
/// critical density
doublereal PureFluidPhase::critDensity() const { return 1.0/m_sub->Vcrit(); }
/// saturation temperature
doublereal PureFluidPhase::satTemperature(doublereal p) const {
try {
doublereal ts = m_sub->Tsat(p);
return ts;
}
catch(tpx::TPX_Error) {
reportTPXError();
return -1.0;
}
}
void PureFluidPhase::setState_HP(doublereal h, doublereal p,
doublereal tol) {
Set(tpx::HP, h, p);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
check();
}
void PureFluidPhase::setState_UV(doublereal u, doublereal v,
doublereal tol) {
Set(tpx::UV, u, v);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
check();
}
void PureFluidPhase::setState_SV(doublereal s, doublereal v,
doublereal tol) {
Set(tpx::SV, s, v);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
check();
}
void PureFluidPhase::setState_SP(doublereal s, doublereal p,
doublereal tol) {
Set(tpx::SP, s, p);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
check();
}
/// saturation pressure
doublereal PureFluidPhase::satPressure(doublereal t) const {
doublereal vsv = m_sub->v();
try {
Set(tpx::TV,t,vsv);
doublereal ps = m_sub->Ps();
return ps;
}
catch(tpx::TPX_Error) {
reportTPXError();
return -1.0;
}
}
doublereal PureFluidPhase::vaporFraction() const {
setTPXState();
doublereal x = m_sub->x();
check(x);
return x;
}
void PureFluidPhase::setState_Tsat(doublereal t, doublereal x) {
setTemperature(t);
setTPXState();
Set(tpx::TX, t, x);
setDensity(1.0/m_sub->v());
check();
}
void PureFluidPhase::setState_Psat(doublereal p, doublereal x) {
setTPXState();
Set(tpx::PX, p, x);
setTemperature(m_sub->Temp());
setDensity(1.0/m_sub->v());
check();
}
}

View file

@ -19,20 +19,23 @@
#ifdef INCL_PURE_FLUIDS
#include "mix_defs.h"
#include "../../ext/tpx/Sub.h"
#include "../../ext/tpx/utils.h"
namespace tpx {
class Substance;
}
namespace Cantera {
/// Class for single-component fluids
class PureFluid : public ThermoPhase {
class PureFluidPhase : public ThermoPhase {
public:
PureFluid() : ThermoPhase(), m_sub(0), m_subflag(0),
PureFluidPhase() : ThermoPhase(), m_sub(0), m_subflag(0),
m_mw(-1.0), m_verbose(false) {}
virtual ~PureFluid() { delete m_sub; }
virtual ~PureFluidPhase();
virtual int eosType() const { return cPureFluid; }
@ -50,109 +53,43 @@ namespace Cantera {
mu[0] = gibbs_mole();
}
virtual doublereal isothermalCompressibility() {
return m_sub->isothermalCompressibility();
}
virtual doublereal isothermalCompressibility();
virtual doublereal thermalExpansionCoeff();
virtual doublereal thermalExpansionCoeff() {
return m_sub->thermalExpansionCoeff();
}
tpx::Substance& TPX_Substance() { return *m_sub; }
tpx::Substance& TPX_Substance();
/// critical temperature
virtual doublereal critTemperature() const { return m_sub->Tcrit(); }
virtual doublereal critTemperature() const;
/// critical pressure
virtual doublereal critPressure() const { return m_sub->Pcrit(); }
virtual doublereal critPressure() const;
/// critical density
virtual doublereal critDensity() const { return 1.0/m_sub->Vcrit(); }
virtual doublereal critDensity() const;
/// saturation temperature
virtual doublereal satTemperature(doublereal p) const {
try {
doublereal ts = m_sub->Tsat(p);
return ts;
}
catch(tpx::TPX_Error) {
reportTPXError();
return -1.0;
}
}
virtual doublereal satTemperature(doublereal p) const;
virtual void setState_HP(doublereal h, doublereal p,
doublereal tol = 1.e-8) {
Set(tpx::HP, h, p);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
check();
}
doublereal tol = 1.e-8);
virtual void setState_UV(doublereal u, doublereal v,
doublereal tol = 1.e-8) {
Set(tpx::UV, u, v);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
check();
}
doublereal tol = 1.e-8);
virtual void setState_SV(doublereal s, doublereal v,
doublereal tol = 1.e-8) {
Set(tpx::SV, s, v);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
check();
}
doublereal tol = 1.e-8);
virtual void setState_SP(doublereal s, doublereal p,
doublereal tol = 1.e-8) {
Set(tpx::SP, s, p);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
check();
}
doublereal tol = 1.e-8);
/// saturation pressure
virtual doublereal satPressure(doublereal t) const {
//doublereal tsv = m_sub->Temp();
doublereal vsv = m_sub->v();
//if (t < 0.0)
// Set(tpx::TP, temperature(), 0.5*m_sub->Pcrit());
//else
// Set(tpx::TP, t, 0.5*m_sub->Pcrit());
try {
Set(tpx::TV,t,vsv);
doublereal ps = m_sub->Ps();
//Set(tpx::TV,tsv,vsv);
//check(ps);
return ps;
}
catch(tpx::TPX_Error) {
reportTPXError();
return -1.0;
}
}
virtual doublereal satPressure(doublereal t) const;
virtual doublereal vaporFraction() const {
setTPXState();
doublereal x = m_sub->x();
check(x);
return x;
}
virtual doublereal vaporFraction() const;
virtual void setState_Tsat(doublereal t, doublereal x) {
setTemperature(t);
setTPXState();
Set(tpx::TX, t, x);
setDensity(1.0/m_sub->v());
check();
}
virtual void setState_Tsat(doublereal t, doublereal x);
virtual void setState_Psat(doublereal p, doublereal x) {
setTPXState();
Set(tpx::PX, p, x);
setTemperature(m_sub->Temp());
setDensity(1.0/m_sub->v());
check();
}
virtual void setState_Psat(doublereal p, doublereal x);
virtual void initThermo();
virtual void setParametersFromXML(const XML_Node& eosdata);

View file

@ -3,18 +3,18 @@
*
* This parameterization requires 7 coefficients A - G:
*
* Cp° = A + B*t + C*t2 + D*t3 + E/t^2
* \f[ C_p = A + B*t + C*t2 + D*t3 + E/t^2 \f]
*
* H° - H°298.15= A*t + B*t^2/2 + C*t^3/3 + D*t^4/4 - E/t + F
* - \Delta_f H°f,298
* \f[ H - H_298.15= A*t + B*t^2/2 + C*t^3/3 + D*t^4/4 - E/t + F
* - \Delta_f H_{f,298} \f]
*
* S° = A*ln(t) + B*t + C*t^2/2 + D*t^3/3 - E/(2*t^2) + G
* \f[ S = A*ln(t) + B*t + C*t^2/2 + D*t^3/3 - E/(2*t^2) + G \f]
*
* Cp = heat capacity (J/mol*K)
* H° = standard enthalpy (kJ/mol)
* \Delta_f H°298.15 = enthalpy of formation at 298.15 K (kJ/mol)
* S° = standard entropy (J/mol*K)
* t = temperature (K) / 1000.
* - Cp = heat capacity (J/mol*K)
* - H = standard enthalpy (kJ/mol)
* - \f$ \Delta_f H_298.15 \f$ = enthalpy of formation at 298.15 K (kJ/mol)
* - S = standard entropy (J/mol*K)
* - t = temperature (K) / 1000.
*
*/

View file

@ -79,7 +79,7 @@ namespace Cantera {
#ifdef INCL_PURE_FLUIDS
case cPureFluid:
th = new PureFluid;
th = new PureFluidPhase;
break;
#endif

View file

@ -11,7 +11,7 @@
// These flags turn on or off features that are still in
// development and are not yet stable.
#undef DEV_EQUIL
#define DEV_EQUIL
//------------------------ Fortran settings -------------------//
@ -59,8 +59,8 @@ typedef int ftnlen; // Fortran hidden string length type
// The configure script defines this if the operatiing system is Mac
// OS X, This used to add some Mac-specific directories to the default
// data file search path.
#define DARWIN 0
/* #undef HAS_SSTREAM */
#define DARWIN 1
#define HAS_SSTREAM 1
// Identify whether the operating system is cygwin's overlay of
// windows, with gcc being used as the compiler.
@ -68,19 +68,33 @@ typedef int ftnlen; // Fortran hidden string length type
// Identify whether the operating system is windows based, with
// microsoft vc++ being used as the compiler
#define WINMSVC
/* #undef WINMSVC */
//--------- Fonts for reaction path diagrams ----------------------
#define RXNPATH_FONT "Helvetica"
//--------------------- Python ------------------------------------
// This path to the python executable is created during
// Cantera's setup. It identifies the python executable
// used to run Python to process .cti files. Note that this is only
// used if environment variable PYTHON_CMD is not set.
#define PYTHON_EXE "python"
// If this is defined, the Cantera Python interface will use the
// Numeric package; otherwise, it will use numarray.
/* #define HAS_NUMERIC 1 */
#define HAS_NUMERIC 1
//--------------------- Cantera -----------------------------------
/* #undef CANTERA_ROOT */
// This data pathway is used to locate a directory where datafiles
// are to be found. Note, the local directory is always searched
// as well.
#define CANTERA_DATA "/Applications/Cantera/data"
#define INCL_PURE_FLUIDS 1
//--------------------- compile options ----------------------------
/* #define USE_PCH 1 */
#define USE_PCH 1
#endif

View file

@ -6,32 +6,15 @@
// Copyright 2001 California Institute of Technology
//
// $Log$
// Revision 1.15 2004-10-10 20:46:36 dggoodwin
// changes to make type integer compatible with f2c
// Revision 1.16 2005-01-07 10:26:43 dggoodwin
// merged changes from branch
//
// Revision 1.14 2004/09/13 11:22:21 dggoodwin
// Revision 1.15.2.2 2004/12/18 15:16:13 dggoodwin
// minor cleanup
//
// Revision 1.15.2.1 2004/12/18 15:00:02 dggoodwin
// *** empty log message ***
//
// Revision 1.13 2004/08/28 16:12:41 dggoodwin
// cleanup
//
// Revision 1.12 2004/08/05 14:56:57 dggoodwin
// *** empty log message ***
//
// Revision 1.11 2004/07/27 14:22:31 dggoodwin
// *** empty log message ***
//
// Revision 1.10 2004/07/23 00:15:15 dggoodwin
// *** empty log message ***
//
// Revision 1.9 2004/07/14 11:24:13 dggoodwin
// *** empty log message ***
//
// Revision 1.8 2004/07/02 17:34:13 hkmoffa
// Eliminated warnings due to signed and unsigned comparisons.
//
// Revision 1.7 2004/07/02 17:27:01 hkmoffa
// static_casts to eliminate VC++ warnings.
//
// Revision 1.6 2004/07/02 16:48:13 hkmoffa
// Moved CK_SyntaxError definition to the .h file. It's used in more
@ -270,7 +253,7 @@ namespace ckr {
* Constructor. Construct a parser for the specified input file.
*/
CKParser::CKParser(istream* infile, const string& fname, ostream* log)
: verbose(true), m_line (0), debug(false) {
: verbose(true), debug(false), m_line (0) {
m_ckfile = infile;
m_ckfilename = fname;
m_log = log;
@ -925,7 +908,7 @@ next:
// look for a metadata line
if (s[0] == '%') {
metaDataLine = true;
if (eqloc > 0 && eqloc < s.size()) {
if (eqloc > 0 && eqloc < int(s.size())) {
int ierr, ierp;
vector<grouplist_t> rg, pg;
s[eqloc] = ' ';
@ -964,7 +947,7 @@ next:
}
}
else if (eqloc >= 0 && eqloc < s.size()) {
else if (eqloc >= 0 && eqloc < int(s.size())) {
if (nRxns > 0) {
rxn.number = nRxns;
reactions.push_back(rxn);

View file

@ -22,7 +22,6 @@ using namespace std;
#include "Element.h"
#include "Species.h"
#include "Reaction.h"
#include "Group.h"
namespace ckr {

View file

@ -21,69 +21,97 @@
#include "CKParser.h"
#include <string>
#include <vector>
using namespace std;
namespace ckr {
class Group {
public:
/// Construct a new empty Group object
Group() : name("<empty>"), index(-1) {}
/**
* Chemkin file reader class. Class CKReader parses and validates a file
* containing a description of a chemical reaction mechanism in Chemkin
* format. See the Examples section for examples of how CKReader is
* used in user programs.
*/
Group(const string& nm) : name(nm), index(-1) {}
/// Destructor
~Group() {}
string name; //!< name
int index; //!< index number
map<string, double> comp; //!< elemental composition
bool operator==(const Group& g) const {
return (name == g.name);
}
bool operator!=(const Group& g) const {
return !(*this == g);
}
};
/// a list (vector) of Groups
typedef vector<Group> groupList;
class CKReader {
public:
/**
* Constructor. Construct a new CKReader instance. By default,
* validation is enabled, as well as verbose output to the log file.
*/
CKReader() : verbose(true), validate(true), debug(false) {}
/// Destructor. Does nothing.
~CKReader() {}
elementList elements; ///< a list of Element objects
speciesList species; ///< a list of Species objects
reactionList reactions; ///< a list of Reaction objects
groupList groups; ///< a list of Groups
speciesTable speciesData; ///< a map from species names to Species objects
ReactionUnits units; ///< reaction units
/**
* Read and optionally validate a Chemkin input file.
* @param inputFile path to the input file.
* @param thermoDatabase path to the species thermodynamic property database.
* If no database is required, enter a null string.
* @param logFile file to write logging and error messages to.
* @return true if no errors encountered, false otherwise.
* Chemkin file reader class. Class CKReader parses and validates a file
* containing a description of a chemical reaction mechanism in Chemkin
* format. See the Examples section for examples of how CKReader is
* used in user programs.
*/
bool read(const string& inputFile,
const string& thermoDatabase, const string& logFile);
void write(string outputFile); ///< not implemented.
class CKReader {
public:
bool verbose; ///< print detailed messages to log file
bool validate; ///< validate elements, species, and reaction
bool debug; ///< enable debugging output
/**
* Constructor. Construct a new CKReader instance. By default,
* validation is enabled, as well as verbose output to the log file.
*/
CKReader() : verbose(true), validate(true), debug(false) {}
private:
/// Destructor. Does nothing.
~CKReader() {}
// void validateElements(ostream& log);
bool validateSpecies(ostream& log); ///< validate the species.
bool validateReactions(ostream& log); ///< validate the reactions.
bool writeReactions(ostream& log);
};
elementList elements; ///< a list of Element objects
speciesList species; ///< a list of Species objects
reactionList reactions; ///< a list of Reaction objects
groupList groups; ///< a list of Groups
speciesTable speciesData; ///< a map from species names to Species objects
ReactionUnits units; ///< reaction units
/**
* Read and optionally validate a Chemkin input file.
* @param inputFile path to the input file.
* @param thermoDatabase path to the species thermodynamic property database.
* If no database is required, enter a null string.
* @param logFile file to write logging and error messages to.
* @return true if no errors encountered, false otherwise.
*/
bool read(const string& inputFile,
const string& thermoDatabase, const string& logFile);
void write(string outputFile); ///< not implemented.
bool verbose; ///< print detailed messages to log file
bool validate; ///< validate elements, species, and reaction
bool debug; ///< enable debugging output
private:
// void validateElements(ostream& log);
bool validateSpecies(ostream& log); ///< validate the species.
bool validateReactions(ostream& log); ///< validate the reactions.
bool writeReactions(ostream& log);
};
bool checkBalance(ostream& f, speciesTable& speciesData, reactionList& r,
vector<int>& unbalanced);
bool checkThermo(ostream& f, speciesList& species, double tol);
bool checkBalance(ostream& f, speciesTable& speciesData, reactionList& r,
vector<int>& unbalanced);
bool checkThermo(ostream& f, speciesList& species, double tol);
bool filter(const string& infile, const string& database,
const string& outfile, const vector<int>& species, const vector<int>& reactions);
bool filter(const string& infile, const string& database,
const string& outfile, const vector<int>& species, const vector<int>& reactions);
}

View file

@ -1,64 +0,0 @@
/**
* @file converters/Group.h
*
*/
// Copyright 2001 California Institute of Technology
#ifndef CKR_GROUP_H
#define CKR_GROUP_H
#include <string>
#include <vector>
using namespace std;
namespace ckr {
/**
* A class for groups.
*/
class Group {
public:
/// Construct a new empty Group object
Group() : name("<empty>"), index(-1) {}
Group(const string& nm) : name(nm), index(-1) {}
/// Destructor
~Group() {}
string name; //!< name
int index; //!< index number
map<string, double> comp; //!< elemental composition
/**
* Compare two Group instances for equality based on name.
* Primarily for internal use.
*/
bool operator==(const Group& g) const {
return (name == g.name);
}
bool operator!=(const Group& g) const {
return !(*this == g);
}
};
/// a list (vector) of Groups
typedef vector<Group> groupList;
}
#endif

View file

@ -29,7 +29,6 @@ bool match(const string& s1, const string& s2)
}
/// remove all white space from string s.
void removeWhiteSpace(string& s) {
string r;
int ssize = static_cast<int>(s.size());

View file

@ -139,12 +139,9 @@ void getTokens(string& begin,
bool match(const string& s1, const string& s2);
/**
*
/**
* Check whether string 'word' begins with a Chemkin keyword.
*
*/
inline bool isKeyword(string word)
{
return (match(word, "ELEM") ||

View file

@ -1,19 +0,0 @@
#ifndef CKR_CONFIG_H
#define CKR_CONFIG_H
namespace ckr {
/**
* define to enable parsing Chemkin-III plasma reactions. Not yet fully
* implemented, so best to leave it undefined for now.
*/
#undef ENABLE_PLASMA_REACTIONS
}
#endif

View file

@ -1,5 +1,5 @@
/**
* @file writelog.cpp
* @file converters/writelog.cpp
*
*/

View file

@ -41,21 +41,13 @@ namespace Cantera {
/// Discard the last error message
void popError();
/// Find a file on a search path
string findInputFile(string name);
/// Add a directory to the search path
void addDirectory(string dir);
/// Delete the application singly defined information
void appdelete();
// Write a message (deprecated; use writelog)
//void write(const string& msg);
// Write a message (deprecated; use writelog)
//void write(const char* msg);
/// The root directory where Cantera is installed
string canteraRoot();

View file

@ -28,71 +28,11 @@ namespace Cantera {
bool isCTMLFile(string infile);
/**
* This routine will locate an XML node in either the input
* XML tree or in another input file specified by the file
* part of the file_ID string. Searches are based on the
* ID attribute of the XML element only.
*
* @param file_ID This is a concatenation of two strings seperated
* by the "#" character. The string before the
* pound character is the file name of an xml
* file to carry out the search. The string after
* the # character is the ID attribute
* of the xml element to search for.
* The string is interpreted as a file string if
* no # character is in the string.
*
* @param root If the file string is empty, searches for the
* xml element with matching ID attribute are
* carried out from this XML node.
*/
XML_Node* get_XML_Node(const string& src, XML_Node* root);
/**
* This routine will locate an XML node in either the input
* XML tree or in another input file specified by the file
* part of the file_ID string. Searches are based on the
* XML element name and the ID attribute of the XML element.
*
* @param nameTarget This is the XML element name to look for.
*
* @param file_ID This is a concatenation of two strings seperated
* by the "#" character. The string before the
* pound character is the file name of an xml
* file to carry out the search. The string after
* the # character is the ID attribute
* of the xml element to search for.
* The string is interpreted as a file string if
* no # character is in the string.
*
* @param root If the file string is empty, searches for the
* xml element with matching ID attribute are
* carried out from this XML node.
*/
XML_Node* get_XML_NameID(const string& nameTarget,
const string& file_ID, XML_Node* root);
/**
* Install a species into a ThermoPhase object, which defines
* the phase thermodynamics and speciation.
*
* This routine first gathers the information from the Species XML
* tree and calls addUniqueSpecies() to add it to the
* ThermoPhase object, p.
* This information consists of:
* ecomp[] = element composition of species.
* chgr = electric charge of species
* name = string name of species
* sz = size of the species
* (option double used a lot in thermo)
*
* Then, the routine processes the "thermo" XML element and
* calls underlying utility routines to read the XML elements
* containing the thermodynamic information for the reference
* state of the species. Failures or lack of information trigger
* an "UnknownSpeciesThermoModel" exception being thrown.
*/
bool installSpecies(int k, const XML_Node& s, thermo_t& p,
SpeciesThermo& spthermo, int rule,
SpeciesThermoFactory* spfactory);
@ -100,14 +40,6 @@ namespace Cantera {
bool importPhase(XML_Node& phase, ThermoPhase* th,
SpeciesThermoFactory* spfactory = 0);
/**
* This function returns true if two reactions are duplicates of
* one another, and false otherwise. The input arguments are two
* maps from species number to stoichiometric coefficient, one for
* each reaction. The reactions are considered duplicates if their
* stoichiometric coefficients have the same ratio for all
* species.
*/
doublereal isDuplicateReaction(map<int, doublereal>& r1,
map<int, doublereal>& r2);

View file

@ -8,38 +8,52 @@
#
###############################################################
SUFFIXES=
SUFFIXES= .cpp .d .o
.SUFFIXES :
.SUFFIXES : .cpp .d .o .h
OBJDIR = .
INCDIR = ../../../build/include/cantera/kernel/transport
INSTALL_TSC = ../../../bin/install_tsc
CXX_FLAGS = @CXXFLAGS@ $(CXX_OPT)
# stirred reactors
# Transport Object Files
OBJS = TransportFactory.o MultiTransport.o MixTransport.o MMCollisionInt.o \
SolidTransport.o DustyGasTransport.o
TRAN_H = TransportFactory.h MultiTransport.h MixTransport.h \
MMCollisionInt.h SolidTransport.h DustyGasTransport.h \
TransportBase.h L_matrix.h FtnTransport.h TransportParams.h
CXX_INCLUDES = -I..
LIB = @buildlib@/libtransport.a
DEPENDS = $(OBJS:.o=.d)
all: $(LIB)
@(for lh in $(TRAN_H) ; do \
$(INSTALL_TSC) "$${lh}" $(INCDIR) ; \
done)
%.d:
g++ -MM $(CXX_INCLUDES) $*.cpp > $*.d
.cpp.o:
@CXX@ -c $< $(CXX_FLAGS) $(CXX_INCLUDES)
.f.o:
@F77@ -c $< $(F77_FLAGS)
all lib: $(LIB)
$(LIB): $(OBJS)
$(LIB): $(OBJS) $(TRAN_H)
@ARCHIVE@ $(LIB) $(OBJS) > /dev/null
clean:
$(RM) *.o *~ $(LIB)
@(for lh in $(TRAN_H) ; do \
th=$(INCDIR)/"$${lh}" ; \
if test -f "$${th}" ; then \
$(RM) "$${th}" ; \
echo "$(RM) $${th}" ; \
fi \
done)
@(if test -f $(LIB) ; then \
$(RM) $(LIB) ; \
echo "$(RM) $(LIB)" ; \
fi)
$(RM) *.o *~
depends: $(DEPENDS)
cat *.d > .depends

View file

@ -8,21 +8,29 @@
#
###############################################################
SUFFIXES=
SUFFIXES= .cpp .d .o
.SUFFIXES :
.SUFFIXES : .cpp .d .o .h
OBJDIR = .
INCDIR = ../../../build/include/cantera/kernel/zeroD
INSTALL_TSC = ../../../bin/install_tsc
CXX_FLAGS = @CXXFLAGS@ $(CXX_OPT)
# stirred reactors
OBJS = Reactor.o ReactorBase.o FlowDevice.o Wall.o ReactorNet.o
ZEROD_H = Reactor.h ReactorBase.h FlowDevice.h Wall.h ReactorNet.h \
flowControllers.h PID_Controller.h Reservoir.h
CXX_INCLUDES = -I..
ZEROD_LIB = @buildlib@/libzeroD.a
DEPENDS = $(OBJS:.o=.d)
all: $(ZEROD_LIB)
@(for lh in $(ZEROD_H) ; do \
$(INSTALL_TSC) "$${lh}" $(INCDIR) ; \
done)
%.d:
g++ -MM $(CXX_INCLUDES) $*.cpp > $*.d
@ -32,13 +40,22 @@ DEPENDS = $(OBJS:.o=.d)
.f.o:
@F77@ -c $< $(F77_FLAGS)
all lib: $(ZEROD_LIB)
$(ZEROD_LIB): $(OBJS)
$(ZEROD_LIB): $(OBJS) $(ZEROD_H)
@ARCHIVE@ $(ZEROD_LIB) $(OBJS) > /dev/null
clean:
$(RM) *.o *~ $(ZEROD_LIB)
@(for lh in $(ZEROD_H) ; do \
th=$(INCDIR)/"$${lh}" ; \
if test -f "$${th}" ; then \
$(RM) "$${th}" ; \
echo "$(RM) $${th}" ; \
fi \
done)
@(if test -f $(ZEROD_LIB) ; then \
$(RM) $(ZEROD_LIB) ; \
echo "$(RM) $(ZEROD_LIB)" ; \
fi)
$(RM) *.o *~
depends: $(DEPENDS)
cat *.d > .depends

View file

@ -1,5 +1,5 @@
/**
* @file FlowDevice.h
* @file flowControllers.h
*
* Some flow devices derived from class FlowDevice.
*