Implemented a number of functions to python's AbstractState that were missing; Closes #505

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2015-02-27 21:24:22 -07:00
parent f50bf8bbf9
commit 527bac72d0
3 changed files with 115 additions and 19 deletions

View File

@@ -18,15 +18,25 @@ cdef class AbstractState:
cpdef set_mass_fractions(self, vector[double] z)
cpdef set_volu_fractions(self, vector[double] z)
cpdef name(self)
cpdef constants_header.phases phase(self) except *
cpdef specify_phase(self, constants_header.phases phase)
cpdef unspecify_phase(self)
## Limits
cpdef double Tmin(self)
cpdef double Tmax(self)
cpdef double pmax(self)
cpdef double Ttriple(self)
## ----------------------------------------
## Fluid property accessors
## ----------------------------------------
cpdef double T(self)
cpdef double p(self)
cpdef double Q(self)
cpdef double rhomolar(self)
cpdef double hmolar(self)
cpdef double smolar(self)
@@ -43,9 +53,19 @@ cdef class AbstractState:
cpdef double cvmass(self) except *
cpdef double speed_sound(self) except *
cpdef double gas_constant(self) except *
cpdef double tau(self) except *
cpdef double delta(self) except *
cpdef double viscosity(self) except *
cpdef double conductivity(self) except *
cpdef double surface_tension(self) except *
cpdef double Prandtl(self) except *
cpdef double molar_mass(self) except *
cpdef double acentric_factor(self) except*
cpdef double keyed_output(self, constants_header.parameters) except *
cpdef double trivial_keyed_output(self, constants_header.parameters) except *
cpdef double saturated_liquid_keyed_output(self, constants_header.parameters) except *
cpdef double saturated_vapor_keyed_output(self, constants_header.parameters) except *
## ----------------------------------------
## Derivatives
@@ -62,7 +82,8 @@ cdef class AbstractState:
cpdef double melting_line(self, int, int, double) except *
cpdef bool has_melting_line(self) except *
cpdef double saturation_ancillary(self, constants_header.parameters, int, constants_header.parameters, double) except *
cpdef build_phase_envelope(self, string)
cpdef PyPhaseEnvelopeData get_phase_envelope_data(self)

View File

@@ -16,6 +16,14 @@ cdef class AbstractState:
def __dealloc__(self):
del self.thisptr
cpdef name(self):
""" Get the backend name - wrapper of c++ function :cpapi:`CoolProp::AbstractState::name` """
return self.thisptr.name()
cpdef constants_header.phases phase(self):
""" Get the phase as key value- wrapper of c++ function :cpapi:`CoolProp::AbstractState::phase` """
return self.thisptr.phase()
cpdef specify_phase(self, constants_header.phases phase):
""" Specify the phase - wrapper of c++ function :cpapi:`CoolProp::AbstractState::specify_phase` """
self.thisptr.specify_phase(phase)
@@ -36,7 +44,23 @@ cdef class AbstractState:
cpdef set_volu_fractions(self, vector[double] z):
""" Set the volume fractions - wrapper of c++ function :cpapi:`CoolProp::AbstractState::set_volu_fractions` """
self.thisptr.set_volu_fractions(z)
## ----------------------------------------
## Limits
## ----------------------------------------
cpdef double Tmin(self):
""" Set the minimum temperature in K- wrapper of c++ function :cpapi:`CoolProp::AbstractState::Tmin` """
return self.thisptr.Tmin()
cpdef double Tmax(self):
""" Set the maximum temperature in K - wrapper of c++ function :cpapi:`CoolProp::AbstractState::Tmax` """
return self.thisptr.Tmax()
cpdef double pmax(self):
""" Set the maximum pressure in Pa - wrapper of c++ function :cpapi:`CoolProp::AbstractState::pmax` """
return self.thisptr.pmax()
cpdef double Ttriple(self):
""" Set the triple point temperature in K - wrapper of c++ function :cpapi:`CoolProp::AbstractState::Ttriple` """
return self.thisptr.Ttriple()
## ----------------------------------------
## Fluid property accessors
## ----------------------------------------
@@ -44,6 +68,15 @@ cdef class AbstractState:
cpdef double keyed_output(self, parameters iOutput) except *:
""" Update :cpapi:`CoolProp::AbstractState::keyed_output(parameters key)` """
return self.thisptr.keyed_output(iOutput)
cpdef double trivial_keyed_output(self, parameters iOutput) except *:
""" Update :cpapi:`CoolProp::AbstractState::trivial_keyed_output(parameters key)` """
return self.thisptr.trivial_keyed_output(iOutput)
cpdef double saturated_liquid_keyed_output(self, parameters iOutput) except *:
""" Update :cpapi:`CoolProp::AbstractState::saturated_liquid_keyed_output(parameters key)` """
return self.thisptr.saturated_liquid_keyed_output(iOutput)
cpdef double saturated_vapor_keyed_output(self, parameters iOutput) except *:
""" Update :cpapi:`CoolProp::AbstractState::saturated_vapor_keyed_output(parameters key)` """
return self.thisptr.saturated_vapor_keyed_output(iOutput)
cpdef double T(self) except *:
""" Get the temperature in K - wrapper of c++ function :cpapi:`CoolProp::AbstractState::T(void)` """
@@ -51,6 +84,9 @@ cdef class AbstractState:
cpdef double p(self) except *:
""" Get the pressure in Pa - wrapper of c++ function :cpapi:`CoolProp::AbstractState::p(void)` """
return self.thisptr.p()
cpdef double Q(self) except *:
""" Get the vapor quality in mol/mol - wrapper of c++ function :cpapi:`CoolProp::AbstractState::Q(void)` """
return self.thisptr.Q()
cpdef double rhomolar(self) except *:
""" Get the density in mol/m^3 - wrapper of c++ function :cpapi:`CoolProp::AbstractState::rhomolar(void)` """
return self.thisptr.rhomolar()
@@ -93,15 +129,36 @@ cdef class AbstractState:
cpdef double cvmass(self) except *:
""" Get the constant volume specific heat in J/kg/K - wrapper of c++ function :cpapi:`CoolProp::AbstractState::cvmass(void)` """
return self.thisptr.cvmass()
cpdef double tau(self) except *:
""" Get the reciprocal reduced temperature - wrapper of c++ function :cpapi:`CoolProp::AbstractState::tau(void)` """
return self.thisptr.tau()
cpdef double delta(self) except *:
""" Get the reduced density - wrapper of c++ function :cpapi:`CoolProp::AbstractState::delta(void)` """
return self.thisptr.delta()
cpdef double speed_sound(self) except *:
""" Get the speed of sound in m/s - wrapper of c++ function :cpapi:`CoolProp::AbstractState::speed_sound(void)` """
return self.thisptr.speed_sound()
cpdef double molar_mass(self) except *:
""" Get the molar mass in kg/mol - wrapper of c++ function :cpapi:`CoolProp::AbstractState::molar_mass(void)` """
return self.thisptr.molar_mass()
cpdef double acentric_factor(self) except *:
""" Get the acentric factor - wrapper of c++ function :cpapi:`CoolProp::AbstractState::acentric_factor(void)` """
return self.thisptr.molar_mass()
cpdef double gas_constant(self) except *:
""" Get the gas constant in J/mol/K - wrapper of c++ function :cpapi:`CoolProp::AbstractState::gas_constant(void)` """
return self.thisptr.gas_constant()
cpdef double viscosity(self) except *:
""" Get the viscosity in Pa-s - wrapper of c++ function :cpapi:`CoolProp::AbstractState::viscosity(void)` """
return self.thisptr.viscosity()
cpdef double conductivity(self) except *:
""" Get the thermal conductivity in W/m/K - wrapper of c++ function :cpapi:`CoolProp::AbstractState::conductivity(void)` """
return self.thisptr.conductivity()
cpdef double surface_tension(self) except *:
""" Get the surface tension N/m - wrapper of c++ function :cpapi:`CoolProp::AbstractState::surface_tension(void)` """
return self.thisptr.surface_tension()
cpdef double Prandtl(self) except *:
""" Get the Prandtl number - wrapper of c++ function :cpapi:`CoolProp::AbstractState::Prandtl(void)` """
return self.thisptr.Prandtl()
cpdef mole_fractions_liquid(self):
""" Get the mole fractions of the liquid phase - wrapper of c++ function :cpapi:`CoolProp::AbstractState::mole_fractions_liquid(void)` """
@@ -137,7 +194,7 @@ cdef class AbstractState:
return self.thisptr.first_two_phase_deriv_splined(Of, Wrt, Constant, x_end)
## ----------------------------------------
## Melting Line
## Ancillary curves
## ----------------------------------------
cpdef bint has_melting_line(self) except *:
@@ -146,7 +203,9 @@ cdef class AbstractState:
cpdef double melting_line(self, int param, int given, double value) except *:
""" Get values from the melting line - wrapper of c++ function :cpapi:`CoolProp::AbstractState::melting_line` """
return self.thisptr.melting_line(param, given, value)
cpdef double saturation_ancillary(self, constants_header.parameters param, int Q, constants_header.parameters given, double value) except *:
""" Get values from the saturation_ancillary - wrapper of c++ function :cpapi:`CoolProp::AbstractState::saturation_ancillary` """
return self.thisptr.saturation_ancillary(param, Q, given, value)
## ----------------------------------------
## Phase envelope

