Skip to content

Commit

Permalink
Add thermal conductivity to DustyGas in python. (#988)
Browse files Browse the repository at this point in the history
* Add thermal conductivity to DustyGas in python.

* Added thermal conductivity example in dustygas python example script

* Added thermal conductivity test to TestDustyGas class
  • Loading branch information
chinahg authored Apr 19, 2021
1 parent 81cffde commit fe29628
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions interfaces/cython/cantera/_cantera.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ cdef extern from "cantera/transport/DustyGasTransport.h" namespace "Cantera":
void setMeanParticleDiameter(double) except +translate_exception
void setPermeability(double) except +translate_exception
void getMolarFluxes(double*, double*, double, double*) except +translate_exception
CxxTransport& gasTransport() except +translate_exception


cdef extern from "cantera/transport/TransportData.h" namespace "Cantera":
Expand Down
5 changes: 4 additions & 1 deletion interfaces/cython/cantera/examples/transport/dusty_gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
The Dusty Gas model is a multicomponent transport model for gas transport
through the pores of a stationary porous medium. This example shows how to
create a transport manager that implements the Dusty Gas model and use it to
compute the multicomponent diffusion coefficients.
compute the multicomponent diffusion coefficients and thermal conductivity.
Requires: cantera >= 2.5.0
"""
Expand All @@ -29,6 +29,9 @@
# print the multicomponent diffusion coefficients
print(g.multi_diff_coeffs)

# print the thermal conductivity of the gas phase
print(g.thermal_conductivity)

# compute molar species fluxes
T1, rho1, Y1 = g.TDY

Expand Down
5 changes: 5 additions & 0 deletions interfaces/cython/cantera/test/test_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ def test_molar_fluxes(self):
# Not sure why the following condition is not satisfied:
# self.assertNear(sum(fluxes1) / sum(abs(fluxes1)), 0.0)

def test_thermal_conductivity(self):
gas1 = ct.Solution('h2o2.xml', transport_model='multicomponent')
gas1.TPX = self.phase.TPX

self.assertEqual(self.phase.thermal_conductivity, gas1.thermal_conductivity)

class TestWaterTransport(utilities.CanteraTest):
"""
Expand Down
11 changes: 10 additions & 1 deletion interfaces/cython/cantera/transport.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ cdef class Transport(_SolutionBase):
return self.transport.electricalConductivity()

property thermal_conductivity:
"""Thermal conductivity. [W/m/K]."""
"""
Thermal conductivity. [W/m/K]
Returns thermal conductivity of the ideal gas object using the multicomponent
model. The value is not specific to the dusty gas model.
"""
def __get__(self):
return self.transport.thermalConductivity()

Expand Down Expand Up @@ -276,6 +280,11 @@ cdef class DustyGasTransport(Transport):
def __set__(self, value):
(<CxxDustyGasTransport*>self.transport).setPermeability(value)

property thermal_conductivity:
def __get__(self):
return (<CxxDustyGasTransport*>self.transport).gasTransport().thermalConductivity()


def molar_fluxes(self, T1, T2, rho1, rho2, Y1, Y2, delta):
"""
Get the molar fluxes [kmol/m^2/s], given the thermodynamic state at
Expand Down

0 comments on commit fe29628

Please sign in to comment.