added ability to enable Soret effect in flame calculations

This commit is contained in:
Dave Goodwin 2007-04-25 20:41:45 +00:00
parent 93be5e02fe
commit 45be8d1924
9 changed files with 59 additions and 10 deletions

View file

@ -355,9 +355,21 @@ extern "C" {
}
int DLL_EXPORT stflow_setTransport(int i, int itr) {
int DLL_EXPORT stflow_setTransport(int i, int itr, int iSoret) {
bool withSoret = false;
if (iSoret > 0) withSoret = true;
try {
_stflow(i)->setTransport(*_transport(itr));
_stflow(i)->setTransport(*_transport(itr), withSoret);
return 0;
}
catch (CanteraError) { return -1; }
}
int DLL_EXPORT stflow_enableSoret(int i, int iSoret) {
bool withSoret = false;
if (iSoret > 0) withSoret = true;
try {
_stflow(i)->enableSoret(withSoret);
return 0;
}
catch (CanteraError) { return -1; }

View file

@ -47,7 +47,8 @@ extern "C" {
int DLL_IMPORT inlet_setSpreadRate(int i, double v);
int DLL_IMPORT stflow_new(int iph, int ikin, int itr, int itype=1);
int DLL_IMPORT stflow_setTransport(int i, int itr);
int DLL_IMPORT stflow_setTransport(int i, int itr, int iSoret);
int DLL_IMPORT stflow_enableSoret(int i, int iSoret);
int DLL_IMPORT stflow_setPressure(int i, double p);
int DLL_IMPORT stflow_setFixedTempProfile(int i, int n, double* pos,
int m, double* temp);

View file

@ -389,11 +389,17 @@ class AxisymmetricFlow(Domain1D):
_cantera.stflow_setPressure(self._hndl, p)
self._p = p
def setTransportModel(self, transp):
def setTransportModel(self, transp, withSoret = 0):
"""Set the transport model. The argument must be a transport
manager for the 'gas' object."""
itr = transp.transport_hndl()
_cantera.stflow_setTransport(self._hndl, itr)
_cantera.stflow_setTransport(self._hndl, itr, withSoret)
def enableSoret(self, withSoret = 1):
"""Include or exclude thermal diffusion (Soret effect) when computing
diffusion velocities. If withSoret is not supplied or is positive,
thermal diffusion is enabled; otherwise it is disabled."""
_cantera.stflow_enableSoret(self._hndl, withSoret)
def pressure(self):
"""Pressure [Pa]."""

View file

@ -72,6 +72,10 @@ f.flame.setTransportModel(gas)
f.solve(loglevel, refine_grid)
f.save('ch4_flame1.xml','energy_multi',
'solution with the energy equation enabled and multicomponent transport')
f.flame.enableSoret()
f.solve(loglevel, refine_grid)
f.save('ch4_flame1.xml','energy_multi_soret',
'solution with the energy equation enabled and multicomponent transport with thermal diffusion')
# write the velocity, temperature, density, and mole fractions to a CSV file
z = f.flame.grid()

View file

@ -489,11 +489,24 @@ static PyObject *
py_stflow_setTransport(PyObject *self, PyObject *args)
{
int _val;
int i, itr;
if (!PyArg_ParseTuple(args, "ii:stflow_setTransport", &i, &itr))
int i, itr, isoret;
if (!PyArg_ParseTuple(args, "iii:stflow_setTransport", &i, &itr, &isoret))
return NULL;
_val = stflow_setTransport(i,itr);
_val = stflow_setTransport(i,itr, isoret);
if (int(_val) == -1) return reportCanteraError();
return Py_BuildValue("i",_val);
}
static PyObject *
py_stflow_enableSoret(PyObject *self, PyObject *args)
{
int _val;
int i, isoret;
if (!PyArg_ParseTuple(args, "ii:stflow_enableSoret", &i, &isoret))
return NULL;
_val = stflow_enableSoret(i,isoret);
if (int(_val) == -1) return reportCanteraError();
return Py_BuildValue("i",_val);
}

View file

@ -127,6 +127,7 @@ static PyMethodDef ct_methods[] = {
{"stflow_new", py_stflow_new, METH_VARARGS},
{"stflow_setPressure", py_stflow_setPressure, METH_VARARGS},
{"stflow_setTransport", py_stflow_setTransport, METH_VARARGS},
{"stflow_enableSoret", py_stflow_enableSoret, METH_VARARGS},
{"stflow_setFixedTempProfile", py_stflow_setFixedTempProfile, METH_VARARGS},
{"stflow_solveSpeciesEqs", py_stflow_solveSpeciesEqs, METH_VARARGS},
{"stflow_solveEnergyEqn", py_stflow_solveEnergyEqn, METH_VARARGS},

View file

@ -130,8 +130,8 @@ namespace Cantera {
break;
#endif
default:
throw UnknownThermoPhaseModel("ThermoFactory::newThermoPhase",
default:
throw UnknownThermoPhaseModel("ThermoFactory::newThermoPhase",
model);
}
return th;

View file

@ -267,6 +267,16 @@ namespace Cantera {
throw CanteraError("setTransport","unknown transport model.");
}
void StFlow::enableSoret(bool withSoret) {
if (m_transport_option == c_Multi_Transport)
m_do_soret = withSoret;
else {
throw CanteraError("setTransport",
"Thermal diffusion (the Soret effect) "
"requires using a multicomponent transport model.");
}
}
/**
* Set the gas object state to be consistent with the solution at

View file

@ -100,6 +100,8 @@ namespace Cantera {
/// set the transport manager
void setTransport(Transport& trans, bool withSoret = false);
void enableSoret(bool withSoret);
bool withSoret() const { return m_do_soret; }
/// Set the pressure. Since the flow equations are for the limit of
/// small Mach number, the pressure is very nearly constant