*** empty log message ***
This commit is contained in:
parent
778347d6dc
commit
dafd2ad411
11 changed files with 124 additions and 34 deletions
|
|
@ -746,6 +746,18 @@ extern "C" {
|
|||
return kin(n)->nReactions();
|
||||
}
|
||||
|
||||
int DLL_EXPORT kin_nPhases(int n) {
|
||||
return kin(n)->nPhases();
|
||||
}
|
||||
|
||||
int DLL_EXPORT kin_phaseIndex(int n, char* ph) {
|
||||
return kin(n)->phaseIndex(string(ph));
|
||||
}
|
||||
|
||||
int DLL_EXPORT kin_reactionPhaseIndex(int n) {
|
||||
return kin(n)->reactionPhaseIndex();
|
||||
}
|
||||
|
||||
double DLL_EXPORT kin_reactantStoichCoeff(int n, int k, int i) {
|
||||
return kin(n)->reactantStoichCoeff(k,i);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,6 +100,9 @@ extern "C" {
|
|||
char* default_phase);
|
||||
int DLL_IMPORT kin_nSpecies(int n);
|
||||
int DLL_IMPORT kin_nReactions(int n);
|
||||
int DLL_IMPORT kin_nPhases(int n);
|
||||
int DLL_IMPORT kin_phaseIndex(int n, char* ph);
|
||||
int DLL_IMPORT kin_reactionPhaseIndex(int n);
|
||||
double DLL_IMPORT kin_reactantStoichCoeff(int n, int i, int k);
|
||||
double DLL_IMPORT kin_productStoichCoeff(int n, int i, int k);
|
||||
int DLL_IMPORT kin_reactionType(int n, int i);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#define CXX_DEMO
|
||||
#include "rankine.cpp"
|
||||
#include "flamespeed.cpp"
|
||||
#include "hydrogen_flamespeed.cpp"
|
||||
#include "kinetics1.cpp"
|
||||
|
||||
#include <time.h>
|
||||
|
|
@ -13,16 +14,17 @@
|
|||
typedef int (*exfun)(int, void*);
|
||||
|
||||
// array of demo functions
|
||||
exfun fex[] = {kinetics1, openRankine, flamespeed};
|
||||
exfun fex[] = {kinetics1, openRankine, flamespeed, h2_flamespeed};
|
||||
|
||||
string demostr[] = {"zero-D kinetics ",
|
||||
"open Rankine cycle ",
|
||||
"flamespeed "};
|
||||
"CH4 flamespeed ",
|
||||
"H2 flamespeed "};
|
||||
|
||||
int np[] = {0, 0, 1};
|
||||
double p[] = {0, 0, 0.9};
|
||||
int np[] = {0, 0, 1, 1};
|
||||
double p[] = {0, 0, 0.9, 0.9};
|
||||
|
||||
#define NDEMOS 3
|
||||
#define NDEMOS 4
|
||||
|
||||
int mainmenu() {
|
||||
int i, idemo;
|
||||
|
|
|
|||
|
|
@ -98,8 +98,10 @@ int flamespeed(int np, void* p) {
|
|||
// specify the objects to use to compute kinetic rates and
|
||||
// transport properties
|
||||
|
||||
Transport* tr = newTransportMgr("Mix", &gas);
|
||||
flow.setTransport(*tr);
|
||||
Transport* trmix = newTransportMgr("Mix", &gas);
|
||||
Transport* trmulti = newTransportMgr("Multi", &gas);
|
||||
|
||||
flow.setTransport(*trmix);
|
||||
flow.setKinetics(gas);
|
||||
flow.setPressure(pressure);
|
||||
|
||||
|
|
@ -192,7 +194,22 @@ int flamespeed(int np, void* p) {
|
|||
refine_grid = true;
|
||||
flow.solveEnergyEqn();
|
||||
flame.solve(loglevel,refine_grid);
|
||||
cout << "Flame speed with mixture-averaged transport: " <<
|
||||
flame.value(flowdomain,flow.componentIndex("u"),0) << " m/s" << endl;
|
||||
|
||||
// now switch to multicomponent transport
|
||||
flow.setTransport(*trmulti);
|
||||
flame.solve(loglevel, refine_grid);
|
||||
cout << "Flame speed with multicomponent transport: " <<
|
||||
flame.value(flowdomain,flow.componentIndex("u"),0) << " m/s" << endl;
|
||||
|
||||
// now enable Soret diffusion
|
||||
flow.enableSoret(true);
|
||||
flame.solve(loglevel, refine_grid);
|
||||
cout << "Flame speed with multicomponent transport + Soret: " <<
|
||||
flame.value(flowdomain,flow.componentIndex("u"),0) << " m/s" << endl;
|
||||
|
||||
//
|
||||
int np=flow.nPoints();
|
||||
vector<doublereal> zvec,Tvec,COvec,CO2vec,Uvec;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class Kinetics:
|
|||
the specification of the parameters.
|
||||
"""
|
||||
np = len(phases)
|
||||
self._np = np
|
||||
#self._np = np
|
||||
self._sp = []
|
||||
self._phnum = {}
|
||||
|
||||
|
|
@ -54,9 +54,10 @@ class Kinetics:
|
|||
|
||||
self.ckin = _cantera.KineticsFromXML(xml_phase,
|
||||
p0, p1, p2, p3, p4)
|
||||
|
||||
|
||||
self._np = self.nPhases()
|
||||
for nn in range(self._np):
|
||||
p = phases[nn] # self.phase(nn)
|
||||
p = self.phase(nn)
|
||||
self._phnum[p.thermophase()] = nn
|
||||
self._end.append(self._end[-1]+p.nSpecies())
|
||||
for k in range(p.nSpecies()):
|
||||
|
|
@ -101,6 +102,14 @@ class Kinetics:
|
|||
"""The starting location of phase n in production rate arrays."""
|
||||
return _cantera.kin_start(self.ckin, n)
|
||||
|
||||
def nPhases(self):
|
||||
"""Number of phases."""
|
||||
return _cantera.kin_nPhases(self.ckin)
|
||||
|
||||
def reactionPhaseIndex(self):
|
||||
"""The phase in which the reactions take place."""
|
||||
return _cantera.kin_reactionPhaseIndex(self)
|
||||
|
||||
def phase(self, n):
|
||||
"""Return an object representing the nth phase."""
|
||||
return ThermoPhase(index = _cantera.kin_phase(self.ckin, n))
|
||||
|
|
|
|||
|
|
@ -57,6 +57,28 @@ kin_nrxns(PyObject *self, PyObject *args) {
|
|||
return Py_BuildValue("i",kin_nReactions(kin));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_nPhases(PyObject *self, PyObject *args) {
|
||||
int kin;
|
||||
if (!PyArg_ParseTuple(args, "i:kin_nPhases", &kin)) return NULL;
|
||||
return Py_BuildValue("i",kin_nPhases(kin));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_phaseIndex(PyObject *self, PyObject *args) {
|
||||
int kin;
|
||||
char* ph;
|
||||
if (!PyArg_ParseTuple(args, "is:kin_phaseIndex", &kin, &ph)) return NULL;
|
||||
return Py_BuildValue("i",kin_phaseIndex(kin, ph));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_reactionPhaseIndex(PyObject *self, PyObject *args) {
|
||||
int kin;
|
||||
if (!PyArg_ParseTuple(args, "i:kin_reactionPhaseIndex", &kin)) return NULL;
|
||||
return Py_BuildValue("i",kin_reactionPhaseIndex(kin));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_isrev(PyObject *self, PyObject *args) {
|
||||
int kin, i;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,9 @@ static PyMethodDef ct_methods[] = {
|
|||
{"kin_delete", kin_delete, METH_VARARGS},
|
||||
{"kin_nspecies", kin_nspecies, METH_VARARGS},
|
||||
{"kin_nreactions", kin_nrxns, METH_VARARGS},
|
||||
{"kin_nPhases", kin_nPhases, METH_VARARGS},
|
||||
{"kin_phaseIndex", kin_phaseIndex, METH_VARARGS},
|
||||
{"kin_reactionPhaseIndex", kin_reactionPhaseIndex, METH_VARARGS},
|
||||
{"kin_isreversible", kin_isrev, METH_VARARGS},
|
||||
{"kin_rstoichcoeff", kin_rstoichcoeff, METH_VARARGS},
|
||||
{"kin_pstoichcoeff", kin_pstoichcoeff, METH_VARARGS},
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ namespace Cantera {
|
|||
nsp = thermo(n).nSpecies();
|
||||
for (k = 0; k < nsp; k++) {
|
||||
delta = Faraday * m_phi[n] * thermo(n).charge(k);
|
||||
cout << thermo(n).speciesName(k) << " " << (delta+dmu[ik])/rt << " " << dmu[ik]/rt << endl;
|
||||
//cout << thermo(n).speciesName(k) << " " << (delta+dmu[ik])/rt << " " << dmu[ik]/rt << endl;
|
||||
dmu[ik] += delta;
|
||||
ik++;
|
||||
}
|
||||
|
|
@ -336,8 +336,15 @@ namespace Cantera {
|
|||
ea = GasConstant * m_E[i];
|
||||
if (eamod + ea < 0.0) {
|
||||
writelog("Warning: act energy mod too large!\n");
|
||||
eamod = -ea;
|
||||
writelog(" Delta phi = "+fp2str(m_rwork[irxn]/Faraday)+"\n");
|
||||
writelog(" Delta Ea = "+fp2str(eamod)+"\n");
|
||||
writelog(" Ea = "+fp2str(ea)+"\n");
|
||||
for (n = 0; n < np; n++) {
|
||||
writelog("Phase "+int2str(n)+": phi = "
|
||||
+fp2str(m_phi[n])+"\n");
|
||||
}
|
||||
}
|
||||
//eamod = -ea;
|
||||
kf[irxn] *= exp(-eamod*rrt);
|
||||
}
|
||||
}
|
||||
|
|
@ -463,6 +470,10 @@ namespace Cantera {
|
|||
for (n = 0; n < np; n++) {
|
||||
thermo(n).getChemPotentials(DATA_PTR(m_grt) + m_start[n]);
|
||||
}
|
||||
//for (n = 0; n < m_grt.size(); n++) {
|
||||
// cout << n << "G_RT = " << m_grt[n] << endl;
|
||||
//}
|
||||
|
||||
/*
|
||||
* Use the stoichiometric manager to find deltaG for each
|
||||
* reaction.
|
||||
|
|
|
|||
|
|
@ -263,28 +263,28 @@ public:
|
|||
}
|
||||
|
||||
/*
|
||||
* Check to see if reactant reaction orders have been specified.
|
||||
* Check to see if reaction orders have been specified.
|
||||
*/
|
||||
if (rp == 1 && rxn.hasChild("order")) {
|
||||
vector<XML_Node*> ord;
|
||||
rxn.getChildren("order",ord);
|
||||
int norder = static_cast<int>(ord.size());
|
||||
int loc;
|
||||
doublereal forder;
|
||||
for (int nn = 0; nn < norder; nn++) {
|
||||
const XML_Node& oo = *ord[nn];
|
||||
string sp = oo["species"];
|
||||
loc = speciesMap[sp];
|
||||
if (loc == 0)
|
||||
throw CanteraError("getReagents",
|
||||
"reaction order specified for non-reactant: "
|
||||
+sp);
|
||||
forder = fpValue(oo());
|
||||
if (forder < 0.0) {
|
||||
throw CanteraError("getReagents",
|
||||
"reaction order must be non-negative");
|
||||
}
|
||||
// replace the forward stoichiometric coefficient
|
||||
vector<XML_Node*> ord;
|
||||
rxn.getChildren("order",ord);
|
||||
int norder = static_cast<int>(ord.size());
|
||||
int loc;
|
||||
doublereal forder;
|
||||
for (int nn = 0; nn < norder; nn++) {
|
||||
const XML_Node& oo = *ord[nn];
|
||||
string sp = oo["species"];
|
||||
loc = speciesMap[sp];
|
||||
if (loc == 0)
|
||||
throw CanteraError("getReagents",
|
||||
"reaction order specified for non-reactantt: "
|
||||
+sp);
|
||||
forder = fpValue(oo());
|
||||
if (forder < 0.0) {
|
||||
throw CanteraError("getReagents",
|
||||
"reaction order must be non-negative");
|
||||
}
|
||||
// replace the stoichiometric coefficient
|
||||
// stored above in 'order' with the specified
|
||||
// reaction order
|
||||
order[loc-1] = forder;
|
||||
|
|
@ -655,7 +655,7 @@ public:
|
|||
* Get the products. We store the id of products in rdata.products
|
||||
*/
|
||||
ok = ok && getReagents(r, kin, -1, default_phase, rdata.products,
|
||||
rdata.pstoich, dummy, rule);
|
||||
rdata.pstoich, rdata.pstoich, rule);
|
||||
|
||||
// if there was a problem getting either the reactants or the products,
|
||||
// then abort.
|
||||
|
|
|
|||
|
|
@ -488,7 +488,10 @@ namespace Cantera {
|
|||
class FreeFlame : public StFlow {
|
||||
public:
|
||||
FreeFlame(igthermo_t* ph = 0, int nsp = 1, int points = 1) :
|
||||
StFlow(ph, nsp, points) { m_dovisc = false; }
|
||||
StFlow(ph, nsp, points) {
|
||||
m_dovisc = false;
|
||||
setID("flame");
|
||||
}
|
||||
virtual ~FreeFlame() {}
|
||||
virtual void eval(int j, doublereal* x, doublereal* r,
|
||||
integer* mask, doublereal rdt);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,14 @@ ideal_gas(name = "ohmech",
|
|||
initial_state = state(temperature = 300.0,
|
||||
pressure = OneAtm) )
|
||||
|
||||
ideal_gas(name = "ohmech-multi",
|
||||
elements = " O H Ar ",
|
||||
species = """ H2 H O O2 OH H2O HO2 H2O2 AR """,
|
||||
reactions = "all",
|
||||
transport = "Multi",
|
||||
initial_state = state(temperature = 300.0,
|
||||
pressure = OneAtm) )
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue