[Transport] Add electricalConductivity method to all language interfaces

Thanks to user 'hencken' for the patch.

Resolves Issue 171.
This commit is contained in:
Ray Speth 2013-08-23 17:43:55 +00:00
parent f61cbeafcb
commit 717a2367b1
13 changed files with 69 additions and 0 deletions

View file

@ -180,6 +180,7 @@ cdef extern from "cantera/transport/TransportBase.h" namespace "Cantera":
int model()
double viscosity() except +
double thermalConductivity() except +
double electricalConductivity() except +
cdef extern from "cantera/transport/DustyGasTransport.h" namespace "Cantera":

View file

@ -50,6 +50,11 @@ cdef class Transport(_SolutionBase):
def __get__(self):
return self.transport.viscosity()
property electrical_conductivity:
"""Electrical conductivity. [S/m]."""
def __get__(self):
return self.transport.electricalConductivity()
property thermal_conductivity:
"""Thermal conductivity. [W/m/K]."""
def __get__(self):

View file

@ -0,0 +1,8 @@
function v = electricalConductivity(a)
% ELECTRICALCONDUCTIVITY Electrical conductivity in S/m.
v = trans_get(a.id, 3);
if v == -1.0
error(geterr);
elseif v < 0.0
error('exception raised');
end

View file

@ -126,6 +126,10 @@ class Transport:
"Viscosity [Pa-s]."""
return _cantera.tran_viscosity(self.__tr_id)
def electricalConductivity(self):
"""electrical conductivity. [S/m]."""
return _cantera.tran_electricalConductivity(self.__tr_id)
def thermalConductivity(self):
"""Thermal conductivity. [W/m/K]."""
return _cantera.tran_thermalConductivity(self.__tr_id)

View file

@ -1190,6 +1190,15 @@ extern "C" {
}
}
double trans_electricalConductivity(int n)
{
try {
return TransportCabinet::item(n).electricalConductivity();
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
double trans_thermalConductivity(int n)
{
try {

View file

@ -127,6 +127,7 @@ extern "C" {
CANTERA_CAPI size_t newTransport(char* model,
int th, int loglevel);
CANTERA_CAPI double trans_viscosity(int n);
CANTERA_CAPI double trans_electricalConductivity(int n);
CANTERA_CAPI double trans_thermalConductivity(int n);
CANTERA_CAPI int trans_getThermalDiffCoeffs(int n, int ldt, double* dt);
CANTERA_CAPI int trans_getMixDiffCoeffs(int n, int ld, double* d);

View file

@ -395,6 +395,10 @@ MODULE CANTERA
MODULE PROCEDURE ctthermo_temperature
END INTERFACE temperature
INTERFACE electricalConductivity
MODULE PROCEDURE ctrans_electricalConductivity
END INTERFACE electricalConductivity
INTERFACE thermalConductivity
MODULE PROCEDURE ctrans_thermalConductivity
END INTERFACE thermalConductivity

View file

@ -25,6 +25,13 @@ contains
self%err = 0
end function ctrans_viscosity
double precision function ctrans_electricalConductivity(self)
implicit none
type(phase_t), intent(inout) :: self
ctrans_electricalConductivity = trans_electricalConductivity(self%tran_id)
self%err = 0
end function ctrans_electricalConductivity
double precision function ctrans_thermalConductivity(self)
implicit none
type(phase_t), intent(inout) :: self

View file

@ -925,6 +925,15 @@ extern "C" {
}
}
doublereal trans_electricalconductivity_(const integer* n)
{
try {
return _ftrans(n)->electricalConductivity();
} catch (...) {
return handleAllExceptions(DERR, DERR);
}
}
doublereal trans_thermalconductivity_(const integer* n)
{
try {

View file

@ -379,6 +379,10 @@ interface
integer, intent(in) :: n
end function trans_viscosity
double precision function trans_electricalConductivity(n)
integer, intent(in) :: n
end function trans_electricalConductivity
double precision function trans_thermalConductivity(n)
integer, intent(in) :: n
end function trans_thermalConductivity

View file

@ -43,6 +43,8 @@ void transportmethods(int nlhs, mxArray* plhs[],
break;
case 2:
vv = trans_thermalConductivity(n);
case 3:
vv = trans_electricalConductivity(n);
break;
default:
mexErrMsgTxt("unknown Transport method");

View file

@ -71,6 +71,20 @@ py_viscosity(PyObject* self, PyObject* args)
return Py_BuildValue("d",mu);
}
static PyObject*
py_electricalConductivity(PyObject* self, PyObject* args)
{
int n;
if (!PyArg_ParseTuple(args, "i:py_electricalConductivity", &n)) {
return NULL;
}
double sigma = trans_electricalConductivity(n);
if (sigma < 0.0) {
return reportError(int(sigma));
}
return Py_BuildValue("d",sigma);
}
static PyObject*
py_thermalConductivity(PyObject* self, PyObject* args)
{

View file

@ -76,6 +76,7 @@ static PyMethodDef ct_methods[] = {
{"Transport", py_transport_new, METH_VARARGS},
{"tran_delete", py_transport_delete, METH_VARARGS},
{"tran_viscosity", py_viscosity, METH_VARARGS},
{"tran_electricalConductivity", py_electricalConductivity, METH_VARARGS},
{"tran_thermalConductivity", py_thermalConductivity, METH_VARARGS},
{"tran_thermalDiffCoeffs", py_thermalDiffCoeffs, METH_VARARGS},
{"tran_binaryDiffCoeffs", py_binaryDiffCoeffs, METH_VARARGS},