Skip to content

Commit

Permalink
[Cython] Add interface for new PureFluid property pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanwweber committed Jan 25, 2016
1 parent af81729 commit 49cb039
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
7 changes: 7 additions & 0 deletions interfaces/cython/cantera/_cantera.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera":
void setState_SP(double, double) except +
void setState_SV(double, double) except +
void setState_RP(double, double) except +
void setState_ST(double, double) except +
void setState_TV(double, double) except +
void setState_PV(double, double) except +
void setState_UP(double, double) except +
void setState_VH(double, double) except +
void setState_TH(double, double) except +
void setState_SH(double, double) except +

# molar thermodynamic properties:
double enthalpy_mole() except +
Expand Down
81 changes: 81 additions & 0 deletions interfaces/cython/cantera/thermo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,87 @@ cdef class PureFluid(ThermoPhase):
X = values[1] if values[1] is not None else self.X
self.thermo.setState_Psat(P, X)

property ST:
"""Get/Set the entropy [J/kg/K] and temperature [K] of a PureFluid."""
def __get__(self):
return self.s, self.T
def __set__(self, values):
S = values[0] if values[0] is not None else self.s
T = values[1] if values[1] is not None else self.T
self.thermo.setState_ST(S / self._mass_factor(), T)

property TV:
"""
Get/Set the temperature [K] and specific volume [m^3/kg] of
a PureFluid.
"""
def __get__(self):
return self.T, self.v
def __set__(self, values):
T = values[0] if values[0] is not None else self.T
V = values[1] if values[1] is not None else self.v
self.thermo.setState_TV(T, V / self._mass_factor())

property PV:
"""
Get/Set the pressure [Pa] and specific volume [m^3/kg] of
a PureFluid.
"""
def __get__(self):
return self.p, self.v
def __set__(self, values):
P = values[0] if values[0] is not None else self.P
V = values[1] if values[1] is not None else self.v
self.thermo.setState_PV(P, V / self._mass_factor())

property UP:
"""
Get/Set the specific internal energy [J/kg] and the
pressure [Pa] of a PureFluid.
"""
def __get__(self):
return self.u, self.P
def __set__(self, values):
U = values[0] if values[0] is not None else self.u
P = values[1] if values[1] is not None else self.P
self.thermo.setState_UP(U / self._mass_factor(), P)

property VH:
"""
Get/Set the specfic volume [m^3/kg] and the specific
enthalpy [J/kg] of a PureFluid.
"""
def __get__(self):
return self.v, self.h
def __set__(self, values):
V = values[0] if values[0] is not None else self.v
H = values[1] if values[1] is not None else self.h
self.thermo.setState_VH(V/self._mass_factor(), H/self._mass_factor())

property TH:
"""
Get/Set the temperature [K] and the specific enthalpy [J/kg]
of a PureFluid.
"""
def __get__(self):
return self.T, self.h
def __set__(self, values):
T = values[0] if values[0] is not None else self.T
H = values[1] if values[1] is not None else self.h
self.thermo.setState_TH(T, H / self._mass_factor())

property SH:
"""
Get/Set the specific entropy [J/kg/K] and the specific
enthalpy [J/kg] of a PureFluid.
"""
def __get__(self):
return self.s, self.h
def __set__(self, values):
S = values[0] if values[0] is not None else self.s
H = values[1] if values[1] is not None else self.h
self.thermo.setState_SH(S/self._mass_factor(), H/self._mass_factor())

property TDX:
"""
Get the temperature [K], density [kg/m^3 or kmol/m^3], and vapor
Expand Down

0 comments on commit 49cb039

Please sign in to comment.