This commit is contained in:
Dave Goodwin 2005-06-25 15:57:50 +00:00
parent d1fc24fa8e
commit dfa29b0f70
7 changed files with 87 additions and 71 deletions

View file

@ -74,9 +74,7 @@ namespace Cantera {
extern "C" {
int DLL_EXPORT mix_new() {
cout << "in mix_new" << endl;
mix_t* m = new MultiPhase;
cout << "did it" << endl;
return Cabinet<mix_t>::cabinet()->add(m);
}

View file

@ -1,9 +1,2 @@
catcomb.csv
catcomb.xml
ct2ctml.log
diamond.xml
gri30.xml
h2o2.xml
ptcombust.xml
transport_log.xml

View file

@ -0,0 +1,47 @@
import os
from os.path import walk
pycmd = os.getenv("PYTHON_CMD")
if not pycmd:
pycmd = "python"
def run_example(dir, file):
print "******************************************"
print " Example "+file+" ("+dir+")"
print "******************************************"
r = os.system("cd "+dir+"; "+pycmd+" "+file)
if r <> 0:
print "error!"
def run_examples(a, dir, files):
for f in files:
base, ext = os.path.splitext(f)
print base, " <> ",ext
if dir <> "." and ext == ".py":
run_example(dir, f)
walk(".",run_examples,None)
## run_example("equilibrium","adiabatic.py")
## run_example("equilibrium","multiphase_plasma.py")
## run_example("equilibrium","plotting.py")
## run_example("equilibrium","simple.py")
## run_example("equilibrium","stoich.py")
## run_example("flames","adiabatic_flame.py")
## run_example("flames","flame1.py")
## run_example("flames","flame2.py")
## run_example("flames","free_h2_air.py")
## run_example("flames","npflame1.py")
## run_example("flames","stflame1.py")
## run_example("gasdynamics","isentropic.py")
## run_example("kinetics","ratecoeffs.py")
## run_example("liquid_vapor","critProperties.py")
## run_example("liquid_vapor","rankine.py")
## run_example("misc","rxnpath1.py")
## run_example("reactors","function1.py")
## run_example("reactors","mix1.py")
## run_example("reactors","mix2.py")
## run_example("reactors","reactor1.py")
## run_example("reactors","reactor2.py")
## run_example("surface_chemistry","catcomb.py")
## run_example("surface_chemistry","diamond.py")
## run_example("transport","dustygas.py")

View file

@ -405,7 +405,7 @@ namespace Cantera {
for (n = 0; n < maxiter; n++) {
MultiPhaseEquil e(this, strt);
start = false;
if (loglevel > 1) {
if (loglevel > 0) {
beginLogGroup("iteration "+int2str(n));
}
try {
@ -413,20 +413,24 @@ namespace Cantera {
hnow = enthalpy();
if (hnow < h0) {
if (m_temp > Tlow) Tlow = m_temp;
if (m_temp > Tlow) {
Tlow = m_temp;
}
}
else {
if (m_temp < Thigh) Thigh = m_temp;
if (m_temp < Thigh) {
Thigh = m_temp;
}
}
herr = fabs((h0 - hnow)/h0);
if (loglevel > 1) {
if (loglevel > 0) {
addLogEntry("T",fp2str(temperature()));
addLogEntry("H",fp2str(hnow));
addLogEntry("H rel error",fp2str(herr));
endLogGroup();
}
dt = (h0 - hnow)/cp();
dtmax = fminn(500.0,0.5*(Thigh - Tlow));
dtmax = 0.5*(Thigh - Tlow);
dta = fabs(dt);
if (dta > dtmax) dt *= dtmax/dta;
if (herr < err || dta < 1.0e-4) {
@ -440,14 +444,6 @@ namespace Cantera {
tnew = m_temp + dt;
setTemperature(tnew);
if (dta < 100.0) strt = false;
// if (Thigh > 0.0 && Tlow > 0.0) {
// slope = (hhigh - hlow)/(Thigh - Tlow);
// setTemperature(0.5*(Tlow + Thigh)); //(h0 - hlow)/slope);
// }
// else if (Tlow > 0.0)
// setTemperature(m_temp + dt);
// else
// setTemperature(m_temp - dt);
}
catch (CanteraError e) {
if (!strt) {
@ -463,12 +459,6 @@ namespace Cantera {
"trying T = "+fp2str(m_temp));
}
// else {
// if (loglevel > 0)
// addLogEntry("no convergence","throwing exception");
// throw e;
//}
}
}
throw CanteraError("MultiPhase::equilibrate",

View file

@ -174,7 +174,7 @@ namespace Cantera {
addLogEntry("error",fp2str(error()));
endLogGroup();
}
printInfo();
if (loglevel > 2) printInfo();
//if (error() == 0.0) {
// write_logfile("equil_err.html");
// Cantera::error("stopping");
@ -185,7 +185,7 @@ namespace Cantera {
if (loglevel > 0) {
addLogEntry("Error","no convergence in "+int2str(maxsteps)
+" iterations");
printInfo();
if (loglevel > 2) printInfo();
endLogGroup();
}
throw CanteraError("MultiPhaseEquil::equilibrate",
@ -573,12 +573,6 @@ namespace Cantera {
k = m_order[ik];
for (j = 0; j < m_nsp - m_nel; j++) {
m_work[ik] += m_N(ik, j) * m_dxi[j];
#ifdef DEBUG_MULTIPHASE_EQUIL
if (m_work[ik] < -999.0) {
cout << ik << " " << m_work[ik] << " " << m_N(ik,j) << " " << m_dxi[j] << endl;
cout << reactionString(j) << endl;
}
#endif
}
}
@ -610,16 +604,6 @@ namespace Cantera {
omegamax = omax;
if (omegamax < 1.0e-5) {
m_force = true;
#ifdef DEBUG_MULTIPHASE_EQUIL
cout << m_mix->speciesName(m_species[k]) << " results in "
<< " omega = " << omegamax << endl;
//cout << m_moles[k] << " " << m_work[k] << endl;
if (ik < m_nel) cout << "(component)" << endl;
index_t nk;
for (nk = 0; nk < m_nel; nk++) {
cout << "component: " << m_mix->speciesName(m_species[m_order[nk]]) << " " << m_moles[m_order[nk]] << endl;
}
#endif
}
}
m_majorsp[k] = true;
@ -635,16 +619,10 @@ namespace Cantera {
omegamax = omax; //*1.000001;
if (omegamax < 1.0e-5) {
m_force = true;
#ifdef DEBUG_MULTIPHASE_EQUIL
cout << m_mix->speciesName(m_species[k]) << " results in "
<< " omega = " << omegamax << endl;
//cout << m_moles[k] << " " << m_work[k] << endl;
if (ik < m_nel) cout << "component" << endl;
#endif
}
}
}
if (loglevel > 0 && m_moles[k] < -SmallNumber) {
if (loglevel > 0 && m_moles[k] < -Tiny) {
addLogEntry("Negative moles for "
+m_mix->speciesName(m_species[k]), fp2str(m_moles[k]));
}
@ -653,6 +631,7 @@ namespace Cantera {
}
// now take a step with this scaled omega
if (loglevel > 0) addLogEntry("Stepping by ", fp2str(omegamax));
step(omegamax, m_work);
// compute the gradient of G at this new position in the
@ -670,6 +649,7 @@ namespace Cantera {
if (grad1 > 0.0) {
omega *= fabs(grad0) / (grad1 + fabs(grad0));
for (k = 0; k < m_nsp; k++) m_moles[k] = m_lastmoles[k];
if (loglevel > 0) addLogEntry("Stepped over minimum. Take smaller step ", fp2str(omega));
step(omega, m_work);
}
if (loglevel > 0) endLogGroup();
@ -827,7 +807,7 @@ namespace Cantera {
// don't require formation reactions for solution species
// present in trace amounts to be equilibrated
if (!isStoichPhase(ik) && fabs(moles(ik)) <= SmallNumber)
if (!isStoichPhase(ik) && fabs(moles(ik)) <= Tiny)
err = 0.0;
// for stoichiometric phase species, no error if not present and

View file

@ -42,7 +42,6 @@ namespace Cantera {
string reactionString(index_t j);
doublereal error();
void printInfo();
void finish();
protected:
@ -55,6 +54,7 @@ namespace Cantera {
void step(doublereal omega, vector_fp& deltaN);
doublereal computeReactionSteps(vector_fp& dxi);
void setMoles();
void finish();
// moles of the species with sorted index ns
double moles(int ns) const { return m_moles[m_order[ns]]; }

View file

@ -16,6 +16,9 @@ cvs_tag = @CVSTAG@
branch = -r $(cvs_tag)
RMDIRTREE = /bin/rm -r -f
PY_EXAMPLES = equilibrium flames reactors misc liquid_vapor \
gasdynamics kinetics surface_chemistry transport
prefix=@prefix@
all: hdr-collect kernel user cxxlib clib fortran python matlab \
@ -143,24 +146,29 @@ python-install:
ifneq ($(build_python),0)
cd Cantera/python; @MAKE@ install
ifeq ($(build_python),2)
@INSTALL@ -d @ct_demodir@/python
@INSTALL@ -d @ct_demodir@/python/equilibrium
@INSTALL@ Cantera/python/examples/equilibrium/*.py \
@ct_demodir@/python/equilibrium
@INSTALL@ Cantera/python/examples/equilibrium/*.cti \
@ct_demodir@/python/equilibrium
@INSTALL@ -d @ct_demodir@/python/flames
@INSTALL@ Cantera/python/examples/flames/*.py \
@ct_demodir@/python/flames
@INSTALL@ Cantera/python/examples/flames/*.cti \
@ct_demodir@/python/flames
@INSTALL@ -d @ct_demodir@/python/kinetics
@INSTALL@ Cantera/python/examples/kinetics/*.py \
@ct_demodir@/python/kinetics
@(for exdir in $(PY_EXAMPLES) ; do \
@INSTALL@ -d @ct_demodir@/python/$${exdir} ; \
@INSTALL@ Cantera/python/examples/$${exdir}/*.py \
@ct_demodir@/python/$${exdir} ; \
done)
# @INSTALL@ -d @ct_demodir@/python
# @INSTALL@ -d @ct_demodir@/python/equilibrium
# @INSTALL@ Cantera/python/examples/equilibrium/*.py \
# @ct_demodir@/python/equilibrium
# @INSTALL@ Cantera/python/examples/equilibrium/*.cti \
# @ct_demodir@/python/equilibrium
# @INSTALL@ -d @ct_demodir@/python/flames
# @INSTALL@ Cantera/python/examples/flames/*.py \
# @ct_demodir@/python/flames
# @INSTALL@ Cantera/python/examples/flames/*.cti \
# @ct_demodir@/python/flames
# @INSTALL@ -d @ct_demodir@/python/kinetics
# @INSTALL@ Cantera/python/examples/kinetics/*.py \
# @ct_demodir@/python/kinetics
# @INSTALL@ Cantera/python/examples/*.py @ct_demodir@/python
@INSTALL@ -d @ct_tutdir@/python
@INSTALL@ Cantera/python/tutorial/*.py \
@ct_tutdir@/python
@ct_tutdir@/python
chown -R @username@ @ct_demodir@/python
chown -R @username@ @ct_tutdir@/python
else