View File

@@ -19,11 +19,26 @@ cdef extern from "AbstractState.h" namespace "CoolProp":
## Constructor with fluid name
AbstractState(string FluidName) except +ValueError
void specify_phase(constants_header.phases phase) except +ValueError
void set_mole_fractions(vector[double]) except+ValueError
void set_mass_fractions(vector[double]) except+ValueError
void set_volu_fractions(vector[double]) except+ValueError
vector[long double] mole_fractions_liquid() except +ValueError
vector[long double] mole_fractions_vapor() except +ValueError
constants_header.phases phase() except +ValueError
void specify_phase(constants_header.phases phase) except +ValueError
void unspecify_phase() except +ValueError
string name() except +ValueError
bool clear()
## Limits
double Tmin()
double Tmax()
double pmax()
double Ttriple()
## Property updater
## Uses the indices in CoolProp for the input parameters
@@ -36,6 +51,7 @@ cdef extern from "AbstractState.h" namespace "CoolProp":
double rhomolar() except +ValueError
double rhomass() except +ValueError
double p() except +ValueError
double Q() except +ValueError
double hmolar() except +ValueError
double hmass() except +ValueError
double smolar() except +ValueError
@@ -49,37 +65,37 @@ cdef extern from "AbstractState.h" namespace "CoolProp":
double cvmolar() except +ValueError
double cvmass() except +ValueError
double speed_sound() except +ValueError
double keyed_output(constants_header.parameters) except+ValueError
double molar_mass() except+ValueError
double gas_constant() except+ValueError
double build_phase_envelope() except+ValueError
double tau() except +ValueError
double delta() except +ValueError
double viscosity() except+ValueError
double conductivity() except+ValueError
double surface_tension() except+ValueError
double Prandtl() except +ValueError
double keyed_output(constants_header.parameters) except+ValueError
double trivial_keyed_output(constants_header.parameters) except+ValueError
double saturated_liquid_keyed_output(constants_header.parameters) except+ValueError
double saturated_vapor_keyed_output(constants_header.parameters) except+ValueError
double molar_mass() except+ValueError
double acentric_factor() except+ValueError
double gas_constant() except+ValueError
long double first_partial_deriv(constants_header.parameters, constants_header.parameters, constants_header.parameters) except+ValueError
long double second_partial_deriv(constants_header.parameters, constants_header.parameters, constants_header.parameters, constants_header.parameters, constants_header.parameters) except+ValueError
long double first_saturation_deriv(constants_header.parameters, constants_header.parameters) except+ValueError
long double second_saturation_deriv(constants_header.parameters, constants_header.parameters, constants_header.parameters, constants_header.parameters) except+ValueError
double first_two_phase_deriv(constants_header.parameters Of, constants_header.parameters Wrt, constants_header.parameters Constant) except+ValueError
double second_two_phase_deriv(constants_header.parameters Of, constants_header.parameters Wrt1, constants_header.parameters Constant1, constants_header.parameters Wrt2, constants_header.parameters Constant2) except+ValueError
double first_two_phase_deriv_splined(constants_header.parameters Of, constants_header.parameters Wrt, constants_header.parameters Constant, double x_end) except+ValueError
void set_mole_fractions(vector[double]) except+ValueError
void set_mass_fractions(vector[double]) except+ValueError
void set_volu_fractions(vector[double]) except+ValueError
double melting_line(int,int,double) except+ValueError
bool has_melting_line() except+ValueError
double saturation_ancillary(constants_header.parameters, int, constants_header.parameters, double) except +ValueError
double build_phase_envelope() except+ValueError
void build_phase_envelope(string) except+ValueError
PhaseEnvelopeData get_phase_envelope_data() except+ValueError
vector[long double] mole_fractions_liquid() except +ValueError
vector[long double] mole_fractions_vapor() except +ValueError
# The static factory method for the AbstractState
cdef extern from "AbstractState.h" namespace "CoolProp::AbstractState":