diff --git a/include/CoolProp.h b/include/CoolProp.h index 9f2796a3..00444191 100644 --- a/include/CoolProp.h +++ b/include/CoolProp.h @@ -21,6 +21,10 @@ You might want to start by looking at CoolProp.h namespace CoolProp { + /// Return a value that does not depend on the thermodynamic state - this is a convenience function that does the call PropsSI(Output, "", 0, "", 0, FluidName) + /// @param FluidName The fluid name + /// @param Output The output parameter, one of "Tcrit","D","H",etc. + double Props1SI(const std::string &FluidName, const std::string &Output); /// Return a value that depends on the thermodynamic state /// @param Output The output parameter, one of "T","D","H",etc. /// @param Name1 The first state variable name, one of "T","D","H",etc. diff --git a/src/CoolProp.cpp b/src/CoolProp.cpp index c8cf07dc..02776101 100644 --- a/src/CoolProp.cpp +++ b/src/CoolProp.cpp @@ -408,6 +408,16 @@ double PropsSI(const char *Output, const char *Name1, double Prop1, const char * std::string _Output = Output, _Name1 = Name1, _Name2 = Name2, _FluidName = FluidName; return PropsSI(_Output,_Name1,Prop1,_Name2,Prop2,_FluidName, x); } +double Props1SI(const std::string &FluidName, const std::string &Output) +{ + std::string _FluidName = FluidName, empty_string = "", _Output = Output; + double val1 = PropsSI(_FluidName, empty_string, 0, empty_string, 0, _Output); + if (!ValidNumber(val1)){ + // Try with them flipped + val1 = PropsSI(_Output, empty_string, 0, empty_string, 0, _FluidName); + } + return val1; +} double PropsSI(const std::string &Output, const std::string &Name1, double Prop1, const std::string &Name2, double Prop2, const std::string &Ref) { std::string backend, fluid; diff --git a/src/CoolPropLib.cpp b/src/CoolPropLib.cpp index 3a8e8538..07dbe838 100644 --- a/src/CoolPropLib.cpp +++ b/src/CoolPropLib.cpp @@ -123,7 +123,7 @@ EXPORT_CODE double CONVENTION Props(const char *Output, char Name1, double Prop1 EXPORT_CODE double CONVENTION Props1SI(const char *FluidName, const char *Output) { std::string _Output = Output, _FluidName = FluidName; - return CoolProp::PropsSI(_Output, "", 0, "", 0, _FluidName); + return CoolProp::Props1SI(_FluidName, _Output); } EXPORT_CODE double CONVENTION PropsSI(const char *Output, const char *Name1, double Prop1, const char *Name2, double Prop2, const char * FluidName) { diff --git a/wrappers/Python/CoolProp5/CoolProp.pxd b/wrappers/Python/CoolProp5/CoolProp.pxd index cdf907d3..471fb2bf 100644 --- a/wrappers/Python/CoolProp5/CoolProp.pxd +++ b/wrappers/Python/CoolProp5/CoolProp.pxd @@ -31,10 +31,8 @@ cdef extern from "CoolProp.h" namespace "CoolProp": double _Props1SI "CoolProp::Props1SI"(string Ref, string Output) # double _IProps "CoolProp::IProps"(long Output, long Name1, double Prop1, long Name2, double Prop2, long Ref) - # double _Props "CoolProp::Props"(string Output, string Name1, double Prop1, string Name2, double Prop2, string Ref) # double _Props1 "CoolProp::Props1"(string Ref, string Output) - # string _get_fluid_param_string "CoolProp::get_fluid_param_string"(string ParamName, string FluidName) # long _get_Fluid_index "CoolProp::get_Fluid_index" (string Fluid) diff --git a/wrappers/Python/CoolProp5/CoolProp.pyx b/wrappers/Python/CoolProp5/CoolProp.pyx index b14bf6d4..a9b303b0 100644 --- a/wrappers/Python/CoolProp5/CoolProp.pyx +++ b/wrappers/Python/CoolProp5/CoolProp.pyx @@ -142,7 +142,7 @@ cpdef __Props_err2(in1, in2, in3, in4, in5, in6): else: raise ValueError("Props failed ungracefully :: inputs were:\"{in1:s}\",\"{in2:s}\",{in3:0.16e},\"{in4:s}\",{in5:0.16e},\"{in6:s}\"; please file a ticket at https://github.com/CoolProp/CoolProp/issues".format(in1=in1,in2=in2,in3=in3,in4=in4,in5=in5,in6=in6)) -# cpdef Props(in1, in2, in3, in4, in5, in6, in7 = None): +# cpdef Props(in1, in2, in3 = None, in4 = None, in5 = None, in6 = None, in7 = None): # """ # $$Props$$ # """ @@ -150,19 +150,20 @@ cpdef __Props_err2(in1, in2, in3, in4, in5, in6): # return _Props(in1, in2, in3, in4, in5, in6) # else: # return _Props(in1, in2, in3, in4, in5, in6, in7) -cpdef PropsSI(in1, in2, in3, in4, in5, in6, in7 = None): +cpdef PropsSI(in1, in2, in3 = None, in4 = None, in5 = None, in6 = None, in7 = None): """ $$PropsSI$$ """ cdef double val - if in7 is None: + if in3 is None and in4 is None and in5 is None and in6 is None and in7 is None: + val = _Props1SI(in1, in2) + return val + elif in7 is None: val = _PropsSI(in1, in2, in3, in4, in5, in6) if not iterable(val) and not _ValidNumber(val): __Props_err2(in1, in2, in3, in4, in5, in6) else: return val - elif in3 is None and in4 is None and in5 is None and in6 is None and in7 is None: - val = _Props1SI(in1, in2) else: return _PropsSI(in1, in2, in3, in4, in5, in6, in7) diff --git a/wrappers/Python/setup.py b/wrappers/Python/setup.py index 1c4dcffc..d8e30f0d 100644 --- a/wrappers/Python/setup.py +++ b/wrappers/Python/setup.py @@ -119,10 +119,10 @@ if __name__=='__main__': ) ) - CoolProp_module = Extension('CoolProp5.CoolProp', + CoolProp_module = Extension('CoolProp.CoolProp', [os.path.join('CoolProp5','CoolProp.' + cy_ext)] + sources, **common_args) - constants_module = Extension('CoolProp5.constants', + constants_module = Extension('CoolProp.constants', [os.path.join('CoolProp5','constants.' + cy_ext)], **common_args) @@ -135,7 +135,7 @@ if __name__=='__main__': ext_modules = cythonize(ext_modules) try: - setup (name = 'CoolProp5', + setup (name = 'CoolProp', version = version, # look above for the definition of version variable - don't modify it here author = "Ian Bell", author_email='ian.h.bell@gmail.com', @@ -143,7 +143,7 @@ if __name__=='__main__': description = """Open-source thermodynamic and transport properties database""", packages = find_packages(), ext_modules = ext_modules, - package_data = {'CoolProp5':['State.pxd', + package_data = {'CoolProp':['State.pxd', 'CoolProp.pxd', 'CoolPropBibTeXLibrary.bib'] + find_cpp_sources(os.path.join('include'), '*.h')}, classifiers = [