*** empty log message ***

This commit is contained in:
Dave Goodwin 2006-04-11 07:15:48 +00:00
parent 38db8309fe
commit 53cbe7e119
10 changed files with 440 additions and 651 deletions

View file

@ -34,10 +34,10 @@ class Func1:
def __init__(self, typ, n, coeffs=[]):
"""
The constructor is meant to be called from constructors of
subclasses of Func1.
See: Polynomial, Gaussian, Arrhenius, Fourier, Const, PeriodicFunction
"""
The constructor is
meant to be called from constructors of subclasses of Func1.
See: Polynomial, Gaussian, Arrhenius, Fourier, Const,
PeriodicFunction """
self.n = n
self.coeffs = asarray(coeffs,'d')
self._func_id = _cantera.func_new(typ, n, self.coeffs)
@ -54,18 +54,26 @@ class Func1:
"""Overloads operator '+'
Returns a new function self(t) + other(t)"""
# if 'other' is a number, then create a 'Const' functor for
# it.
if type(other) == types.FloatType:
return SumFunction(self, Const(other))
return SumFunction(self, other)
def __radd__(self, other):
"""Overloads operator '+'
Returns a new function other(t) + self(t)"""
Returns a new function other(t) + self(t)"""
# if 'other' is a number, then create a 'Const' functor for
# it.
if type(other) == types.FloatType:
return SumFunction(Const(other),self)
return SumFunction(other, self)
def __mul__(self, other):
"""Overloads operator '*'
@ -102,9 +110,12 @@ class Polynomial(Func1):
\f[
f(t) = \sum_{n = 0}^N a_n t^n.
\f]
The coefficients are supplied as a list, beginning with \f$a_N\f$ and ending with \f$a_0\f$.
The coefficients are supplied as a list, beginning with
\f$a_N\f$ and ending with \f$a_0\f$.
>>> p1 = Polynomial([1.0, -2.0, 3.0]) # 3t^2 - 2t + 1
>>> p2 = Polynomial([6.0, 8.0]) # 8t + 6
"""
def __init__(self, coeffs=[]):
"""
@ -112,6 +123,7 @@ class Polynomial(Func1):
"""
Func1.__init__(self, 2, len(coeffs)-1, coeffs)
class Gaussian(Func1):
"""A Gaussian pulse. Instances of class 'Gaussian' evaluate
@ -257,27 +269,36 @@ class SumFunction(Func1):
self._func_id = _cantera.func_newcombo(20, f1.func_id(), f2.func_id())
class ProdFunction(Func1):
"""Product of two functions.
Instances of class ProdFunction evaluate the product of two supplied functors.
It is not necessary to explicitly create an instance of 'ProdFunction', since
the multiplication operator of the base class is overloaded to return a 'ProdFunction'
instance.
"""Product of two functions. Instances of class ProdFunction
evaluate the product of two supplied functors. It is not
necessary to explicitly create an instance of 'ProdFunction',
since the multiplication operator of the base class is overloaded
to return a 'ProdFunction' instance.
>>> f1 = Polynomial([2.0, 1.0])
>>> f2 = Polynomial([3.0, -5.0])
>>> f3 = f1 * f2 # functor to evaluate (2t + 1)*(3t - 5)
In this example, object 'f3' is a functor of class'ProdFunction' that calls f1 and f2
and returns their product.
"""
In this example, object 'f3' is a functor of class'ProdFunction'
that calls f1 and f2 and returns their product. """
def __init__(self, f1, f2):
"""
f1 - first functor.
""" f1 - first functor.
f2 - second functor.
"""
self.f1 = f1
self.f2 = f2
"""
if type(f1) == types.FloatType:
self.f1 = Const(f1)
else:
self.f1 = f1
if type(f2) == types.FloatType:
self.f2 = Const(f2)
else:
self.f2 = f2
self.n = -1
self._func_id = _cantera.func_newcombo(30, f1.func_id(), f2.func_id())
self._func_id = _cantera.func_newcombo(30, self.f1.func_id(), self.f2.func_id())
class RatioFunction(Func1):
"""Ratio of two functions.

View file

