*** empty log message ***
This commit is contained in:
parent
918ee4a588
commit
c471052ef8
5 changed files with 121 additions and 46 deletions
|
|
@ -19,16 +19,18 @@ SPECIES_SET = 20
|
|||
COLLECTION = 30
|
||||
THERMO = 40
|
||||
|
||||
ALL = 10
|
||||
SKIP_UNDECLARED_ELEMENTS = 20
|
||||
SKIP_UNDECLARED_SPECIES = 30
|
||||
STOP = 0
|
||||
#ALL = 10
|
||||
#SKIP_UNDECLARED_ELEMENTS = 20
|
||||
#SKIP_UNDECLARED_SPECIES = 30
|
||||
#STOP = 0
|
||||
|
||||
_EXCEPT = 10
|
||||
_WARN = 2
|
||||
_SKIP = 1
|
||||
_handle_undeclared_element = _EXCEPT
|
||||
_handle_undeclared_species = _EXCEPT
|
||||
#_EXCEPT = 10
|
||||
#_WARN = 2
|
||||
#_SKIP = 1
|
||||
_handle_error = {}
|
||||
#_handle_undeclared_element = _EXCEPT
|
||||
#_handle_undeclared_species = _EXCEPT
|
||||
#_handle_neg_A = _EXCEPT
|
||||
|
||||
# default units
|
||||
_ulen = 'm'
|
||||
|
|
@ -71,13 +73,17 @@ def standard_pressure(p0):
|
|||
global _pref
|
||||
_pref = p0
|
||||
|
||||
def on_error(undeclared_element = '', undeclared_species = ''):
|
||||
global _handle_undeclared_species
|
||||
global _handle_undeclared_element
|
||||
def on_error(undeclared_element = '',
|
||||
undeclared_species = '',
|
||||
negative_A = ''):
|
||||
global _handle_error
|
||||
|
||||
_handle_undeclared_species = undeclared_species
|
||||
_handle_undeclared_element = undeclared_element
|
||||
|
||||
if undeclared_element:
|
||||
_handle_error['undeclared_element'] = undeclared_element
|
||||
if undeclared_species:
|
||||
_handle_error['undeclared_species'] = undeclared_species
|
||||
if negative_A:
|
||||
_handle_error['negative_A'] = negative_A
|
||||
|
||||
|
||||
def get_atomic_wts():
|
||||
|
|
@ -324,8 +330,9 @@ class NASA(thermo):
|
|||
class const_cp(thermo):
|
||||
"""Constant specific heat."""
|
||||
|
||||
def __init__(self, tmax = -1.0, tmin = -1.0,
|
||||
t0 = 298.15, cp0 = 0.0, h0 = 0.0, s0 = 0.0):
|
||||
def __init__(self,
|
||||
t0 = 298.15, cp0 = 0.0, h0 = 0.0, s0 = 0.0,
|
||||
tmax = -1.0, tmin = -1.0):
|
||||
self._t = [tmin, tmax]
|
||||
self._c = [t0, h0, s0, cp0]
|
||||
|
||||
|
|
@ -373,6 +380,16 @@ class Arrhenius(writer):
|
|||
self._c = [A, n, E]
|
||||
|
||||
def build(self, p, units = '', gas_species = [], name = ''):
|
||||
if self._c[0] < 0.0:
|
||||
e = _handle_error['negative_A']
|
||||
if e == 'skip': return
|
||||
elif e == 'warn':
|
||||
print 'Warning: negative pre-exponential: A = ',self._c[0]
|
||||
elif e == 'continue':
|
||||
pass
|
||||
else:
|
||||
raise CanteraError('negative pre-exponential: A = '+`self._c[0]`)
|
||||
|
||||
a = p.addChild('Arrhenius')
|
||||
if name: a['name'] = name
|
||||
if isnum(self._c[0]):
|
||||
|
|
@ -809,7 +826,7 @@ class phase(writer):
|
|||
datasrc = r[0]
|
||||
ra = p.addChild('reactionArray')
|
||||
ra['datasrc'] = datasrc+'#reaction_data'
|
||||
if _handle_undeclared_species == 'skip':
|
||||
if _handle_error['undeclared_species'] == 'skip':
|
||||
rk = ra.addChild('skip')
|
||||
rk['species'] = 'undeclared'
|
||||
|
||||
|
|
@ -836,7 +853,7 @@ class phase(writer):
|
|||
sa = ph.addChild('speciesArray',names)
|
||||
sa['datasrc'] = datasrc+'#species_data'
|
||||
|
||||
if _handle_undeclared_element == 'skip':
|
||||
if _handle_error['undeclared_element'] == 'skip':
|
||||
sk = sa.addChild('skip')
|
||||
sk['element'] = 'undeclared'
|
||||
|
||||
|
|
|
|||
|
|
@ -21,15 +21,50 @@
|
|||
|
||||
namespace Cantera {
|
||||
|
||||
ImplicitSurfChem::ImplicitSurfChem(InterfaceKinetics& kin)
|
||||
: FuncEval(), m_kin(&kin), m_integ(0),
|
||||
// ImplicitSurfChem::ImplicitSurfChem(InterfaceKinetics& kin)
|
||||
// : FuncEval(), m_kin(&kin), m_integ(0),
|
||||
// m_atol(1.e-14), m_rtol(1.e-7), m_maxstep(0.0)
|
||||
// {
|
||||
// m_integ = new CVodeInt;
|
||||
// m_surfindex = kin.surfacePhaseIndex();
|
||||
// if (m_surfindex < 0)
|
||||
// throw CanteraError("ImplicitSurfChem","kinetics manager contains no surface phase");
|
||||
// m_surf = (SurfPhase*)&kin.thermo(m_surfindex);;
|
||||
|
||||
// // use backward differencing, with a full Jacobian computed
|
||||
// // numerically, and use a Newton linear iterator
|
||||
|
||||
// m_integ->setMethod(BDF_Method);
|
||||
// m_integ->setProblemType(DENSE + NOJAC);
|
||||
// m_integ->setIterator(Newton_Iter);
|
||||
// m_nsp = m_surf->nSpecies();
|
||||
// m_work.resize(m_kin->nTotalSpecies());
|
||||
// }
|
||||
|
||||
|
||||
ImplicitSurfChem::ImplicitSurfChem(vector<InterfaceKinetics*> k)
|
||||
: FuncEval(), m_nv(0), m_integ(0),
|
||||
m_atol(1.e-14), m_rtol(1.e-7), m_maxstep(0.0)
|
||||
{
|
||||
m_nsurf = k.size();
|
||||
int ns;
|
||||
int nt, ntmax = 0;
|
||||
for (int n = 0; n < m_nsurf; n++) {
|
||||
m_kin.push_back(k[n]);
|
||||
ns = k[n]->surfacePhaseIndex();
|
||||
if (ns < 0)
|
||||
throw CanteraError("ImplicitSurfChem",
|
||||
"kinetics manager contains no surface phase");
|
||||
m_surfindex.push_back(ns);
|
||||
m_surf.push_back((SurfPhase*)&k[n]->thermo(ns));
|
||||
m_nsp.push_back(m_surf.back()->nSpecies());
|
||||
m_nv += m_nsp.back();
|
||||
nt = k[n]->nTotalSpecies();
|
||||
if (nt > ntmax) ntmax = nt;
|
||||
}
|
||||
m_integ = new CVodeInt;
|
||||
m_surfindex = kin.surfacePhaseIndex();
|
||||
if (m_surfindex < 0)
|
||||
throw CanteraError("ImplicitSurfChem","kinetics manager contains no surface phase");
|
||||
m_surf = (SurfPhase*)&kin.thermo(m_surfindex);;
|
||||
//m_surfindex = kin.surfacePhaseIndex();
|
||||
//m_surf = (SurfPhase*)&kin.thermo(m_surfindex);;
|
||||
|
||||
// use backward differencing, with a full Jacobian computed
|
||||
// numerically, and use a Newton linear iterator
|
||||
|
|
@ -37,8 +72,8 @@ namespace Cantera {
|
|||
m_integ->setMethod(BDF_Method);
|
||||
m_integ->setProblemType(DENSE + NOJAC);
|
||||
m_integ->setIterator(Newton_Iter);
|
||||
m_nsp = m_surf->nSpecies();
|
||||
m_work.resize(m_kin->nTotalSpecies());
|
||||
//m_nsp = m_surf->nSpecies();
|
||||
m_work.resize(ntmax);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -47,7 +82,11 @@ namespace Cantera {
|
|||
void ImplicitSurfChem::getInitialConditions(double t0, size_t lenc,
|
||||
double* c)
|
||||
{
|
||||
m_surf->getCoverages(c);
|
||||
int loc = 0;
|
||||
for (int n = 0; n < m_nsurf; n++) {
|
||||
m_surf[n]->getCoverages(c + loc);
|
||||
loc += m_nsp[n];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -61,7 +100,11 @@ namespace Cantera {
|
|||
|
||||
|
||||
void ImplicitSurfChem::updateState(doublereal* c) {
|
||||
m_surf->setCoverages(c);
|
||||
int loc = 0;
|
||||
for (int n = 0; n < m_nsurf; n++) {
|
||||
m_surf[n]->setCoverages(c + loc);
|
||||
loc += m_nsp[n];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -71,18 +114,22 @@ namespace Cantera {
|
|||
void ImplicitSurfChem::eval(doublereal time, doublereal* y,
|
||||
doublereal* ydot)
|
||||
{
|
||||
updateState(y); // synchronize the surface state with y
|
||||
doublereal rs0 = 1.0/m_surf->siteDensity();
|
||||
m_kin->getNetProductionRates(m_work.begin());
|
||||
int k;
|
||||
int kstart = m_kin->start(m_surfindex);
|
||||
doublereal sum = 0.0;
|
||||
for (k = 1; k < m_nsp; k++) {
|
||||
ydot[k] = m_work[kstart + k] * rs0 * m_surf->size(k);
|
||||
sum -= ydot[k];
|
||||
updateState(y); // synchronize the surface state(s) with y
|
||||
doublereal rs0, sum;
|
||||
int loc, k, kstart;
|
||||
for (int n = 0; n < m_nsurf; n++) {
|
||||
rs0 = 1.0/m_surf[n]->siteDensity();
|
||||
m_kin[n]->getNetProductionRates(m_work.begin());
|
||||
kstart = m_kin[n]->start(m_surfindex[n]);
|
||||
sum = 0.0;
|
||||
loc = 0;
|
||||
for (k = 1; k < m_nsp[n]; k++) {
|
||||
ydot[k + loc] = m_work[kstart + k] * rs0 * m_surf[n]->size(k);
|
||||
sum -= ydot[k];
|
||||
}
|
||||
ydot[loc] = sum;
|
||||
loc += m_nsp[n];
|
||||
}
|
||||
//if (sum < 0.0) sum = 0.0;
|
||||
ydot[0] = sum;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,8 +38,12 @@ namespace Cantera {
|
|||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
ImplicitSurfChem(InterfaceKinetics& kin);
|
||||
//ImplicitSurfChem(InterfaceKinetics& kin);
|
||||
|
||||
/**
|
||||
* Constructor for multiple surfaces.
|
||||
*/
|
||||
ImplicitSurfChem(vector<InterfaceKinetics*> k);
|
||||
|
||||
/**
|
||||
* Destructor. Deletes the integrator.
|
||||
|
|
@ -77,7 +81,7 @@ namespace Cantera {
|
|||
}
|
||||
|
||||
// overloaded methods of class FuncEval
|
||||
virtual int neq() { return m_nsp; }
|
||||
virtual int neq() { return m_nv; }
|
||||
virtual void eval(doublereal t, doublereal* y, doublereal* ydot);
|
||||
virtual void getInitialConditions(doublereal t0,
|
||||
size_t leny, doublereal* y);
|
||||
|
|
@ -91,9 +95,13 @@ namespace Cantera {
|
|||
*/
|
||||
void updateState(doublereal* y);
|
||||
|
||||
SurfPhase* m_surf;
|
||||
InterfaceKinetics* m_kin;
|
||||
int m_nsp, m_surfindex;
|
||||
vector<SurfPhase*> m_surf;
|
||||
vector<InterfaceKinetics*> m_kin;
|
||||
vector_int m_nsp;
|
||||
vector_int m_surfindex;
|
||||
int m_nsurf;
|
||||
int m_nv;
|
||||
//int m_nsp, m_surfindex;
|
||||
Integrator* m_integ; // pointer to integrator
|
||||
doublereal m_atol, m_rtol; // tolerances
|
||||
doublereal m_maxstep; // max step size
|
||||
|
|
|
|||
|
|
@ -608,7 +608,9 @@ namespace Cantera {
|
|||
void InterfaceKinetics::
|
||||
advanceCoverages(doublereal tstep) {
|
||||
if (m_integrator == 0) {
|
||||
m_integrator = new ImplicitSurfChem(*this);
|
||||
vector<InterfaceKinetics*> k;
|
||||
k.push_back(this);
|
||||
m_integrator = new ImplicitSurfChem(k);
|
||||
m_integrator->initialize();
|
||||
}
|
||||
m_integrator->integrate(0.0, tstep);
|
||||
|
|
|
|||
|
|
@ -166,6 +166,7 @@ namespace Cantera {
|
|||
|
||||
void advanceCoverages(doublereal tstep);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
int m_kk;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue