*** empty log message ***
This commit is contained in:
parent
2a64690ab7
commit
d14283ea08
11 changed files with 175 additions and 39 deletions
|
|
@ -325,13 +325,22 @@ extern "C" {
|
|||
IdealGasPhase* ph = (IdealGasPhase*)_thermo(iph);
|
||||
AxiStagnFlow* x = new AxiStagnFlow(ph, ph->nSpecies(), 2);
|
||||
x->setKinetics(*_kinetics(ikin));
|
||||
x->setTransport(*_transport(ikin));
|
||||
x->setTransport(*_transport(itr));
|
||||
|
||||
return Cabinet<Domain1D>::cabinet()->add(x);
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
|
||||
int DLL_EXPORT stflow_setTransport(int i, int itr) {
|
||||
try {
|
||||
_stflow(i)->setTransport(*_transport(itr));
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT stflow_setPressure(int i, double p) {
|
||||
try {
|
||||
_stflow(i)->setPressure(p);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ extern "C" {
|
|||
int DLL_IMPORT inlet_setSpreadRate(int i, double v);
|
||||
|
||||
int DLL_IMPORT stflow_new(int iph, int ikin, int itr);
|
||||
int DLL_IMPORT stflow_setTransport(int i, int itr);
|
||||
int DLL_IMPORT stflow_setPressure(int i, double p);
|
||||
int DLL_IMPORT stflow_setFixedTempProfile(int i, int n, double* pos,
|
||||
int m, double* temp);
|
||||
|
|
|
|||
|
|
@ -316,6 +316,10 @@ class AxisymmetricFlow(Domain1D):
|
|||
_cantera.stflow_setPressure(self._hndl, p)
|
||||
self._p = p
|
||||
|
||||
def setTransportModel(self, transp):
|
||||
itr = transp.transport_hndl()
|
||||
_cantera.stflow_setTransport(self._hndl, itr)
|
||||
|
||||
def pressure(self):
|
||||
return self._p
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import _cantera
|
||||
from Numeric import asarray
|
||||
import exceptions
|
||||
|
||||
class Transport:
|
||||
|
||||
|
|
@ -32,6 +33,7 @@ class Transport:
|
|||
self.__tr_id = _cantera.Transport(self.model,
|
||||
phase._phase_id, loglevel)
|
||||
self.trnsp = phase.nSpecies()
|
||||
self._phase_id = phase._phase_id
|
||||
self._models = {}
|
||||
self._models[self.model] = self.__tr_id
|
||||
|
||||
|
|
@ -41,13 +43,26 @@ class Transport:
|
|||
except:
|
||||
pass
|
||||
|
||||
def addTransportModel(self, model, loglevel=1):
|
||||
new_id = _cantera.Transport(model,
|
||||
self._phase_id, loglevel)
|
||||
self._models[model] = new_id
|
||||
|
||||
|
||||
def switchTransportModel(self, model):
|
||||
if self._models.has_key(model):
|
||||
self.__tr_id = self._models[model]
|
||||
else:
|
||||
raise CanteraError("Transport model "+model+" not defined. Use "
|
||||
+"method addTransportModel first.")
|
||||
|
||||
def desc(self):
|
||||
if self.model == 'Multi':
|
||||
return 'Multicomponent'
|
||||
elif self.model == 'Mix':
|
||||
return 'Mixture-averaged'
|
||||
else:
|
||||
return 'Unknown'
|
||||
return self.model
|
||||
|
||||
def transport_id(self):
|
||||
return self.__tr_id
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ tol_ss = [1.0e-5, 1.0e-9] # [rtol atol] for steady-state
|
|||
# problem
|
||||
tol_ts = [1.0e-5, 1.0e-4] # [rtol atol] for time stepping
|
||||
|
||||
loglevel = 1 # amount of diagnostic output (0
|
||||
loglevel = 5 # amount of diagnostic output (0
|
||||
# to 5)
|
||||
|
||||
refine_grid = 1 # 1 to enable refinement, 0 to
|
||||
|
|
@ -39,6 +39,7 @@ refine_grid = 1 # 1 to enable refinement, 0 to
|
|||
# and transport properties
|
||||
#
|
||||
gas = GRI30('Mix')
|
||||
gas.addTransportModel('Multi')
|
||||
|
||||
# set its state to that of the unburned gas at the burner
|
||||
gas.setState_TPX(tburner, p, comp)
|
||||
|
|
@ -56,16 +57,22 @@ f.setRefineCriteria(ratio = 10.0, slope = 1, curve = 1)
|
|||
f.setMaxJacAge(50, 50)
|
||||
f.setTimeStep(1.0e-5, [1, 2, 5, 10, 20])
|
||||
|
||||
f.solve(loglevel,refine_grid)
|
||||
f.solve(loglevel, refine_grid)
|
||||
f.save('ch4_flame1.xml','no_energy',
|
||||
'solution with the energy equation disabled')
|
||||
|
||||
f.set(energy = 'on')
|
||||
f.setRefineCriteria(ratio = 3.0, slope = 0.1, curve = 0.2)
|
||||
f.solve(loglevel,refine_grid)
|
||||
f.solve(loglevel, refine_grid)
|
||||
f.save('ch4_flame1.xml','energy',
|
||||
'solution with the energy equation enabled')
|
||||
|
||||
gas.switchTransportModel('Multi')
|
||||
f.flame.setTransportModel(gas)
|
||||
f.solve(loglevel, refine_grid)
|
||||
f.save('ch4_flame1.xml','energy_multi',
|
||||
'solution with the energy equation enabled')
|
||||
|
||||
# write the velocity, temperature, and mole fractions to a CSV file
|
||||
z = f.flame.grid()
|
||||
T = f.T()
|
||||
|
|
|
|||
|
|
@ -475,6 +475,19 @@ py_stflow_new(PyObject *self, PyObject *args)
|
|||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_stflow_setTransport(PyObject *self, PyObject *args)
|
||||
{
|
||||
int _val;
|
||||
int i, itr;
|
||||
if (!PyArg_ParseTuple(args, "ii:stflow_setTransport", &i, &itr))
|
||||
return NULL;
|
||||
|
||||
_val = stflow_setTransport(i,itr);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
py_stflow_setPressure(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ static PyMethodDef ct_methods[] = {
|
|||
{"reactingsurf_new", py_reactingsurf_new, METH_VARARGS},
|
||||
{"stflow_new", py_stflow_new, METH_VARARGS},
|
||||
{"stflow_setPressure", py_stflow_setPressure, METH_VARARGS},
|
||||
{"stflow_setTransport", py_stflow_setTransport, METH_VARARGS},
|
||||
{"stflow_setFixedTempProfile", py_stflow_setFixedTempProfile, METH_VARARGS},
|
||||
{"stflow_solveSpeciesEqs", py_stflow_solveSpeciesEqs, METH_VARARGS},
|
||||
{"stflow_solveEnergyEqn", py_stflow_solveEnergyEqn, METH_VARARGS},
|
||||
|
|
|
|||
|
|
@ -55,7 +55,10 @@ EVERYTHING = $(KINETICS) $(HETEROKIN) $(ELECTROCHEM) $(EQUIL) $(CK) \
|
|||
$(TRANSPORT) $(REACTOR) $(RPATH) $(SOLVERS) $(FLOW1D)
|
||||
|
||||
|
||||
all: @KERNEL@ lib
|
||||
all: config.h @KERNEL@ lib
|
||||
|
||||
config.h: ../../config.h
|
||||
cp -f ../../config.h ./config.h
|
||||
|
||||
base: $(BASE)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,63 @@
|
|||
/* ../config.h. Generated by configure. */
|
||||
//
|
||||
// Run the 'configure' script to generate 'config.h' from this input file.
|
||||
//
|
||||
#ifndef CT_CONFIG_H
|
||||
#define CT_CONFIG_H
|
||||
|
||||
#include "../../config.h"
|
||||
|
||||
//------------------------ Fortran settings -------------------//
|
||||
|
||||
|
||||
// define types doublereal, integer, and ftnlen to match the
|
||||
// corresponding Fortran data types on your system. The defaults
|
||||
// are OK for most systems
|
||||
|
||||
typedef double doublereal; // Fortran double precision
|
||||
typedef int integer; // Fortran integer
|
||||
typedef int ftnlen; // Fortran hidden string length type
|
||||
|
||||
|
||||
// Fortran compilers pass character strings in argument lists by
|
||||
// adding a hidden argement with the length of the string. Some
|
||||
// compilers add the hidden length argument immediately after the
|
||||
// CHARACTER variable being passed, while others put all of the hidden
|
||||
// length arguments at the end of the argument list. Define this if
|
||||
// the lengths are at the end of the argument list. This is usually the
|
||||
// case for most unix Fortran compilers, but is (by default) false for
|
||||
// Visual Fortran under Windows.
|
||||
#define STRING_LEN_AT_END
|
||||
|
||||
|
||||
// Define this if Fortran adds a trailing underscore to names in object files.
|
||||
// For linux and most unix systems, this is the case.
|
||||
#define FTN_TRAILING_UNDERSCORE
|
||||
|
||||
|
||||
//-------- LAPACK / BLAS ---------
|
||||
|
||||
// Define if you are using LAPACK and BLAS from the Intel Math Kernel
|
||||
// Library
|
||||
/* #undef HAVE_INTEL_MKL */
|
||||
|
||||
#define LAPACK_FTN_STRING_LEN_AT_END
|
||||
#define LAPACK_NAMES_LOWERCASE
|
||||
#define LAPACK_FTN_TRAILING_UNDERSCORE
|
||||
|
||||
// The configure script defines this if the operatiing system is Mac
|
||||
// OS X, This used to add some Mac-specific directories to the default
|
||||
// data file search path.
|
||||
#define DARWIN 1
|
||||
|
||||
//--------- Cantera --------------
|
||||
|
||||
|
||||
//--------- CKReader -------------
|
||||
|
||||
|
||||
|
||||
//--------- CtLib ----------------
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -154,6 +154,7 @@ namespace Cantera {
|
|||
m_do_energy.resize(m_points,false);
|
||||
|
||||
m_diff.resize(m_nsp*m_points);
|
||||
m_multidiff.resize(m_nsp*m_nsp*m_points);
|
||||
m_flux.resize(m_nsp,m_points);
|
||||
m_wdot.resize(m_nsp,m_points, 0.0);
|
||||
m_surfdot.resize(m_nsp, 0.0);
|
||||
|
|
@ -225,7 +226,8 @@ namespace Cantera {
|
|||
m_diff.resize(m_nsp*m_points);
|
||||
}
|
||||
else {
|
||||
m_diff.resize(m_nsp*m_nsp*m_points);
|
||||
m_multidiff.resize(m_nsp*m_nsp*m_points);
|
||||
m_diff.resize(m_nsp*m_points);
|
||||
}
|
||||
m_flux.resize(m_nsp,m_points);
|
||||
m_wdot.resize(m_nsp,m_points, 0.0);
|
||||
|
|
@ -261,7 +263,8 @@ namespace Cantera {
|
|||
|
||||
if (m_trans->model() == cMulticomponent) {
|
||||
m_transport_option = c_Multi_Transport;
|
||||
m_diff.resize(m_nsp*m_nsp*m_points);
|
||||
m_multidiff.resize(m_nsp*m_nsp*m_points);
|
||||
m_diff.resize(m_nsp*m_points);
|
||||
m_dthermal.resize(m_nsp, m_points, 0.0);
|
||||
}
|
||||
else if (m_trans->model() == cMixtureAveraged) {
|
||||
|
|
@ -379,7 +382,7 @@ namespace Cantera {
|
|||
|
||||
// update thermodynamic properties only if a Jacobian is not
|
||||
// being evaluated
|
||||
if (jpt < 0 || (m_transport_option == c_Multi_Transport)) {
|
||||
if (jpt < 0) { //if (jpt < 0 || (m_transport_option == c_Multi_Transport)) {
|
||||
updateThermo(x, j0, j1);
|
||||
|
||||
// update transport properties only if a Jacobian is not being
|
||||
|
|
@ -591,7 +594,8 @@ namespace Cantera {
|
|||
* from j0 to j1, based on solution x.
|
||||
*/
|
||||
void AxiStagnFlow::updateTransport(doublereal* x,int j0, int j1) {
|
||||
int j;
|
||||
int j,k,m;
|
||||
// writelog("\nentered updateTransport\n");
|
||||
if (m_transport_option == c_Mixav_Transport) {
|
||||
for (j = j0; j < j1; j++) {
|
||||
setGasAtMidpoint(x,j);
|
||||
|
|
@ -601,22 +605,39 @@ namespace Cantera {
|
|||
}
|
||||
}
|
||||
else if (m_transport_option == c_Multi_Transport) {
|
||||
for (j = j0; j < j1; j++) {
|
||||
setGasAtMidpoint(x,j);
|
||||
doublereal sum, sumx, wtm, dz;
|
||||
doublereal eps = 1.0e-12;
|
||||
for (m = j0; m < j1; m++) {
|
||||
setGasAtMidpoint(x,m);
|
||||
dz = m_z[m+1] - m_z[m];
|
||||
//dz = m_z[j+1] - m_z[j];
|
||||
wtm = m_thermo->meanMolecularWeight();
|
||||
|
||||
m_visc[j] = m_trans->viscosity();
|
||||
m_visc[m] = m_trans->viscosity();
|
||||
|
||||
m_trans->getMultiDiffCoeffs(m_nsp,
|
||||
m_diff.begin() + mindex(0,0,j));
|
||||
//for (k = 0; k < m_nsp; k++) {
|
||||
|
||||
m_tcon[j] = m_trans->thermalConductivity();
|
||||
m_multidiff.begin() + mindex(0,0,m));
|
||||
|
||||
for (k = 0; k < m_nsp; k++) {
|
||||
sum = 0.0;
|
||||
sumx = 0.0;
|
||||
for (j = 0; j < m_nsp; j++) {
|
||||
if (j != k) {
|
||||
sum += m_wt[j]*m_multidiff[mindex(k,j,m)]*
|
||||
((X(x,j,m+1) - X(x,j,m))/dz + eps);
|
||||
sumx += (X(x,j,m+1) - X(x,j,m))/dz;
|
||||
}
|
||||
}
|
||||
m_diff[k + m*m_nsp] = sum/(wtm*(sumx+eps));
|
||||
}
|
||||
|
||||
m_tcon[m] = m_trans->thermalConductivity();
|
||||
if (m_do_soret) {
|
||||
m_trans->getThermalDiffCoeffs(m_dthermal.begin() + j*m_nsp);
|
||||
m_trans->getThermalDiffCoeffs(m_dthermal.begin() + m*m_nsp);
|
||||
}
|
||||
}
|
||||
}
|
||||
//writelog("leaving updateTransport\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -920,6 +941,7 @@ namespace Cantera {
|
|||
switch (m_transport_option) {
|
||||
|
||||
case c_Mixav_Transport:
|
||||
case c_Multi_Transport:
|
||||
for (j = j0; j < j1; j++) {
|
||||
sum = 0.0;
|
||||
wtm = m_wtm[j];
|
||||
|
|
@ -936,26 +958,26 @@ namespace Cantera {
|
|||
}
|
||||
break;
|
||||
|
||||
case c_Multi_Transport:
|
||||
for (m = j0; m < j1; m++) {
|
||||
wtm = m_wtm[m];
|
||||
rho = density(m);
|
||||
dz = z(m+1) - z(m);
|
||||
fluxsum = 0.0;
|
||||
for (k = 0; k < m_nsp; k++) {
|
||||
sum = 0.0;
|
||||
for (j = 0; j < m_nsp; j++) {
|
||||
if (j != k) {
|
||||
s = m_wt[j]*m_diff[mindex(k,j,m)];
|
||||
s *= (X(x,j,m+1) - X(x,j,m))/dz;
|
||||
sum += s;
|
||||
}
|
||||
}
|
||||
m_flux(k,m) = sum*rho*m_wt[k]/(wtm*wtm);
|
||||
fluxsum -= m_flux(k,m);
|
||||
}
|
||||
}
|
||||
break;
|
||||
// case c_Multi_Transport:
|
||||
// for (m = j0; m < j1; m++) {
|
||||
// wtm = m_wtm[m];
|
||||
// rho = density(m);
|
||||
// dz = z(m+1) - z(m);
|
||||
// fluxsum = 0.0;
|
||||
// for (k = 0; k < m_nsp; k++) {
|
||||
// sum = 0.0;
|
||||
// for (j = 0; j < m_nsp; j++) {
|
||||
// if (j != k) {
|
||||
// s = m_wt[j]*m_diff[mindex(k,j,m)];
|
||||
// s *= (X(x,j,m+1) - X(x,j,m))/dz;
|
||||
// sum += s;
|
||||
// }
|
||||
// }
|
||||
// m_flux(k,m) = sum*rho*m_wt[k]/(wtm*wtm);
|
||||
// fluxsum -= m_flux(k,m);
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
default:
|
||||
throw CanteraError("updateDiffFluxes","unknown transport model");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -427,6 +427,7 @@ namespace Cantera {
|
|||
vector_fp m_visc;
|
||||
vector_fp m_tcon;
|
||||
vector_fp m_diff;
|
||||
vector_fp m_multidiff;
|
||||
Array2D m_dthermal;
|
||||
Array2D m_flux;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue