From 226dc8ed09ddf57c3717c19ca1bc32e525375046 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Jun 2014 15:56:21 +0200 Subject: [PATCH] Added mass-based methods to python wrapper Signed-off-by: Ian Bell --- wrappers/Python/CoolProp5/AbstractState.pxd | 6 ++++ wrappers/Python/CoolProp5/AbstractState.pyx | 35 ++++++++++++++------- wrappers/Python/CoolProp5/CoolProp.pyx | 4 +-- wrappers/Python/setup2.py | 4 +-- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/wrappers/Python/CoolProp5/AbstractState.pxd b/wrappers/Python/CoolProp5/AbstractState.pxd index f132b0c2..3898d8a0 100644 --- a/wrappers/Python/CoolProp5/AbstractState.pxd +++ b/wrappers/Python/CoolProp5/AbstractState.pxd @@ -19,6 +19,12 @@ cdef class AbstractState: cpdef double smolar(self) cpdef double cpmolar(self) cpdef double cvmolar(self) + cpdef double rhomass(self) + cpdef double hmass(self) + cpdef double smass(self) + cpdef double cpmass(self) + cpdef double cvmass(self) cpdef double speed_sound(self) + cpdef double keyed_output(self, long) \ No newline at end of file diff --git a/wrappers/Python/CoolProp5/AbstractState.pyx b/wrappers/Python/CoolProp5/AbstractState.pyx index adc3f3f6..18f01809 100644 --- a/wrappers/Python/CoolProp5/AbstractState.pyx +++ b/wrappers/Python/CoolProp5/AbstractState.pyx @@ -13,7 +13,7 @@ cdef class AbstractState: del self.thisptr cpdef update(self, long ipair, double Value1, double Value2): - """ Update :cpapi:`AbstractState::update` """ + """ Update function - mirrors c++ function :cpapi:`AbstractState::update` """ self.thisptr.update(ipair, Value1, Value2) ## ---------------------------------------- @@ -25,30 +25,43 @@ cdef class AbstractState: return self.thisptr.keyed_output(iOutput) cpdef double T(self) except *: + """ Get the temperature in K - wrapper of c++ function :cpapi:`AbstractState::T` """ return self.thisptr.T() cpdef double p(self) except *: + """ Get the pressure in Pa - wrapper of c++ function :cpapi:`AbstractState::p` """ return self.thisptr.p() cpdef double rhomolar(self) except *: + """ Get the density in mol/m^3 - wrapper of c++ function :cpapi:`AbstractState::rhomolar` """ return self.thisptr.rhomolar() -# cpdef double rhomass(self) except *: -# return self.thisptr.rhomass() + cpdef double rhomass(self) except *: + """ Get the density in kg/m^3 - wrapper of c++ function :cpapi:`AbstractState::rhomass` """ + return self.thisptr.rhomass() cpdef double hmolar(self) except *: + """ Get the enthalpy in J/mol - wrapper of c++ function :cpapi:`AbstractState::hmolar` """ return self.thisptr.hmolar() cpdef double smolar(self) except *: + """ Get the entropy in J/mol/K - wrapper of c++ function :cpapi:`AbstractState::smolar` """ return self.thisptr.smolar() cpdef double cpmolar(self) except *: + """ Get the constant pressure specific heat in J/mol/K - wrapper of c++ function :cpapi:`AbstractState::cpmolar` """ return self.thisptr.cpmolar() cpdef double cvmolar(self) except *: + """ Get the constant volume specific heat in J/mol/K - wrapper of c++ function :cpapi:`AbstractState::cvmolar` """ return self.thisptr.cvmolar() -# cpdef double hmass(self) except *: -# return self.thisptr.hmass() -# cpdef double smass(self) except *: -# return self.thisptr.smass() -# cpdef double cpmass(self) except *: -# return self.thisptr.cpmass() -# cpdef double cvmass(self) except *: -# return self.thisptr.cvmass() + cpdef double hmass(self) except *: + """ Get the enthalpy in J/kg - wrapper of c++ function :cpapi:`AbstractState::hmass` """ + return self.thisptr.hmass() + cpdef double smass(self) except *: + """ Get the entropy in J/kg/K - wrapper of c++ function :cpapi:`AbstractState::smass` """ + return self.thisptr.smass() + cpdef double cpmass(self) except *: + """ Get the constant pressure specific heat in J/kg/K - wrapper of c++ function :cpapi:`AbstractState::cpmass` """ + return self.thisptr.cpmass() + cpdef double cvmass(self) except *: + """ Get the constant volume specific heat in J/kg/K - wrapper of c++ function :cpapi:`AbstractState::cvmass` """ + return self.thisptr.cvmass() cpdef double speed_sound(self) except *: + """ Get the speed of sound in m/s - wrapper of c++ function :cpapi:`AbstractState::speed_sound` """ return self.thisptr.speed_sound() \ No newline at end of file diff --git a/wrappers/Python/CoolProp5/CoolProp.pyx b/wrappers/Python/CoolProp5/CoolProp.pyx index be03e060..21a2a966 100644 --- a/wrappers/Python/CoolProp5/CoolProp.pyx +++ b/wrappers/Python/CoolProp5/CoolProp.pyx @@ -276,8 +276,8 @@ cdef dict paras = {iDmass : 'D', iCpmass : 'C', # iC0 : 'C0', iCvmass : 'O', - iV : 'V', - iL : 'L', + iviscosity : 'V', + iconductivity : 'L', iSmass : 'S', iUmass : 'U', # iDpdT : 'dpdT' diff --git a/wrappers/Python/setup2.py b/wrappers/Python/setup2.py index 5780bc70..d48e1e49 100644 --- a/wrappers/Python/setup2.py +++ b/wrappers/Python/setup2.py @@ -126,7 +126,7 @@ if __name__=='__main__': url='http://coolprop.sourceforge.net', description = """Open-source thermodynamic and transport properties database""", packages = ['CoolProp5','CoolProp5.Plots','CoolProp5.tests','CoolProp5.GUI'], - ext_modules = [CoolProp_module, constants_module], + ext_modules = [CoolProp_module, AbstractState_module, constants_module], package_dir = {'CoolProp5':'CoolProp5',}, #package_data = {'CoolProp5':['State.pxd','CoolProp.pxd','constants_header.pxd','include/*.h','include/rapidjson/*.h','include/rapidjson/internal/*.h','CoolPropBibTeXLibrary.bib']}, cmdclass={'build_ext': build_ext}, @@ -144,7 +144,7 @@ if __name__=='__main__': sys.path.pop(0) import CoolProp5.CoolProp as CP5 - print(CP5.PropsSI('P','T',300,'D',1e-10,'Water')) + print(CP5.PropsSI('L','T',300,'D',1e-10,'Water')) # #Clean up the include folder # shutil.rmtree(os.path.join('CoolProp','include'), ignore_errors = True)