Re-applied consistent formatting to trunk

Applied using: astyle -n --style=kr --add-brackets --indent=spaces=4
--indent-col1-comments --unpad-paren --pad-header --align-pointer=type
--lineend=linux
This commit is contained in:
Ray Speth 2013-02-07 23:40:59 +00:00
parent a1d24776f1
commit 7da738d238
93 changed files with 1793 additions and 1778 deletions

View file

@ -26,7 +26,7 @@ void thermo_demo(const std::string& file, const std::string& phase)
gas->getChemPotentials(&mu[0]);
int n;
for (n = 0; n < numSpecies; n++) {
std::cout << gas->speciesName(n) << " " << mu[n] << std::endl;
std::cout << gas->speciesName(n) << " " << mu[n] << std::endl;
}
}

View file

@ -221,7 +221,7 @@ void addFloatArray(Cantera::XML_Node& node, const std::string& titleString,
* @param name Name of the XML node
* @param n Length of the doubles vector.
* @param values Pointer to a vector of doubles
* @param unitsString String name of the Units attribute. This is an optional
* @param unitsString String name of the Units attribute. This is an optional
* parameter. The default is to
* have an empty string.
* @param type String type. This is an optional parameter. The default
@ -236,7 +236,7 @@ void addFloatArray(Cantera::XML_Node& node, const std::string& titleString,
* entry.
*
*/
void addNamedFloatArray(Cantera::XML_Node& parentNode, const std::string &name, const int n,
void addNamedFloatArray(Cantera::XML_Node& parentNode, const std::string& name, const int n,
const doublereal* const vals, const std::string units = "",
const std::string type = "",
const doublereal minval = Cantera::Undef,
@ -760,19 +760,19 @@ Cantera::XML_Node* getByTitle(const Cantera::XML_Node& node, const std::string&
//! This function reads a child node with the name string with a specific
//! title attribute named titleString
/*!
* This function will read a child node to the current XML node with the name "string".
/*!
* This function will read a child node to the current XML node with the name "string".
* It must have a title attribute, named titleString, and the body
* of the XML node will be read into the valueString output argument.
*
* If the child node is not found then the empty string is returned.
*
* Example:
* Example:
*
* Code snipet:
* @verbatim
const XML_Node &node;
getString(XML_Node& node, std::string titleString, std::string valueString,
getString(XML_Node& node, std::string titleString, std::string valueString,
std::string typeString);
@endverbatim
*
@ -789,8 +789,8 @@ Cantera::XML_Node* getByTitle(const Cantera::XML_Node& node, const std::string&
* @param typeString String type. This is an optional output variable. It is filled
* with the attribute "type" of the XML entry.
*/
void getString(const Cantera::XML_Node& node, const std::string &titleString,
std::string& valueString, std::string& typeString);
void getString(const Cantera::XML_Node& node, const std::string& titleString,
std::string& valueString, std::string& typeString);
//! This function attempts to read a named child node and returns with the contents in the value string.

View file

@ -251,10 +251,11 @@ std::string canteraRoot();
void writelog(const std::string& msg);
inline void writelog(const std::string& msg, int loglevel) {
if (loglevel > 0) {
writelog(msg);
}
inline void writelog(const std::string& msg, int loglevel)
{
if (loglevel > 0) {
writelog(msg);
}
}
//! Write a message to the screen.
@ -529,7 +530,8 @@ XML_Node* get_XML_NameID(const std::string& nameTarget,
//! Clip *value* such that lower <= value <= upper
template <class T>
inline T clip(const T& value, const T& lower, const T& upper) {
inline T clip(const T& value, const T& lower, const T& upper)
{
return std::max(lower, std::min(upper, value));
}

View file

@ -1446,46 +1446,46 @@ private:
void vcs_updateMolNumVolPhases(const int stateCalc);
public:
//! Calculate the rank of a matrix and return the rows and columns that will generate an independent basis
//! for that rank
/*
* Choose the optimum component species basis for the calculations, finding the rank and
* set of linearly independent rows for that calculation.
* Then find the set of linearly indepedent element columns that can support that rank.
* This is done by taking the transpose of the matrix and redoing the same calculation.
* (there may be a better way to do this. I don't know.)
*
*
* Input
* ---------
*
* @param awtmp Vector of mole numbers which will be used to construct a
* ranking for how to pick the basis species. This is largely ignored
* here.
*
* @param numSpecies Number of species. This is the number of rows in the matrix.
*
* @param matrix Matrix. This is the formula matrix. Nominally, the rows are species, while
* the columns are element compositions. However, this routine
* is totally general, so that the rows and columns can be anything.
*
* @param numElemConstraints Number of element constraints
*
* Output
* ---------
* @param usedZeroedSpecies = If true, then a species with a zero concentration
* was used as a component.
*
*
* @param compRes Vector of rows which are linearly independent. (these are the components)
*
* @param elemComp Vector of columns which are linearly independent (These are the actionable element
* constraints).
*
* @return Returns number of components. This is the rank of the matrix
*/
int vcs_rank(const double * awtmp, size_t numSpecies, const double * matrix, size_t numElemConstraints,
std::vector<size_t> &compRes, std::vector<size_t> &elemComp, int * const usedZeroedSpecies) const;
//! Calculate the rank of a matrix and return the rows and columns that will generate an independent basis
//! for that rank
/*
* Choose the optimum component species basis for the calculations, finding the rank and
* set of linearly independent rows for that calculation.
* Then find the set of linearly indepedent element columns that can support that rank.
* This is done by taking the transpose of the matrix and redoing the same calculation.
* (there may be a better way to do this. I don't know.)
*
*
* Input
* ---------
*
* @param awtmp Vector of mole numbers which will be used to construct a
* ranking for how to pick the basis species. This is largely ignored
* here.
*
* @param numSpecies Number of species. This is the number of rows in the matrix.
*
* @param matrix Matrix. This is the formula matrix. Nominally, the rows are species, while
* the columns are element compositions. However, this routine
* is totally general, so that the rows and columns can be anything.
*
* @param numElemConstraints Number of element constraints
*
* Output
* ---------
* @param usedZeroedSpecies = If true, then a species with a zero concentration
* was used as a component.
*
*
* @param compRes Vector of rows which are linearly independent. (these are the components)
*
* @param elemComp Vector of columns which are linearly independent (These are the actionable element
* constraints).
*
* @return Returns number of components. This is the rank of the matrix
*/
int vcs_rank(const double* awtmp, size_t numSpecies, const double* matrix, size_t numElemConstraints,
std::vector<size_t> &compRes, std::vector<size_t> &elemComp, int* const usedZeroedSpecies) const;
public:

View file

@ -157,8 +157,7 @@ public:
m_ecov(0.0),
m_mcov(0.0),
m_ncov(0),
m_nmcov(0)
{
m_nmcov(0) {
if (m_A <= 0.0) {
m_logA = -1.0E300;
} else {
@ -359,8 +358,7 @@ class Plog
{
public:
//! return the rate coefficient type.
static int type()
{
static int type() {
return PLOG_REACTION_RATECOEFF_TYPE;
}
@ -371,16 +369,15 @@ public:
explicit Plog(const ReactionData& rdata) :
logP1_(1000),
logP2_(-1000),
maxRates_(1)
{
maxRates_(1) {
typedef std::multimap<double, vector_fp>::const_iterator iter_t;
size_t j = 0;
size_t rateCount = 0;
// Insert intermediate pressures
for (iter_t iter = rdata.plogParameters.begin();
iter != rdata.plogParameters.end();
iter++) {
iter != rdata.plogParameters.end();
iter++) {
double logp = std::log(iter->first);
if (pressures_.empty() || pressures_.rbegin()->first != logp) {
// starting a new group
@ -402,8 +399,8 @@ public:
// For pressures with only one Arrhenius expression, it is more
// efficient to work with log(A)
for (pressureIter iter = pressures_.begin();
iter != pressures_.end();
iter++) {
iter != pressures_.end();
iter++) {
if (iter->second.first == iter->second.second - 1) {
A_[iter->second.first] = std::log(A_[iter->second.first]);
}
@ -428,8 +425,7 @@ public:
//! Update concentration-dependent parts of the rate coefficient.
//! @param c natural log of the pressure in Pa
void update_C(const doublereal* c)
{
void update_C(const doublereal* c) {
logP_ = c[0];
if (logP_ > logP1_ && logP_ < logP2_) {
return;
@ -467,8 +463,7 @@ public:
/**
* Update the value of the logarithm of the rate constant.
*/
doublereal update(doublereal logT, doublereal recipT) const
{
doublereal update(doublereal logT, doublereal recipT) const {
double log_k1, log_k2;
if (m1_ == 1) {
log_k1 = A1_[0] + n1_[0] * logT - Ea1_[0] * recipT;
@ -517,9 +512,8 @@ public:
void validate(const ReactionData& rdata) {
double T[] = {1.0, 10.0, 100.0, 1000.0, 10000.0};
for (pressureIter iter = pressures_.begin();
iter->first < 1000;
iter++)
{
iter->first < 1000;
iter++) {
update_C(&iter->first);
for (size_t i=0; i < 5; i++) {
double k = updateRC(log(T[i]), 1.0/T[i]);
@ -528,10 +522,10 @@ public:
// message will correctly indicate that the problematic rate
// expression is at the higher of the adjacent pressures.
throw CanteraError("Plog::validate",
"Invalid rate coefficient for reaction #" +
int2str(rdata.number) + ":\n" + rdata.equation + "\n" +
"at P = " + fp2str(std::exp((++iter)->first)) +
", T = " + fp2str(T[i]));
"Invalid rate coefficient for reaction #" +
int2str(rdata.number) + ":\n" + rdata.equation + "\n" +
"at P = " + fp2str(std::exp((++iter)->first)) +
", T = " + fp2str(T[i]));
}
}
}
@ -567,8 +561,7 @@ class ChebyshevRate
{
public:
//! return the rate coefficient type.
static int type()
{
static int type() {
return CHEBYSHEV_REACTION_RATECOEFF_TYPE;
}
@ -580,8 +573,7 @@ public:
nP_(rdata.chebDegreeP),
nT_(rdata.chebDegreeT),
chebCoeffs_(rdata.chebCoeffs),
dotProd_(rdata.chebDegreeT)
{
dotProd_(rdata.chebDegreeT) {
double logPmin = std::log10(rdata.chebPmin);
double logPmax = std::log10(rdata.chebPmax);
double TminInv = 1.0 / rdata.chebTmin;
@ -595,8 +587,7 @@ public:
//! Update concentration-dependent parts of the rate coefficient.
//! @param c base-10 logarithm of the pressure in Pa
void update_C(const doublereal* c)
{
void update_C(const doublereal* c) {
double Pr = (2 * c[0] + PrNum_) * PrDen_;
double Cnm1 = 1;
double Cn = Pr;
@ -617,8 +608,7 @@ public:
/**
* Update the value of the base-10 logarithm of the rate constant.
*/
doublereal update(doublereal logT, doublereal recipT) const
{
doublereal update(doublereal logT, doublereal recipT) const {
double Tr = (2 * recipT + TrNum_) * TrDen_;
double Cnm1 = 1;
double Cn = Tr;

View file

@ -696,7 +696,7 @@ inline static void _writeDecrementReaction(InputIter begin, InputIter end,
template<class InputIter>
inline static void _writeMultiply(InputIter begin, InputIter end,
const std::string& r, std::map<size_t, std::string>& out)
const std::string& r, std::map<size_t, std::string>& out)
{
for (; begin != end; ++begin) {
begin->writeMultiply(r, out);

View file

@ -144,7 +144,7 @@ public:
* @param b input DenseMatrix B of size NxN
* @param prod output output DenseMatrix prod size NxN
*/
virtual void mult(const DenseMatrix &b, DenseMatrix &prod) const;
virtual void mult(const DenseMatrix& b, DenseMatrix& prod) const;
//! Left-multiply the matrix by transpose(b), and write the result to prod.
/*!

View file

@ -58,7 +58,9 @@ public:
return m_temp;
}
virtual size_t nSpecies() { return 0; }
virtual size_t nSpecies() {
return 0;
}
/// Set the mole fractions by specifying a std::string.
virtual void setMoleFractions(const std::string& xin) {
@ -171,7 +173,9 @@ public:
virtual void _finalize(const doublereal* x) {}
virtual size_t nSpecies() { return m_nsp; }
virtual size_t nSpecies() {
return m_nsp;
}
virtual void setMoleFractions(const std::string& xin);
virtual void setMoleFractions(doublereal* xin);
@ -323,7 +327,9 @@ public:
;
}
virtual size_t nSpecies() { return m_nsp; }
virtual size_t nSpecies() {
return m_nsp;
}
virtual void setMoleFractions(const std::string& xin);
virtual void setMoleFractions(doublereal* xin);

View file

@ -76,7 +76,7 @@ public:
const std::string& desc, int loglevel=1);
void saveResidual(const std::string& fname, const std::string& id,
const std::string& desc, int loglevel=1);
const std::string& desc, int loglevel=1);
/// Print to stream s the current solution for all domains.
void showSolution(std::ostream& s);

View file

@ -423,7 +423,7 @@ public:
* Length = m_kk. units are m^3/kmol.
*/
virtual void getPartialMolarVolumes(doublereal* vbar) const;
virtual const vector_fp & getPartialMolarVolumes() const;
virtual const vector_fp& getPartialMolarVolumes() const;
//@}
/// @name Properties of the Standard State of the Species in the Solution

View file

@ -1334,44 +1334,44 @@ public:
ThermoPhase* duplMyselfAsThermoPhase() const;
//! Import, construct, and initialize a HMWSoln phase
/*! specification from an XML tree into the current object.
*
* This routine is a precursor to constructPhaseXML(XML_Node*)
* routine, which does most of the work.
*
* @param inputfile XML file containing the description of the phase
*
* @param id Optional parameter identifying the name of the
* phase. If none is given, the first XML
* phase element will be used.
*/
void constructPhaseFile(std::string inputFile, std::string id);
//! Import, construct, and initialize a HMWSoln phase
/*! specification from an XML tree into the current object.
*
* This routine is a precursor to constructPhaseXML(XML_Node*)
* routine, which does most of the work.
*
* @param inputfile XML file containing the description of the phase
*
* @param id Optional parameter identifying the name of the
* phase. If none is given, the first XML
* phase element will be used.
*/
void constructPhaseFile(std::string inputFile, std::string id);
//! Import and initialize a HMWSoln phase specification in an XML tree into the current object.
/*!
* Here we read an XML description of the phase.
* We import descriptions of the elements that make up the
* species in a phase.
* We import information about the species, including their
* reference state thermodynamic polynomials. We then freeze
* the state of the species.
*
* Then, we read the species molar volumes from the xml
* tree to finish the initialization.
*
* @param phaseNode This object must be the phase node of a complete XML tree
* description of the phase, including all of the
* species data. In other words while "phase" must
* point to an XML phase object, it must have
* sibling nodes "speciesData" that describe
* the species in the phase.
*
* @param id ID of the phase. If nonnull, a check is done
* to see if phaseNode is pointing to the phase
* with the correct id.
*/
void constructPhaseXML(XML_Node& phaseNode, std::string id);
//! Import and initialize a HMWSoln phase specification in an XML tree into the current object.
/*!
* Here we read an XML description of the phase.
* We import descriptions of the elements that make up the
* species in a phase.
* We import information about the species, including their
* reference state thermodynamic polynomials. We then freeze
* the state of the species.
*
* Then, we read the species molar volumes from the xml
* tree to finish the initialization.
*
* @param phaseNode This object must be the phase node of a complete XML tree
* description of the phase, including all of the
* species data. In other words while "phase" must
* point to an XML phase object, it must have
* sibling nodes "speciesData" that describe
* the species in the phase.
*
* @param id ID of the phase. If nonnull, a check is done
* to see if phaseNode is pointing to the phase
* with the correct id.
*/
void constructPhaseXML(XML_Node& phaseNode, std::string id);
/**
* @name Utilities

View file

@ -763,7 +763,7 @@ public:
#ifdef H298MODIFY_CAPABILITY
virtual void modifyOneHf298SS(const size_t &k, const doublereal Hf298New) {
virtual void modifyOneHf298SS(const size_t& k, const doublereal Hf298New) {
m_spthermo->modifyOneHf298(k, Hf298New);
m_tlast += 0.0001234;
}

View file

@ -824,7 +824,7 @@ public:
ThermoPhase* neutralMoleculePhase_;
private:
GibbsExcessVPSSTP *geThermo;
GibbsExcessVPSSTP* geThermo;
// Temporary vectors that I don't want to allocate every time the function is called
mutable vector_fp y;
mutable vector_fp dlnActCoeff_NeutralMolecule;

View file

@ -768,7 +768,7 @@ public:
* @param k Species k
* @param Hf298New Specify the new value of the Heat of Formation at 298K and 1 bar
*/
virtual void modifyOneHf298SS(const size_t &k, const doublereal Hf298New) {
virtual void modifyOneHf298SS(const size_t& k, const doublereal Hf298New) {
m_spthermo->modifyOneHf298(k, Hf298New);
m_tlast += 0.0001234;
}

View file

@ -653,7 +653,7 @@ public:
* @param k Species k
* @param Hf298New Specify the new value of the Heat of Formation at 298K and 1 bar
*/
virtual void modifyOneHf298SS(const size_t &k, const doublereal Hf298New);
virtual void modifyOneHf298SS(const size_t& k, const doublereal Hf298New);
#endif
private:

View file

@ -294,7 +294,7 @@ public:
return h;
}
virtual void modifyOneHf298(const size_t &k, const doublereal Hf298New) {
virtual void modifyOneHf298(const size_t& k, const doublereal Hf298New) {
if (k != m_index) {
return;
}

View file

@ -402,7 +402,7 @@ public:
* @param k Species k
* @param Hf298New Specify the new value of the Heat of Formation at 298K and 1 bar
*/
virtual void modifyOneHf298SS(const size_t &k, const doublereal Hf298New) {
virtual void modifyOneHf298SS(const size_t& k, const doublereal Hf298New) {
m_spthermo->modifyOneHf298(k, Hf298New);
m_tlast += 0.0001234;
}

View file

@ -328,7 +328,7 @@ public:
#ifdef H298MODIFY_CAPABILITY
virtual void modifyOneHf298SS(const size_t &k, const doublereal Hf298New) {
virtual void modifyOneHf298SS(const size_t& k, const doublereal Hf298New) {
m_spthermo->modifyOneHf298(k, Hf298New);
m_tlast += 0.0001234;
}

View file

@ -536,7 +536,7 @@ public:
* @param k Species k
* @param Hf298New Specify the new value of the Heat of Formation at 298K and 1 bar
*/
virtual void modifyOneHf298SS(const size_t &k, const doublereal Hf298New) {
virtual void modifyOneHf298SS(const size_t& k, const doublereal Hf298New) {
m_spthermo->modifyOneHf298(k, Hf298New);
m_tlast += 0.0001234;
}

View file

@ -203,7 +203,7 @@ public:
* @param k Species k
* @param Hf298New Specify the new value of the Heat of Formation at 298K and 1 bar
*/
virtual void modifyOneHf298SS(const size_t &k, const doublereal Hf298New) {
virtual void modifyOneHf298SS(const size_t& k, const doublereal Hf298New) {
m_spthermo->modifyOneHf298(k, Hf298New);
}

View file

@ -413,7 +413,7 @@ public:
* units = m^3 / kmol
*/
virtual void getStandardVolumes(doublereal* vol) const;
virtual const vector_fp & getStandardVolumes() const;
virtual const vector_fp& getStandardVolumes() const;
//! Return a reference to a vector of the species standard molar volumes
const vector_fp& standardVolumes() const {

View file

@ -269,7 +269,7 @@ public:
* units = m^3 / kmol
*/
virtual void getStandardVolumes(doublereal* vol) const;
virtual const vector_fp & getStandardVolumes() const;
virtual const vector_fp& getStandardVolumes() const;
//! Set the temperature of the phase
@ -427,7 +427,7 @@ public:
* @param Hf298New Specify the new value of the Heat of Formation at 298K and 1 bar.
* units = J/kmol.
*/
void modifyOneHf298SS(const size_t &k, const doublereal Hf298New);
void modifyOneHf298SS(const size_t& k, const doublereal Hf298New);
#endif
//! Returns the vector of nondimensional

View file

@ -100,11 +100,11 @@ public:
* These routines are basically wrappers around the derived copy
* constructor.
*/
virtual Transport *duplMyselfAsTransport() const;
virtual Transport* duplMyselfAsTransport() const;
//! Specifies the %ThermPhase object.
//! Specifies the %ThermPhase object.
/*!
* We have relaxed this operation so that it will succeed when
* We have relaxed this operation so that it will succeed when
* the underlying old and new ThermoPhase objects have the same
* number of species and the same names of the species in the
* same order. The idea here is to allow copy constructors and duplicators

View file

@ -98,10 +98,10 @@ public:
* @param tp_ind enum TransportPropertyType containing the property id that this object
* is creating a parameterization for (e.g., viscosity)
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
*/
LTPspecies(const XML_Node * const propNode = 0, const std::string name = "-",
TransportPropertyType tp_ind = TP_UNKNOWN, const thermo_t* thermo = 0);
*/
LTPspecies(const XML_Node* const propNode = 0, const std::string name = "-",
TransportPropertyType tp_ind = TP_UNKNOWN, const thermo_t* thermo = 0);
//! Copy constructor
/*!
* @param right Object to be copied
@ -226,10 +226,10 @@ public:
* @param tp_ind enum TransportPropertyType containing the property id that this object
* is creating a parameterization for (e.g., viscosity)
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
*/
LTPspecies_Const(const XML_Node &propNode, const std::string name,
TransportPropertyType tp_ind, const thermo_t * const thermo);
*/
LTPspecies_Const(const XML_Node& propNode, const std::string name,
TransportPropertyType tp_ind, const thermo_t* const thermo);
//! Copy constructor
/*!
* @param right Object to be copied
@ -311,10 +311,10 @@ public:
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
*
*/
LTPspecies_Arrhenius(const XML_Node &propNode, const std::string name,
TransportPropertyType tp_ind, const thermo_t * thermo);
*/
LTPspecies_Arrhenius(const XML_Node& propNode, const std::string name,
TransportPropertyType tp_ind, const thermo_t* thermo);
//! Copy constructor
/*!
* @param right Object to be copied
@ -419,9 +419,9 @@ public:
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
*
*/
LTPspecies_Poly(const XML_Node &propNode, const std::string name, TransportPropertyType tp_ind, const thermo_t * thermo);
*/
LTPspecies_Poly(const XML_Node& propNode, const std::string name, TransportPropertyType tp_ind, const thermo_t* thermo);
//! Copy constructor
/*!
* @param right Object to be copied
@ -507,10 +507,10 @@ public:
* is creating a parameterization for (e.g., viscosity)
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
*
*/
LTPspecies_ExpT(const XML_Node &propNode, const std::string name,
TransportPropertyType tp_ind, const thermo_t* thermo);
*/
LTPspecies_ExpT(const XML_Node& propNode, const std::string name,
TransportPropertyType tp_ind, const thermo_t* thermo);
//! Copy constructor
/*!

View file

@ -260,14 +260,14 @@ private:
//! Update boolean for the mixture rule for the mixture thermal conductivity
bool m_condmix_ok;
public:
public:
vector_fp m_eps;
vector_fp m_sigma;
vector_fp m_alpha;
DenseMatrix m_dipole;
vector_fp m_zrot;
vector_fp m_crot;
private:
private:
//! Debug flag - turns on more printing
bool m_debug;
};

View file

@ -176,7 +176,7 @@ private:
//! Dense matrix for omega22
DenseMatrix m_om22;
public:
public:
vector_fp m_crot;
vector_fp m_cinternal;
vector_fp m_zrot;
@ -184,7 +184,7 @@ private:
vector_fp m_sigma;
vector_fp m_alpha;
DenseMatrix m_dipole;
private:
private:
vector_fp m_sqrt_eps_k;
DenseMatrix m_log_eps_k;

View file

@ -68,12 +68,12 @@ public:
}
/**
* The ionic conducitivity in 1/ohm/m.
* The ionic conducitivity in 1/ohm/m.
*/
virtual doublereal ionConductivity() ;
//! Returns the mixture thermal conductivity in W/m/K.
//! Returns the mixture thermal conductivity in W/m/K.
/*!
* Units are in W / m K or equivalently kg m / s3 K
*
@ -139,15 +139,15 @@ public:
friend class TransportFactory;
protected:
protected:
//! Initialize the transport object
/*!
* Here we change all of the internal dimensions to be sufficient.
* We get the object ready to do property evaluations.
* A lot of the input required to do property evaluations is
* contained in the SolidTransportParams class that is
* filled in TransportFactory.
* A lot of the input required to do property evaluations is
* contained in the SolidTransportParams class that is
* filled in TransportFactory.
*
* @param tr Transport parameters for all of the species
* in the phase.
@ -155,27 +155,27 @@ public:
virtual bool initSolid(SolidTransportData& tr);
private:
private:
//! Model type for the ionic conductivity
/*!
* shallow pointer that should be zero during destructor
*/
LTPspecies* m_ionConductivity;
//! Model type for the thermal conductivity
/*!
* shallow pointer that should be zero during destructor
*/
LTPspecies* m_thermalConductivity;
//! Model type for the electrical conductivity
/*!
* shallow pointer that should be zero during destructor
*/
LTPspecies* m_electConductivity;
//! Model type for the defectDiffusivity -- or more like a defect diffusivity in the context of the solid phase.
/*!
* shallow pointer that should be zero during destructor

View file

@ -23,49 +23,51 @@
#include "cantera/base/FactoryBase.h"
#include "cantera/transport/LTPspecies.h"
namespace Cantera {
namespace Cantera
{
//! Class SolidTransportData holds transport parameters for a
//! specific solid-phase species.
/*!
* A SolidTransportData object is created for a solid phase
* (not for each species as happens for the analogous LiquidTransportData).
*
* This class is mainly used to collect transport properties
* from the parse phase in the TranportFactory and transfer
* them to the Transport class. Transport properties are
* expressed by subclasses of LTPspecies.
* Note that we use the liquid phase species model for the solid phases.
* That is, for the time being at least, we ignore mixing models for
* solid phases and just specify a transport property at the level
* that we specify the transport property for a species in the liquid phase.
* One may need to be careful about deleting pointers to LTPspecies
* objects created in the TransportFactory.
*
* All of the pointers in this class are shallow pointers. Therefore, this
* is a passthrough class, which keeps track of pointer ownership by zeroing
* pointers as we go. Yes, Yes, yes, this is not good.
*/
class SolidTransportData : public TransportParams {
//! Class SolidTransportData holds transport parameters for a
//! specific solid-phase species.
/*!
* A SolidTransportData object is created for a solid phase
* (not for each species as happens for the analogous LiquidTransportData).
*
* This class is mainly used to collect transport properties
* from the parse phase in the TranportFactory and transfer
* them to the Transport class. Transport properties are
* expressed by subclasses of LTPspecies.
* Note that we use the liquid phase species model for the solid phases.
* That is, for the time being at least, we ignore mixing models for
* solid phases and just specify a transport property at the level
* that we specify the transport property for a species in the liquid phase.
* One may need to be careful about deleting pointers to LTPspecies
* objects created in the TransportFactory.
*
* All of the pointers in this class are shallow pointers. Therefore, this
* is a passthrough class, which keeps track of pointer ownership by zeroing
* pointers as we go. Yes, Yes, yes, this is not good.
*/
class SolidTransportData : public TransportParams
{
public:
public:
//! Default constructor
SolidTransportData();
//! Copy constructor
SolidTransportData(const SolidTransportData &right);
SolidTransportData(const SolidTransportData& right);
//! Assignment operator
SolidTransportData& operator=(const SolidTransportData& right );
SolidTransportData& operator=(const SolidTransportData& right);
//! Destructor
~SolidTransportData();
//! A SolidTransportData object is instantiated for each species.
//! A SolidTransportData object is instantiated for each species.
//! This is the species name for which this object is instantiated.
std::string speciesName;
std::string speciesName;
//! Model type for the ionic conductivity
/*!
* shallow pointer that should be zero during destructor
@ -77,13 +79,13 @@ namespace Cantera {
* shallow pointer that should be zero during destructor
*/
LTPspecies* thermalConductivity;
//! Model type for the electrical conductivity
/*!
* shallow pointer that should be zero during destructor
*/
LTPspecies* electConductivity;
//! Model type for the defectDiffusivity -- or more like a defect diffusivity in the context of the solid phase.
/*!
* shallow pointer that should be zero during destructor
@ -96,7 +98,7 @@ namespace Cantera {
*/
LTPspecies* defectActivity;
protected:
protected:
//protected members of SolidTransportData are analogous to those found in TransportParams
//! Local storage of the number of species
@ -123,7 +125,7 @@ namespace Cantera {
//! Log level
// int log_level;
};
};
}
#endif

View file

@ -30,7 +30,7 @@ namespace Cantera
class TransportParams;
class GasTransportParams;
class LiquidTransportParams;
class SolidTransportData;
class SolidTransportData;
/*!
* \addtogroup tranprops
@ -843,16 +843,15 @@ public:
* @param tr Reference to the parameter list that will be used
* to initialize the class
*/
virtual bool initSolid(SolidTransportData& tr)
{
err("initSolid");
return false;
virtual bool initSolid(SolidTransportData& tr) {
err("initSolid");
return false;
}
public:
//! Specifies the %ThermPhase object.
public:
//! Specifies the %ThermPhase object.
/*!
* We have relaxed this operation so that it will succeed when
* We have relaxed this operation so that it will succeed when
* the underlying old and new ThermoPhase objects have the same
* number of species and the same names of the species in the
* same order. The idea here is to allow copy constructors and duplicators
@ -863,7 +862,7 @@ public:
*
* @param thermo Reference to the ThermoPhase object that
* the transport object will use
*/
*/
virtual void setThermo(thermo_t& thermo);

View file

@ -95,8 +95,8 @@ public:
* @param thermo Pointer to the %ThermoPhase class
*/
virtual LTPspecies* newLTP(const XML_Node &trNode, const std::string &name,
TransportPropertyType tp_ind, thermo_t* thermo);
virtual LTPspecies* newLTP(const XML_Node& trNode, const std::string& name,
TransportPropertyType tp_ind, thermo_t* thermo);
//! Factory function for the construction of new LiquidTranInteraction
@ -186,7 +186,7 @@ private:
virtual void initSolidTransport(Transport* tr, thermo_t* thermo, int log_level=0);
private:
private:
//! Static instance of the factor -> This is the only instance of this
@ -267,17 +267,17 @@ private:
//! Read transport property data from a file for a solid phase
/*!
* Given a phase XML data base, this method constructs the
* Given a phase XML data base, this method constructs the
* SolidTransportData object containing the transport data for the phase.
*
* @param db Reference to XML_Node containing the phase.
* @param log Reference to an XML log file. (currently unused)
* @param tr Reference to the SolidTransportData object that will contain the results.
*/
void getSolidTransportData(const XML_Node &transportNode,
XML_Node& log,
const std::string phaseName,
SolidTransportData& tr);
void getSolidTransportData(const XML_Node& transportNode,
XML_Node& log,
const std::string phaseName,
SolidTransportData& tr);
//! Generate polynomial fits to the viscosity, conductivity, and
@ -348,14 +348,14 @@ private:
*/
void setupLiquidTransport(std::ostream& flog, thermo_t* thermo, int log_level, LiquidTransportParams& trParam);
//! Prepare to build a new transport manager for solids
//! Prepare to build a new transport manager for solids
/*!
* @param flog Reference to the ostream for writing log info
* @param thermo Pointer to the %ThermoPhase object
* @param log_level log level
* @param trParam SolidTransportData structure to be filled up with information
*/
void setupSolidTransport(std::ostream &flog, thermo_t* thermo, int log_level, SolidTransportData& trParam);
void setupSolidTransport(std::ostream& flog, thermo_t* thermo, int log_level, SolidTransportData& trParam);
//! Second-order correction to the binary diffusion coefficients

View file

@ -3,7 +3,7 @@
#include "cantera/numerics/Func1.h"
typedef double (*callback_wrapper)(double, void*, void**);
typedef double(*callback_wrapper)(double, void*, void**);
// A C++ exception that holds a Python exception so that it can be re-raised
// by translate_exception()
@ -25,8 +25,7 @@ class Func1Py : public Cantera::Func1
public:
Func1Py(callback_wrapper callback, void* pyobj) :
m_callback(callback),
m_pyobj(pyobj)
{
m_pyobj(pyobj) {
}
double eval(double t) const {
@ -49,8 +48,7 @@ private:
// cdef double eval(double) except +translate_exception
inline int translate_exception()
{
try
{
try {
if (!PyErr_Occurred()) {
// Let the latest Python exception pass through and ignore the
// current one.

View file

@ -5,12 +5,12 @@
// Wrappers for preprocessor defines
std::string get_cantera_version()
{
return std::string(CANTERA_VERSION);
return std::string(CANTERA_VERSION);
}
int get_sundials_version()
{
return SUNDIALS_VERSION;
return SUNDIALS_VERSION;
}
// Function which populates a 1D array

View file

@ -269,7 +269,7 @@ void addFloatArray(Cantera::XML_Node& node, const std::string& title, const size
* @param name Name of the XML node
* @param n Length of the doubles vector.
* @param values Pointer to a vector of doubles
* @param unitsString String name of the Units attribute. This is an optional
* @param unitsString String name of the Units attribute. This is an optional
* parameter. The default is to
* have an empty string.
* @param type String type. This is an optional parameter. The default
@ -284,22 +284,26 @@ void addFloatArray(Cantera::XML_Node& node, const std::string& title, const size
* entry.
*
*/
void addNamedFloatArray(Cantera::XML_Node& node, const std::string &name, const int n,
const doublereal* const vals, const std::string units,
const std::string type, const doublereal minval,
const doublereal maxval)
void addNamedFloatArray(Cantera::XML_Node& node, const std::string& name, const int n,
const doublereal* const vals, const std::string units,
const std::string type, const doublereal minval,
const doublereal maxval)
{
int i;
std::string v = "";
for (i = 0; i < n; i++) {
v += fp2str(vals[i],FP_Format);
if (i == n-1) v += "\n";
else if (i > 0 && (i+1) % 3 == 0) v += ",\n";
else v += ", ";
v += fp2str(vals[i],FP_Format);
if (i == n-1) {
v += "\n";
} else if (i > 0 && (i+1) % 3 == 0) {
v += ",\n";
} else {
v += ", ";
}
}
XML_Node& f = node.addChild(name, v);
if (type != "") {
f.addAttribute("type",type);
f.addAttribute("type",type);
}
/*
* Add vtype, which indicates the type of the value. Here we specify it as a list of floats separated
@ -308,9 +312,15 @@ void addNamedFloatArray(Cantera::XML_Node& node, const std::string &name, const
f.addAttribute("vtype", "floatArray");
f.addAttribute("size", n);
if (units != "") f.addAttribute("units", units);
if (minval != Undef) f.addAttribute("min", minval);
if (maxval != Undef) f.addAttribute("max", maxval);
if (units != "") {
f.addAttribute("units", units);
}
if (minval != Undef) {
f.addAttribute("min", minval);
}
if (maxval != Undef) {
f.addAttribute("max", maxval);
}
}
//====================================================================================================================
@ -401,62 +411,63 @@ std::string getChildValue(const Cantera::XML_Node& parent, const std::string& na
return parent(nameString);
}
//====================================================================================================================
// This function reads a child node with the name, "string", with a specific
// title attribute named "titleString"
/*
* This function will read a child node to the current XML node, with the
* name "string". It must have a title attribute, named titleString, and the body
* of the XML node will be read into the valueString output argument.
*
* Example:
*
* Code snipet:
* @verbatum
const XML_Node &node;
getString(XML_Node& node, std::string titleString, std::string valueString,
std::string typeString);
@endverbatum
*
* Reads the following the snippet in the XML file:
* @verbatum
<string title="titleString" type="typeString">
valueString
<\string>
@endverbatum
*
* @param node Reference to the XML_Node object of the parent XML element
* @param titleString String name of the title attribute of the child node
* @param valueString Value string that is found in the child node. output variable
* @param typeString String type. This is an optional output variable. It is filled
* with the attribute "type" of the XML entry.
*/
void getString(const Cantera::XML_Node& node, const std::string &titleString, std::string& valueString,
std::string& typeString) {
//====================================================================================================================
// This function reads a child node with the name, "string", with a specific
// title attribute named "titleString"
/*
* This function will read a child node to the current XML node, with the
* name "string". It must have a title attribute, named titleString, and the body
* of the XML node will be read into the valueString output argument.
*
* Example:
*
* Code snipet:
* @verbatum
const XML_Node &node;
getString(XML_Node& node, std::string titleString, std::string valueString,
std::string typeString);
@endverbatum
*
* Reads the following the snippet in the XML file:
* @verbatum
<string title="titleString" type="typeString">
valueString
<\string>
@endverbatum
*
* @param node Reference to the XML_Node object of the parent XML element
* @param titleString String name of the title attribute of the child node
* @param valueString Value string that is found in the child node. output variable
* @param typeString String type. This is an optional output variable. It is filled
* with the attribute "type" of the XML entry.
*/
void getString(const Cantera::XML_Node& node, const std::string& titleString, std::string& valueString,
std::string& typeString)
{
valueString = "";
typeString = "";
XML_Node* s = getByTitle(node, titleString);
if (s)
if (s->name() == "string") {
valueString = (*s).value();
typeString = (*s)["type"];
return;
}
}
if (s->name() == "string") {
valueString = (*s).value();
typeString = (*s)["type"];
return;
}
}
//=======================================================================================================================
// This function attempts to read a named child node and returns with the contents in the value string.
// title attribute named "titleString"
/*
/*
* This function will read a child node to the current XML node, with the
* name "string". It must have a title attribute, named titleString, and the body
* of the XML node will be read into the valueString output argument.
*
* If the child node is not found then the empty string is returned.
*
* Example:
* Example:
*
* Code snipet:
* @verbatum
@ -489,24 +500,24 @@ std::string getChildValue(const Cantera::XML_Node& parent, const std::string& na
* @param typeString String type. This is an optional output variable. It is filled
* with the attribute "type" of the XML entry. output variable
*/
void getNamedStringValue(const Cantera::XML_Node& node, const std::string &nameString, std::string& valueString,
std::string& typeString)
void getNamedStringValue(const Cantera::XML_Node& node, const std::string& nameString, std::string& valueString,
std::string& typeString)
{
valueString = "";
typeString = "";
if (node.hasChild(nameString)) {
XML_Node &xc = node.child(nameString);
valueString = xc.value();
typeString = xc["type"];
XML_Node& xc = node.child(nameString);
valueString = xc.value();
typeString = xc["type"];
} else {
XML_Node* s = getByTitle(node, nameString);
if (s) {
if (s->name() == "string") {
valueString = (*s).value();
typeString = (*s)["type"];
return;
}
}
XML_Node* s = getByTitle(node, nameString);
if (s) {
if (s->name() == "string") {
valueString = (*s).value();
typeString = (*s)["type"];
return;
}
}
}
}
//====================================================================================================================
@ -1111,17 +1122,18 @@ size_t getFloatArray(const Cantera::XML_Node& node, std::vector<doublereal> & v,
return v.size();
}
//====================================================================================================================
int getNamedFloatArray(const Cantera::XML_Node& parentNode, const std::string & nodeName, std::vector<doublereal> & v,
const bool convert, const std::string unitsString) {
//====================================================================================================================
int getNamedFloatArray(const Cantera::XML_Node& parentNode, const std::string& nodeName, std::vector<doublereal> & v,
const bool convert, const std::string unitsString)
{
std::string::size_type icom;
std::string numstr;
doublereal dtmp;
std::string nn = parentNode.name();
v.clear();
const Cantera::XML_Node *readNode = parentNode.findByName(nodeName);
const Cantera::XML_Node* readNode = parentNode.findByName(nodeName);
if (!readNode) {
return 0;
return 0;
}
doublereal vmin = Undef;
@ -1132,17 +1144,19 @@ size_t getFloatArray(const Cantera::XML_Node& node, std::vector<doublereal> & v,
*/
std::string units = (*readNode)["units"];
if (units != "" && convert) {
if (unitsString == "actEnergy" && units != "") {
funit = actEnergyToSI(units);
} else if (unitsString != "" && units != "") {
funit = toSI(units);
}
if (unitsString == "actEnergy" && units != "") {
funit = actEnergyToSI(units);
} else if (unitsString != "" && units != "") {
funit = toSI(units);
}
}
if ((*readNode)["min"] != "")
vmin = atofCheck((*readNode)["min"].c_str());
if ((*readNode)["max"] != "")
vmax = atofCheck((*readNode)["max"].c_str());
if ((*readNode)["min"] != "") {
vmin = atofCheck((*readNode)["min"].c_str());
}
if ((*readNode)["max"] != "") {
vmax = atofCheck((*readNode)["max"].c_str());
}
int expectedSize = 0;
nn = (*readNode)["size"];
@ -1150,58 +1164,57 @@ size_t getFloatArray(const Cantera::XML_Node& node, std::vector<doublereal> & v,
nn = (*readNode)["vtype"];
if (nn != "floatArray") {
throw CanteraError("getNamedFloatArray",
"node named " + nodeName + "didn't have correct vtype");
throw CanteraError("getNamedFloatArray",
"node named " + nodeName + "didn't have correct vtype");
}
doublereal vv;
doublereal vv;
std::string val = readNode->value();
while (1 > 0) {
icom = val.find(',');
if (icom != string::npos) {
numstr = val.substr(0,icom);
val = val.substr(icom+1,val.size());
dtmp = atofCheck(numstr.c_str());
v.push_back(dtmp);
}
else {
/*
* This little bit of code is to allow for the
* possibility of a comma being the last
* item in the value text. This was allowed in
* previous versions of Cantera, even though it
* would appear to be odd. So, we keep the
* possibilty in for backwards compatibility.
*/
int nlen = strlen(val.c_str());
if (nlen > 0) {
dtmp = atofCheck(val.c_str());
v.push_back(dtmp);
icom = val.find(',');
if (icom != string::npos) {
numstr = val.substr(0,icom);
val = val.substr(icom+1,val.size());
dtmp = atofCheck(numstr.c_str());
v.push_back(dtmp);
} else {
/*
* This little bit of code is to allow for the
* possibility of a comma being the last
* item in the value text. This was allowed in
* previous versions of Cantera, even though it
* would appear to be odd. So, we keep the
* possibilty in for backwards compatibility.
*/
int nlen = strlen(val.c_str());
if (nlen > 0) {
dtmp = atofCheck(val.c_str());
v.push_back(dtmp);
}
break;
}
vv = v.back();
if (vmin != Undef && vv < vmin - Tiny) {
writelog("\nWarning: value "+fp2str(vv)+
" is below lower limit of " +fp2str(vmin)+".\n");
}
if (vmax != Undef && vv > vmax + Tiny) {
writelog("\nWarning: value "+fp2str(vv)+
" is above upper limit of " +fp2str(vmin)+".\n");
}
break;
}
vv = v.back();
if (vmin != Undef && vv < vmin - Tiny) {
writelog("\nWarning: value "+fp2str(vv)+
" is below lower limit of " +fp2str(vmin)+".\n");
}
if (vmax != Undef && vv > vmax + Tiny) {
writelog("\nWarning: value "+fp2str(vv)+
" is above upper limit of " +fp2str(vmin)+".\n");
}
}
int nv = v.size();
for (int n = 0; n < nv; n++) {
v[n] *= funit;
v[n] *= funit;
}
if (nv != expectedSize) {
throw CanteraError("getNamedFloatArray",
"node named " + nodeName + "didn't have correct number of floats"
+ int2str(expectedSize) + " vs " + int2str(nv));
throw CanteraError("getNamedFloatArray",
"node named " + nodeName + "didn't have correct number of floats"
+ int2str(expectedSize) + " vs " + int2str(nv));
}
return nv;
}
}
//====================================================================================================================
// This routine is used to interpret the value portions of XML
// elements that contain colon separated pairs.

View file

@ -160,7 +160,7 @@ addPhase(ThermoPhase* p, doublereal moles)
// If the mixture temperature hasn't been set, then set the
// temperature and pressure to the values for the phase being
// added. There is no good way to do this. However, this will be overridden later.
// added. There is no good way to do this. However, this will be overridden later.
if (m_temp == 298.15 && p->temperature() > 2.0E-3) {
m_temp = p->temperature();
m_press = p->pressure();

View file

@ -79,7 +79,7 @@ bool VCS_SOLVE::vcs_elabcheck(int ibound)
* This logic is for charge neutrality condition
*/
if (m_elType[i] == VCS_ELEM_TYPE_CHARGENEUTRALITY &&
m_elemAbundancesGoal[i] != 0.0) {
m_elemAbundancesGoal[i] != 0.0) {
throw Cantera::CanteraError("VCS_SOLVE::vcs_elabcheck",
"Problem with charge neutrality condition");
}

View file

@ -160,8 +160,8 @@ void VCS_SOLVE::vcs_nondim_TP()
tmole_orig);
plogendl();
throw Cantera::CanteraError("VCS_SOLVE::vcs_nondim_TP",
" Total input moles ," + Cantera::fp2str(tmole_orig) +
"is outside the range handled by vcs.\n");
" Total input moles ," + Cantera::fp2str(tmole_orig) +
"is outside the range handled by vcs.\n");
}
// Determine the scale of the problem

View file

@ -16,7 +16,8 @@
#include <cstdlib>
#include <cmath>
namespace VCSnonideal {
namespace VCSnonideal
{
// Calculates formation reaction step sizes.
/*
@ -63,7 +64,7 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
}
plogf("\n");
plogf(" --- Species KMoles Rxn_Adjustment DeltaG"
" | Comment\n");
" | Comment\n");
}
#endif
/*
@ -73,9 +74,9 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
if (m_useActCoeffJac) {
vcs_CalcLnActCoeffJac(VCS_DATA_PTR(m_molNumSpecies_old));
}
/************************************************************************
******** LOOP OVER THE FORMATION REACTIONS *****************************
************************************************************************/
/************************************************************************
******** LOOP OVER THE FORMATION REACTIONS *****************************
************************************************************************/
for (size_t irxn = 0; irxn < m_numRxnRdc; ++irxn) {
#ifdef DEBUG_MODE
@ -167,8 +168,8 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
if (m_debug_print_lvl >= 2) {
plogf(" --- %-12.12s", m_speciesName[kspec].c_str());
plogf(" %12.4E %12.4E %12.4E | %s\n",
m_molNumSpecies_old[kspec], m_deltaMolNumSpecies[kspec],
m_deltaGRxn_new[irxn], ANOTE);
m_molNumSpecies_old[kspec], m_deltaMolNumSpecies[kspec],
m_deltaGRxn_new[irxn], ANOTE);
}
#endif
continue;
@ -183,8 +184,8 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
if (m_debug_print_lvl >= 2) {
plogf(" --- %-12.12s", m_speciesName[kspec].c_str());
plogf(" %12.4E %12.4E %12.4E | %s\n",
m_molNumSpecies_old[kspec], m_deltaMolNumSpecies[kspec],
m_deltaGRxn_new[irxn], ANOTE);
m_molNumSpecies_old[kspec], m_deltaMolNumSpecies[kspec],
m_deltaGRxn_new[irxn], ANOTE);
}
#endif
continue;
@ -328,8 +329,8 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
if (m_debug_print_lvl >= 2) {
plogf(" --- %-12.12s", m_speciesName[kspec].c_str());
plogf(" %12.4E %12.4E %12.4E | %s\n",
m_molNumSpecies_old[kspec], m_deltaMolNumSpecies[kspec],
m_deltaGRxn_new[irxn], ANOTE);
m_molNumSpecies_old[kspec], m_deltaMolNumSpecies[kspec],
m_deltaGRxn_new[irxn], ANOTE);
}
#endif
continue;
@ -358,10 +359,10 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
if (m_debug_print_lvl >= 2) {
plogf(" --- %-12.12s", m_speciesName[kspec].c_str());
plogf(" %12.4E %12.4E %12.4E | %s\n",
m_molNumSpecies_old[kspec], m_deltaMolNumSpecies[kspec],
m_deltaGRxn_new[irxn], ANOTE);
m_molNumSpecies_old[kspec], m_deltaMolNumSpecies[kspec],
m_deltaGRxn_new[irxn], ANOTE);
plogf(" --- vcs_RxnStepSizes Special section to set up to delete %s",
m_speciesName[k].c_str());
m_speciesName[k].c_str());
plogendl();
}
#endif
@ -388,8 +389,8 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
if (m_debug_print_lvl >= 2) {
plogf(" --- %-12.12s", m_speciesName[kspec].c_str());
plogf(" %12.4E %12.4E %12.4E | %s\n",
m_molNumSpecies_old[kspec], m_deltaMolNumSpecies[kspec],
m_deltaGRxn_new[irxn], ANOTE);
m_molNumSpecies_old[kspec], m_deltaMolNumSpecies[kspec],
m_deltaGRxn_new[irxn], ANOTE);
}
#endif
} /* End of loop over m_speciesUnknownType */
@ -499,7 +500,7 @@ int VCS_SOLVE::vcs_rxn_adj_cg()
plogf(" --- ");
plogf("%-12.12s", m_speciesName[kspec].c_str());
plogf(" %12.4E %12.4E | %s\n", m_molNumSpecies_old[kspec],
m_deltaMolNumSpecies[kspec], ANOTE);
m_deltaMolNumSpecies[kspec], ANOTE);
#endif
continue;
}
@ -513,7 +514,7 @@ int VCS_SOLVE::vcs_rxn_adj_cg()
plogf(" --- ");
plogf("%-12.12s", m_speciesName[kspec].c_str());
plogf(" %12.4E %12.4E | %s\n", m_molNumSpecies_old[kspec],
m_deltaMolNumSpecies[kspec], ANOTE);
m_deltaMolNumSpecies[kspec], ANOTE);
#endif
continue;
}
@ -616,7 +617,7 @@ int VCS_SOLVE::vcs_rxn_adj_cg()
plogf(" --- ");
plogf("%-12.12s", m_speciesName[kspec].c_str());
plogf(" %12.4E %12.4E | %s\n", m_molNumSpecies_old[kspec],
m_deltaMolNumSpecies[kspec], ANOTE);
m_deltaMolNumSpecies[kspec], ANOTE);
#endif
} /* End of loop over non-component stoichiometric formation reactions */
@ -877,7 +878,7 @@ double VCS_SOLVE::vcs_line_search(const size_t irxn, const double dx_orig)
vcs_setFlagsVolPhases(false, VCS_STATECALC_NEW);
double deltaG1 = deltaG_Recalc_Rxn(VCS_STATECALC_NEW, irxn, VCS_DATA_PTR(m_molNumSpecies_new),
ac, VCS_DATA_PTR(m_feSpecies_new));
ac, VCS_DATA_PTR(m_feSpecies_new));
/*
* If deltaG hasn't switched signs when going the full distance
@ -916,7 +917,7 @@ double VCS_SOLVE::vcs_line_search(const size_t irxn, const double dx_orig)
}
vcs_setFlagsVolPhases(false, VCS_STATECALC_NEW);
double deltaG = deltaG_Recalc_Rxn(VCS_STATECALC_NEW, irxn, VCS_DATA_PTR(m_molNumSpecies_new),
ac, VCS_DATA_PTR(m_feSpecies_new));
ac, VCS_DATA_PTR(m_feSpecies_new));
/*
* If deltaG hasn't switched signs when going the full distance
* then we are heading in the appropriate direction, and
@ -938,7 +939,8 @@ double VCS_SOLVE::vcs_line_search(const size_t irxn, const double dx_orig)
}
}
finalize: vcs_setFlagsVolPhases(false, VCS_STATECALC_NEW);
finalize:
vcs_setFlagsVolPhases(false, VCS_STATECALC_NEW);
if (its >= MAXITS) {
#ifdef DEBUG_MODE
sprintf(ANOTE, "Rxn reduced to zero step size from %g to %g (MAXITS)", dx_orig, dx);

View file

@ -54,7 +54,7 @@ VCS_SOLVE::VCS_SOLVE() :
m_totalMoleScale(1.0),
m_useActCoeffJac(0),
m_totalVol(0.0),
m_Faraday_dim(Cantera::ElectronCharge * Cantera::Avogadro),
m_Faraday_dim(Cantera::ElectronCharge* Cantera::Avogadro),
m_VCount(0),
m_debug_print_lvl(0),
m_timing_print_lvl(1),

View file

@ -3651,12 +3651,12 @@ size_t VCS_SOLVE::vcs_basisOptMax(const double* const molNum, const size_t j,
double big = molNum[j] * m_spSize[j] * 1.01;
if (m_spSize[j] <= 0.0) {
throw CanteraError("VCS_SOLVE::vcs_basisOptMax",
"spSize is nonpositive");
"spSize is nonpositive");
}
for (size_t i = j + 1; i < n; ++i) {
if (m_spSize[i] <= 0.0) {
throw CanteraError("VCS_SOLVE::vcs_basisOptMax",
"spSize is nonpositive");
"spSize is nonpositive");
}
bool doSwap = false;
if (m_SSPhase[j]) {

View file

@ -1367,7 +1367,7 @@ void InterfaceKinetics::setPhaseExistence(const size_t iphase, const int exists)
if (!m_phaseExists[iphase]) {
m_phaseExistsCheck--;
if (m_phaseExistsCheck < 0) {
m_phaseExistsCheck = 0;
m_phaseExistsCheck = 0;
}
m_phaseExists[iphase] = true;
}

View file

@ -27,7 +27,7 @@ void onedimmethods(int nlhs, mxArray* plhs[],
switch (job) {
// construct a new stagnation flow instance
// construct a new stagnation flow instance
case 1:
checkNArgs(7, nrhs);
ph = getInt(prhs[3]);
@ -37,38 +37,38 @@ void onedimmethods(int nlhs, mxArray* plhs[],
indx = stflow_new(ph, kin, tr, itype);
break;
// construct a new Inlet1D instance
// construct a new Inlet1D instance
case 2:
checkNArgs(3, nrhs);
indx = inlet_new();
break;
// construct a new Surf1D instance
// construct a new Surf1D instance
case 3:
checkNArgs(3, nrhs);
indx = surf_new();
break;
// construct a new Symm1D instance
// construct a new Symm1D instance
case 4:
checkNArgs(3, nrhs);
indx = symm_new();
break;
// construct a new Outlet1D instance
// construct a new Outlet1D instance
case 5:
checkNArgs(3, nrhs);
indx = outlet_new();
break;
// construct a new ReactingSurf1D instance
// construct a new ReactingSurf1D instance
case 6:
checkNArgs(4, nrhs);
indx = reactingsurf_new();
reactingsurf_setkineticsmgr(indx, getInt(prhs[3]));
break;
// construct a new Sim1D instance
// construct a new Sim1D instance
case 8: {
checkNArgs(5, nrhs);
nd = getInt(prhs[3]);

View file

@ -534,7 +534,8 @@ double CVodesIntegrator::sensitivity(size_t k, size_t p)
return NV_Ith_S(m_yS[p],k);
}
string CVodesIntegrator::getErrorInfo(int N) {
string CVodesIntegrator::getErrorInfo(int N)
{
N_Vector errs = N_VNew_Serial(m_neq);
N_Vector errw = N_VNew_Serial(m_neq);
CVodeGetErrWeights(m_cvode_mem, errw);

View file

@ -113,20 +113,18 @@ void DenseMatrix::mult(const double* b, double* prod) const
static_cast<int>(nRows()), b, 1, 0.0, prod, 1);
}
//====================================================================================================================
void DenseMatrix::mult(const DenseMatrix &B, DenseMatrix &prod) const
void DenseMatrix::mult(const DenseMatrix& B, DenseMatrix& prod) const
{
if(m_ncols != B.nColumns() || m_nrows != B.nRows() || m_ncols != m_nrows || m_ncols != prod.nColumns() || m_nrows != prod.nColumns() )
{
throw CanteraError("mult(const DenseMatrix &B, DenseMatrix &prod)",
"Cannot multiply matrices that are not square and/or not the same size.");
}
const doublereal * const *bcols = B.const_colPts();
doublereal * const *prodcols = prod.colPts();
for(size_t col=0; col < m_ncols; ++col)
{
// Loop over ncols multiplying A*column of B and storing in corresponding prod column
mult(bcols[col], prodcols[col]);
}
if (m_ncols != B.nColumns() || m_nrows != B.nRows() || m_ncols != m_nrows || m_ncols != prod.nColumns() || m_nrows != prod.nColumns()) {
throw CanteraError("mult(const DenseMatrix &B, DenseMatrix &prod)",
"Cannot multiply matrices that are not square and/or not the same size.");
}
const doublereal* const* bcols = B.const_colPts();
doublereal* const* prodcols = prod.colPts();
for (size_t col=0; col < m_ncols; ++col) {
// Loop over ncols multiplying A*column of B and storing in corresponding prod column
mult(bcols[col], prodcols[col]);
}
}
//====================================================================================================================
void DenseMatrix::leftMult(const double* const b, double* const prod) const

View file

@ -27,7 +27,8 @@ namespace Cantera
{
// unnamed-namespace for local helpers
namespace {
namespace
{
class Indx
{

View file

@ -343,7 +343,7 @@ void StFlow::_finalize(const doublereal* x)
*/
void StFlow::eval(size_t jg, doublereal* xg,
doublereal* rg, integer* diagg, doublereal rdt)
doublereal* rg, integer* diagg, doublereal rdt)
{
// if evaluating a Jacobian, and the global point is outside
@ -519,8 +519,7 @@ void StFlow::eval(size_t jg, doublereal* xg,
rsd[index(c_offset_T, j)] -= rdt*(T(x,j) - T_prev(j));
diag[index(c_offset_T, j)] = 1;
}
else {
} else {
// residual equations if the energy equation is disabled
rsd[index(c_offset_T, j)] = T(x,j) - T_fixed(j);
diag[index(c_offset_T, j)] = 0;
@ -675,7 +674,7 @@ void StFlow::updateDiffFluxes(const doublereal* x, size_t j0, size_t j1)
if (m_do_soret) {
for (m = j0; m < j1; m++) {
gradlogT = 2.0 * (T(x,m+1) - T(x,m)) /
((T(x,m+1) + T(x,m)) * (z(m+1) - z(m)));
((T(x,m+1) + T(x,m)) * (z(m+1) - z(m)));
for (k = 0; k < m_nsp; k++) {
m_flux(k,m) -= m_dthermal(k,m)*gradlogT;
}
@ -921,7 +920,7 @@ void StFlow::setJac(MultiJac* jac)
}
void AxiStagnFlow::evalRightBoundary(doublereal* x, doublereal* rsd,
integer* diag, doublereal rdt)
integer* diag, doublereal rdt)
{
size_t j = m_points - 1;
// the boundary object connected to the right of this one may modify or
@ -943,7 +942,7 @@ void AxiStagnFlow::evalRightBoundary(doublereal* x, doublereal* rsd,
}
void AxiStagnFlow::evalContinuity(size_t j, doublereal* x, doublereal* rsd,
integer* diag, doublereal rdt)
integer* diag, doublereal rdt)
{
//----------------------------------------------
// Continuity equation
@ -965,7 +964,7 @@ void AxiStagnFlow::evalContinuity(size_t j, doublereal* x, doublereal* rsd,
}
void FreeFlame::evalRightBoundary(doublereal* x, doublereal* rsd,
integer* diag, doublereal rdt)
integer* diag, doublereal rdt)
{
size_t j = m_points - 1;
@ -990,7 +989,7 @@ void FreeFlame::evalRightBoundary(doublereal* x, doublereal* rsd,
void FreeFlame::evalContinuity(size_t j, doublereal* x, doublereal* rsd,
integer* diag, doublereal rdt)
integer* diag, doublereal rdt)
{
//----------------------------------------------
// Continuity equation

View file

@ -141,7 +141,7 @@ int Refiner::analyze(size_t n, const doublereal* z,
for (j = 0; j < n-2; j++) {
r = fabs(s[j+1] - s[j]) / (dmax + m_thresh/dz[j]);
if (r > 1.0 && dz[j] >= 2 * m_gridmin &&
dz[j+1] >= 2 * m_gridmin) {
dz[j+1] >= 2 * m_gridmin) {
m_c[name] = 1;
m_loc[j] = 1;
m_loc[j+1] = 1;

View file

@ -155,7 +155,7 @@ doublereal ConstCpPoly::reportHf298(doublereal* const h298) const
return h;
}
void ConstCpPoly::modifyOneHf298(const size_t &k, const doublereal Hf298New)
void ConstCpPoly::modifyOneHf298(const size_t& k, const doublereal Hf298New)
{
if (k != m_index) {
return;

View file

@ -175,7 +175,7 @@ public:
virtual doublereal reportHf298(doublereal* const h298 = 0) const;
virtual void modifyOneHf298(const size_t &k, const doublereal Hf298New);
virtual void modifyOneHf298(const size_t& k, const doublereal Hf298New);
#endif

View file

@ -186,7 +186,7 @@ void GibbsExcessVPSSTP::calcDensity()
{
vector_fp vbar = getPartialMolarVolumes();
// double *vbar = &m_pp[0];
// getPartialMolarVolumes(&vbar[0]);
// getPartialMolarVolumes(&vbar[0]);
doublereal vtotal = 0.0;
for (size_t i = 0; i < m_kk; i++) {
@ -294,9 +294,9 @@ void GibbsExcessVPSSTP::getPartialMolarVolumes(doublereal* vbar) const
getStandardVolumes(vbar);
}
const vector_fp & GibbsExcessVPSSTP::getPartialMolarVolumes() const
const vector_fp& GibbsExcessVPSSTP::getPartialMolarVolumes() const
{
return getStandardVolumes();
return getStandardVolumes();
}

View file

@ -329,27 +329,27 @@ operator=(const HMWSoln& b)
m_Lambda_nj_P = b.m_Lambda_nj_P;
m_Lambda_nj_coeff = b.m_Lambda_nj_coeff;
m_Mu_nnn = b.m_Mu_nnn;
m_Mu_nnn_L = b.m_Mu_nnn_L;
m_Mu_nnn_LL = b.m_Mu_nnn_LL;
m_Mu_nnn_P = b.m_Mu_nnn_P;
m_Mu_nnn_coeff = b.m_Mu_nnn_coeff;
m_Mu_nnn = b.m_Mu_nnn;
m_Mu_nnn_L = b.m_Mu_nnn_L;
m_Mu_nnn_LL = b.m_Mu_nnn_LL;
m_Mu_nnn_P = b.m_Mu_nnn_P;
m_Mu_nnn_coeff = b.m_Mu_nnn_coeff;
m_lnActCoeffMolal_Scaled = b.m_lnActCoeffMolal_Scaled;
m_lnActCoeffMolal_Unscaled = b.m_lnActCoeffMolal_Unscaled;
m_dlnActCoeffMolaldT_Scaled = b.m_dlnActCoeffMolaldT_Scaled;
m_dlnActCoeffMolaldT_Scaled = b.m_dlnActCoeffMolaldT_Scaled;
m_dlnActCoeffMolaldT_Unscaled = b.m_dlnActCoeffMolaldT_Unscaled;
m_d2lnActCoeffMolaldT2_Scaled = b.m_d2lnActCoeffMolaldT2_Scaled;
m_d2lnActCoeffMolaldT2_Scaled = b.m_d2lnActCoeffMolaldT2_Scaled;
m_d2lnActCoeffMolaldT2_Unscaled= b.m_d2lnActCoeffMolaldT2_Unscaled;
m_dlnActCoeffMolaldP_Scaled = b.m_dlnActCoeffMolaldP_Scaled;
m_dlnActCoeffMolaldP_Scaled = b.m_dlnActCoeffMolaldP_Scaled;
m_dlnActCoeffMolaldP_Unscaled = b.m_dlnActCoeffMolaldP_Unscaled;
m_molalitiesCropped = b.m_molalitiesCropped;
m_molalitiesAreCropped = b.m_molalitiesAreCropped;
m_CounterIJ = b.m_CounterIJ;
m_molalitiesCropped = b.m_molalitiesCropped;
m_molalitiesAreCropped = b.m_molalitiesAreCropped;
m_CounterIJ = b.m_CounterIJ;
m_gfunc_IJ = b.m_gfunc_IJ;
m_g2func_IJ = b.m_g2func_IJ;
@ -411,7 +411,7 @@ operator=(const HMWSoln& b)
CROP_ln_gamma_k_min = b.CROP_ln_gamma_k_min;
CROP_ln_gamma_k_max = b.CROP_ln_gamma_k_max;
CROP_speciesCropped_ = b.CROP_speciesCropped_;
m_debugCalc = b.m_debugCalc;
}
return *this;

View file

@ -1047,203 +1047,205 @@ void HMWSoln::initThermo()
initLengths();
}
/*
* Import, construct, and initialize a HMWSoln phase
* specification from an XML tree into the current object.
*
* This routine is a precursor to constructPhaseXML(XML_Node*)
* routine, which does most of the work.
*
* @param infile XML file containing the description of the
* phase
*
* @param id Optional parameter identifying the name of the
* phase. If none is given, the first XML
* phase element will be used.
*/
void HMWSoln::constructPhaseFile(std::string inputFile, std::string id) {
/*
* Import, construct, and initialize a HMWSoln phase
* specification from an XML tree into the current object.
*
* This routine is a precursor to constructPhaseXML(XML_Node*)
* routine, which does most of the work.
*
* @param infile XML file containing the description of the
* phase
*
* @param id Optional parameter identifying the name of the
* phase. If none is given, the first XML
* phase element will be used.
*/
void HMWSoln::constructPhaseFile(std::string inputFile, std::string id)
{
if (inputFile.size() == 0) {
throw CanteraError("HMWSoln:constructPhaseFile",
"input file is null");
}
string path = findInputFile(inputFile);
std::ifstream fin(path.c_str());
if (!fin) {
throw CanteraError("HMWSoln:constructPhaseFile","could not open "
+path+" for reading.");
}
/*
* The phase object automatically constructs an XML object.
* Use this object to store information.
*/
XML_Node &phaseNode_XML = xml();
XML_Node *fxml = new XML_Node();
fxml->build(fin);
XML_Node *fxml_phase = findXMLPhase(fxml, id);
if (!fxml_phase) {
throw CanteraError("HMWSoln:constructPhaseFile",
"ERROR: Can not find phase named " +
id + " in file named " + inputFile);
}
fxml_phase->copy(&phaseNode_XML);
constructPhaseXML(*fxml_phase, id);
delete fxml;
}
if (inputFile.size() == 0) {
throw CanteraError("HMWSoln:constructPhaseFile",
"input file is null");
}
string path = findInputFile(inputFile);
std::ifstream fin(path.c_str());
if (!fin) {
throw CanteraError("HMWSoln:constructPhaseFile","could not open "
+path+" for reading.");
}
/*
* The phase object automatically constructs an XML object.
* Use this object to store information.
*/
XML_Node& phaseNode_XML = xml();
XML_Node* fxml = new XML_Node();
fxml->build(fin);
XML_Node* fxml_phase = findXMLPhase(fxml, id);
if (!fxml_phase) {
throw CanteraError("HMWSoln:constructPhaseFile",
"ERROR: Can not find phase named " +
id + " in file named " + inputFile);
}
fxml_phase->copy(&phaseNode_XML);
constructPhaseXML(*fxml_phase, id);
delete fxml;
}
/*
* Import, construct, and initialize a HMWSoln phase
* specification from an XML tree into the current object.
*
* Most of the work is carried out by the cantera base
* routine, importPhase(). That routine imports all of the
* species and element data, including the standard states
* of the species.
*
* Then, In this routine, we read the information
* particular to the specification of the activity
* coefficient model for the Pitzer parameterization.
*
* We also read information about the molar volumes of the
* standard states if present in the XML file.
*
* @param phaseNode This object must be the phase node of a
* complete XML tree
* description of the phase, including all of the
* species data. In other words while "phase" must
* point to an XML phase object, it must have
* sibling nodes "speciesData" that describe
* the species in the phase.
* @param id ID of the phase. If nonnull, a check is done
* to see if phaseNode is pointing to the phase
* with the correct id.
*/
void HMWSoln::constructPhaseXML(XML_Node& phaseNode, std::string id) {
string stemp;
if (id.size() > 0) {
string idp = phaseNode.id();
if (idp != id) {
throw CanteraError("HMWSoln::constructPhaseXML",
"phasenode and Id are incompatible");
}
}
/*
* Import, construct, and initialize a HMWSoln phase
* specification from an XML tree into the current object.
*
* Most of the work is carried out by the cantera base
* routine, importPhase(). That routine imports all of the
* species and element data, including the standard states
* of the species.
*
* Then, In this routine, we read the information
* particular to the specification of the activity
* coefficient model for the Pitzer parameterization.
*
* We also read information about the molar volumes of the
* standard states if present in the XML file.
*
* @param phaseNode This object must be the phase node of a
* complete XML tree
* description of the phase, including all of the
* species data. In other words while "phase" must
* point to an XML phase object, it must have
* sibling nodes "speciesData" that describe
* the species in the phase.
* @param id ID of the phase. If nonnull, a check is done
* to see if phaseNode is pointing to the phase
* with the correct id.
*/
void HMWSoln::constructPhaseXML(XML_Node& phaseNode, std::string id)
{
string stemp;
if (id.size() > 0) {
string idp = phaseNode.id();
if (idp != id) {
throw CanteraError("HMWSoln::constructPhaseXML",
"phasenode and Id are incompatible");
}
}
/*
* Find the Thermo XML node
*/
if (!phaseNode.hasChild("thermo")) {
throw CanteraError("HMWSoln::constructPhaseXML",
"no thermo XML node");
}
XML_Node& thermoNode = phaseNode.child("thermo");
/*
* Find the Thermo XML node
*/
if (!phaseNode.hasChild("thermo")) {
throw CanteraError("HMWSoln::constructPhaseXML",
"no thermo XML node");
}
XML_Node& thermoNode = phaseNode.child("thermo");
/*
* Possibly change the form of the standard concentrations
*/
if (thermoNode.hasChild("standardConc")) {
XML_Node& scNode = thermoNode.child("standardConc");
m_formGC = 2;
stemp = scNode.attrib("model");
string formString = lowercase(stemp);
if (formString != "") {
if (formString == "unity") {
m_formGC = 0;
printf("exit standardConc = unity not done\n");
exit(EXIT_FAILURE);
} else if (formString == "molar_volume") {
m_formGC = 1;
printf("exit standardConc = molar_volume not done\n");
exit(EXIT_FAILURE);
} else if (formString == "solvent_volume") {
m_formGC = 2;
} else {
throw CanteraError("HMWSoln::constructPhaseXML",
"Unknown standardConc model: " + formString);
}
}
}
/*
* Get the Name of the Solvent:
* <solvent> solventName </solvent>
*/
string solventName = "";
if (thermoNode.hasChild("solvent")) {
XML_Node& scNode = thermoNode.child("solvent");
vector<string> nameSolventa;
getStringArray(scNode, nameSolventa);
int nsp = static_cast<int>(nameSolventa.size());
if (nsp != 1) {
throw CanteraError("HMWSoln::constructPhaseXML",
"badly formed solvent XML node");
}
solventName = nameSolventa[0];
}
/*
* Possibly change the form of the standard concentrations
*/
if (thermoNode.hasChild("standardConc")) {
XML_Node& scNode = thermoNode.child("standardConc");
m_formGC = 2;
stemp = scNode.attrib("model");
string formString = lowercase(stemp);
if (formString != "") {
if (formString == "unity") {
m_formGC = 0;
printf("exit standardConc = unity not done\n");
exit(EXIT_FAILURE);
} else if (formString == "molar_volume") {
m_formGC = 1;
printf("exit standardConc = molar_volume not done\n");
exit(EXIT_FAILURE);
} else if (formString == "solvent_volume") {
m_formGC = 2;
} else {
throw CanteraError("HMWSoln::constructPhaseXML",
"Unknown standardConc model: " + formString);
}
}
}
/*
* Get the Name of the Solvent:
* <solvent> solventName </solvent>
*/
string solventName = "";
if (thermoNode.hasChild("solvent")) {
XML_Node& scNode = thermoNode.child("solvent");
vector<string> nameSolventa;
getStringArray(scNode, nameSolventa);
int nsp = static_cast<int>(nameSolventa.size());
if (nsp != 1) {
throw CanteraError("HMWSoln::constructPhaseXML",
"badly formed solvent XML node");
}
solventName = nameSolventa[0];
}
/*
* Determine the form of the Pitzer model,
* We will use this information to size arrays below.
*/
if (thermoNode.hasChild("activityCoefficients")) {
XML_Node& scNode = thermoNode.child("activityCoefficients");
stemp = scNode.attrib("model");
string formString = lowercase(stemp);
if (formString != "") {
if (formString == "pitzer" || formString == "default") {
m_formPitzer = PITZERFORM_BASE;
} else if (formString == "base") {
m_formPitzer = PITZERFORM_BASE;
} else {
throw CanteraError("HMWSoln::constructPhaseXML",
"Unknown Pitzer ActivityCoeff model: "
+ formString);
}
}
/*
* Determine the form of the temperature dependence
* of the Pitzer activity coefficient model.
*/
stemp = scNode.attrib("TempModel");
formString = lowercase(stemp);
if (formString != "") {
if (formString == "constant" || formString == "default") {
m_formPitzerTemp = PITZER_TEMP_CONSTANT;
} else if (formString == "linear") {
m_formPitzerTemp = PITZER_TEMP_LINEAR;
} else if (formString == "complex" || formString == "complex1") {
m_formPitzerTemp = PITZER_TEMP_COMPLEX1;
} else {
throw CanteraError("HMWSoln::constructPhaseXML",
"Unknown Pitzer ActivityCoeff Temp model: "
+ formString);
}
}
/*
* Determine the form of the Pitzer model,
* We will use this information to size arrays below.
*/
if (thermoNode.hasChild("activityCoefficients")) {
XML_Node& scNode = thermoNode.child("activityCoefficients");
stemp = scNode.attrib("model");
string formString = lowercase(stemp);
if (formString != "") {
if (formString == "pitzer" || formString == "default") {
m_formPitzer = PITZERFORM_BASE;
} else if (formString == "base") {
m_formPitzer = PITZERFORM_BASE;
} else {
throw CanteraError("HMWSoln::constructPhaseXML",
"Unknown Pitzer ActivityCoeff model: "
+ formString);
}
}
/*
* Determine the form of the temperature dependence
* of the Pitzer activity coefficient model.
*/
stemp = scNode.attrib("TempModel");
formString = lowercase(stemp);
if (formString != "") {
if (formString == "constant" || formString == "default") {
m_formPitzerTemp = PITZER_TEMP_CONSTANT;
} else if (formString == "linear") {
m_formPitzerTemp = PITZER_TEMP_LINEAR;
} else if (formString == "complex" || formString == "complex1") {
m_formPitzerTemp = PITZER_TEMP_COMPLEX1;
} else {
throw CanteraError("HMWSoln::constructPhaseXML",
"Unknown Pitzer ActivityCoeff Temp model: "
+ formString);
}
}
/*
* Determine the reference temperature
* of the Pitzer activity coefficient model's temperature
* dependence formulation: defaults to 25C
*/
stemp = scNode.attrib("TempReference");
formString = lowercase(stemp);
if (formString != "") {
m_TempPitzerRef = atofCheck(formString.c_str());
} else {
m_TempPitzerRef = 273.15 + 25;
}
/*
* Determine the reference temperature
* of the Pitzer activity coefficient model's temperature
* dependence formulation: defaults to 25C
*/
stemp = scNode.attrib("TempReference");
formString = lowercase(stemp);
if (formString != "") {
m_TempPitzerRef = atofCheck(formString.c_str());
} else {
m_TempPitzerRef = 273.15 + 25;
}
}
}
/*
* Call the Cantera importPhase() function. This will import
* all of the species into the phase. This will also handle
* all of the solvent and solute standard states
*/
bool m_ok = importPhase(phaseNode, this);
if (!m_ok) {
throw CanteraError("HMWSoln::constructPhaseXML","importPhase failed ");
}
/*
* Call the Cantera importPhase() function. This will import
* all of the species into the phase. This will also handle
* all of the solvent and solute standard states
*/
bool m_ok = importPhase(phaseNode, this);
if (!m_ok) {
throw CanteraError("HMWSoln::constructPhaseXML","importPhase failed ");
}
}
}

View file

@ -40,8 +40,7 @@ IdealSolidSolnPhase::IdealSolidSolnPhase(int formGC) :
}
IdealSolidSolnPhase::IdealSolidSolnPhase(const std::string& inputFile,
const std::string& id,
int formGC) :
const std::string& id, int formGC) :
ThermoPhase(),
m_formGC(formGC),
m_Pref(OneAtm),

View file

@ -108,7 +108,7 @@ IonsFromNeutralVPSSTP::IonsFromNeutralVPSSTP(const std::string& inputFile,
//dX_NeutralMolecule.resize(numNeutMolSpec);
}
//====================================================================================================================
IonsFromNeutralVPSSTP::IonsFromNeutralVPSSTP(XML_Node& phaseRoot,
IonsFromNeutralVPSSTP::IonsFromNeutralVPSSTP(XML_Node& phaseRoot,
const std::string& id, ThermoPhase* neutralPhase) :
GibbsExcessVPSSTP(),
ionSolnType_(cIonSolnType_SINGLEANION),
@ -271,34 +271,35 @@ IonsFromNeutralVPSSTP::duplMyselfAsThermoPhase() const
* phase. If none is given, the first XML
* phase element will be used.
*/
void IonsFromNeutralVPSSTP::constructPhaseFile(std::string inputFile, std::string id) {
void IonsFromNeutralVPSSTP::constructPhaseFile(std::string inputFile, std::string id)
{
if (inputFile.size() == 0) {
throw CanteraError("MargulesVPSSTP:constructPhaseFile",
"input file is null");
}
string path = findInputFile(inputFile);
std::ifstream fin(path.c_str());
if (!fin) {
throw CanteraError("MargulesVPSSTP:constructPhaseFile","could not open "
+path+" for reading.");
}
/*
* The phase object automatically constructs an XML object.
* Use this object to store information.
*/
XML_Node &phaseNode_XML = xml();
XML_Node *fxml = new XML_Node();
fxml->build(fin);
XML_Node *fxml_phase = findXMLPhase(fxml, id);
if (!fxml_phase) {
throw CanteraError("MargulesVPSSTP:constructPhaseFile",
"ERROR: Can not find phase named " +
id + " in file named " + inputFile);
}
fxml_phase->copy(&phaseNode_XML);
constructPhaseXML(*fxml_phase, id);
delete fxml;
if (inputFile.size() == 0) {
throw CanteraError("MargulesVPSSTP:constructPhaseFile",
"input file is null");
}
string path = findInputFile(inputFile);
std::ifstream fin(path.c_str());
if (!fin) {
throw CanteraError("MargulesVPSSTP:constructPhaseFile","could not open "
+path+" for reading.");
}
/*
* The phase object automatically constructs an XML object.
* Use this object to store information.
*/
XML_Node& phaseNode_XML = xml();
XML_Node* fxml = new XML_Node();
fxml->build(fin);
XML_Node* fxml_phase = findXMLPhase(fxml, id);
if (!fxml_phase) {
throw CanteraError("MargulesVPSSTP:constructPhaseFile",
"ERROR: Can not find phase named " +
id + " in file named " + inputFile);
}
fxml_phase->copy(&phaseNode_XML);
constructPhaseXML(*fxml_phase, id);
delete fxml;
}
/*
@ -329,72 +330,73 @@ void IonsFromNeutralVPSSTP::constructPhaseFile(std::string inputFile, std::strin
* with the correct id.
*/
void IonsFromNeutralVPSSTP::constructPhaseXML(XML_Node& phaseNode, std::string id) {
string stemp;
if (id.size() > 0) {
string idp = phaseNode.id();
if (idp != id) {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"phasenode and Id are incompatible");
}
}
void IonsFromNeutralVPSSTP::constructPhaseXML(XML_Node& phaseNode, std::string id)
{
string stemp;
if (id.size() > 0) {
string idp = phaseNode.id();
if (idp != id) {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"phasenode and Id are incompatible");
}
}
/*
* Find the thermo XML node
*/
if (!phaseNode.hasChild("thermo")) {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"no thermo XML node");
}
XML_Node& thermoNode = phaseNode.child("thermo");
/*
* Find the thermo XML node
*/
if (!phaseNode.hasChild("thermo")) {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"no thermo XML node");
}
XML_Node& thermoNode = phaseNode.child("thermo");
/*
* Make sure that the thermo model is IonsFromNeutralMolecule
*/
stemp = thermoNode.attrib("model");
string formString = lowercase(stemp);
if (formString != "ionsfromneutralmolecule") {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"model name isn't IonsFromNeutralMolecule: " + formString);
}
/*
* Make sure that the thermo model is IonsFromNeutralMolecule
*/
stemp = thermoNode.attrib("model");
string formString = lowercase(stemp);
if (formString != "ionsfromneutralmolecule") {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"model name isn't IonsFromNeutralMolecule: " + formString);
}
/*
* Find the Neutral Molecule Phase
*/
if (!thermoNode.hasChild("neutralMoleculePhase")) {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"no neutralMoleculePhase XML node");
}
XML_Node& neutralMoleculeNode = thermoNode.child("neutralMoleculePhase");
/*
* Find the Neutral Molecule Phase
*/
if (!thermoNode.hasChild("neutralMoleculePhase")) {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"no neutralMoleculePhase XML node");
}
XML_Node& neutralMoleculeNode = thermoNode.child("neutralMoleculePhase");
string nsource = neutralMoleculeNode["datasrc"];
XML_Node *neut_ptr = get_XML_Node(nsource, 0);
if (!neut_ptr) {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"neut_ptr = 0");
}
string nsource = neutralMoleculeNode["datasrc"];
XML_Node* neut_ptr = get_XML_Node(nsource, 0);
if (!neut_ptr) {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"neut_ptr = 0");
}
/*
* Create the neutralMolecule ThermoPhase if we haven't already
*/
if (!neutralMoleculePhase_) {
neutralMoleculePhase_ = newPhase(*neut_ptr);
}
/*
* Create the neutralMolecule ThermoPhase if we haven't already
*/
if (!neutralMoleculePhase_) {
neutralMoleculePhase_ = newPhase(*neut_ptr);
}
/*
* Call the Cantera importPhase() function. This will import
* all of the species into the phase. This will also handle
* all of the solvent and solute standard states
*/
bool m_ok = importPhase(phaseNode, this);
if (!m_ok) {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"importPhase failed ");
}
/*
* Call the Cantera importPhase() function. This will import
* all of the species into the phase. This will also handle
* all of the solvent and solute standard states
*/
bool m_ok = importPhase(phaseNode, this);
if (!m_ok) {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"importPhase failed ");
}
}
}
/*
@ -1505,8 +1507,8 @@ void IonsFromNeutralVPSSTP::getdlnActCoeffds(const doublereal dTds, const double
return;
}
// static vector_fp dlnActCoeff_NeutralMolecule(numNeutMolSpec);
// static vector_fp dX_NeutralMolecule(numNeutMolSpec);
// static vector_fp dlnActCoeff_NeutralMolecule(numNeutMolSpec);
// static vector_fp dX_NeutralMolecule(numNeutMolSpec);
getNeutralMoleculeMoleGrads(DATA_PTR(dXds),DATA_PTR(dX_NeutralMolecule));

View file

@ -673,7 +673,7 @@ void LatticeSolidPhase::setParametersFromXML(const XML_Node& eosdata)
* @param k Species k
* @param Hf298New Specify the new value of the Heat of Formation at 298K and 1 bar
*/
void LatticeSolidPhase::modifyOneHf298SS(const size_t &k, const doublereal Hf298New)
void LatticeSolidPhase::modifyOneHf298SS(const size_t& k, const doublereal Hf298New)
{
for (size_t n = 0; n < m_nlattice; n++) {
if (lkstart_[n+1] < k) {

View file

@ -491,7 +491,7 @@ void MargulesVPSSTP::getPartialMolarVolumes(doublereal* vbar) const
for (size_t iK = 0; iK < m_kk; iK++) {
vbar[iK] += all;
// vbar[iK] += XA*XB*temp1+((delAK-XA)*XB+XA*(delBK-XB))*temp1+XB*XA*(delBK-XB)*g1;
// vbar[iK] += XA*XB*temp1+((delAK-XA)*XB+XA*(delBK-XB))*temp1+XB*XA*(delBK-XB)*g1;
}
vbar[iA] += XB * temp1;
vbar[iB] += XA * temp1 + XA*XB*g1;
@ -686,7 +686,7 @@ void MargulesVPSSTP::s_update_dlnActCoeff_dT() const
const doublereal mult = 2.0 * invT;
const doublereal dT2all = mult * all;
for (iK = 0; iK < m_kk; iK++) {
// double temp = (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
// double temp = (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
dlnActCoeffdT_Scaled_[iK] += all;
d2lnActCoeffdT2_Scaled_[iK] -= dT2all;
}
@ -755,8 +755,8 @@ void MargulesVPSSTP::getdlnActCoeffds(const doublereal dTds, const doublereal*
const doublereal g2XAdXB = 2*g1*XA*dXB;
const doublereal all = (-XB * dXA - XA *dXB) * g02g1XB - XB *g2XAdXB;
for (iK = 0; iK < m_kk; iK++) {
// dlnActCoeffds[iK] += ((delBK-XB)*dXA + (delAK-XA)*dXB)*(g0+2*g1*XB) + (delBK-XB)*2*g1*XA*dXB
// + dlnActCoeffdT_Scaled_[iK]*dTds;
// dlnActCoeffds[iK] += ((delBK-XB)*dXA + (delAK-XA)*dXB)*(g0+2*g1*XB) + (delBK-XB)*2*g1*XA*dXB
// + dlnActCoeffdT_Scaled_[iK]*dTds;
dlnActCoeffds[iK] += all + dlnActCoeffdT_Scaled_[iK]*dTds;
}
dlnActCoeffds[iA] += dXB * g02g1XB;

View file

@ -46,7 +46,7 @@ MixedSolventElectrolyte::MixedSolventElectrolyte() :
*/
MixedSolventElectrolyte::MixedSolventElectrolyte(const std::string& inputFile,
const std::string& id) :
const std::string& id) :
MolarityIonicVPSSTP(),
numBinaryInteractions_(0),
formMargules_(0),
@ -56,7 +56,7 @@ MixedSolventElectrolyte::MixedSolventElectrolyte(const std::string& inputFile,
}
MixedSolventElectrolyte::MixedSolventElectrolyte(XML_Node& phaseRoot,
const std::string& id) :
const std::string& id) :
MolarityIonicVPSSTP(),
numBinaryInteractions_(0),
formMargules_(0),

View file

@ -53,7 +53,7 @@ MolarityIonicVPSSTP::MolarityIonicVPSSTP() :
* XML database to get the info for the phase.
*/
MolarityIonicVPSSTP::MolarityIonicVPSSTP(const std::string& inputFile,
const std::string& id) :
const std::string& id) :
GibbsExcessVPSSTP(),
PBType_(PBTYPE_PASSTHROUGH),
numPBSpecies_(m_kk),
@ -67,7 +67,7 @@ MolarityIonicVPSSTP::MolarityIonicVPSSTP(const std::string& inputFile,
}
//====================================================================================================================
MolarityIonicVPSSTP::MolarityIonicVPSSTP(XML_Node& phaseRoot,
const std::string& id) :
const std::string& id) :
GibbsExcessVPSSTP(),
PBType_(PBTYPE_PASSTHROUGH),
numPBSpecies_(m_kk),

View file

@ -261,7 +261,7 @@ public:
return h;
}
void modifyOneHf298(const size_t &k, const doublereal Hf298New) {
void modifyOneHf298(const size_t& k, const doublereal Hf298New) {
if (k != m_index) {
return;
}

View file

@ -37,7 +37,7 @@ PDSS_IonsFromNeutral::PDSS_IonsFromNeutral(VPStandardStateTP* tp, size_t spindex
}
//====================================================================================================================
PDSS_IonsFromNeutral::PDSS_IonsFromNeutral(VPStandardStateTP* tp, size_t spindex,
const std::string& inputFile, const std::string& id) :
const std::string& inputFile, const std::string& id) :
PDSS(tp, spindex),
neutralMoleculePhase_(0),
numMult_(0),
@ -223,7 +223,7 @@ void PDSS_IonsFromNeutral::constructPDSSXML(VPStandardStateTP* tp, size_t spinde
* phase element will be used.
*/
void PDSS_IonsFromNeutral::constructPDSSFile(VPStandardStateTP* tp, size_t spindex,
const std::string& inputFile, const std::string& id)
const std::string& inputFile, const std::string& id)
{
if (inputFile.size() == 0) {

View file

@ -322,18 +322,18 @@ void Phase::setMoleFractions(const doublereal* const x)
* Set m_ym_ to the normalized mole fractions divided by the normalized mean molecular weight:
* m_ym_k = X_k / (sum_k X_k M_k)
*/
// transform(m_y.begin(), m_y.end(), m_ym.begin(), timesConstant<double>(1.0/sum));
// transform(m_y.begin(), m_y.end(), m_ym.begin(), timesConstant<double>(1.0/sum));
const doublereal invSum = 1.0/sum;
for (size_t k=0; k < m_kk; k++) {
m_ym[k] = m_y[k]*invSum;
m_ym[k] = m_y[k]*invSum;
}
/*
* Now set m_y to the normalized mass fractions
* m_y = X_k M_k / (sum_k X_k M_k)
*/
// transform(m_ym.begin(), m_ym.begin() + m_kk, m_molwts.begin(), m_y.begin(), multiplies<double>());
for(size_t k=0; k < m_kk; k++) {
m_y[k] = m_ym[k] * m_molwts[k];
// transform(m_ym.begin(), m_ym.begin() + m_kk, m_molwts.begin(), m_y.begin(), multiplies<double>());
for (size_t k=0; k < m_kk; k++) {
m_y[k] = m_ym[k] * m_molwts[k];
}
/*
* Calculate the normalized molecular weight

View file

@ -45,7 +45,7 @@ PhaseCombo_Interaction::PhaseCombo_Interaction() :
* HKM - Checked for Transition
*/
PhaseCombo_Interaction::PhaseCombo_Interaction(const std::string& inputFile,
const std::string& id) :
const std::string& id) :
GibbsExcessVPSSTP(),
numBinaryInteractions_(0),
formMargules_(0),
@ -60,7 +60,7 @@ PhaseCombo_Interaction::PhaseCombo_Interaction(const std::string& inputFile,
* HKM - Checked for Transition
*/
PhaseCombo_Interaction::PhaseCombo_Interaction(XML_Node& phaseRoot,
const std::string& id) :
const std::string& id) :
GibbsExcessVPSSTP(),
numBinaryInteractions_(0),
formMargules_(0),

View file

@ -53,7 +53,7 @@ RedlichKisterVPSSTP::RedlichKisterVPSSTP() :
*/
RedlichKisterVPSSTP::RedlichKisterVPSSTP(const std::string& inputFile,
const std::string& id) :
const std::string& id) :
GibbsExcessVPSSTP(),
numBinaryInteractions_(0),
m_pSpecies_A_ij(0),
@ -69,7 +69,7 @@ RedlichKisterVPSSTP::RedlichKisterVPSSTP(const std::string& inputFile,
}
//====================================================================================================================
RedlichKisterVPSSTP::RedlichKisterVPSSTP(XML_Node& phaseRoot,
const std::string& id) :
const std::string& id) :
GibbsExcessVPSSTP(),
numBinaryInteractions_(0),
m_pSpecies_A_ij(0),

View file

@ -665,7 +665,7 @@ public:
return h;
}
virtual void modifyOneHf298(const size_t &k, const doublereal Hf298New) {
virtual void modifyOneHf298(const size_t& k, const doublereal Hf298New) {
if (k != m_index) {
return;
}

View file

@ -252,18 +252,15 @@ ThermoPhase* newPhase(XML_Node& xmlphase)
string model = th["model"];
ThermoPhase* t = newThermoPhase(model);
if (model == "singing cows") {
throw CanteraError("ThermoPhase::newPhase", "Cows don't sing");
}
else if (model == "HMW") {
HMWSoln* p = dynamic_cast<HMWSoln*>(t);
p->constructPhaseXML(xmlphase,"");
}
else if (model == "IonsFromNeutralMolecule") {
IonsFromNeutralVPSSTP* p = dynamic_cast<IonsFromNeutralVPSSTP*>(t);
p->constructPhaseXML(xmlphase,"");
}
else {
importPhase(xmlphase, t);
throw CanteraError("ThermoPhase::newPhase", "Cows don't sing");
} else if (model == "HMW") {
HMWSoln* p = dynamic_cast<HMWSoln*>(t);
p->constructPhaseXML(xmlphase,"");
} else if (model == "IonsFromNeutralMolecule") {
IonsFromNeutralVPSSTP* p = dynamic_cast<IonsFromNeutralVPSSTP*>(t);
p->constructPhaseXML(xmlphase,"");
} else {
importPhase(xmlphase, t);
}
//return t;
//importPhase(xmlphase, t);

View file

@ -384,10 +384,10 @@ void ThermoPhase::setState_HPorUV(doublereal Htarget, doublereal p,
// spinodal value of H.
for (int its = 0; its < 10; its++) {
Tnew = Told + dt;
if (Tnew < Told / 3.0) {
Tnew = Told / 3.0;
dt = -2.0 * Told / 3.0;
}
if (Tnew < Told / 3.0) {
Tnew = Told / 3.0;
dt = -2.0 * Told / 3.0;
}
setState_conditional_TP(Tnew, p, !doUV);
if (doUV) {
Hnew = intEnergy_mass();

View file

@ -228,11 +228,11 @@ VPSSMgr::getStandardVolumes(doublereal* vol) const
err("getStandardVolumes");
}
}
const vector_fp &
const vector_fp&
VPSSMgr::getStandardVolumes() const
{
if (m_useTmpStandardStateStorage) {
return m_Vss;
return m_Vss;
} else {
err("getStandardVolumes");
}

View file

@ -228,7 +228,7 @@ void VPStandardStateTP::getEnthalpy_RT(doublereal* hrt) const
* @param k Species k
* @param Hf298New Specify the new value of the Heat of Formation at 298K and 1 bar
*/
void VPStandardStateTP::modifyOneHf298SS(const size_t &k, const doublereal Hf298New)
void VPStandardStateTP::modifyOneHf298SS(const size_t& k, const doublereal Hf298New)
{
m_spthermo->modifyOneHf298(k, Hf298New);
m_Tlast_ss += 0.0001234;
@ -272,7 +272,7 @@ void VPStandardStateTP::getStandardVolumes(doublereal* vol) const
updateStandardStateThermo();
m_VPSS_ptr->getStandardVolumes(vol);
}
const vector_fp & VPStandardStateTP::getStandardVolumes() const
const vector_fp& VPStandardStateTP::getStandardVolumes() const
{
updateStandardStateThermo();
return m_VPSS_ptr->getStandardVolumes();

View file

@ -106,56 +106,59 @@ DustyGasTransport& DustyGasTransport::operator=(const DustyGasTransport& right)
DustyGasTransport::~DustyGasTransport()
{
delete m_gastran;
}
//====================================================================================================================
// Duplication routine for objects which inherit from %Transport
/*
* This virtual routine can be used to duplicate %Transport objects
* inherited from %Transport even if the application only has
* a pointer to %Transport to work with.
*
* These routines are basically wrappers around the derived copy
* constructor.
*/
Transport *DustyGasTransport::duplMyselfAsTransport() const {
}
//====================================================================================================================
// Duplication routine for objects which inherit from %Transport
/*
* This virtual routine can be used to duplicate %Transport objects
* inherited from %Transport even if the application only has
* a pointer to %Transport to work with.
*
* These routines are basically wrappers around the derived copy
* constructor.
*/
Transport* DustyGasTransport::duplMyselfAsTransport() const
{
DustyGasTransport* tr = new DustyGasTransport(*this);
return (dynamic_cast<Transport *>(tr));
}
//====================================================================================================================
// Specifies the %ThermPhase object.
/*
* We have relaxed this operation so that it will succeed when
* the underlying old and new ThermoPhase objects have the same
* number of species and the same names of the species in the
* same order. The idea here is to allow copy constructors and duplicators
* to work. In order for them to work, we need a method to switch the
* internal pointer within the Transport object after the duplication
* takes place. Also, different thermodynamic instanteations of the same
* species should also work.
*
* @param thermo Reference to the ThermoPhase object that
* the transport object will use
*/
void DustyGasTransport::setThermo(thermo_t& thermo) {
return (dynamic_cast<Transport*>(tr));
}
//====================================================================================================================
// Specifies the %ThermPhase object.
/*
* We have relaxed this operation so that it will succeed when
* the underlying old and new ThermoPhase objects have the same
* number of species and the same names of the species in the
* same order. The idea here is to allow copy constructors and duplicators
* to work. In order for them to work, we need a method to switch the
* internal pointer within the Transport object after the duplication
* takes place. Also, different thermodynamic instanteations of the same
* species should also work.
*
* @param thermo Reference to the ThermoPhase object that
* the transport object will use
*/
void DustyGasTransport::setThermo(thermo_t& thermo)
{
Transport::setThermo(thermo);
m_gastran->setThermo(thermo);
}
//====================================================================================================================
// Set the Parameters in the model
/*
* @param type Type of the parameter to set
* 0 - porosity
* 1 - tortuosity
* 2 - mean pore radius
* 3 - mean particle radius
* 4 - permeability
* @param k Unused int
* @param p pointer to double for the input list of parameters
*
*/
void DustyGasTransport::setParameters(const int type, const int k, const doublereal* const p) {
switch(type) {
}
//====================================================================================================================
// Set the Parameters in the model
/*
* @param type Type of the parameter to set
* 0 - porosity
* 1 - tortuosity
* 2 - mean pore radius
* 3 - mean particle radius
* 4 - permeability
* @param k Unused int
* @param p pointer to double for the input list of parameters
*
*/
void DustyGasTransport::setParameters(const int type, const int k, const doublereal* const p)
{
switch (type) {
case 0:
setPorosity(p[0]);
break;

View file

@ -48,39 +48,39 @@ static void getArrhenius(const XML_Node& node,
E = getFloat(node, "E", "actEnergy");
E /= GasConstant;
}
//====================================================================================================================
// Construct an LTPspecies object for a liquid tranport property.
/*
* The species transport property is constructed from the XML node,
* \verbatim <propNode>, \endverbatim that is a child of the
* \verbatim <transport> \endverbatim node in the species block and specifies a type of transport
* property (like viscosity)
*
* @param propNode Pointer to the XML node that contains the property information
* @param name String containing the species name
* @param tp_ind enum TransportPropertyType containing the property id that this object
* is creating a parameterization for (e.g., viscosity)
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
*/
LTPspecies::LTPspecies(const XML_Node * const propNode, const std::string name,
TransportPropertyType tp_ind, const thermo_t * thermo) :
m_speciesName(name),
m_model(LTP_TD_NOTSET),
m_property(tp_ind),
m_thermo(thermo),
m_mixWeight(1.0)
{
if (propNode) {
if (propNode->hasChild("mixtureWeighting") ) {
m_mixWeight = getFloat(*propNode, "mixtureWeighting");
}
}
}
//====================================================================================================================
// Copy constructor
LTPspecies::LTPspecies(const LTPspecies &right)
{
}
//====================================================================================================================
// Construct an LTPspecies object for a liquid tranport property.
/*
* The species transport property is constructed from the XML node,
* \verbatim <propNode>, \endverbatim that is a child of the
* \verbatim <transport> \endverbatim node in the species block and specifies a type of transport
* property (like viscosity)
*
* @param propNode Pointer to the XML node that contains the property information
* @param name String containing the species name
* @param tp_ind enum TransportPropertyType containing the property id that this object
* is creating a parameterization for (e.g., viscosity)
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
*/
LTPspecies::LTPspecies(const XML_Node* const propNode, const std::string name,
TransportPropertyType tp_ind, const thermo_t* thermo) :
m_speciesName(name),
m_model(LTP_TD_NOTSET),
m_property(tp_ind),
m_thermo(thermo),
m_mixWeight(1.0)
{
if (propNode) {
if (propNode->hasChild("mixtureWeighting")) {
m_mixWeight = getFloat(*propNode, "mixtureWeighting");
}
}
}
//====================================================================================================================
// Copy constructor
LTPspecies::LTPspecies(const LTPspecies& right)
{
*this = right;
}
@ -129,35 +129,35 @@ bool LTPspecies::checkPositive() const
{
return (m_coeffs[0] > 0);
}
//====================================================================================================================
doublereal LTPspecies::getMixWeight() const
{
return m_mixWeight;
}
//====================================================================================================================
// Internal model to adjust species-specific properties for composition.
/*
* Currently just a place holder, but this method could take
* the composition from the thermo object and adjust coefficients
* accoding to some unspecified model.
*/
void LTPspecies::adjustCoeffsForComposition()
{
}
//====================================================================================================================
// Construct an LTPspecies object for a liquid tranport property
// expressed as a constant value.
/* The transport property is constructed from the XML node,
* \verbatim <propNode>, \endverbatim that is a child of the
* \verbatim <transport> \endverbatim node and specifies a type of
* transport property (like viscosity)
*/
LTPspecies_Const::LTPspecies_Const(const XML_Node &propNode, const std::string name,
TransportPropertyType tp_ind, const thermo_t * const thermo) :
LTPspecies(&propNode, name, tp_ind, thermo)
{
m_model = LTP_TD_CONSTANT;
}
//====================================================================================================================
doublereal LTPspecies::getMixWeight() const
{
return m_mixWeight;
}
//====================================================================================================================
// Internal model to adjust species-specific properties for composition.
/*
* Currently just a place holder, but this method could take
* the composition from the thermo object and adjust coefficients
* accoding to some unspecified model.
*/
void LTPspecies::adjustCoeffsForComposition()
{
}
//====================================================================================================================
// Construct an LTPspecies object for a liquid tranport property
// expressed as a constant value.
/* The transport property is constructed from the XML node,
* \verbatim <propNode>, \endverbatim that is a child of the
* \verbatim <transport> \endverbatim node and specifies a type of
* transport property (like viscosity)
*/
LTPspecies_Const::LTPspecies_Const(const XML_Node& propNode, const std::string name,
TransportPropertyType tp_ind, const thermo_t* const thermo) :
LTPspecies(&propNode, name, tp_ind, thermo)
{
m_model = LTP_TD_CONSTANT;
double A_k = getFloatCurrent(propNode, "toSI");
if (A_k > 0.0) {
m_coeffs.push_back(A_k);
@ -200,28 +200,28 @@ doublereal LTPspecies_Const::getSpeciesTransProp()
{
return m_coeffs[0];
}
//====================================================================================================================
// Construct an LTPspecies object for a liquid tranport property
// expressed in extended Arrhenius form.
/*
* The transport property is constructed from the XML node,
* \verbatim <propNode>, \endverbatim that is a child of the
* \verbatim <transport> \endverbatim node and specifies a type of transport property (like viscosity)
*
*
* @param propNode Referenc to the XML node that contains the property information.This class
* is assumed to be parameterized by reading XML_Node information.
* @param name String containing the species name
* @param tp_ind enum TransportPropertyType containing the property id that this object
* is creating a parameterization for (e.g., viscosity)
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
*
*/
LTPspecies_Arrhenius::LTPspecies_Arrhenius(const XML_Node &propNode, const std::string name,
TransportPropertyType tp_ind, const thermo_t* thermo) :
LTPspecies(&propNode, name, tp_ind, thermo)
{
}
//====================================================================================================================
// Construct an LTPspecies object for a liquid tranport property
// expressed in extended Arrhenius form.
/*
* The transport property is constructed from the XML node,
* \verbatim <propNode>, \endverbatim that is a child of the
* \verbatim <transport> \endverbatim node and specifies a type of transport property (like viscosity)
*
*
* @param propNode Referenc to the XML node that contains the property information.This class
* is assumed to be parameterized by reading XML_Node information.
* @param name String containing the species name
* @param tp_ind enum TransportPropertyType containing the property id that this object
* is creating a parameterization for (e.g., viscosity)
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
*
*/
LTPspecies_Arrhenius::LTPspecies_Arrhenius(const XML_Node& propNode, const std::string name,
TransportPropertyType tp_ind, const thermo_t* thermo) :
LTPspecies(&propNode, name, tp_ind, thermo)
{
m_model = LTP_TD_ARRHENIUS;
m_temp = 0.0;
@ -316,24 +316,24 @@ doublereal LTPspecies_Arrhenius::getSpeciesTransProp()
}
return m_prop;
}
//====================================================================================================================
// Construct an LTPspecies object for a liquid tranport property expressed as a polynomial in temperature.
/*
* The transport property is constructed from the XML node, \verbatim <propNode>, \endverbatim that is a child of the
* \verbatim <transport> \endverbatim node and specifies a type of transport property (like viscosity).
*
*
* @param propNode Referenc to the XML node that contains the property information. This class
* must be parameterized by reading XML_Node information.
* @param name String containing the species name
* @param tp_ind enum TransportPropertyType containing the property id that this object
* is creating a parameterization for (e.g., viscosity)
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
*
*/
LTPspecies_Poly::LTPspecies_Poly(const XML_Node &propNode, const std::string name,
TransportPropertyType tp_ind, const thermo_t* thermo) :
}
//====================================================================================================================
// Construct an LTPspecies object for a liquid tranport property expressed as a polynomial in temperature.
/*
* The transport property is constructed from the XML node, \verbatim <propNode>, \endverbatim that is a child of the
* \verbatim <transport> \endverbatim node and specifies a type of transport property (like viscosity).
*
*
* @param propNode Referenc to the XML node that contains the property information. This class
* must be parameterized by reading XML_Node information.
* @param name String containing the species name
* @param tp_ind enum TransportPropertyType containing the property id that this object
* is creating a parameterization for (e.g., viscosity)
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
*
*/
LTPspecies_Poly::LTPspecies_Poly(const XML_Node& propNode, const std::string name,
TransportPropertyType tp_ind, const thermo_t* thermo) :
LTPspecies(&propNode, name, tp_ind, thermo),
m_temp(-1.0),
m_prop(0.0)
@ -388,25 +388,25 @@ doublereal LTPspecies_Poly::getSpeciesTransProp()
}
return m_prop;
}
//====================================================================================================================
// Construct an LTPspecies object for a liquid tranport property
// expressed as an exponential in temperature.
/*
* The transport property is constructed from the XML node, \verbatim <propNode>, \endverbatim that is a child of the
* \verbatim <transport> \endverbatim node and specifies a type of transport property (like viscosity).
*
*
* @param propNode Referenc to the XML node that contains the property information. This class
* must be parameterized by reading XML_Node information.
* @param name String containing the species name
* @param tp_ind enum TransportPropertyType containing the property id that this object
* is creating a parameterization for (e.g., viscosity)
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
*
*/
LTPspecies_ExpT::LTPspecies_ExpT(const XML_Node &propNode, const std::string name, TransportPropertyType tp_ind,
const thermo_t* thermo) :
}
//====================================================================================================================
// Construct an LTPspecies object for a liquid tranport property
// expressed as an exponential in temperature.
/*
* The transport property is constructed from the XML node, \verbatim <propNode>, \endverbatim that is a child of the
* \verbatim <transport> \endverbatim node and specifies a type of transport property (like viscosity).
*
*
* @param propNode Referenc to the XML node that contains the property information. This class
* must be parameterized by reading XML_Node information.
* @param name String containing the species name
* @param tp_ind enum TransportPropertyType containing the property id that this object
* is creating a parameterization for (e.g., viscosity)
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
*
*/
LTPspecies_ExpT::LTPspecies_ExpT(const XML_Node& propNode, const std::string name, TransportPropertyType tp_ind,
const thermo_t* thermo) :
LTPspecies(&propNode, name, tp_ind, thermo),
m_temp(-1.0),

View file

@ -836,7 +836,7 @@ void LiquidTransport::getFluidMobilities(doublereal* const mobil_f)
/*
* @param grad_T Gradient of the temperature (length num dimensions);
*/
void LiquidTransport::set_Grad_T(const doublereal *grad_T)
void LiquidTransport::set_Grad_T(const doublereal* grad_T)
{
for (size_t a = 0; a < m_nDim; a++) {
m_Grad_T[a] = grad_T[a];
@ -848,7 +848,7 @@ void LiquidTransport::set_Grad_T(const doublereal *grad_T)
*
* @param grad_V Gradient of the voltage (length num dimensions);
*/
void LiquidTransport::set_Grad_V(const doublereal *grad_V)
void LiquidTransport::set_Grad_V(const doublereal* grad_V)
{
for (size_t a = 0; a < m_nDim; a++) {
m_Grad_V[a] = grad_V[a];
@ -860,7 +860,7 @@ void LiquidTransport::set_Grad_V(const doublereal *grad_V)
*
* @param grad_X Gradient of the mole fractions(length nsp * num dimensions);
*/
void LiquidTransport::set_Grad_X(const doublereal *grad_X)
void LiquidTransport::set_Grad_X(const doublereal* grad_X)
{
size_t itop = m_nDim * m_nsp;
for (size_t i = 0; i < itop; i++) {
@ -1516,7 +1516,7 @@ void LiquidTransport::updateHydrodynamicRadius_T()
void LiquidTransport::update_Grad_lnAC()
{
doublereal grad_T;
// static vector_fp grad_lnAC(m_nsp), grad_X(m_nsp);
// static vector_fp grad_lnAC(m_nsp), grad_X(m_nsp);
// IonsFromNeutralVPSSTP * tempIons = dynamic_cast<IonsFromNeutralVPSSTP *> m_thermo;
//MargulesVPSSTP * tempMarg = dynamic_cast<MargulesVPSSTP *> (tempIons->neutralMoleculePhase_);

View file

@ -83,7 +83,6 @@ Transport* MixTransport::duplMyselfAsTransport() const
bool MixTransport::initGas(GasTransportParams& tr)
{
GasTransport::initGas(tr);
m_eps = tr.eps;
m_sigma = tr.sigma;

View file

@ -74,26 +74,27 @@ SolidTransport& SolidTransport::operator=(const SolidTransport& b)
return *this;
}
//====================================================================================================================
Transport *SolidTransport::duplMyselfAsTransport() const
{
SolidTransport* tr = new SolidTransport(*this);
return (dynamic_cast<Transport *>(tr));
}
}
//====================================================================================================================
Transport* SolidTransport::duplMyselfAsTransport() const
{
SolidTransport* tr = new SolidTransport(*this);
return (dynamic_cast<Transport*>(tr));
}
//====================================================================================================================
// Initialize the transport object
/*
* Here we change all of the internal dimensions to be sufficient.
* We get the object ready to do property evaluations.
* A lot of the input required to do property evaluations is
* contained in the SolidTransportData class that is
* filled in TransportFactory.
*
* @param tr Transport parameters for the phase
*/
bool SolidTransport::initSolid(SolidTransportData& tr) {
//====================================================================================================================
// Initialize the transport object
/*
* Here we change all of the internal dimensions to be sufficient.
* We get the object ready to do property evaluations.
* A lot of the input required to do property evaluations is
* contained in the SolidTransportData class that is
* filled in TransportFactory.
*
* @param tr Transport parameters for the phase
*/
bool SolidTransport::initSolid(SolidTransportData& tr)
{
m_thermo = tr.thermo;
tr.thermo = 0;
@ -103,7 +104,7 @@ SolidTransport& SolidTransport::operator=(const SolidTransport& b)
// make a local copy of the molecular weights
//m_mw.resize(m_nsp, 0.0);
//copy(m_thermo->molecularWeights().begin(),
//copy(m_thermo->molecularWeights().begin(),
// m_thermo->molecularWeights().end(), m_mw.begin());
m_ionConductivity = tr.ionConductivity;
@ -118,11 +119,12 @@ SolidTransport& SolidTransport::operator=(const SolidTransport& b)
tr.defectActivity = 0;
return true;
}
}
//====================================================================================================================
//====================================================================================================================
void SolidTransport::setParameters(const int n, const int k, const doublereal * const p) {
void SolidTransport::setParameters(const int n, const int k, const doublereal* const p)
{
switch (n) {
case 0:
@ -148,105 +150,111 @@ SolidTransport& SolidTransport::operator=(const SolidTransport& b)
m_work.resize(m_thermo->nSpecies());
}
}
/****************** ionConductivity ******************************/
/****************** ionConductivity ******************************/
// Returns the ionic conductivity of the phase
/*
* The thermo phase needs to be updated (temperature) prior to calling this.
* The ionConductivity calculation is handled by subclasses of
* LTPspecies as specified in the input file.
*
*/
doublereal SolidTransport::ionConductivity() {
// Returns the ionic conductivity of the phase
/*
* The thermo phase needs to be updated (temperature) prior to calling this.
* The ionConductivity calculation is handled by subclasses of
* LTPspecies as specified in the input file.
*
*/
doublereal SolidTransport::ionConductivity()
{
// LTPspecies method
return m_ionConductivity->getSpeciesTransProp();
}
}
/****************** electron Conductivity ******************************/
/****************** electron Conductivity ******************************/
// Returns the electron conductivity of the phase
/*
* The thermo phase needs to be updated (temperature) prior to calling this.
* The ionConductivity calculation is handled by subclasses of
* LTPspecies as specified in the input file.
*
* There is also a legacy multicomponent diffusion approach to electrical conductivity.
*
*/
doublereal SolidTransport::electricalConductivity() {
if ( m_nmobile == 0 ) {
// LTPspecies method
return m_electConductivity->getSpeciesTransProp();
// Returns the electron conductivity of the phase
/*
* The thermo phase needs to be updated (temperature) prior to calling this.
* The ionConductivity calculation is handled by subclasses of
* LTPspecies as specified in the input file.
*
* There is also a legacy multicomponent diffusion approach to electrical conductivity.
*
*/
doublereal SolidTransport::electricalConductivity()
{
if (m_nmobile == 0) {
// LTPspecies method
return m_electConductivity->getSpeciesTransProp();
} else {
getMobilities(&m_work[0]);
int nsp = m_thermo->nSpecies();
doublereal sum = 0.0;
for (int k = 0; k < nsp; k++) {
sum += m_thermo->charge(k) * m_thermo->moleFraction(k) * m_work[k];
}
return sum * m_thermo->molarDensity();
}
}
getMobilities(&m_work[0]);
int nsp = m_thermo->nSpecies();
doublereal sum = 0.0;
for (int k = 0; k < nsp; k++) {
sum += m_thermo->charge(k) * m_thermo->moleFraction(k) * m_work[k];
}
return sum * m_thermo->molarDensity();
}
}
/****************** thermalConductivity ******************************/
/****************** thermalConductivity ******************************/
// Returns the thermal conductivity of the phase
/*
* The thermo phase needs to be updated (temperature) prior to calling this.
* The thermalConductivity calculation is handled by subclasses of
* LTPspecies as specified in the input file.
*
* There is also a legacy method to evaluate
* \f[
* \lambda = A T^n \exp(-E/RT)
* \f]
*/
doublereal SolidTransport::thermalConductivity() {
if ( m_Alam > 0.0 ) {
//legacy test case?
doublereal t = m_thermo->temperature();
return m_Alam * pow(t, m_Nlam) * exp(-m_Elam/t);
// Returns the thermal conductivity of the phase
/*
* The thermo phase needs to be updated (temperature) prior to calling this.
* The thermalConductivity calculation is handled by subclasses of
* LTPspecies as specified in the input file.
*
* There is also a legacy method to evaluate
* \f[
* \lambda = A T^n \exp(-E/RT)
* \f]
*/
doublereal SolidTransport::thermalConductivity()
{
if (m_Alam > 0.0) {
//legacy test case?
doublereal t = m_thermo->temperature();
return m_Alam * pow(t, m_Nlam) * exp(-m_Elam/t);
} else {
// LTPspecies method
return m_thermalConductivity->getSpeciesTransProp();
}
}
// LTPspecies method
return m_thermalConductivity->getSpeciesTransProp();
}
}
/****************** defectDiffusivity ******************************/
/****************** defectDiffusivity ******************************/
// Returns the diffusivity of the phase
/*
* The thermo phase needs to be updated (temperature) prior to calling this.
* The defectDiffusivity calculation is handled by subclasses of
* LTPspecies as specified in the input file.
*
*/
doublereal SolidTransport::defectDiffusivity() {
// Returns the diffusivity of the phase
/*
* The thermo phase needs to be updated (temperature) prior to calling this.
* The defectDiffusivity calculation is handled by subclasses of
* LTPspecies as specified in the input file.
*
*/
doublereal SolidTransport::defectDiffusivity()
{
// LTPspecies method
return m_defectDiffusivity->getSpeciesTransProp();
}
}
/****************** defectActivity ******************************/
/****************** defectActivity ******************************/
// Returns the diffusivity of the phase
/*
* The thermo phase needs to be updated (temperature) prior to calling this.
* The defectActivity calculation is handled by subclasses of
* LTPspecies as specified in the input file.
*
*/
doublereal SolidTransport::defectActivity() {
// Returns the diffusivity of the phase
/*
* The thermo phase needs to be updated (temperature) prior to calling this.
* The defectActivity calculation is handled by subclasses of
* LTPspecies as specified in the input file.
*
*/
doublereal SolidTransport::defectActivity()
{
// LTPspecies method
return m_defectActivity->getSpeciesTransProp();
}
//====================================================================================================================
/*
* Compute the mobilities of the species from the diffusion coefficients,
* using the Einstein relation.
*/
void SolidTransport::getMobilities(doublereal* const mobil) {
}
//====================================================================================================================
/*
* Compute the mobilities of the species from the diffusion coefficients,
* using the Einstein relation.
*/
void SolidTransport::getMobilities(doublereal* const mobil)
{
getMixDiffCoeffs(mobil);
doublereal t = m_thermo->temperature();
doublereal c1 = ElectronCharge / (Boltzmann * t);
@ -254,24 +262,25 @@ SolidTransport& SolidTransport::operator=(const SolidTransport& b)
mobil[k] *= c1;
}
}
//====================================================================================================================
/*
* The diffusion coefficients are computed from
*
* \f[
* D_k = A_k T^{n_k} \exp(-E_k/RT).
* \f]
*
* The diffusion coefficients are only non-zero for species for
* which parameters have been specified using method
* setParameters.
*/
void SolidTransport::getMixDiffCoeffs(doublereal* const d) {
}
//====================================================================================================================
/*
* The diffusion coefficients are computed from
*
* \f[
* D_k = A_k T^{n_k} \exp(-E_k/RT).
* \f]
*
* The diffusion coefficients are only non-zero for species for
* which parameters have been specified using method
* setParameters.
*/
void SolidTransport::getMixDiffCoeffs(doublereal* const d)
{
size_t nsp = m_thermo->nSpecies();
for (size_t k = 0; k < nsp; k++) {
d[k] = 0.0;
}
}
}
}
//====================================================================================================================

View file

@ -15,59 +15,61 @@ using namespace std;
#ifndef SAFE_DELETE
#define SAFE_DELETE(x) if (x) { delete (x); x = 0; }
#endif
namespace Cantera {
namespace Cantera
{
//====================================================================================================================
SolidTransportData::SolidTransportData() :
speciesName("-"),
//====================================================================================================================
SolidTransportData::SolidTransportData() :
speciesName("-"),
ionConductivity(0),
thermalConductivity(0),
electConductivity(0),
defectDiffusivity(0),
defectActivity(0)
{
{
}
//====================================================================================================================
// Copy constructor
SolidTransportData::SolidTransportData(const SolidTransportData &right) :
speciesName("-"),
}
//====================================================================================================================
// Copy constructor
SolidTransportData::SolidTransportData(const SolidTransportData& right) :
speciesName("-"),
ionConductivity(0),
thermalConductivity(0),
electConductivity(0),
defectDiffusivity(0),
defectActivity(0)
{
{
*this = right; //use assignment operator to do other work
}
//====================================================================================================================
// Assignment operator
SolidTransportData& SolidTransportData::operator=(const SolidTransportData& right)
{
}
//====================================================================================================================
// Assignment operator
SolidTransportData& SolidTransportData::operator=(const SolidTransportData& right)
{
if (&right != this) {
// These are all shallow pointer copies - yes, yes, yes horrible crime.
speciesName = right.speciesName;
if (right.ionConductivity) {
ionConductivity = (right.ionConductivity)->duplMyselfAsLTPspecies();
}
// These are all shallow pointer copies - yes, yes, yes horrible crime.
speciesName = right.speciesName;
if (right.ionConductivity) {
ionConductivity = (right.ionConductivity)->duplMyselfAsLTPspecies();
}
if (right.thermalConductivity) {
thermalConductivity = (right.thermalConductivity)->duplMyselfAsLTPspecies();
}
if (right.electConductivity) {
electConductivity = (right.electConductivity)->duplMyselfAsLTPspecies();
}
if (right.defectDiffusivity) {
defectDiffusivity = (right.defectDiffusivity)->duplMyselfAsLTPspecies();
}
if (right.defectActivity) {
defectActivity = (right.defectActivity)->duplMyselfAsLTPspecies();
}
if (right.thermalConductivity) {
thermalConductivity = (right.thermalConductivity)->duplMyselfAsLTPspecies();
}
if (right.electConductivity) {
electConductivity = (right.electConductivity)->duplMyselfAsLTPspecies();
}
if (right.defectDiffusivity) {
defectDiffusivity = (right.defectDiffusivity)->duplMyselfAsLTPspecies();
}
if (right.defectActivity) {
defectActivity = (right.defectActivity)->duplMyselfAsLTPspecies();
}
}
return *this;
}
//====================================================================================================================
SolidTransportData::~SolidTransportData() {
}
//====================================================================================================================
SolidTransportData::~SolidTransportData()
{
SAFE_DELETE(ionConductivity);
SAFE_DELETE(thermalConductivity);
@ -75,6 +77,6 @@ namespace Cantera {
SAFE_DELETE(defectDiffusivity);
SAFE_DELETE(defectActivity);
}
//====================================================================================================================
}
//====================================================================================================================
}

View file

@ -102,31 +102,31 @@ void Transport::setParameters(const int type, const int k,
}
void Transport::setThermo(thermo_t& thermo) {
if (!ready()) {
m_thermo = &thermo;
m_nsp = m_thermo->nSpecies();
}
else {
int newNum = thermo.nSpecies();
int oldNum = m_thermo->nSpecies();
if (newNum != oldNum) {
throw CanteraError("Transport::setThermo",
"base object cannot be changed after "
"the transport manager has been constructed because num species isn't the same.");
}
for (int i = 0; i < newNum; i++) {
std::string newS0 = thermo.speciesName(i);
std::string oldS0 = m_thermo->speciesName(i);
void Transport::setThermo(thermo_t& thermo)
{
if (!ready()) {
m_thermo = &thermo;
m_nsp = m_thermo->nSpecies();
} else {
int newNum = thermo.nSpecies();
int oldNum = m_thermo->nSpecies();
if (newNum != oldNum) {
throw CanteraError("Transport::setThermo",
"base object cannot be changed after "
"the transport manager has been constructed because species names are not the same");
throw CanteraError("Transport::setThermo",
"base object cannot be changed after "
"the transport manager has been constructed because num species isn't the same.");
}
}
m_thermo = &thermo;
for (int i = 0; i < newNum; i++) {
std::string newS0 = thermo.speciesName(i);
std::string oldS0 = m_thermo->speciesName(i);
if (newNum != oldNum) {
throw CanteraError("Transport::setThermo",
"base object cannot be changed after "
"the transport manager has been constructed because species names are not the same");
}
}
m_thermo = &thermo;
}
}
}
doublereal Transport::err(const std::string& msg) const

View file

@ -210,8 +210,8 @@ TransportFactory::TransportFactory() :
m_models["None"] = None;
//m_models["Radiative"] = cRadiative;
for (map<string, int>::iterator iter = m_models.begin();
iter != m_models.end();
iter++) {
iter != m_models.end();
iter++) {
m_modelNames[iter->second] = iter->first;
}
@ -266,15 +266,15 @@ std::string TransportFactory::modelName(int model)
}
/*
make one of several transport models, and return a base class
pointer to it. This method operates at the level of a
single transport property as a function of temperature
and possibly composition.
*/
LTPspecies* TransportFactory::newLTP(const XML_Node &trNode, const std::string &name,
TransportPropertyType tp_ind, thermo_t* thermo)
{
/*
make one of several transport models, and return a base class
pointer to it. This method operates at the level of a
single transport property as a function of temperature
and possibly composition.
*/
LTPspecies* TransportFactory::newLTP(const XML_Node& trNode, const std::string& name,
TransportPropertyType tp_ind, thermo_t* thermo)
{
LTPspecies* ltps = 0;
std::string model = lowercase(trNode["model"]);
switch (m_LTRmodelMap[model]) {
@ -402,10 +402,10 @@ Transport* TransportFactory::newTransport(const std::string& transportModel,
break;
case cSolidTransport:
tr = new SolidTransport;
initSolidTransport(tr, phase, log_level);
tr->setThermo(*phase);
break;
tr = new SolidTransport;
initSolidTransport(tr, phase, log_level);
tr->setThermo(*phase);
break;
case cDustyGasTransport:
tr = new DustyGasTransport;
gastr = new MultiTransport;
@ -651,20 +651,21 @@ void TransportFactory::setupLiquidTransport(std::ostream& flog, thermo_t* thermo
getLiquidInteractionsTransportData(transportNode, log, trParam.thermo->speciesNames(), trParam);
}
}
}
//====================================================================================================================
// Prepare to build a new transport manager for solids
/*
* @param flog Reference to the ostream for writing log info
* @param thermo Pointer to the %ThermoPhase object
* @param log_level log level
* @param trParam SolidTransportParams structure to be filled up with information
*/
void TransportFactory::setupSolidTransport(std::ostream &flog, thermo_t* thermo, int log_level,
SolidTransportData& trParam) {
//====================================================================================================================
// Prepare to build a new transport manager for solids
/*
* @param flog Reference to the ostream for writing log info
* @param thermo Pointer to the %ThermoPhase object
* @param log_level log level
* @param trParam SolidTransportParams structure to be filled up with information
*/
void TransportFactory::setupSolidTransport(std::ostream& flog, thermo_t* thermo, int log_level,
SolidTransportData& trParam)
{
const XML_Node* phase_database = &thermo->xml();
// constant mixture attributes
@ -678,44 +679,45 @@ void TransportFactory::setupLiquidTransport(std::ostream& flog, thermo_t* thermo
// Get the molecular weights and load them into trParam
trParam.mw.resize(nsp);
copy(trParam.thermo->molecularWeights().begin(),
trParam.thermo->molecularWeights().end(), trParam.mw.begin());
copy(trParam.thermo->molecularWeights().begin(),
trParam.thermo->molecularWeights().end(), trParam.mw.begin());
// Resize all other vectors in trParam
//trParam.LTData.resize(nsp);
XML_Node root, log;
// Note that getSolidSpeciesTransportData just populates the pure species transport data.
// Note that getSolidSpeciesTransportData just populates the pure species transport data.
// const std::vector<const XML_Node*> & species_database = thermo->speciesData();
// getSolidSpeciesTransportData(species_database, log, trParam.thermo->speciesNames(), trParam);
// getSolidSpeciesTransportData(species_database, log, trParam.thermo->speciesNames(), trParam);
// getSolidTransportData() populates the
// getSolidTransportData() populates the
// phase transport models like electronic conductivity
// thermal conductivity, interstitial diffusion
if (phase_database->hasChild("transport")) {
XML_Node& transportNode = phase_database->child("transport");
getSolidTransportData(transportNode, log, thermo->name(), trParam);
XML_Node& transportNode = phase_database->child("transport");
getSolidTransportData(transportNode, log, thermo->name(), trParam);
}
}
//====================================================================================================================
// Initialize an existing transport manager
/*
* This routine sets up an existing gas-phase transport manager.
* It calculates the collision integrals and calls the initGas() function to
* populate the species-dependent data structure.
*
* @param tr Pointer to the Transport manager
* @param thermo Pointer to the ThermoPhase object
* @param mode Chemkin compatible mode or not. This alters the specification of the
* collision integrals. defaults to no.
* @param log_level Defaults to zero, no logging
*
* In DEBUG_MODE, this routine will create the file transport_log.xml
* and write informative information to it.
*/
void TransportFactory::initTransport(Transport* tran,
thermo_t* thermo, int mode, int log_level) {
}
//====================================================================================================================
// Initialize an existing transport manager
/*
* This routine sets up an existing gas-phase transport manager.
* It calculates the collision integrals and calls the initGas() function to
* populate the species-dependent data structure.
*
* @param tr Pointer to the Transport manager
* @param thermo Pointer to the ThermoPhase object
* @param mode Chemkin compatible mode or not. This alters the specification of the
* collision integrals. defaults to no.
* @param log_level Defaults to zero, no logging
*
* In DEBUG_MODE, this routine will create the file transport_log.xml
* and write informative information to it.
*/
void TransportFactory::initTransport(Transport* tran,
thermo_t* thermo, int mode, int log_level)
{
ScopedLock transportLock(transport_mutex);
@ -782,15 +784,16 @@ void TransportFactory::initLiquidTransport(Transport* tran,
return;
}
//====================================================================================================================
}
//====================================================================================================================
/* Similar to initTransport except uses SolidTransportParams
class and calls setupSolidTransport().
*/
void TransportFactory::initSolidTransport(Transport* tran,
thermo_t* thermo,
int log_level) {
/* Similar to initTransport except uses SolidTransportParams
class and calls setupSolidTransport().
*/
void TransportFactory::initSolidTransport(Transport* tran,
thermo_t* thermo,
int log_level)
{
SolidTransportData trParam;
@ -799,28 +802,28 @@ void TransportFactory::initLiquidTransport(Transport* tran,
ofstream flog("transport_log.xml");
trParam.xml = new XML_Writer(flog);
if (m_verbose) {
trParam.xml->XML_open(flog, "transport");
trParam.xml->XML_open(flog, "transport");
}
#else
// create the object, but don't associate it with a file
std::ostream &flog(std::cout);
std::ostream& flog(std::cout);
#endif
//real work next two statements
setupSolidTransport(flog, thermo, log_level, trParam );
setupSolidTransport(flog, thermo, log_level, trParam);
// do model-specific initialization
tran->initSolid( trParam );
tran->initSolid(trParam);
#ifdef DEBUG_MODE
if (m_verbose) {
trParam.xml->XML_close(flog, "transport");
trParam.xml->XML_close(flog, "transport");
}
// finished with log file
flog.close();
#endif
return;
}
}
void TransportFactory::fitCollisionIntegrals(ostream& logfile,
@ -1154,9 +1157,9 @@ void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transp
XML_Node& tranTypeNode = transportNode.child(iChild);
std::string nodeName = tranTypeNode.name();
trParam.mobilityRatio.resize(nsp*nsp,0);
trParam.selfDiffusion.resize(nsp,0);
ThermoPhase *temp_thermo = trParam.thermo;
trParam.mobilityRatio.resize(nsp*nsp,0);
trParam.selfDiffusion.resize(nsp,0);
ThermoPhase* temp_thermo = trParam.thermo;
if (tranTypeNode.hasChild("compositionDependence")) {
@ -1255,79 +1258,78 @@ void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transp
/*
* Given a phase XML data base, this method constructs the
* SolidTransportData object containing the transport data for the phase.
*
* @param db Reference to a vector of XML_Node pointers containing the species XML
* nodes.
* @param log Reference to an XML log file. (currently unused)
* @param tr Reference to the SolidTransportData object that will contain the results.
* NOTE: For now we are using the LTPspecies class to describe the solid transport models.
*/
void TransportFactory::getSolidTransportData(const XML_Node &transportNode,
XML_Node& log,
const std::string phaseName,
SolidTransportData& trParam)
{
/*
* Given a phase XML data base, this method constructs the
* SolidTransportData object containing the transport data for the phase.
*
* @param db Reference to a vector of XML_Node pointers containing the species XML
* nodes.
* @param log Reference to an XML log file. (currently unused)
* @param tr Reference to the SolidTransportData object that will contain the results.
* NOTE: For now we are using the LTPspecies class to describe the solid transport models.
*/
void TransportFactory::getSolidTransportData(const XML_Node& transportNode,
XML_Node& log,
const std::string phaseName,
SolidTransportData& trParam)
{
try {
int num = transportNode.nChildren();
for (int iChild = 0; iChild < num; iChild++) {
//tranTypeNode is a type of transport property like viscosity
XML_Node &tranTypeNode = transportNode.child(iChild);
std::string nodeName = tranTypeNode.name();
ThermoPhase *temp_thermo = trParam.thermo;
int num = transportNode.nChildren();
for (int iChild = 0; iChild < num; iChild++) {
//tranTypeNode is a type of transport property like viscosity
XML_Node& tranTypeNode = transportNode.child(iChild);
std::string nodeName = tranTypeNode.name();
//tranTypeNode contains the interaction model
// XML_Node &compDepNode = tranTypeNode.child("compositionDependence");
switch (m_tranPropMap[nodeName]) {
case TP_IONCONDUCTIVITY:
trParam.ionConductivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_THERMALCOND:
trParam.thermalConductivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_DEFECTDIFF:
trParam.defectDiffusivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_DEFECTCONC:
trParam.defectActivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_ELECTCOND:
trParam.electConductivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
default:
throw CanteraError("getSolidTransportData","unknown transport property: " + nodeName);
}
}
}
catch (CanteraError) {
ThermoPhase* temp_thermo = trParam.thermo;
//tranTypeNode contains the interaction model
// XML_Node &compDepNode = tranTypeNode.child("compositionDependence");
switch (m_tranPropMap[nodeName]) {
case TP_IONCONDUCTIVITY:
trParam.ionConductivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_THERMALCOND:
trParam.thermalConductivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_DEFECTDIFF:
trParam.defectDiffusivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_DEFECTCONC:
trParam.defectActivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_ELECTCOND:
trParam.electConductivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
default:
throw CanteraError("getSolidTransportData","unknown transport property: " + nodeName);
}
}
} catch (CanteraError) {
showErrors(std::cout);
}
//catch(CanteraError) {
// ;
//}
return;
}
}
/*********************************************************
*
* Polynomial fitting
*
*********************************************************/
/*********************************************************
*
* Polynomial fitting
*
*********************************************************/
/*********************************************************

View file

@ -320,7 +320,7 @@ void Reactor::addSensitivityReaction(size_t rxn)
"Reaction number out of range ("+int2str(rxn)+")");
network().registerSensitivityReaction(this, rxn,
name()+": "+m_kin->reactionString(rxn));
name()+": "+m_kin->reactionString(rxn));
m_pnum.push_back(rxn);
m_mult_save.push_back(1.0);
}

View file

@ -67,8 +67,8 @@ void ReactorNet::initialize()
for (size_t i = 0; i < sens_objs.size(); i++) {
std::map<size_t, size_t>& s = m_sensOrder[sens_objs[i]];
for (std::map<size_t, size_t>::iterator iter = s.begin();
iter != s.end();
++iter) {
iter != s.end();
++iter) {
m_sensIndex.resize(std::max(iter->second + 1, m_sensIndex.size()));
m_sensIndex[iter->second] = sensParamNumber++;
}
@ -288,9 +288,9 @@ void ReactorNet::registerSensitivityReaction(void* reactor,
{
std::pair<void*, int> R = std::make_pair(reactor, leftright);
if (m_sensOrder.count(R) &&
m_sensOrder[R].count(reactionIndex)) {
throw CanteraError("ReactorNet::registerSensitivityReaction",
"Attempted to register duplicate sensitivity reaction");
m_sensOrder[R].count(reactionIndex)) {
throw CanteraError("ReactorNet::registerSensitivityReaction",
"Attempted to register duplicate sensitivity reaction");
}
m_paramNames.push_back(name);
m_sensOrder[R][reactionIndex] = m_ntotpar;

View file

@ -30,7 +30,7 @@ public:
void SetUp() {
std::string Xref = "H:1.0, R1A:1.0, R1B:1.0, R2:1.0, "
"R3:1.0, R4:1.0, R5:1.0, R6:1.0";
"R3:1.0, R4:1.0, R5:1.0, R6:1.0";
thermo_->setState_TPX(900.0, 101325 * 8.0, Xref);
}
@ -55,11 +55,13 @@ protected:
ThermoPhase* PdepTest::thermo_ = NULL;
Kinetics* PdepTest::kin_ = NULL;
TEST_F(PdepTest, reactionCounts) {
TEST_F(PdepTest, reactionCounts)
{
EXPECT_EQ((size_t) 6, kin_->nReactions());
}
TEST_F(PdepTest, PlogLowPressure) {
TEST_F(PdepTest, PlogLowPressure)
{
// Test that P-log reactions have the right low-pressure limit
set_TP(500.0, 1e-7);
vector_fp kf(6);
@ -78,7 +80,8 @@ TEST_F(PdepTest, PlogLowPressure) {
EXPECT_NEAR(kf3, kf[3], 1e-9 * kf3);
}
TEST_F(PdepTest, PlogHighPressure) {
TEST_F(PdepTest, PlogHighPressure)
{
// Test that P-log reactions have the right high-pressure limit
set_TP(500.0, 1e10);
vector_fp kf(6);
@ -93,7 +96,8 @@ TEST_F(PdepTest, PlogHighPressure) {
EXPECT_NEAR(kf3, kf[3], 1e-9 * kf3);
}
TEST_F(PdepTest, PlogDuplicatePressures) {
TEST_F(PdepTest, PlogDuplicatePressures)
{
// Test that multiple rate expressions are combined when necessary
set_TP(500.0, 1e10);
vector_fp kf(6);
@ -106,7 +110,8 @@ TEST_F(PdepTest, PlogDuplicatePressures) {
EXPECT_NEAR(kf2, kf[2], 1e-9 * kf2);
}
TEST_F(PdepTest, PlogCornerCases) {
TEST_F(PdepTest, PlogCornerCases)
{
// Test rate evaluation at the corner cases where the pressure
// is exactly of the specified interpolation values
set_TP(500.0, 101325);
@ -122,7 +127,8 @@ TEST_F(PdepTest, PlogCornerCases) {
EXPECT_NEAR(kf2, kf[2], 1e-9 * kf2);
}
TEST_F(PdepTest, PlogIntermediatePressure1) {
TEST_F(PdepTest, PlogIntermediatePressure1)
{
set_TP(1100.0, 20*101325);
vector_fp ropf(6);
kin_->getFwdRatesOfProgress(&ropf[0]);
@ -135,7 +141,8 @@ TEST_F(PdepTest, PlogIntermediatePressure1) {
EXPECT_NEAR(1.774796e+06, ropf[3], 1e2);
}
TEST_F(PdepTest, PlogIntermediatePressure2) {
TEST_F(PdepTest, PlogIntermediatePressure2)
{
thermo_->setState_TP(1100.0, 0.5*101325);
vector_fp ropf(6);
kin_->getFwdRatesOfProgress(&ropf[0]);
@ -146,7 +153,8 @@ TEST_F(PdepTest, PlogIntermediatePressure2) {
EXPECT_NEAR(1.109248e+03, ropf[3], 1e-1);
}
TEST_F(PdepTest, PlogIntermediatePressure3) {
TEST_F(PdepTest, PlogIntermediatePressure3)
{
thermo_->setState_TP(800.0, 70*101325);
vector_fp ropf(6);
kin_->getFwdRatesOfProgress(&ropf[0]);
@ -157,7 +165,8 @@ TEST_F(PdepTest, PlogIntermediatePressure3) {
EXPECT_NEAR(1.007440e+07, ropf[3], 1e+3);
}
TEST_F(PdepTest, ChebyshevIntermediate1) {
TEST_F(PdepTest, ChebyshevIntermediate1)
{
// Test Chebyshev rates in the normal interpolation region
vector_fp kf(6);
@ -168,7 +177,8 @@ TEST_F(PdepTest, ChebyshevIntermediate1) {
EXPECT_NEAR(1.187949573e+00, kf[5], 1e-7);
}
TEST_F(PdepTest, ChebyshevIntermediate2) {
TEST_F(PdepTest, ChebyshevIntermediate2)
{
// Test Chebyshev rates in the normal interpolation region
vector_fp kf(6);
@ -179,7 +189,8 @@ TEST_F(PdepTest, ChebyshevIntermediate2) {
EXPECT_NEAR(9.581780687e-24, kf[5], 1e-31);
}
TEST_F(PdepTest, ChebyshevIntermediateROP) {
TEST_F(PdepTest, ChebyshevIntermediateROP)
{
set_TP(1100.0, 30 * 101325);
vector_fp ropf(6);
// Expected rates computed using Chemkin
@ -188,7 +199,8 @@ TEST_F(PdepTest, ChebyshevIntermediateROP) {
EXPECT_NEAR(4.877390e-02, ropf[5], 1e-5);
}
TEST_F(PdepTest, ChebyshevEdgeCases) {
TEST_F(PdepTest, ChebyshevEdgeCases)
{
vector_fp kf(6);
// Minimum P

View file

@ -45,13 +45,12 @@ int main(int argc, char** argv)
* The MultiPhaseEquil solver just gets the wrong result.
*/
int it = equilibrate(g, "TP", -1);
if (it != 1)
{
cerr << "incorrect number of iterations." << endl;
return -1;
}
cout.unsetf(ios::floatfield);
cout.precision(3);
if (it != 1) {
cerr << "incorrect number of iterations." << endl;
return -1;
}
cout.unsetf(ios::floatfield);
cout.precision(3);
//cout << g;
return 0;

View file

@ -3,7 +3,7 @@
* test problem for mixture transport
*/
// Example
// Example
//
// Test case for mixture transport in a gas
// The basic idea is to set up a gradient of some kind.
@ -12,8 +12,8 @@
// exercised and the results dumped out.
//
// A blessed solution test will make sure that the actual
// solution doesn't change as a function of time or
// further development.
// solution doesn't change as a function of time or
// further development.
// perhaps, later, an analytical solution could be added
@ -27,7 +27,7 @@
using namespace std;
#define MAX(x,y) (( (x) > (y) ) ? (x) : (y))
#define MAX(x,y) (( (x) > (y) ) ? (x) : (y))
/*****************************************************************/
/*****************************************************************/
@ -38,226 +38,227 @@ using namespace std;
using namespace Cantera;
void printDbl(double val) {
if (fabs(val) < 5.0E-17) {
cout << " nil";
} else {
cout << val;
}
void printDbl(double val)
{
if (fabs(val) < 5.0E-17) {
cout << " nil";
} else {
cout << val;
}
}
int main(int argc, char** argv) {
size_t k;
string infile = "diamond.xml";
try {
int main(int argc, char** argv)
{
size_t k;
string infile = "diamond.xml";
IdealGasMix g("gri30.xml", "gri30_mix");
size_t nsp = g.nSpecies();
double pres = 1.0E5;
vector_fp Xset(nsp, 0.0);
Xset[0] = 0.269205 ;
Xset[1] = 0.000107082;
Xset[2] = 1.36377e-09 ;
Xset[3] = 4.35475e-10;
Xset[4] = 4.34036e-06 ;
Xset[5] = 0.192249;
Xset[6] = 3.59356e-13;
Xset[7] = 2.78061e-12 ;
Xset[8] = 4.7406e-18 ;
Xset[9] = 4.12955e-17 ;
Xset[10] = 2.58549e-14 ;
Xset[11] = 8.96502e-16 ;
Xset[12] = 6.09056e-11 ;
Xset[13] = 7.56752e-09 ;
Xset[14] = 0.192253;
Xset[15] = 0.0385036;
Xset[16] = 1.49596e-08 ;
Xset[17] = 2.22378e-08 ;
Xset[18] = 1.43096e-13 ;
Xset[19] = 1.45312e-15 ;
Xset[20] = 1.96948e-12 ;
Xset[21] = 8.41937e-19;
Xset[22] = 3.18852e-13 ;
Xset[23] = 7.93625e-18 ;
Xset[24] = 3.20653e-15 ;
Xset[25] = 1.15149e-19 ;
Xset[26] = 1.61189e-18 ;
Xset[27] = 1.4719e-15 ;
Xset[28] = 5.24728e-13 ;
Xset[29] = 6.90582e-17 ;
Xset[30] = 6.37248e-12 ;
Xset[31] =5.93728e-11 ;
Xset[32] = 2.71219e-09 ;
Xset[33] = 2.66645e-06 ;
Xset[34] = 6.57142e-11 ;
Xset[35] = 9.52453e-08 ;
Xset[36] = 1.26006e-14;
Xset[37] = 3.49802e-12;
Xset[38] = 1.19232e-11 ;
Xset[39] = 7.17782e-13 ;
Xset[40] = 1.85347e-07 ;
Xset[41] = 8.25325e-14 ;
Xset[42] = 5.00914e-20 ;
Xset[43] = 1.54407e-16 ;
Xset[44] =3.07176e-11 ;
Xset[45] =4.93198e-08 ;
Xset[46] =4.84792e-12 ;
Xset[47] = 0.307675 ;
Xset[48] =0;
Xset[49] =6.21649e-29;
Xset[50] = 8.42393e-28 ;
Xset[51] = 6.77865e-18;
Xset[52] = 2.19225e-16;
double T1 = 1500.;
try {
double sum = 0.0;
for (k = 0; k < nsp; k++) {
sum += Xset[k];
}
for (k = 0; k < nsp; k++) {
Xset[k] /= sum;
IdealGasMix g("gri30.xml", "gri30_mix");
size_t nsp = g.nSpecies();
double pres = 1.0E5;
vector_fp Xset(nsp, 0.0);
Xset[0] = 0.269205 ;
Xset[1] = 0.000107082;
Xset[2] = 1.36377e-09 ;
Xset[3] = 4.35475e-10;
Xset[4] = 4.34036e-06 ;
Xset[5] = 0.192249;
Xset[6] = 3.59356e-13;
Xset[7] = 2.78061e-12 ;
Xset[8] = 4.7406e-18 ;
Xset[9] = 4.12955e-17 ;
Xset[10] = 2.58549e-14 ;
Xset[11] = 8.96502e-16 ;
Xset[12] = 6.09056e-11 ;
Xset[13] = 7.56752e-09 ;
Xset[14] = 0.192253;
Xset[15] = 0.0385036;
Xset[16] = 1.49596e-08 ;
Xset[17] = 2.22378e-08 ;
Xset[18] = 1.43096e-13 ;
Xset[19] = 1.45312e-15 ;
Xset[20] = 1.96948e-12 ;
Xset[21] = 8.41937e-19;
Xset[22] = 3.18852e-13 ;
Xset[23] = 7.93625e-18 ;
Xset[24] = 3.20653e-15 ;
Xset[25] = 1.15149e-19 ;
Xset[26] = 1.61189e-18 ;
Xset[27] = 1.4719e-15 ;
Xset[28] = 5.24728e-13 ;
Xset[29] = 6.90582e-17 ;
Xset[30] = 6.37248e-12 ;
Xset[31] =5.93728e-11 ;
Xset[32] = 2.71219e-09 ;
Xset[33] = 2.66645e-06 ;
Xset[34] = 6.57142e-11 ;
Xset[35] = 9.52453e-08 ;
Xset[36] = 1.26006e-14;
Xset[37] = 3.49802e-12;
Xset[38] = 1.19232e-11 ;
Xset[39] = 7.17782e-13 ;
Xset[40] = 1.85347e-07 ;
Xset[41] = 8.25325e-14 ;
Xset[42] = 5.00914e-20 ;
Xset[43] = 1.54407e-16 ;
Xset[44] =3.07176e-11 ;
Xset[45] =4.93198e-08 ;
Xset[46] =4.84792e-12 ;
Xset[47] = 0.307675 ;
Xset[48] =0;
Xset[49] =6.21649e-29;
Xset[50] = 8.42393e-28 ;
Xset[51] = 6.77865e-18;
Xset[52] = 2.19225e-16;
double T1 = 1500.;
double sum = 0.0;
for (k = 0; k < nsp; k++) {
sum += Xset[k];
}
for (k = 0; k < nsp; k++) {
Xset[k] /= sum;
}
vector_fp X2set(nsp, 0.0);
X2set[0] = 0.25 ;
X2set[5] = 0.17;
X2set[14] = 0.15;
X2set[15] = 0.05;
X2set[47] = 0.38 ;
double T2 = 1200.;
double dist = 0.1;
vector_fp X3set(nsp, 0.0);
X3set[0] = 0.27 ;
X3set[5] = 0.15;
X3set[14] = 0.18;
X3set[15] = 0.06;
X3set[47] = 0.36 ;
double T3 = 1400.;
vector_fp grad_T(3, 0.0);
Array2D grad_X(nsp, 2, 0.0);
for (k = 0; k < nsp; k++) {
grad_X(k,0) = (X2set[k] - Xset[k])/dist;
grad_X(k,1) = (X3set[k] - Xset[k])/dist;
}
grad_T[0] = (T2 - T1) / dist;
grad_T[1] = (T3 - T1) / dist;
int log_level = 0;
Transport* tran = newTransportMgr("Pecos", &g, log_level=0);
PecosTransport* tranMix = dynamic_cast<PecosTransport*>(tran);
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
vector_fp mixDiffs(nsp, 0.0);
tranMix->getMixDiffCoeffsMass(DATA_PTR(mixDiffs));
printf(" Dump of the mixture Diffusivities:\n");
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
printf(" %15s %13.5g\n", sss.c_str(), mixDiffs[k]);
}
vector_fp specVisc(nsp, 0.0);
tranMix->getSpeciesViscosities(DATA_PTR(specVisc));
printf(" Dump of the species viscosities:\n");
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
printf(" %15s %13.5g\n", sss.c_str(), specVisc[k]);
}
vector_fp thermDiff(nsp, 0.0);
tranMix->getThermalDiffCoeffs(DATA_PTR(thermDiff));
printf(" Dump of the Thermal Diffusivities :\n");
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
printf(" %15s %13.5g\n", sss.c_str(), thermDiff[k]);
}
printf("Viscoscity and thermal Cond vs. T\n");
for (k = 0; k < 10; k++) {
T1 = 400. + 100. * k;
g.setState_TPX(T1, pres, DATA_PTR(Xset));
double visc = tran->viscosity();
double cond = tran->thermalConductivity();
printf(" %13g %13.5g %13.5g\n", T1, visc, cond);
}
g.setState_TPX(T1, pres, DATA_PTR(Xset));
Array2D Bdiff(nsp, nsp, 0.0);
printf("Binary Diffusion Coefficients H2 vs species\n");
tranMix->getBinaryDiffCoeffs(nsp, Bdiff.ptrColumn(0));
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
printf(" H2 - %15s %13.5g %13.5g\n", sss.c_str(), Bdiff(0,k), Bdiff(k,0));
}
vector_fp specMob(nsp, 0.0);
tranMix->getMobilities(DATA_PTR(specMob));
printf(" Dump of the species mobilities:\n");
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
printf(" %15s %13.5g\n", sss.c_str(), specMob[k]);
}
Array2D fluxes(nsp, 2, 0.0);
tranMix->getSpeciesFluxes(2, DATA_PTR(grad_T), nsp,
grad_X.ptrColumn(0), nsp, fluxes.ptrColumn(0));
printf(" Dump of the species fluxes:\n");
double sum1 = 0.0;
double sum2 = 0.0;
double max1 = 0.0;
double max2 = 0.0;
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
printf(" %15s %13.5g %13.5g\n", sss.c_str(), fluxes(k,0), fluxes(k,1));
sum1 += fluxes(k,0);
if (fabs(fluxes(k,0)) > max1) {
max1 = fabs(fluxes(k,0));
}
sum2 += fluxes(k,1);
if (fabs(fluxes(k,1)) > max2) {
max2 = fabs(fluxes(k,0));
}
}
// Make sure roundoff error doesn't interfere with the printout.
// these should be zero.
if (fabs(sum1) * 1.0E14 > max1) {
printf("sum in x direction = %13.5g\n", sum1);
} else {
printf("sum in x direction = 0\n");
}
if (fabs(sum2) * 1.0E14 > max2) {
printf("sum in y direction = %13.5g\n", sum1);
} else {
printf("sum in y direction = 0\n");
}
std::cout << "Sum of Diffusive Mass Fluxes: " << sum1 << std::endl;
std::cout << "Sum of Diffusive Mass Fluxes: " << sum2 << std::endl;
} catch (CanteraError) {
showErrors(cout);
}
vector_fp X2set(nsp, 0.0);
X2set[0] = 0.25 ;
X2set[5] = 0.17;
X2set[14] = 0.15;
X2set[15] = 0.05;
X2set[47] = 0.38 ;
double T2 = 1200.;
double dist = 0.1;
vector_fp X3set(nsp, 0.0);
X3set[0] = 0.27 ;
X3set[5] = 0.15;
X3set[14] = 0.18;
X3set[15] = 0.06;
X3set[47] = 0.36 ;
double T3 = 1400.;
vector_fp grad_T(3, 0.0);
Array2D grad_X(nsp, 2, 0.0);
for( k = 0; k < nsp; k++) {
grad_X(k,0) = (X2set[k] - Xset[k])/dist;
grad_X(k,1) = (X3set[k] - Xset[k])/dist;
}
grad_T[0] = (T2 - T1) / dist;
grad_T[1] = (T3 - T1) / dist;
int log_level = 0;
Transport * tran = newTransportMgr("Pecos", &g, log_level=0);
PecosTransport * tranMix = dynamic_cast<PecosTransport *>(tran);
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
vector_fp mixDiffs(nsp, 0.0);
tranMix->getMixDiffCoeffsMass(DATA_PTR(mixDiffs));
printf(" Dump of the mixture Diffusivities:\n");
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
printf(" %15s %13.5g\n", sss.c_str(), mixDiffs[k]);
}
vector_fp specVisc(nsp, 0.0);
tranMix->getSpeciesViscosities(DATA_PTR(specVisc));
printf(" Dump of the species viscosities:\n");
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
printf(" %15s %13.5g\n", sss.c_str(), specVisc[k]);
}
vector_fp thermDiff(nsp, 0.0);
tranMix->getThermalDiffCoeffs(DATA_PTR(thermDiff));
printf(" Dump of the Thermal Diffusivities :\n");
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
printf(" %15s %13.5g\n", sss.c_str(), thermDiff[k]);
}
printf("Viscoscity and thermal Cond vs. T\n");
for (k = 0; k < 10; k++) {
T1 = 400. + 100. * k;
g.setState_TPX(T1, pres, DATA_PTR(Xset));
double visc = tran->viscosity();
double cond = tran->thermalConductivity();
printf(" %13g %13.5g %13.5g\n", T1, visc, cond);
}
g.setState_TPX(T1, pres, DATA_PTR(Xset));
Array2D Bdiff(nsp, nsp, 0.0);
printf("Binary Diffusion Coefficients H2 vs species\n");
tranMix->getBinaryDiffCoeffs(nsp, Bdiff.ptrColumn(0));
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
printf(" H2 - %15s %13.5g %13.5g\n", sss.c_str(), Bdiff(0,k), Bdiff(k,0));
}
vector_fp specMob(nsp, 0.0);
tranMix->getMobilities(DATA_PTR(specMob));
printf(" Dump of the species mobilities:\n");
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
printf(" %15s %13.5g\n", sss.c_str(), specMob[k]);
}
Array2D fluxes(nsp, 2, 0.0);
tranMix->getSpeciesFluxes(2, DATA_PTR(grad_T), nsp,
grad_X.ptrColumn(0), nsp, fluxes.ptrColumn(0));
printf(" Dump of the species fluxes:\n");
double sum1 = 0.0;
double sum2 = 0.0;
double max1 = 0.0;
double max2 = 0.0;
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
printf(" %15s %13.5g %13.5g\n", sss.c_str(), fluxes(k,0), fluxes(k,1));
sum1 += fluxes(k,0);
if (fabs(fluxes(k,0)) > max1) {
max1 = fabs(fluxes(k,0));
}
sum2 += fluxes(k,1);
if (fabs(fluxes(k,1)) > max2) {
max2 = fabs(fluxes(k,0));
}
}
// Make sure roundoff error doesn't interfere with the printout.
// these should be zero.
if (fabs(sum1) * 1.0E14 > max1) {
printf("sum in x direction = %13.5g\n", sum1);
} else {
printf("sum in x direction = 0\n");
}
if (fabs(sum2) * 1.0E14 > max2) {
printf("sum in y direction = %13.5g\n", sum1);
} else {
printf("sum in y direction = 0\n");
}
std::cout << "Sum of Diffusive Mass Fluxes: " << sum1 << std::endl;
std::cout << "Sum of Diffusive Mass Fluxes: " << sum2 << std::endl;
}
catch (CanteraError) {
showErrors(cout);
}
return 0;
return 0;
}
/***********************************************************/

View file

@ -16,7 +16,7 @@ void testProblem()
// Create the phases
std::auto_ptr<ThermoPhase> LiSi_solid(newPhase("Li7Si3_ls.xml",
"Li7Si3_and_Interstitials(S)"));
"Li7Si3_and_Interstitials(S)"));
FixedChemPotSSTP LiFixed("Li", -2.3E7);
MargulesVPSSTP salt(1);

View file

@ -21,7 +21,7 @@ int main(int argc, char** argv)
Cantera::IdealSolnGasVPSS gg("silane.xml", "silane");
ThermoPhase* g = &gg;
//ThermoPhase *g = newPhase("silane.xml", "silane");
cout.precision(4);
cout.precision(4);
g->setState_TPX(1500.0, 100.0, "SIH4:0.01, H2:0.99");
//g.setState_TPX(1500.0, 1.0132E5, "SIH4:0.01, H2:0.99");
Cantera::ChemEquil_print_lvl = 40;

View file

@ -37,7 +37,7 @@ int main(int argc, char** argv)
#endif
if (argc != 2) {
cout << "Error: no input file specified.\n"
"Choose either 'diamond.cti' or 'diamond_blessed.xml" << endl;
"Choose either 'diamond.cti' or 'diamond_blessed.xml" << endl;
exit(-1);
}
std::string infile(argv[1]);
@ -51,7 +51,7 @@ int main(int argc, char** argv)
XML_Node* const xg = xc->findNameID("phase", "gas");
ThermoPhase* gasTP = newPhase(*xg);
size_t nsp = gasTP->nSpecies();
cout.precision(4);
cout.precision(4);
cout << "Number of species = " << nsp << endl;
XML_Node* const xd = xc->findNameID("phase", "diamond");

View file

@ -39,7 +39,7 @@ int main(int argc, char** argv)
XML_Node* xc = new XML_Node();
string path = findInputFile(infile);
ctml::get_CTML_Tree(xc, path);
cout.precision(3);
cout.precision(3);
XML_Node* const xg = xc->findNameID("phase", "gas");
ThermoPhase* gasTP = newPhase(*xg);

View file

@ -46,7 +46,7 @@ int main(int argc, char** argv)
XML_Node* const xg = xc->findNameID("phase", "gas");
ThermoPhase* gasTP = newPhase(*xg);
size_t nsp = gasTP->nSpecies();
cout.precision(4);
cout.precision(4);
cout << "Number of species = " << nsp << endl;
vector<ThermoPhase*> phaseList;

View file

@ -13,7 +13,7 @@ int main(int argc, char** argv)
try {
if (argc != 2) {
cout << "Error: no input file specified.\n"
"Choose either 'noxNeg.cti' or 'noxNeg_blessed.xml" << endl;
"Choose either 'noxNeg.cti' or 'noxNeg_blessed.xml" << endl;
exit(-1);
}
std::string infile(argv[1]);

View file

@ -8,71 +8,71 @@
using namespace std;
using namespace Cantera;
int main(int argc, char **argv)
int main(int argc, char** argv)
{
try {
int log_level = 3;
try {
int log_level = 3;
HMWSoln HMW("HMW_NaCl_pdss.xml", "NaCl_electrolyte");
HMWSoln HMW("HMW_NaCl_pdss.xml", "NaCl_electrolyte");
auto_ptr<Transport> tran(newDefaultTransportMgr(&HMW, log_level));
auto_ptr<Transport> tran(newDefaultTransportMgr(&HMW, log_level));
SimpleTransport& tranSimple = dynamic_cast<SimpleTransport&>(*tran.get());
size_t nsp = HMW.nSpecies();
SimpleTransport& tranSimple = dynamic_cast<SimpleTransport&>(*tran.get());
size_t nsp = HMW.nSpecies();
HMW.setState_TP(30+273.13, OneAtm);
HMW.setState_TP(30+273.13, OneAtm);
double visc = tranSimple.viscosity();
printf("visc = %g\n", visc);
double visc = tranSimple.viscosity();
printf("visc = %g\n", visc);
vector_fp x(nsp, 0.0);
vector_fp x(nsp, 0.0);
tranSimple.getSpeciesViscosities(&x[0]);
for (size_t k = 0; k < nsp; k++) {
printf("sp visc (%s) = %g\n", HMW.speciesName(k).c_str(), x[k]);
tranSimple.getSpeciesViscosities(&x[0]);
for (size_t k = 0; k < nsp; k++) {
printf("sp visc (%s) = %g\n", HMW.speciesName(k).c_str(), x[k]);
}
double cond = tranSimple.thermalConductivity();
printf("cond = %g\n", cond);
tranSimple.getMixDiffCoeffs(&x[0]);
for (size_t k = 0; k < nsp; k++) {
printf("sp diff (%s) = %g\n", HMW.speciesName(k).c_str(), x[k]);
}
tranSimple.getMobilities(&x[0]);
for (size_t k = 0; k < nsp; k++) {
printf("Mobility (%s) = %g\n", HMW.speciesName(k).c_str(), x[k]);
}
vector_fp gradX(nsp, 0.0);
gradX[1] = 1.0;
double gradT = 0.0;
tranSimple.getSpeciesFluxes(1, &gradT, 5, &gradX[0], 5, &x[0]);
for (size_t k = 0; k < nsp; k++) {
string spName = HMW.speciesName(k);
printf("SpeciesFlux (%s) = %g\n", spName.c_str(), x[k]);
}
gradX[1] = 0.0;
double gradV = 1.0;
tranSimple.set_Grad_T(&gradT);
tranSimple.set_Grad_V(&gradV);
tranSimple.set_Grad_X(&gradX[0]);
tranSimple.getSpeciesFluxesExt(5, &x[0]);
for (size_t k = 0; k < nsp; k++) {
printf("SpeciesFlux (%s) = %g\n", HMW.speciesName(k).c_str(), x[k]);
}
Cantera::appdelete();
return 0;
} catch (CanteraError) {
showErrors();
return -1;
}
double cond = tranSimple.thermalConductivity();
printf("cond = %g\n", cond);
tranSimple.getMixDiffCoeffs(&x[0]);
for (size_t k = 0; k < nsp; k++) {
printf("sp diff (%s) = %g\n", HMW.speciesName(k).c_str(), x[k]);
}
tranSimple.getMobilities(&x[0]);
for (size_t k = 0; k < nsp; k++) {
printf("Mobility (%s) = %g\n", HMW.speciesName(k).c_str(), x[k]);
}
vector_fp gradX(nsp, 0.0);
gradX[1] = 1.0;
double gradT = 0.0;
tranSimple.getSpeciesFluxes(1, &gradT, 5, &gradX[0], 5, &x[0]);
for (size_t k = 0; k < nsp; k++) {
string spName = HMW.speciesName(k);
printf("SpeciesFlux (%s) = %g\n", spName.c_str(), x[k]);
}
gradX[1] = 0.0;
double gradV = 1.0;
tranSimple.set_Grad_T(&gradT);
tranSimple.set_Grad_V(&gradV);
tranSimple.set_Grad_X(&gradX[0]);
tranSimple.getSpeciesFluxesExt(5, &x[0]);
for (size_t k = 0; k < nsp; k++) {
printf("SpeciesFlux (%s) = %g\n", HMW.speciesName(k).c_str(), x[k]);
}
Cantera::appdelete();
return 0;
} catch (CanteraError) {
showErrors();
return -1;
}
}

View file

@ -3,7 +3,7 @@
* test problem for statistical mechanics in cantera
*/
// Example
// Example
//
// Test case for the statistical mechanics in cantera
//
@ -27,36 +27,33 @@ using namespace std;
using namespace Cantera;
int main(int argc, char** argv)
int main(int argc, char** argv)
{
try
{
int k;
IdealGasMix g("test_stat.xml");
int nsp = g.nSpecies();
double pres = 1.0E5;
try {
int k;
IdealGasMix g("test_stat.xml");
int nsp = g.nSpecies();
double pres = 1.0E5;
vector_fp Xset(nsp, 0.0);
Xset[0] = 0.5 ;
Xset[1] = 0.5;
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
equilibrate(g, "TP", -1);
vector_fp Xset(nsp, 0.0);
Xset[0] = 0.5 ;
Xset[1] = 0.5;
vector_fp cp_R(nsp, 0.0);
g.getCp_R(DATA_PTR(cp_R));
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
equilibrate(g, "TP", -1);
vector_fp cp_R(nsp, 0.0);
g.getCp_R(DATA_PTR(cp_R));
} catch (CanteraError) {
showErrors(cout);
return 1;
}
catch (CanteraError)
{
showErrors(cout);
return 1;
}
// Mark it zero!
return 0;
// Mark it zero!
return 0;
}

View file

@ -3,7 +3,7 @@
* test problem for statistical mechanics in cantera
*/
// Example
// Example
//
// Test case for the statistical mechanics in cantera
//
@ -26,87 +26,81 @@
using namespace std;
using namespace Cantera;
int main(int argc, char** argv)
int main(int argc, char** argv)
{
try
{
int k;
IdealGasMix g("test_stat.xml");
int nsp = g.nSpecies();
double pres = 1.0E5;
try {
int k;
IdealGasMix g("test_stat.xml");
int nsp = g.nSpecies();
double pres = 1.0E5;
vector_fp Xset(nsp, 0.0);
Xset[0] = 0.5 ;
Xset[1] = 0.5;
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
equilibrate(g, "TP", -1);
vector_fp Xset(nsp, 0.0);
Xset[0] = 0.5 ;
Xset[1] = 0.5;
vector_fp cp_R(nsp, 0.0);
g.getCp_R(DATA_PTR(cp_R));
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
equilibrate(g, "TP", -1);
//for(int i=0;i<nsp;i++)
//{
// std::cout.precision(10);
// std::cout << cp_R[i] << std::endl;
// }
vector_fp cp_R(nsp, 0.0);
g.getCp_R(DATA_PTR(cp_R));
// error check-- exactly 2.5 for atoms
if(cp_R[0] != 2.5)
{
std::cout << "Error for monotomic Species!\n";
return 1;
}
//for(int i=0;i<nsp;i++)
//{
// std::cout.precision(10);
// std::cout << cp_R[i] << std::endl;
// }
// error check: analytical result is more complicated for
// molecules. One species should suffice, lets try NO2, with
// three vibrational modes:
/// theta[0]: 1.07900e3
/// theta[1]: 1.90000e3
/// theta[2]: 2.32700e3
// at T = 1500
//
// This is precisely: 6.655804161 (e.g. 5/2 + 2 + 3.1558..)
//
double theta[3];
theta[0] = 1.07900e3;
theta[1] = 1.90000e3;
theta[2] = 2.32700e3;
// error check-- exactly 2.5 for atoms
if (cp_R[0] != 2.5) {
std::cout << "Error for monotomic Species!\n";
return 1;
}
double T;
T = 1500.0;
// error check: analytical result is more complicated for
// molecules. One species should suffice, lets try NO2, with
// three vibrational modes:
/// theta[0]: 1.07900e3
/// theta[1]: 1.90000e3
/// theta[2]: 2.32700e3
// at T = 1500
//
// This is precisely: 6.655804161 (e.g. 5/2 + 2 + 3.1558..)
//
double theta[3];
theta[0] = 1.07900e3;
theta[1] = 1.90000e3;
theta[2] = 2.32700e3;
double denom;
double ctr = 0.0;
double GasConstant = 1.0;
double T;
T = 1500.0;
for(int i = 0; i < 3; i++)
{
denom = exp(2*theta[i]/T) - 2* exp(theta[i]/T) + 1;
ctr += GasConstant * theta[i] * (theta[i] * exp(theta[i]/T)/(T*T))/ (denom);
//std::cout << "survey says: " << ctr << " and denom is: " << denom << std::endl;
}
//std::cout << "survey says: " << ctr << " and denom is: " << denom << std::endl;
double sol = ctr + 5/2 + 2;
double tol = 1e-9;
double denom;
double ctr = 0.0;
double GasConstant = 1.0;
if(abs(cp_R[3] - sol) >= tol )
{
double diff = cp_R[3]-sol;
std::cout << "Error for Species NO2!\n";
std::cout << "Diff was: " << diff << "\n";
return 1;
}
for (int i = 0; i < 3; i++) {
denom = exp(2*theta[i]/T) - 2* exp(theta[i]/T) + 1;
ctr += GasConstant * theta[i] * (theta[i] * exp(theta[i]/T)/(T*T))/ (denom);
//std::cout << "survey says: " << ctr << " and denom is: " << denom << std::endl;
}
//std::cout << "survey says: " << ctr << " and denom is: " << denom << std::endl;
double sol = ctr + 5/2 + 2;
double tol = 1e-9;
if (abs(cp_R[3] - sol) >= tol) {
double diff = cp_R[3]-sol;
std::cout << "Error for Species NO2!\n";
std::cout << "Diff was: " << diff << "\n";
return 1;
}
} catch (CanteraError) {
showErrors(cout);
return 1;
}
catch (CanteraError)
{
showErrors(cout);
return 1;
}
// Mark it zero!
return 0;
// Mark it zero!
return 0;
}

View file

@ -3,7 +3,7 @@
* test problem for statistical mechanics in cantera
*/
// Example
// Example
//
// Test case to check error thrown if using Fe (not supported species)
//
@ -27,47 +27,42 @@ using namespace std;
using namespace Cantera;
int main(int argc, char** argv)
int main(int argc, char** argv)
{
try
{
int k;
IdealGasMix g("test_stat_Fe.xml");
int nsp = g.nSpecies();
double pres = 1.0E5;
try {
int k;
IdealGasMix g("test_stat_Fe.xml");
int nsp = g.nSpecies();
double pres = 1.0E5;
vector_fp Xset(nsp, 0.0);
Xset[0] = 0.5 ;
Xset[1] = 0.5;
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
equilibrate(g, "TP", -1);
vector_fp Xset(nsp, 0.0);
Xset[0] = 0.5 ;
Xset[1] = 0.5;
vector_fp cp_R(nsp, 0.0);
g.getCp_R(DATA_PTR(cp_R));
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
equilibrate(g, "TP", -1);
for(int i=0;i<nsp;i++)
{
std::cout << cp_R[i] << std::endl;
}
vector_fp cp_R(nsp, 0.0);
g.getCp_R(DATA_PTR(cp_R));
// error check
if(cp_R[0] != 0)
{
std::cout << "Error for monotomic Species!\n";
return 1;
}
for (int i=0; i<nsp; i++) {
std::cout << cp_R[i] << std::endl;
}
// error check
if (cp_R[0] != 0) {
std::cout << "Error for monotomic Species!\n";
return 1;
}
} catch (CanteraError) {
// need to get error here because of loading Fe in input file, when
// no Fe exists in the species information table, in statmech.cpp
//showErrors(cout);
return 0;
}
catch (CanteraError)
{
// need to get error here because of loading Fe in input file, when
// no Fe exists in the species information table, in statmech.cpp
//showErrors(cout);
return 0;
}
// Mark it zero!
return 1;
// Mark it zero!
return 1;
}

View file

@ -3,7 +3,7 @@
* test problem for statistical mechanics in cantera
*/
// Example
// Example
//
// Test case for the statistical mechanics in cantera
//
@ -27,38 +27,35 @@ using namespace std;
using namespace Cantera;
int main(int argc, char** argv)
int main(int argc, char** argv)
{
try
{
int k;
IdealGasMix g("test_stat_err.xml");
int nsp = g.nSpecies();
double pres = 1.0E5;
try {
int k;
IdealGasMix g("test_stat_err.xml");
int nsp = g.nSpecies();
double pres = 1.0E5;
vector_fp Xset(nsp, 0.0);
Xset[0] = 0.5 ;
Xset[1] = 0.5;
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
equilibrate(g, "TP", -1);
vector_fp Xset(nsp, 0.0);
Xset[0] = 0.5 ;
Xset[1] = 0.5;
vector_fp cp_R(nsp, 0.0);
g.getCp_R(DATA_PTR(cp_R));
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
equilibrate(g, "TP", -1);
vector_fp cp_R(nsp, 0.0);
g.getCp_R(DATA_PTR(cp_R));
} catch (CanteraError) {
// we wanted to catch an error here for incorrectly trying to use poly methods
// for the statmech species data, so exit successfully
//showErrors(cout);
// Mark it zero!
return 0;
}
catch (CanteraError)
{
// we wanted to catch an error here for incorrectly trying to use poly methods
// for the statmech species data, so exit successfully
//showErrors(cout);
// Mark it zero!
return 0;
}
// something is wrong: we were suppose to catch an error here: paradox!
return 1;
// something is wrong: we were suppose to catch an error here: paradox!
return 1;
}

View file

@ -3,7 +3,7 @@
* test problem for statistical mechanics in cantera
*/
// Example
// Example
//
// Test case for the statistical mechanics in cantera
//
@ -26,95 +26,89 @@
using namespace std;
using namespace Cantera;
int main(int argc, char** argv)
int main(int argc, char** argv)
{
try
{
int k;
IdealGasMix g("test_stat_trans.xml", "example");
int nsp = g.nSpecies();
double pres = 1.0E5;
try {
int k;
IdealGasMix g("test_stat_trans.xml", "example");
int nsp = g.nSpecies();
double pres = 1.0E5;
vector_fp Xset(nsp, 0.0);
Xset[0] = 0.5 ;
Xset[1] = 0.5;
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
equilibrate(g, "TP", -1);
vector_fp Xset(nsp, 0.0);
Xset[0] = 0.5 ;
Xset[1] = 0.5;
// init pecos transport
int log_level = 0;
Transport * tran = newTransportMgr("Pecos", &g, log_level=0);
PecosTransport * tranMix = dynamic_cast<PecosTransport *>(tran);
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
equilibrate(g, "TP", -1);
cout << "here";
// init pecos transport
int log_level = 0;
Transport* tran = newTransportMgr("Pecos", &g, log_level=0);
PecosTransport* tranMix = dynamic_cast<PecosTransport*>(tran);
cout << "here";
vector_fp cp_R(nsp, 0.0);
g.getCp_R(DATA_PTR(cp_R));
vector_fp cp_R(nsp, 0.0);
g.getCp_R(DATA_PTR(cp_R));
//for(int i=0;i<nsp;i++)
//{
// std::cout.precision(10);
// std::cout << cp_R[i] << std::endl;
// }
//for(int i=0;i<nsp;i++)
//{
// std::cout.precision(10);
// std::cout << cp_R[i] << std::endl;
// }
// error check-- exactly 2.5 for atoms
if(cp_R[0] != 2.5)
{
std::cout << "Error for monotomic Species!\n";
return 1;
}
// error check-- exactly 2.5 for atoms
if (cp_R[0] != 2.5) {
std::cout << "Error for monotomic Species!\n";
return 1;
}
// error check: analytical result is more complicated for
// molecules. One species should suffice, lets try NO2, with
// three vibrational modes:
/// theta[0]: 1.07900e3
/// theta[1]: 1.90000e3
/// theta[2]: 2.32700e3
// at T = 1500
//
// This is precisely: 6.655804161 (e.g. 5/2 + 2 + 3.1558..)
//
double theta[3];
theta[0] = 1.07900e3;
theta[1] = 1.90000e3;
theta[2] = 2.32700e3;
// error check: analytical result is more complicated for
// molecules. One species should suffice, lets try NO2, with
// three vibrational modes:
/// theta[0]: 1.07900e3
/// theta[1]: 1.90000e3
/// theta[2]: 2.32700e3
// at T = 1500
//
// This is precisely: 6.655804161 (e.g. 5/2 + 2 + 3.1558..)
//
double theta[3];
theta[0] = 1.07900e3;
theta[1] = 1.90000e3;
theta[2] = 2.32700e3;
double T;
T = 1500.0;
double T;
T = 1500.0;
double denom;
double ctr = 0.0;
double GasConstant = 1.0;
double denom;
double ctr = 0.0;
double GasConstant = 1.0;
for(int i = 0; i < 3; i++)
{
denom = exp(2*theta[i]/T) - 2* exp(theta[i]/T) + 1;
ctr += GasConstant * theta[i] * (theta[i] * exp(theta[i]/T)/(T*T))/ (denom);
//std::cout << "survey says: " << ctr << " and denom is: " << denom << std::endl;
}
//std::cout << "survey says: " << ctr << " and denom is: " << denom << std::endl;
double sol = ctr + 5/2 + 2;
double tol = 1e-9;
for (int i = 0; i < 3; i++) {
denom = exp(2*theta[i]/T) - 2* exp(theta[i]/T) + 1;
ctr += GasConstant * theta[i] * (theta[i] * exp(theta[i]/T)/(T*T))/ (denom);
//std::cout << "survey says: " << ctr << " and denom is: " << denom << std::endl;
}
//std::cout << "survey says: " << ctr << " and denom is: " << denom << std::endl;
double sol = ctr + 5/2 + 2;
double tol = 1e-9;
if(abs(cp_R[3] - sol) >= tol )
{
double diff = cp_R[3]-sol;
std::cout << "Error for Species NO2!\n";
std::cout << "Diff was: " << diff << "\n";
return 1;
}
if (abs(cp_R[3] - sol) >= tol) {
double diff = cp_R[3]-sol;
std::cout << "Error for Species NO2!\n";
std::cout << "Diff was: " << diff << "\n";
return 1;
}
} catch (CanteraError) {
showErrors(cout);
return 1;
}
catch (CanteraError)
{
showErrors(cout);
return 1;
}
// Mark it zero!
return 0;
// Mark it zero!
return 0;
}

View file

@ -24,7 +24,7 @@ int main()
vector_fp cov;
cov.push_back(0.8);
cov.push_back(0.2);
cout.precision(4);
cout.precision(4);
surf.setCoverages(DATA_PTR(cov));
vector_fp wdot(gas.nSpecies() + surf.nSpecies());
surf.getNetProductionRates(DATA_PTR(wdot));
@ -32,7 +32,7 @@ int main()
cout << gas.speciesName(k) << " " << wdot[k] << endl;
}
for (size_t k = 0; k < surf.nSpecies(); k++)
for (size_t k = 0; k < surf.nSpecies(); k++)
cout << surf.speciesName(k) << " "
<< wdot[k+gas.nSpecies()] << endl;