From 2f6b083aff63ba61822e6f75539366dc24a9760a Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Thu, 2 Oct 2014 14:21:15 +0200 Subject: [PATCH] Expose BibTeX all the way back to python wrapper Closes https://github.com/CoolProp/CoolProp/issues/164 Signed-off-by: Ian Bell --- src/Backends/Helmholtz/Fluids/FluidLibrary.h | 6 +-- wrappers/Python/CoolProp/CoolProp.pxd | 9 ++-- wrappers/Python/CoolProp/CoolProp.pyx | 45 ++++++++++---------- wrappers/Python/setup.py | 8 ++++ 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/Backends/Helmholtz/Fluids/FluidLibrary.h b/src/Backends/Helmholtz/Fluids/FluidLibrary.h index c9c36421..dc3b27f0 100644 --- a/src/Backends/Helmholtz/Fluids/FluidLibrary.h +++ b/src/Backends/Helmholtz/Fluids/FluidLibrary.h @@ -808,6 +808,9 @@ protected: /// Parse the thermal conductivity data void parse_thermal_conductivity(rapidjson::Value &conductivity, CoolPropFluid & fluid) { + // Load the BibTeX key + fluid.transport.BibTeX_conductivity = cpjson::get_string(conductivity,"BibTeX"); + // If it is using ECS, set ECS parameters and quit if (conductivity.HasMember("type") && !cpjson::get_string(conductivity, "type").compare("ECS")){ parse_ECS_conductivity(conductivity, fluid); @@ -830,9 +833,6 @@ protected: } } - // Load the BibTeX key - fluid.transport.BibTeX_conductivity = cpjson::get_string(conductivity,"BibTeX"); - // Load dilute conductivity term if (conductivity.HasMember("dilute")){ parse_dilute_conductivity(conductivity["dilute"], fluid); diff --git a/wrappers/Python/CoolProp/CoolProp.pxd b/wrappers/Python/CoolProp/CoolProp.pxd index f8c6deb6..9ba48844 100644 --- a/wrappers/Python/CoolProp/CoolProp.pxd +++ b/wrappers/Python/CoolProp/CoolProp.pxd @@ -32,13 +32,12 @@ cdef extern from "CoolProp.h" namespace "CoolProp": vector[double] _PropsSI "CoolProp::PropsSI"(string Output, string Name1, vector[double] Prop1, string Name2, vector[double] Prop2, string FluidName, vector[double] fractions) vector[double] _PropsSII "CoolProp::PropsSI"(string Output, string Name1, vector[double] Prop1, string Name2, vector[double] Prop2, string FluidName) string _get_global_param_string "CoolProp::get_global_param_string"(string ParamName) except + - int _get_debug_level "CoolProp::get_debug_level"() - void _set_debug_level "CoolProp::set_debug_level"(int level) - string _get_fluid_param_string "CoolProp::get_fluid_param_string"(string ParamName, string FluidName) - #long _get_parameter_index "CoolProp::get_parameter_index" (string param) - + int _get_debug_level "CoolProp::get_debug_level"() except + + void _set_debug_level "CoolProp::set_debug_level"(int level) except + + string _get_fluid_param_string "CoolProp::get_fluid_param_string"(string ParamName, string FluidName) except + # Convenience functions +# long _get_parameter_index "CoolProp::get_parameter_index" (string param) # int _IsFluidType "IsFluidType"(char* Ref, char* Type) # string _get_BibTeXKey "CoolProp::get_BibTeXKey"(string Ref, string key) # long _get_Fluid_index "CoolProp::get_Fluid_index" (string Fluid) diff --git a/wrappers/Python/CoolProp/CoolProp.pyx b/wrappers/Python/CoolProp/CoolProp.pyx index aa98be71..fb837dc3 100644 --- a/wrappers/Python/CoolProp/CoolProp.pyx +++ b/wrappers/Python/CoolProp/CoolProp.pyx @@ -252,28 +252,29 @@ cpdef string get_REFPROPname(string Fluid): """ return _get_fluid_param_string(Fluid,'REFPROP_name') -# cpdef string get_BibTeXKey(str Fluid, str key): -# """ -# Return the BibTeX key for the given fluid. -# -# The possible keys are -# -# * ``EOS`` -# * ``CP0`` -# * ``VISCOSITY`` -# * ``CONDUCTIVITY`` -# * ``ECS_LENNARD_JONES`` -# * ``ECS_FITS`` -# * ``SURFACE_TENSION`` -# -# BibTeX keys refer to the BibTeX file in the trunk/CoolProp folder -# -# Returns -# ------- -# key, string -# empty string if Fluid not in CoolProp, "Bad key" if key is invalid -# """ -# return _get_BibTeXKey(Fluid, key) +cpdef string get_BibTeXKey(str Fluid, str key): + """ + Return the BibTeX key for the given fluid. + + The possible keys are + + * ``EOS`` + * ``CP0`` + * ``VISCOSITY`` + * ``CONDUCTIVITY`` + * ``ECS_LENNARD_JONES`` + * ``ECS_FITS`` + * ``SURFACE_TENSION`` + * ``MELTING_LINE`` + + BibTeX keys refer to the BibTeX file in the trunk/CoolProp folder + + Returns + ------- + key, string + empty string if Fluid not in CoolProp, "Bad key" if key is invalid + """ + return _get_fluid_param_string(Fluid, "BibTeX-"+key) cpdef string get_errstr(): """ diff --git a/wrappers/Python/setup.py b/wrappers/Python/setup.py index 2ec7468b..7889b939 100644 --- a/wrappers/Python/setup.py +++ b/wrappers/Python/setup.py @@ -23,6 +23,14 @@ if __name__=='__main__': import subprocess, shutil, os, sys, glob + + # ****************************** + # CMAKE OPTIONS + # ****************************** + + # Example using CMake to build static library: + # python setup.py install --cmake-compiler vc9 --cmake-bitness 64 + if '--cmake-compiler' in sys.argv: i = sys.argv.index('--cmake-compiler') sys.argv.pop(i)