@ -27,7 +27,8 @@ namespace Cantera {
/// for this species in the reaction.
/// @param first if this is false, then a " + " string will be
/// added to the beginning of the string.
/// @param nu Stoichiometric coefficient. May be positive or negative.
/// @param nu Stoichiometric coefficient. May be positive or negative. The
/// absolute value will be used in the string.
/// @param sym Species chemical symbol.
///
static string coeffString(bool first, doublereal nu, string sym) {
@ -41,13 +42,16 @@ namespace Cantera {
}
/// Constructor. Construct a multiphase equilibrium manager for
/// a multiphase mixture.
/// @param mix Pointer to a multiphase mixture object.
/// Constructor. Construct a multiphase equilibrium manager for a
/// multiphase mixture.
/// @param mix Pointer to a multiphase mixture object.
/// @param start If true, the initial composition will be
/// determined by a linear Gibbs minimization, otherwise the
/// initial mixture composition will be used.
MultiPhaseEquil::MultiPhaseEquil(mix_t* mix, bool start) : m_mix(mix)
{
// the multi-phase mixture
m_mix = mix;
// m_mix = mix;
// store some mixture parameters locally
m_nel_mix = mix->nElements();
@ -64,9 +68,17 @@ namespace Cantera {
m_incl_element.resize(m_nel_mix,1);
for (m = 0; m < m_nel_mix; m++) {
string enm = mix->elementName(m);
// element 'E' or 'e' represents an electron; this
// requires special handling, so save its index
// for later use
if (enm == "E" || enm == "e") {
m_eloc = m;
}
// if an element other than electrons is not present in
// the mixture, then exclude it and all species containing
// it from the calculation. Electrons are a special case,
// since a species can have a negative number of 'atoms'
// of electrons (positive ions).
if (m_mix->elementMoles(m) <= 0.0) {
if (m != m_eloc) {
m_incl_element[m] = 0;
@ -79,11 +91,13 @@ namespace Cantera {
}
}
// Now build the list of elements to be included, starting with
// electrons, if they are present.
if (m_eloc < m_nel_mix) {
m_element.push_back(m_eloc);
m_nel++;
}
// add the included elements other than electrons
for (m = 0; m < m_nel_mix; m++) {
if (m_incl_element[m] == 1 && m != m_eloc) {
m_nel++;
@ -91,6 +105,17 @@ namespace Cantera {
}
}
// include pure single-constituent phases only if their thermo
// data are valid for this temperature. This is necessary,
// since some thermo polynomial fits are done only for a
// limited temperature range. For example, using the NASA
// polynomial fits for solid ice and liquid water, if this
// were not done the calculation would predict solid ice to be
// present far above its melting point, since the thermo
// polynomial fits only extend to 273.15 K, and give
// unphysical results above this temperature, leading
// (incorrectly) to Gibbs free energies at high temperature
// lower than for liquid water.
index_t ip;
for (k = 0; k < m_nsp_mix; k++) {
ip = m_mix->speciesPhaseIndex(k);
@ -106,6 +131,9 @@ namespace Cantera {
}
}
}
// Now build the list of all species to be included in the
// calculation.
for (k = 0; k < m_nsp_mix; k++) {
if (m_incl_species[k] ==1) {
m_nsp++;
@ -124,6 +152,7 @@ namespace Cantera {
m_lastmoles.resize(m_nsp);
m_dxi.resize(m_nsp - m_nel);
// initialize the mole numbers to the mixture composition
index_t ik;
for (ik = 0; ik < m_nsp; ik++) {
m_moles[ik] = m_mix->speciesMoles(m_species[ik]);
@ -131,6 +160,7 @@ namespace Cantera {
// Delta G / RT for each reaction
m_deltaG_RT.resize(m_nsp - m_nel, 0.0);
m_majorsp.resize(m_nsp);
m_sortindex.resize(m_nsp,0);
m_lastsort.resize(m_nel);
@ -139,11 +169,17 @@ namespace Cantera {
m_N.resize(m_nsp, m_nsp - m_nel);
m_order.resize(m_nsp, 0);
// if the 'start' flag is set, estimate the initial mole
// numbers by doing a linear Gibbs minimization. In this case,
// only the elemental composition of the initial mixture state
// matters.
if (start) {
setInitialMoles();
}
computeN();
// Take a very small step in composition space, so that no
// species has precisely zero moles.
vector_fp dxi(m_nsp - m_nel, 1.0e-20);
multiply(m_N, dxi.begin(), m_work.begin());
unsort(m_work);
@ -158,6 +194,11 @@ namespace Cantera {
}
m_force = false;
updateMixMoles();
// At this point, the instance has been created, the species
// to be included have been determined, and an initial
// composition has been selected that has all non-zero mole
// numbers for the included species.
}

View file

@ -195,17 +195,17 @@ namespace Cantera {
protected:
/**
* m_kk = Number of species in the phase.
* @internal m_kk is a member of both the State and Constituents classes.
* Therefore, to avoid multiple inheritance problems, we need to
* restate it in here, so that the declarations in the two base classes
* become hidden.
* m_kk = Number of species in the phase. @internal m_kk is a
* member of both the State and Constituents classes.
* Therefore, to avoid multiple inheritance problems, we need
* to restate it in here, so that the declarations in the two
* base classes become hidden.
*/
int m_kk;
/**
* m_ndim is the dimensionality of the phase.
* Volumetric phases have dimensionality 3 and surface phases
* have dimensionality 2.
* m_ndim is the dimensionality of the phase. Volumetric
* phases have dimensionality 3 and surface phases have
* dimensionality 2.
*/
int m_ndim;
/**

View file

@ -159,7 +159,6 @@ namespace Cantera {
}
void State::getConcentrations(doublereal* c) const {
//ct_dscal(m_kk, m_dens, m_ym.begin(), 1);
scale(m_ym.begin(), m_ym.end(), c, m_dens);
}
@ -172,7 +171,6 @@ namespace Cantera {
}
void State::getMoleFractions(doublereal* x) const {
//ct_dscal(m_kk, m_mmw, m_ym.begin(), 1);
scale(m_ym.begin(), m_ym.end(), x, m_mmw);
}

View file

@ -24,18 +24,16 @@
namespace Cantera {
/**
* Manages the independent variables of temperature, mass
* density, and mass/mole species fraction that define the
* thermodynamic state.
* Class State stores just enough
* information about a multicomponent solution to specify its
* intensive thermodynamic state. It stores values for the
* temperature, mass density, and an array of species mass
* fractions. It also stores an array of species molecular
* weights, which are used to convert between mole and mass
* representations of the composition. These are the \e only
* properties of the species that class State knows about. For
* efficiency in mass/mole conversion, the vector of mass
* Manages the independent variables of temperature, mass density,
* and mass/mole species fraction that define the thermodynamic
* state. Class State stores just enough information about a
* multicomponent solution to specify its intensive thermodynamic
* state. It stores values for the temperature, mass density, and
* an array of species mass fractions. It also stores an array of
* species molecular weights, which are used to convert between
* mole and mass representations of the composition. These are the
* \e only properties of the species that class State knows about.
* For efficiency in mass/mole conversion, the vector of mass
* fractions divided by molecular weight \f$ Y_k/M_k \f$ is also
* stored.
*

View file

@ -250,7 +250,7 @@ namespace Cantera {
/**
* Check a reaction to see if it the elements balance.
* Check a reaction to see if the elements balance.
*/
void checkRxnElementBalance(Kinetics& kin,
const ReactionData &rdata, doublereal errorTolerance) {

923
config/configure vendored

File diff suppressed because it is too large Load diff

View file

@ -421,7 +421,7 @@ if test "$ENABLE_RXNPATH" = "y" ; then
KERNEL_OBJ=$KERNEL_OBJ' $(RPATH_OBJ)'
fi
if test "$ENABLE_TPX" = "y" ; then
if test "$WITH_PURE_FLUIDS" = "y" ; then
KERNEL=$KERNEL' 'tpx
NEED_TPX=1
AC_DEFINE(INCL_PURE_FLUIDS)

6
configure vendored
View file

@ -139,7 +139,7 @@ F90=${F90:="default"}
# these compilers will be added automatically, and you do not need to
# specify them here. Otherwise, add any required compiler-specific
# flags here.
F90FLAGS=${F90FLAGS:='-O0 -g'}
F90FLAGS=${F90FLAGS:='-O3'}
#----------------------------------------------------------------------
@ -280,7 +280,7 @@ CXX=${CXX:=g++}
CC=${CC:=gcc}
# C++ compiler flags
CXXFLAGS=${CXXFLAGS:="-O0 -Wall"}
CXXFLAGS=${CXXFLAGS:="-O3 -Wall"}
# the C++ flags required for linking. Uncomment if additional flags
# need to be passed to the linker.
@ -324,7 +324,7 @@ F77=${F77:=g77}
# Fortran 77 compiler flags. Note that the Fortran compiler flags must be set
# to produce object code compatible with the C/C++ compiler you are using.
FFLAGS=${FFLAGS:='-O3 -g'}
FFLAGS=${FFLAGS:='-O3'}
# the additional Fortran flags required for linking, if any. Leave commented
# out if no additional flags are required.

View file

@ -5,7 +5,7 @@
#
#
all:
(cd ../../examples/cxx ; gmake )
(cd ../../examples/cxx ; @MAKE@ )
test:
./runtest