Export the Transport::getMassFluxes function
This commit is contained in:
parent
107ba5d381
commit
4aa54c3419
5 changed files with 44 additions and 0 deletions
|
|
@ -1107,6 +1107,17 @@ extern "C" {
|
|||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT trans_getMassFluxes(int n, const double* state1,
|
||||
const double* state2, double delta, double* fluxes)
|
||||
{
|
||||
try {
|
||||
trans(n)->getMassFluxes(state1, state2, delta, fluxes);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------- Functions ---------------------------
|
||||
|
||||
int DLL_EXPORT import_phase(int nth, int nxml, char* id) {
|
||||
|
|
|
|||
|
|
@ -155,6 +155,8 @@ extern "C" {
|
|||
EEXXTT int DLL_CPREFIX trans_setParameters(int n, int type, int k, double* d);
|
||||
EEXXTT int DLL_CPREFIX trans_getMolarFluxes(int n, const double* state1,
|
||||
const double* state2, double delta, double* fluxes);
|
||||
EEXXTT int DLL_CPREFIX trans_getMassFluxes(int n, const double* state1,
|
||||
const double* state2, double delta, double* fluxes);
|
||||
|
||||
EEXXTT int DLL_CPREFIX import_phase(int nth, int nxml, char* id);
|
||||
EEXXTT int DLL_CPREFIX import_kinetics(int nxml, char* id,
|
||||
|
|
|
|||
|
|
@ -166,3 +166,7 @@ class Transport:
|
|||
asarray(state1), asarray(state2),
|
||||
delta)
|
||||
|
||||
def massFluxes(self, state1, state2, delta):
|
||||
return _cantera.tran_getMassFluxes(self.__tr_id, self.trnsp,
|
||||
asarray(state1), asarray(state2),
|
||||
delta)
|
||||
|
|
|
|||
|
|
@ -165,3 +165,29 @@ py_getMolarFluxes(PyObject *self, PyObject *args) {
|
|||
if (iok < 0) return reportError(iok);
|
||||
return PyArray_Return(f);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_getMassFluxes(PyObject *self, PyObject *args)
|
||||
{
|
||||
int n, id;
|
||||
PyObject *state1, *state2;
|
||||
double delta;
|
||||
if (!PyArg_ParseTuple(args, "iiOOd:py_getMassFluxes", &n, &id,
|
||||
&state1, &state2, &delta))
|
||||
|
||||
return NULL;
|
||||
PyArrayObject* state1array = (PyArrayObject*)state1;
|
||||
PyArrayObject* state2array = (PyArrayObject*)state2;
|
||||
double* d1 = (double*)state1array->data;
|
||||
double* d2 = (double*)state2array->data;
|
||||
#ifdef HAS_NUMPY
|
||||
npy_intp nid = id;
|
||||
PyArrayObject* f = (PyArrayObject*)PyArray_SimpleNew(1, &nid, PyArray_DOUBLE);
|
||||
#else
|
||||
PyArrayObject* f = (PyArrayObject*)PyArray_FromDims(1, &id, PyArray_DOUBLE);
|
||||
#endif
|
||||
double* fd = (double*)f->data;
|
||||
int iok = trans_getMassFluxes(n, d1, d2, delta, fd);
|
||||
if (iok < 0) return reportError(iok);
|
||||
return PyArray_Return(f);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ static PyMethodDef ct_methods[] = {
|
|||
{"tran_multiDiffCoeffs", py_multiDiffCoeffs, METH_VARARGS},
|
||||
{"tran_setParameters", py_setParameters, METH_VARARGS},
|
||||
{"tran_getMolarFluxes", py_getMolarFluxes, METH_VARARGS},
|
||||
{"tran_getMassFluxes", py_getMassFluxes, METH_VARARGS},
|
||||
|
||||
{"get_Cantera_Error", ct_get_cantera_error, METH_VARARGS},
|
||||
//{"ct_print", ct_print, METH_VARARGS},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue