*** empty log message ***
This commit is contained in:
parent
9b779faab9
commit
f238409026
19 changed files with 66 additions and 121 deletions
|
|
@ -447,6 +447,14 @@ extern "C" {
|
|||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_getInitialSoln(int i) {
|
||||
try {
|
||||
_sim1D(i)->getInitialSoln();
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_solve(int i, int loglevel, int refine_grid) {
|
||||
try {
|
||||
bool r = (refine_grid == 0 ? false : true);
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ extern "C" {
|
|||
int DLL_IMPORT sim1D_setFlatProfile(int i, int dom, int comp, double v);
|
||||
int DLL_IMPORT sim1D_showSolution(int i, char* fname);
|
||||
int DLL_IMPORT sim1D_setTimeStep(int i, double stepsize, int ns, int* nsteps);
|
||||
int DLL_IMPORT sim1D_getInitialSoln(int i);
|
||||
int DLL_IMPORT sim1D_solve(int i, int loglevel, int refine_grid);
|
||||
int DLL_IMPORT sim1D_refine(int i, int loglevel);
|
||||
int DLL_IMPORT sim1D_setRefineCriteria(int i, int dom, double ratio,
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ set(inlt,'X',comp2);
|
|||
setRefineCriteria(sim1D, 2, 100.0, 0.15, 0.2);
|
||||
|
||||
% solve the problem for the final time
|
||||
solve(sim1D, 1, refine_grid);
|
||||
solve(sim1D, loglevel, refine_grid); %refine_grid);
|
||||
|
||||
% show the solution
|
||||
sim1D
|
||||
|
|
|
|||
|
|
@ -21,16 +21,16 @@ comp = 'H2:1.8, O2:1, AR:7'; % premixed gas composition
|
|||
initial_grid = [0.0 0.02 0.04 0.06 0.08 0.1 ...
|
||||
0.15 0.2 0.4 0.49 0.5]; % m
|
||||
|
||||
tol_ss = [1.0e-5 1.0e-9]; % [rtol atol] for steady-state
|
||||
tol_ss = [1.0e-5 1.0e-13]; % [rtol atol] for steady-state
|
||||
% problem
|
||||
tol_ts = [1.0e-3 1.0e-4]; % [rtol atol] for time stepping
|
||||
tol_ts = [1.0e-4 1.0e-9]; % [rtol atol] for time stepping
|
||||
|
||||
loglevel = 1; % amount of diagnostic output (0
|
||||
% to 5)
|
||||
|
||||
refine_grid = 1; % 1 to enable refinement, 0 to
|
||||
% disable
|
||||
|
||||
max_jacobian_age = [5, 10];
|
||||
|
||||
%%%%%%%%%%%%%%%% create the gas object %%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
|
|
@ -78,12 +78,13 @@ s = Outlet('out');
|
|||
% to create the flame object.
|
||||
%
|
||||
fl = flame(gas, burner, f, s);
|
||||
setMaxJacAge(fl, max_jacobian_age(1), max_jacobian_age(2));
|
||||
|
||||
% if the starting solution is to be read from a previously-saved
|
||||
% solution, uncomment this line and edit the file name and solution id.
|
||||
%restore(fl,'h2flame2.xml', 'energy')
|
||||
|
||||
solve(fl, 1, refine_grid);
|
||||
solve(fl, loglevel, refine_grid);
|
||||
|
||||
%%%%%%%%%%%% enable the energy equation %%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class BurnerFlame(Stack):
|
|||
|
||||
def init(self):
|
||||
"""Set the initial guess for the solution."""
|
||||
self.getInitialSoln()
|
||||
gas = self.gas
|
||||
nsp = gas.nSpecies()
|
||||
yin = Numeric.zeros(nsp, 'd')
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class CounterFlame(Stack):
|
|||
|
||||
The initial guess is generated by assuming infinitely-fast
|
||||
chemistry."""
|
||||
|
||||
self.getInitialSoln()
|
||||
gas = self.gas
|
||||
nsp = gas.nSpecies()
|
||||
wt = gas.molecularWeights()
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ class StagnationFlow(Stack):
|
|||
self.setRefineCriteria()
|
||||
self._initialized = 0
|
||||
|
||||
|
||||
def init(self):
|
||||
def init(self, products = 'inlet'):
|
||||
"""Set the initial guess for the solution."""
|
||||
self.getInitialSoln()
|
||||
gas = self.gas
|
||||
|
|
@ -36,13 +35,24 @@ class StagnationFlow(Stack):
|
|||
zz = self.flow.grid()
|
||||
dz = zz[-1] - zz[0]
|
||||
|
||||
|
||||
locs = Numeric.array([0.0, 1.0],'d')
|
||||
if products == 'equil':
|
||||
gas.equilibrate('HP')
|
||||
teq = gas.temperature()
|
||||
yeq = gas.massFractions()
|
||||
locs = Numeric.array([0.0, 0.3, 0.7, 1.0],'d')
|
||||
self.setProfile('T', locs, [t0, teq, teq, tsurf])
|
||||
for n in range(nsp):
|
||||
self.setProfile(gas.speciesName(n), locs, [yin[n], yeq[n], yeq[n], yeq[n]])
|
||||
else:
|
||||
locs = Numeric.array([0.0, 1.0],'d')
|
||||
self.setProfile('T', locs, [t0, tsurf])
|
||||
for n in range(nsp):
|
||||
self.setProfile(gas.speciesName(n), locs, [yin[n], yin[n]])
|
||||
|
||||
locs = Numeric.array([0.0, 1.0],'d')
|
||||
self.setProfile('u', locs, [u0, 0.0])
|
||||
self.setProfile('V', locs, [V0, V0])
|
||||
self.setProfile('T', locs, [t0, tsurf])
|
||||
for n in range(nsp):
|
||||
self.setProfile(gas.speciesName(n), locs, [yin[n], yin[n]])
|
||||
|
||||
self._initialized = 1
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ fmt = 'svg'
|
|||
print 'writing dot file',output_file+'...'
|
||||
#rxnpath.write(gas, element, join(output_dir, output_file), d)
|
||||
rxnpath.write(gas, element, output_file, d)
|
||||
os.system('scp '+output_file+' blue:/var/www/html')
|
||||
print 'generating browser view...'
|
||||
rxnpath.view(url, fmt)
|
||||
#os.system('scp '+output_file+' blue:/var/www/html')
|
||||
#print 'generating browser view...'
|
||||
#rxnpath.view(url, fmt)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,84 +0,0 @@
|
|||
"""
|
||||
A stagnation-point flame using GRI-Mech 3.0.
|
||||
|
||||
In this script, a hydrogen / oxygen / argon flame is first solved,
|
||||
and then used as the starting estimate for a methane / oxygen / argon
|
||||
flame.
|
||||
|
||||
"""
|
||||
|
||||
from Cantera.flame import *
|
||||
from Cantera import units
|
||||
|
||||
# start with only a hydrogen/oxygen mechanism
|
||||
gas = IdealGasMix('h2o2.cti')
|
||||
|
||||
flame = StagnationFlame(
|
||||
domain = (0, 0.02),
|
||||
fuel = 'H2:1',
|
||||
oxidizer = 'O2:1, AR:4',
|
||||
gas = gas,
|
||||
grid = [0.0, 0.0025, 0.005, 0.0075, 0.01, 0.016, 0.02]
|
||||
)
|
||||
|
||||
flame.set(mdot = 0.4,
|
||||
equiv_ratio = 0.9,
|
||||
T_burner = 373.7,
|
||||
T_surface = 600.0,
|
||||
pressure = 1.0 * units.atm,
|
||||
tol = (1.e-7, 1.e-11),
|
||||
timesteps = ([1,2,5,10,20], 1.e-5),
|
||||
refine = (10.0, 1.0, 1.0),
|
||||
jac_age = (50, 50),
|
||||
)
|
||||
|
||||
# first solve the fixed-temperature problem
|
||||
flame.set(energy = 'off')
|
||||
flame.solve(1)
|
||||
|
||||
# now enable the energy equation, and specify that rough
|
||||
# grid refinement should be done
|
||||
flame.set(energy = 'on', refine = (3.0, 0.9, 0.9))
|
||||
flame.solve(1)
|
||||
|
||||
flame.save('energy','h2/o2 soln with energy equation', 'h2.xml')
|
||||
|
||||
|
||||
#-----------------------------------------------------------
|
||||
|
||||
# Now construct the methane flame using GRI-Mech 3.0
|
||||
gas2 = GRI30(transport = 'Mix')
|
||||
|
||||
flame2 = StagnationFlame(
|
||||
domain = (0, 0.02),
|
||||
fuel = 'CH4:1',
|
||||
oxidizer = 'O2:1, AR:4',
|
||||
gas = gas2,
|
||||
grid = [0.0, 0.0025, 0.005, 0.0075, 0.01, 0.016, 0.02]
|
||||
)
|
||||
|
||||
flame2.set(mdot = 0.8,
|
||||
equiv_ratio = 0.9,
|
||||
T_burner = 373.7,
|
||||
T_surface = 600.0,
|
||||
pressure = 1.0 * units.atm,
|
||||
tol = (1.e-7, 1.e-11),
|
||||
timesteps = ([1,2,5], 1.e-5),
|
||||
refine = (2.0, 0.1, 0.2),
|
||||
jac_age = (50, 50),
|
||||
)
|
||||
|
||||
# Use the hydrogen results as the starting guess.
|
||||
flame2.restore(src = 'h2.xml', solution = 'energy')
|
||||
|
||||
flame2.set(energy = 'on')
|
||||
flame2.solve(1)
|
||||
flame2.show()
|
||||
|
||||
# write plot files
|
||||
flame2.plot(plotfile = 'stflame2.dat', title = 'methane/air flame',
|
||||
fmt = 'TECPLOT')
|
||||
flame2.plot(plotfile = 'stflame2.csv', fmt = 'EXCEL')
|
||||
print 'Solution written to TECPLOT file stflame2.dat and Excel CSV file stflame2.csv'
|
||||
flame2.showStatistics()
|
||||
|
||||
|
|
@ -721,6 +721,18 @@ py_sim1D_setRefineCriteria(PyObject *self, PyObject *args)
|
|||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_sim1D_getInitialSoln(PyObject *self, PyObject *args)
|
||||
{
|
||||
int i, iok;
|
||||
if (!PyArg_ParseTuple(args, "i:sim1D_getInitialSoln", &i))
|
||||
return NULL;
|
||||
|
||||
iok = sim1D_getInitialSoln(i);
|
||||
if (iok == -1) return reportCanteraError();
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
py_sim1D_save(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ static PyMethodDef ct_methods[] = {
|
|||
{"sim1D_setFlatProfile", py_sim1D_setFlatProfile, METH_VARARGS},
|
||||
{"sim1D_showSolution", py_sim1D_showSolution, METH_VARARGS},
|
||||
{"sim1D_setTimeStep", py_sim1D_setTimeStep, METH_VARARGS},
|
||||
{"sim1D_getInitialSoln", py_sim1D_getInitialSoln, METH_VARARGS},
|
||||
{"sim1D_solve", py_sim1D_solve, METH_VARARGS},
|
||||
{"sim1D_refine", py_sim1D_refine, METH_VARARGS},
|
||||
{"sim1D_setRefineCriteria", py_sim1D_setRefineCriteria, METH_VARARGS},
|
||||
|
|
|
|||
|
|
@ -23,11 +23,6 @@
|
|||
#include "ctexceptions.h"
|
||||
#include "ct_defs.h"
|
||||
|
||||
// cvode includes
|
||||
//#include "cvode/nvector.h"
|
||||
//#include "cvode/cvode.h"
|
||||
|
||||
|
||||
namespace Cantera {
|
||||
|
||||
/**
|
||||
|
|
@ -74,8 +69,7 @@ namespace Cantera {
|
|||
int m_neq;
|
||||
void* m_cvode_mem;
|
||||
double m_t0;
|
||||
void *m_y, *m_abstol; //N_Vector m_y;
|
||||
//N_Vector m_abstol;
|
||||
void *m_y, *m_abstol;
|
||||
int m_type;
|
||||
int m_itol;
|
||||
int m_method;
|
||||
|
|
@ -87,9 +81,7 @@ namespace Cantera {
|
|||
double m_hmax;
|
||||
|
||||
vector_fp m_ropt;
|
||||
//vector_int m_iopt;
|
||||
long int* m_iopt; //[OPT_SIZE];
|
||||
//N_Vector m_yprime;
|
||||
long int* m_iopt;
|
||||
void* m_data;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace Cantera {
|
|||
|
||||
public:
|
||||
|
||||
virtual ~Integrator() {}
|
||||
|
||||
/** Set or reset the number of equations. */
|
||||
//virtual void resize(int n)=0;
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace ctml {
|
|||
"The Cantera Python interface is required in order to process\n"
|
||||
"Cantera input files, but it does not seem to be correctly installed.\n\n"
|
||||
"Check that you can invoke the Python interpreter with \n"
|
||||
"the command \"python\", and that typing \"from Cantera import *\"\n"
|
||||
"the command \"python\", and that typing \"from Cantera import *\" \n"
|
||||
"at the Python prompt does not produce an error. If Python on your system\n"
|
||||
"is invoked with some other command, set environment variable PYTHON_CMD\n"
|
||||
"to the full path to the Python interpreter. \n\n"
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ namespace Cantera {
|
|||
|
||||
virtual void showSolution(const doublereal* x) {
|
||||
char buf[80];
|
||||
sprintf(buf, " Temperature: %10.4g K \n", m_temp);
|
||||
sprintf(buf, " Temperature: %10.4g K \n", x[0]);
|
||||
writelog(buf);
|
||||
writelog(" Coverages: \n");
|
||||
for (int k = 0; k < m_nsp; k++) {
|
||||
|
|
|
|||
|
|
@ -121,9 +121,9 @@ namespace Cantera {
|
|||
step[n] = -step[n];
|
||||
}
|
||||
//try {
|
||||
jac.solve(sz, step, step);
|
||||
//}
|
||||
//catch (CanteraError) {
|
||||
jac.solve(sz, step, step);
|
||||
//}
|
||||
//catch (CanteraError) {
|
||||
#undef DEBUG_STEP
|
||||
#ifdef DEBUG_STEP
|
||||
bool ok = false;
|
||||
|
|
@ -141,7 +141,7 @@ namespace Cantera {
|
|||
}
|
||||
#endif
|
||||
//throw CanteraError("step","step error");
|
||||
//}
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -272,7 +272,6 @@ namespace Cantera {
|
|||
int MultiNewton::solve(doublereal* x0, doublereal* x1,
|
||||
OneDim& r, MultiJac& jac, int loglevel) {
|
||||
clock_t t0 = clock();
|
||||
|
||||
int m = 0;
|
||||
bool forceNewJac = false;
|
||||
doublereal s1=1.e30;
|
||||
|
|
@ -308,7 +307,6 @@ namespace Cantera {
|
|||
|
||||
// increment the Jacobian age
|
||||
jac.incrementAge();
|
||||
//cout << jac.age() << endl;
|
||||
|
||||
// damp the Newton step
|
||||
m = dampStep(x, stp, x1, stp1, s1, r, jac, loglevel-1, frst);
|
||||
|
|
|
|||
|
|
@ -146,7 +146,6 @@ namespace Cantera {
|
|||
void setMaxTimeStep(doublereal tmax) { m_tmax = tmax; }
|
||||
void setTimeStepFactor(doublereal tfactor) { m_tfactor = tfactor; }
|
||||
void setJacAge(int ss_age, int ts_age=-1) {
|
||||
cout << "setting jac age " << ss_age << " " << ts_age << endl;
|
||||
m_ss_jac_age = ss_age;
|
||||
if (ts_age > 0)
|
||||
m_ts_jac_age = ts_age;
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ namespace Cantera {
|
|||
m_x.resize(size(), 0.0);
|
||||
m_xnew.resize(size(), 0.0);
|
||||
for (int n = 0; n < m_nd; n++) {
|
||||
// writelog("calling domain "+int2str(n)+" _getInitialSoln\n");
|
||||
domain(n)._getInitialSoln(m_x.begin() + start(n));
|
||||
// writelog("ret\n");
|
||||
}
|
||||
|
||||
// set some defaults
|
||||
|
|
@ -178,6 +176,11 @@ namespace Cantera {
|
|||
}
|
||||
}
|
||||
|
||||
void Sim1D::getInitialSoln() {
|
||||
for (int n = 0; n < m_nd; n++) {
|
||||
domain(n)._getInitialSoln(m_x.begin() + start(n));
|
||||
}
|
||||
}
|
||||
|
||||
void Sim1D::finalize() {
|
||||
for (int n = 0; n < m_nd; n++) {
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ namespace Cantera {
|
|||
doublereal slope = 0.8, doublereal curve = 0.8, doublereal prune = -0.1);
|
||||
|
||||
void restore(string fname, string id);
|
||||
void getInitialSoln();
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue