From 8df7e56dd45c016f5d724372141e56d6be682b91 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Fri, 2 Jan 2015 13:45:54 +0100 Subject: [PATCH 01/27] First test to make the the buildbot send messages --- dev/buildbot/master/master.cfg | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/dev/buildbot/master/master.cfg b/dev/buildbot/master/master.cfg index 7c0fd27d..821cd8a0 100644 --- a/dev/buildbot/master/master.cfg +++ b/dev/buildbot/master/master.cfg @@ -204,7 +204,7 @@ def gitModeInput(props): return 'full' else: return 'incremental' - + @properties.renderer def masterdestLocation(props): """ @@ -515,7 +515,7 @@ def excel_slave(gitMode = 'incremental'): # Upload the files factory.addStep(DirectoryUpload(slavesrc="bin",masterdest=masterdestLocation,url="MicrosoftExcel",compress="bz2")) return factory - + def julia_builder(gitMode = 'incremental'): """ """ @@ -1211,9 +1211,17 @@ authz_cfg=authz.Authz( c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg)) from buildbot.status import mail -mn = mail.MailNotifier(fromaddr="buildbot@coolprop.org", - mode = ('problem',) - ) +#mn = mail.MailNotifier(fromaddr="buildbot@coolprop.org", +# mode = ('problem',) +# ) +mn = status.MailNotifier(fromaddr="buildbot@coolprop.dreamhosters.com", + sendToInterestedUsers=False, + mode=('all',), + extraRecipients=["coolprop@jorrit.org"],#,"ian.h.bell@gmail.com"], + useTls=True, relayhost="coolprop.dreamhosters.com", + smtpPort=587, smtpUser=email_auth['user'], + smtpPassword=email_auth['pass']) + c['status'].append(mn) ####### PROJECT IDENTITY From 7901206ae47648589b75d02b41946eeea40f1b13 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Fri, 2 Jan 2015 13:58:53 +0100 Subject: [PATCH 02/27] Added email authentication and clean function in script --- dev/buildbot/master/master.cfg | 3 ++- dev/scripts/buildbot.sh | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dev/buildbot/master/master.cfg b/dev/buildbot/master/master.cfg index 821cd8a0..c9035425 100644 --- a/dev/buildbot/master/master.cfg +++ b/dev/buildbot/master/master.cfg @@ -1211,13 +1211,14 @@ authz_cfg=authz.Authz( c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg)) from buildbot.status import mail +from buildbot_private email_auth #mn = mail.MailNotifier(fromaddr="buildbot@coolprop.org", # mode = ('problem',) # ) mn = status.MailNotifier(fromaddr="buildbot@coolprop.dreamhosters.com", sendToInterestedUsers=False, mode=('all',), - extraRecipients=["coolprop@jorrit.org"],#,"ian.h.bell@gmail.com"], + extraRecipients=["coolprop@jorrit.org"], #,"ian.h.bell@gmail.com"], useTls=True, relayhost="coolprop.dreamhosters.com", smtpPort=587, smtpUser=email_auth['user'], smtpPassword=email_auth['pass']) diff --git a/dev/scripts/buildbot.sh b/dev/scripts/buildbot.sh index 4beddbc7..c9c81592 100644 --- a/dev/scripts/buildbot.sh +++ b/dev/scripts/buildbot.sh @@ -23,23 +23,30 @@ function git_pull { function stop { buildbot stop /home/$USER/buildbot/server-master/ } +function clean { + rm -f /home/$USER/buildbot/server-master/buildbot_private.pyc +} # # Check for input CMD="$1" if [ "$CMD" = "restart" ]; then stop git_pull + clean start elif [ "$CMD" = "reconfig" ]; then git_pull + clean reconfig elif [ "$CMD" = "start" ]; then git_pull + clean start elif [ "$CMD" = "stop" ]; then stop else git_pull + clean start fi # From bfe346debc57de15c481873fc325439abe3d5e01 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Fri, 2 Jan 2015 14:05:50 +0100 Subject: [PATCH 03/27] Just a typo in master.cfg --- dev/buildbot/master/master.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/buildbot/master/master.cfg b/dev/buildbot/master/master.cfg index c9035425..0c10cc7b 100644 --- a/dev/buildbot/master/master.cfg +++ b/dev/buildbot/master/master.cfg @@ -1211,7 +1211,7 @@ authz_cfg=authz.Authz( c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg)) from buildbot.status import mail -from buildbot_private email_auth +from buildbot_private import email_auth #mn = mail.MailNotifier(fromaddr="buildbot@coolprop.org", # mode = ('problem',) # ) From cee44c0d70cad28fb48b741bac13152573313184 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Fri, 2 Jan 2015 14:06:32 +0100 Subject: [PATCH 04/27] more typos in master.cfg --- dev/buildbot/master/master.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/buildbot/master/master.cfg b/dev/buildbot/master/master.cfg index 0c10cc7b..8c5e87df 100644 --- a/dev/buildbot/master/master.cfg +++ b/dev/buildbot/master/master.cfg @@ -1215,7 +1215,7 @@ from buildbot_private import email_auth #mn = mail.MailNotifier(fromaddr="buildbot@coolprop.org", # mode = ('problem',) # ) -mn = status.MailNotifier(fromaddr="buildbot@coolprop.dreamhosters.com", +mn = mail.MailNotifier(fromaddr="buildbot@coolprop.dreamhosters.com", sendToInterestedUsers=False, mode=('all',), extraRecipients=["coolprop@jorrit.org"], #,"ian.h.bell@gmail.com"], From c646445014716ba3aefff9bae3c124ceb9f7b7a6 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Fri, 2 Jan 2015 15:04:00 +0100 Subject: [PATCH 05/27] Buildbot sends emails, closes #329 --- dev/buildbot/master/master.cfg | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/dev/buildbot/master/master.cfg b/dev/buildbot/master/master.cfg index 8c5e87df..b5a67e2f 100644 --- a/dev/buildbot/master/master.cfg +++ b/dev/buildbot/master/master.cfg @@ -1212,19 +1212,18 @@ c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg)) from buildbot.status import mail from buildbot_private import email_auth -#mn = mail.MailNotifier(fromaddr="buildbot@coolprop.org", -# mode = ('problem',) -# ) mn = mail.MailNotifier(fromaddr="buildbot@coolprop.dreamhosters.com", sendToInterestedUsers=False, - mode=('all',), - extraRecipients=["coolprop@jorrit.org"], #,"ian.h.bell@gmail.com"], - useTls=True, relayhost="coolprop.dreamhosters.com", + mode=('problem',), + extraRecipients=["coolprop@jorrit.org"], "ian.h.bell@gmail.com"], + #useTls=True, + relayhost="homie.mail.dreamhost.com", smtpPort=587, smtpUser=email_auth['user'], smtpPassword=email_auth['pass']) c['status'].append(mn) + ####### PROJECT IDENTITY # the 'title' string will appear at the top of this buildbot From 303ae1148f504190aea4f9e93942d7199a914611 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Fri, 2 Jan 2015 15:06:35 +0100 Subject: [PATCH 06/27] ... and fixing #329 once more. --- dev/buildbot/master/master.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/buildbot/master/master.cfg b/dev/buildbot/master/master.cfg index b5a67e2f..ed88d83d 100644 --- a/dev/buildbot/master/master.cfg +++ b/dev/buildbot/master/master.cfg @@ -1214,8 +1214,8 @@ from buildbot.status import mail from buildbot_private import email_auth mn = mail.MailNotifier(fromaddr="buildbot@coolprop.dreamhosters.com", sendToInterestedUsers=False, - mode=('problem',), - extraRecipients=["coolprop@jorrit.org"], "ian.h.bell@gmail.com"], + mode=('problem'), + extraRecipients=["coolprop@jorrit.org", "ian.h.bell@gmail.com"], #useTls=True, relayhost="homie.mail.dreamhost.com", smtpPort=587, smtpUser=email_auth['user'], From 40030df8ed0af01a290c9327e991625640e6387d Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Fri, 2 Jan 2015 15:50:36 +0100 Subject: [PATCH 07/27] Trying to force a build error in Fortran, testing the fix for #329 --- wrappers/Fortran/detailed_example/cool_fortran_bind.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 b/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 index 8437cdc4..31e23854 100644 --- a/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 +++ b/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 @@ -15,7 +15,7 @@ program hello !--------------------- T = 300 ! Temperature [K] - Q = 0 ! Quality [-] + Q = -1 ! Quality [-] out1 = "D"//CHAR(0) ! String with of the output Property n1 = "T"//CHAR(0) ! String with of the input Property #1 From 2520b6051202383d3aa32fe83b8aaadbb4975ec5 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Fri, 2 Jan 2015 15:53:15 +0100 Subject: [PATCH 08/27] Breaking the build process for the Fortran wrapper, see #329 --- wrappers/Fortran/detailed_example/cool_fortran_bind.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 b/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 index 31e23854..35bea5ac 100644 --- a/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 +++ b/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 @@ -15,7 +15,7 @@ program hello !--------------------- T = 300 ! Temperature [K] - Q = -1 ! Quality [-] + !Q = 0 ! Quality [-] out1 = "D"//CHAR(0) ! String with of the output Property n1 = "T"//CHAR(0) ! String with of the input Property #1 From f105af24fc272bc33b610b2bac0b4d2704199b42 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Fri, 2 Jan 2015 15:57:18 +0100 Subject: [PATCH 09/27] it simply won't break, see #329 --- wrappers/Fortran/detailed_example/cool_fortran_bind.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 b/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 index 35bea5ac..9fa15629 100644 --- a/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 +++ b/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 @@ -6,7 +6,7 @@ program hello implicit none !Initialize the variables used in the example - double precision T, Q + double precision T character(LEN=32) fluid, out1, n1, n2 double precision dens1, dens2 @@ -15,7 +15,7 @@ program hello !--------------------- T = 300 ! Temperature [K] - !Q = 0 ! Quality [-] + Q = 0 ! Quality [-] out1 = "D"//CHAR(0) ! String with of the output Property n1 = "T"//CHAR(0) ! String with of the input Property #1 From 2fe68a9eb876c4f042ef5a645092af24c3ac407e Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Fri, 2 Jan 2015 16:00:35 +0100 Subject: [PATCH 10/27] It works, just received an email from the buildbot... see #329 --- wrappers/Fortran/detailed_example/cool_fortran_bind.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 b/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 index 9fa15629..8437cdc4 100644 --- a/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 +++ b/wrappers/Fortran/detailed_example/cool_fortran_bind.f90 @@ -6,7 +6,7 @@ program hello implicit none !Initialize the variables used in the example - double precision T + double precision T, Q character(LEN=32) fluid, out1, n1, n2 double precision dens1, dens2 From 5db8338ceb258bbe086d3314b5f50a9b6da5cd28 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Sun, 4 Jan 2015 00:36:07 -0500 Subject: [PATCH 11/27] Make import of _constant be absolute import for py3.x; See #388 Signed-off-by: Ian Bell --- wrappers/Python/generate_constants_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/Python/generate_constants_module.py b/wrappers/Python/generate_constants_module.py index 6cc0f322..6ab57c89 100644 --- a/wrappers/Python/generate_constants_module.py +++ b/wrappers/Python/generate_constants_module.py @@ -61,7 +61,7 @@ def generate_cython(data): # Write the PY implementation file py_output_file = open('CoolProp/constants.py','w') - py_output_file.write('# This file is automatically generated by the generate_constants_module.py script in wrappers/Python.\n# DO NOT MODIFY THE CONTENTS OF THIS FILE!\nimport _constants\n\n') + py_output_file.write('# This file is automatically generated by the generate_constants_module.py script in wrappers/Python.\n# DO NOT MODIFY THE CONTENTS OF THIS FILE!\nfrom __future__ import absolute_import\n\nfrom . import _constants\n\n') for enum_key, entries in data: for param in entries: param = param.strip() From c60ee1d567e5654b113c51055c6a6d8adf1a9dc3 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Sun, 4 Jan 2015 16:15:04 +0100 Subject: [PATCH 12/27] This is a preliminary fix for the issue #387 because I need the code. I hope this does not break things for others. --- wrappers/Python/CoolProp/CoolProp.pyx | 342 +++++++++++++------------- 1 file changed, 171 insertions(+), 171 deletions(-) diff --git a/wrappers/Python/CoolProp/CoolProp.pyx b/wrappers/Python/CoolProp/CoolProp.pyx index 12929415..cef74783 100644 --- a/wrappers/Python/CoolProp/CoolProp.pyx +++ b/wrappers/Python/CoolProp/CoolProp.pyx @@ -27,7 +27,7 @@ cimport constants_header cdef bint iterable(object a): """ - If numpy is supported, this function retuns true if the argument is a + If numpy is supported, this function retuns true if the argument is a numpy array or another iterable, otherwise just checks if list or tuple """ if _numpy_supported: @@ -37,77 +37,77 @@ cdef bint iterable(object a): cdef ndarray_or_iterable(object input): if _numpy_supported: - return np.array(input) + return np.squeeze(np.array(input)) else: return input include "HumidAirProp.pyx" include "AbstractState.pyx" - + def set_reference_state(string FluidName, *args): """ Accepts one of two signatures: - + Type #1 (A Python wrapper of :cpapi:`CoolProp::set_reference_stateS`): - - set_reference_state(FluidName,reference_state) - + + set_reference_state(FluidName,reference_state) + FluidName The name of the fluid - param reference_state The reference state to use, one of - + param reference_state The reference state to use, one of + ========== =========================================== ``IIR`` (h=200 kJ/kg, s=1 kJ/kg/K at 0C sat. liq.) ``ASHRAE`` (h=0,s=0 @ -40C sat liq) ``NBP`` (h=0,s=0 @ 1.0 bar sat liq.) ========== =========================================== - + Type #2 (A Python wrapper of :cpapi:`CoolProp::set_reference_stateD`): - + set_reference_state(FluidName,T0,rho0,h0,s0) - + ``FluidName`` The name of the fluid - + ``T0`` The temperature at the reference point [K] - + ``rho0`` The density at the reference point [kg/m^3] - + ``h0`` The enthalpy at the reference point [J/kg] - + ``s0`` The entropy at the reference point [J/kg] """ - + cdef bytes _param cdef int retval - + if len(args) == 1: _set_reference_stateS(FluidName, args[0]) elif len(args) == 4: _set_reference_stateD(FluidName, args[0], args[1], args[2], args[3]) else: raise ValueError('Invalid number of inputs') - + # cpdef long get_Fluid_index(string_like Fluid): # """ # Gets the integer index of the given CoolProp fluid (primarily for use in ``IProps`` function) # """ # return _get_Fluid_index(Fluid) -# +# # cpdef double IProps(long iOutput, long iInput1, double Input1, long iInput2, double Input2, long iFluid) except *: # """ # This is a more computationally efficient version of the Props() function as it uses integer keys for the input and output codes as well as the fluid index for the fluid. It can only be used with CoolProp fluids. An example of how it should be used:: -# +# # # These should be run once in the header of your file # from CoolProp.CoolProp import IProps, get_Fluid_index # from CoolProp import param_constants # iPropane = get_Fluid_index('Propane') -# +# # # This should be run using the cached values - much faster ! # IProps(param_constants.iP,param_constants.iT,0.8*Tc,param_constants.iQ,1,iPropane) -# +# # The reason that this function is significantly faster than Props is that it skips all the string comparisons which slows down the Props function quite a lot. At the C++ level, IProps doesn't use any strings and operates on integers and floating point values # """ # cdef double val = _IProps(iOutput, iInput1, Input1, iInput2, Input2, iFluid) -# +# # if math.isinf(val) or math.isnan(val): # err_string = _get_global_param_string('errstring') # if not len(err_string) == 0: @@ -129,7 +129,7 @@ cpdef tuple generate_update_pair(constants_header.parameters key1, double value1 cpdef string get_config_as_json_string(): """ Obtain a json formulation of the internal configuration in CoolProp - + Values can be set by passing a modified json library (converted to string) to set_config_as_json_string """ return _get_config_as_json_string() @@ -137,36 +137,36 @@ cpdef string get_config_as_json_string(): cpdef set_config_as_json_string(string s): """ Set the internal configuration in CoolProp from a json data string - + Current state can be obtained by calling get_config_as_json_string """ _set_config_as_json_string(s) - + cpdef int get_parameter_index(string key): return _get_parameter_index(key) - + cpdef int get_phase_index(string key): return _get_phase_index(key) cpdef string get_parameter_information(int key, string info): return _get_parameter_information(key, info) - + cpdef string get_mixture_binary_pair_data(CAS1, CAS2, key) except *: return _get_mixture_binary_pair_data(CAS1, CAS2, key) cpdef get_global_param_string(string param): return _get_global_param_string(param) - + cpdef get_fluid_param_string(string fluid, string param): return _get_fluid_param_string(fluid, param) - + cpdef __Props_err1(fcn, in1,in2): errstr = _get_global_param_string('errstring') if not len(errstr) == 0: raise ValueError("{err:s} :: inputs were :\"{in1:s}\",\"{in2:s}\"".format(err= errstr,in1=in1,in2=in2)) else: raise ValueError("{fcn:s} failed ungracefully with inputs:\"{in1:s}\",\"{in2:s}\"; please file a ticket at https://github.com/CoolProp/CoolProp/issues".format(fcn=fcn, in1=in1,in2=in2)) - + cpdef __Props_err2(fcn, in1, in2, in3, in4, in5, in6): errstr = _get_global_param_string('errstring') if not len(errstr) == 0: @@ -177,13 +177,13 @@ cpdef __Props_err2(fcn, in1, in2, in3, in4, in5, in6): cpdef Props(in1, in2, in3 = None, in4 = None, in5 = None, in6 = None): """ A Python wrapper of :cpapi:`CoolProp::Props`. This function is deprecated, use PropsSI instead - """ + """ import warnings dep_warning = "Props() function is deprecated; Use the PropsSI() function" warnings.warn_explicit(dep_warning, category=UserWarning, filename='CoolProp.pyx', lineno = -1) - if len(in2) != 1: + if len(in2) != 1: raise ValueError('Length of input name #1 must be 1 character') - if len(in4) != 1: + if len(in4) != 1: raise ValueError('Length of input name #2 must be 1 character') cdef char* c1 = (in2) cdef char* c2 = (in4) @@ -196,7 +196,7 @@ cpdef Props(in1, in2, in3 = None, in4 = None, in5 = None, in6 = None): cpdef PhaseSI(in1, in2, in3, in4, in5): """ A Python wrapper of C++ function :cpapi:`CoolProp::PhaseSI` - + Does not support vectorization of the inputs like PropsSI """ return _PhaseSI(in1, in2, in3, in4, in5) @@ -204,13 +204,13 @@ cpdef PhaseSI(in1, in2, in3, in4, in5): cpdef PropsSI(in1, in2, in3 = None, in4 = None, in5 = None, in6 = None, in7 = None): """ A Python wrapper of C++ function :cpapi:`CoolProp::PropsSI` . - """ + """ cdef vector[string] vin1 cdef vector[double] fractions, vval1, vval2 cdef double val cdef string backend, fluid, delimitedfluids cdef bool is_iterable1, is_iterable3, is_iterable5 - + # Two parameter inputs if in3 is None and in4 is None and in5 is None and in6 is None and in7 is None: val = _Props1SI(in1, in2) @@ -252,24 +252,24 @@ cpdef PropsSI(in1, in2, in3 = None, in4 = None, in5 = None, in6 = None, in7 = No vval1[0] = in3 vval1.resize(1) vval2[0] = in5 - + # Extract the backend and the fluid from the input string _extract_backend(in6, backend, fluid) - + # Extract the fractions fractions.push_back(1.0) delimitedfluids = _extract_fractions(fluid, fractions) - + # Extract the fluids fluids = delimitedfluids.split('&') # Call the function - this version takes iterables outmat = _PropsSImulti(vin1, in2, vval1, in4, vval2, backend, fluids, fractions) - + # Check that we got some output if outmat.empty(): raise ValueError(_get_global_param_string('errstring')) - + return ndarray_or_iterable(outmat) else: # This version takes doubles @@ -282,22 +282,22 @@ cpdef PropsSI(in1, in2, in3 = None, in4 = None, in5 = None, in6 = None, in7 = No cpdef list FluidsList(): """ Return a list of strings of all fluid names - + Returns ------- FluidsList : list of strings of fluid names All the fluids that are included in CoolProp - + Notes ----- - + Here is an example:: - + In [0]: from CoolProp.CoolProp import FluidsList - + In [1]: FluidsList() - - """ + + """ return _get_global_param_string("FluidsList").split(',') cpdef get_aliases(string Fluid): @@ -310,17 +310,17 @@ cpdef get_aliases(string Fluid): cpdef string get_REFPROPname(string Fluid): """ Return the REFPROP compatible name for the fluid - - Some fluids do not use the REFPROP name. For instance, + + Some fluids do not use the REFPROP name. For instance, ammonia is R717, and propane is R290. You can still can still call CoolProp using the name ammonia or R717, but REFPROP requires that you use a limited subset of names. Therefore, this function that returns the REFPROP compatible name. To then use this to call REFPROP, you would do something like:: - + In [0]: from CoolProp.CoolProp import get_REFPROPname, PropsSI - + In [1]: get_REFPROPname('R290') - + In [2]: PropsSI('D', 'T', 300, 'P', 300, Fluid) """ return _get_fluid_param_string(Fluid,'REFPROP_name') @@ -328,9 +328,9 @@ cpdef string get_REFPROPname(string Fluid): cpdef string get_BibTeXKey(string Fluid, string key): """ Return the BibTeX key for the given fluid. - + The possible keys are - + * ``EOS`` * ``CP0`` * ``VISCOSITY`` @@ -339,9 +339,9 @@ cpdef string get_BibTeXKey(string Fluid, string key): * ``ECS_FITS`` * ``SURFACE_TENSION`` * ``MELTING_LINE`` - + BibTeX keys refer to the BibTeX file in the trunk/CoolProp folder - + Returns ------- key, string @@ -354,16 +354,16 @@ cpdef string get_errstr(): Return the current error string """ return _get_global_param_string("errstring") - + cpdef set_debug_level(int level): """ Set the current debug level as integer in the range [0,10] - + Parameters ---------- level : int - If level is 0, no output will be written to screen, if >0, - some output will be written to screen. The larger level is, + If level is 0, no output will be written to screen, if >0, + some output will be written to screen. The larger level is, the more verbose the output will be """ _set_debug_level(level) @@ -371,12 +371,12 @@ cpdef set_debug_level(int level): cpdef int get_debug_level(): """ Return the current debug level as integer - + Returns ------- level : int - If level is 0, no output will be written to screen, if >0, - some output will be written to screen. The larger level is, + If level is 0, no output will be written to screen, if >0, + some output will be written to screen. The larger level is, the more verbose the output will be """ return _get_debug_level() @@ -384,9 +384,9 @@ cpdef int get_debug_level(): # cpdef bint IsFluidType(string Fluid, string Type): # """ # Check if a fluid is of a given type -# +# # Valid types are: -# +# # * ``Brine`` # * ``PseudoPure`` (or equivalently ``PseudoPureFluid``) # * ``PureFluid`` @@ -397,7 +397,7 @@ cpdef int get_debug_level(): # return True # else: # return False -# +# cdef toSI(constants_header.parameters key, double val): """ @@ -432,34 +432,34 @@ cdef dict paras_inverse = {v:k for k,v in paras.iteritems()} cdef class State: """ A class that contains all the code that represents a thermodynamic state - + .. warning:: - + This class is deprecated. You should use :py:class:`CoolProp.AbstractState` instead - + The motivation for this class is that it is useful to be able to define the state once using whatever state inputs you like and then be able to calculate other thermodynamic properties with the minimum of computational work. - + Let's suppose that you have inputs of pressure and temperature and you want to calculate the enthalpy and pressure. Since the Equations of State are all explicit in temperature and density, each time you call something like:: - + h = PropsSI('H','T',T','P',P,Fluid) s = PropsSI('S','T',T','P',P,Fluid) - + the solver is used to carry out the T-P flash calculation. And if you wanted entropy as well you could either intermediately calculate ``T``, ``rho`` and then use ``T``, ``rho`` in the EOS in a manner like:: - + rho = PropsSI('D','T',T','P',P,Fluid) h = PropsSI('H','T',T','D',rho,Fluid) s = PropsSI('S','T',T','D',rho,Fluid) - + Instead in this class all that is handled internally. So the call to update sets the internal variables in the most computationally efficient way possible """ - + def __init__(self, object Fluid, dict StateDict, object phase = None, backend = None): """ Parameters @@ -473,7 +473,7 @@ cdef class State: The CoolProp backend that should be used, one of "HEOS" (default), "REFPROP", "INCOMP", "BRINE", etc. """ cdef string _Fluid = Fluid - + if _Fluid == 'none': return else: @@ -481,23 +481,23 @@ cdef class State: backend, Fluid = Fluid.split(u'::',1) elif backend is None: backend = u'?' - + self.set_Fluid(Fluid, backend) self.Fluid = _Fluid - + # Parse the inputs provided self.update(StateDict) - + self.phase = phase if phase is None: self.phase = u'??'.encode('ascii') - + # Set the phase flag if self.phase.lower() == 'gas': self.pAS.specify_phase(constants_header.iphase_gas) elif self.phase.lower() == 'liquid': self.pAS.specify_phase(constants_header.iphase_liquid) - + # def __reduce__(self): # d={} # d['Fluid']=self.Fluid @@ -505,9 +505,9 @@ cdef class State: # d['rho']=self.rho_ # d['phase'] = self.phase # return rebuildState,(d,) - + cpdef set_Fluid(self, string Fluid, string backend): - + cdef object _Fluid = Fluid cdef object _backend = backend new_fluid = [] @@ -523,11 +523,11 @@ cdef class State: fracs = [1] self.pAS = AbstractState(_backend, _Fluid) self.pAS.set_mole_fractions(fracs) - + cpdef update_ph(self, double p, double h): """ Use the pressure and enthalpy directly - + Parameters ---------- p: float @@ -538,11 +538,11 @@ cdef class State: self.pAS.update(HmassP_INPUTS, h*1000, p*1000) self.T_ = self.pAS.T() self.rho_ = self.pAS.rhomass() - + cpdef update_Trho(self, double T, double rho): """ Just use the temperature and density directly for speed - + Parameters ---------- T: float @@ -553,22 +553,22 @@ cdef class State: self.T_ = T self.rho_ = rho self.pAS.update(DmassT_INPUTS, rho, T) - + cpdef update(self, dict params): """ Parameters - params, dictionary + params, dictionary A dictionary of terms to be updated, with keys equal to single-char inputs to the Props function, for instance ``dict(T=298, P = 101.325)`` would be one standard atmosphere """ - + # Convert to integer_pair input - + cdef double p, val1, val2, o1 = 0, o2 = 0 cdef long iInput1, iInput2 cdef bytes errstr cdef constants_header.input_pairs input_pair - + # Convert inputs to input pair items = list(params.items()) key1 = paras_inverse[items[0][0]] @@ -576,33 +576,33 @@ cdef class State: # Convert to SI units val1 = toSI(key1, items[0][1]) val2 = toSI(key2, items[1][1]) - + input_pair = _generate_update_pair(key1, val1, key2, val2, o1, o2) self.pAS.update(input_pair, o1, o2); - + self.T_ = self.pAS.T() self.p_ = self.pAS.p()/1000; self.rho_ = self.pAS.rhomass() - + cpdef long Phase(self) except *: """ Returns an integer flag for the phase of the fluid, where the flag value is one of iLiquid, iSupercritical, iGas, iTwoPhase - + These constants are defined in the phase_constants module, and are imported into this module """ - + if self.is_CPFluid: return self.pAS.phase() else: raise NotImplementedError("Phase not defined for fluids other than CoolProp fluids") - - cpdef double Props(self, constants_header.parameters iOutput) except *: + + cpdef double Props(self, constants_header.parameters iOutput) except *: if iOutput<0: - raise ValueError('Your output is invalid') + raise ValueError('Your output is invalid') return self.pAS.keyed_output(iOutput) - + cpdef double get_Q(self) except *: """ Get the quality [-] """ return self.Props(iQ) @@ -610,7 +610,7 @@ cdef class State: """ The quality [-] """ def __get__(self): return self.get_Q() - + cpdef double get_MM(self) except *: """ Get the mole mass [kg/kmol] or [g/mol] """ return self.Props(imolar_mass)*1000 @@ -618,55 +618,55 @@ cdef class State: """ The molar mass [kg/kmol] or [g/mol] """ def __get__(self): return self.get_MM() - + cpdef double get_rho(self) except *: - """ Get the density [kg/m^3] """ + """ Get the density [kg/m^3] """ return self.Props(iDmass) property rho: """ The density [kg/m^3] """ def __get__(self): return self.Props(iDmass) - + cpdef double get_p(self) except *: - """ Get the pressure [kPa] """ + """ Get the pressure [kPa] """ return self.Props(iP)/1000 property p: """ The pressure [kPa] """ def __get__(self): return self.get_p() - - cpdef double get_T(self) except *: + + cpdef double get_T(self) except *: """ Get the temperature [K] """ return self.Props(iT) property T: """ The temperature [K] """ def __get__(self): return self.get_T() - - cpdef double get_h(self) except *: + + cpdef double get_h(self) except *: """ Get the specific enthalpy [kJ/kg] """ return self.Props(iHmass)/1000 property h: """ The specific enthalpy [kJ/kg] """ def __get__(self): return self.get_h() - - cpdef double get_u(self) except *: + + cpdef double get_u(self) except *: """ Get the specific internal energy [kJ/kg] """ return self.Props(iUmass)/1000 property u: """ The internal energy [kJ/kg] """ def __get__(self): return self.get_u() - - cpdef double get_s(self) except *: + + cpdef double get_s(self) except *: """ Get the specific enthalpy [kJ/kg/K] """ return self.Props(iSmass)/1000 property s: """ The specific enthalpy [kJ/kg/K] """ def __get__(self): return self.get_s() - + cpdef double get_cp0(self) except *: """ Get the specific heat at constant pressure for the ideal gas [kJ/kg/K] """ return self.Props(iCp0mass)/1000 @@ -674,27 +674,27 @@ cdef class State: """ The ideal-gas specific heat at constant pressure [kJ/kg/K] """ def __get__(self): return self.get_cp0() - - cpdef double get_cp(self) except *: + + cpdef double get_cp(self) except *: """ Get the specific heat at constant pressure [kJ/kg/K] """ return self.Props(iCpmass)/1000 property cp: """ The specific heat at constant pressure [kJ/kg/K] """ def __get__(self): return self.get_cp() - - cpdef double get_cv(self) except *: + + cpdef double get_cv(self) except *: """ Get the specific heat at constant volume [kJ/kg/K] """ return self.Props(iCvmass)/1000 property cv: """ The specific heat at constant volume [kJ/kg/K] """ def __get__(self): return self.get_cv() - - cpdef double get_speed_sound(self) except *: + + cpdef double get_speed_sound(self) except *: """ Get the speed of sound [m/s] """ return self.Props(ispeed_sound) - + cpdef double get_visc(self) except *: """ Get the viscosity, in [Pa-s]""" return self.Props(iviscosity) @@ -710,77 +710,77 @@ cdef class State: """ The thermal conductivity, in [kW/m/K]""" def __get__(self): return self.get_cond() - + cpdef get_Tsat(self, double Q = 1): - """ + """ Get the saturation temperature, in [K] - - Returns ``None`` if pressure is not within the two-phase pressure range + + Returns ``None`` if pressure is not within the two-phase pressure range """ if self.p_ > _Props('pcrit','T',0,'P',0,self.Fluid) or self.p_ < _Props('ptriple','T',0,'P',0, self.Fluid): - return None + return None else: return _Props('T', 'P', self.p_, 'Q', Q, self.Fluid) property Tsat: """ The saturation temperature (dew) for the given pressure, in [K]""" def __get__(self): return self.get_Tsat(1.0) - + cpdef get_superheat(self): - """ - Get the amount of superheat above the saturation temperature corresponding to the pressure, in [K] - - Returns ``None`` if pressure is not within the two-phase pressure range """ - + Get the amount of superheat above the saturation temperature corresponding to the pressure, in [K] + + Returns ``None`` if pressure is not within the two-phase pressure range + """ + Tsat = self.get_Tsat(1) #dewpoint temp - + if Tsat is not None: return self.T_-Tsat else: return None property superheat: - """ + """ The amount of superheat above the saturation temperature corresponding to the pressure, in [K] - - Returns ``None`` if pressure is not within the two-phase pressure range + + Returns ``None`` if pressure is not within the two-phase pressure range """ - def __get__(self): + def __get__(self): return self.get_superheat() - + cpdef get_subcooling(self): - """ - Get the amount of subcooling below the saturation temperature corresponding to the pressure, in [K] - - Returns ``None`` if pressure is not within the two-phase pressure range """ - + Get the amount of subcooling below the saturation temperature corresponding to the pressure, in [K] + + Returns ``None`` if pressure is not within the two-phase pressure range + """ + Tsat = self.get_Tsat(0) #bubblepoint temp - + if Tsat is not None: return Tsat - self.T_ else: return None property subcooling: - """ - The amount of subcooling below the saturation temperature corresponding to the pressure, in [K] - - Returns ``None`` if pressure is not within the two-phase pressure range """ - def __get__(self): + The amount of subcooling below the saturation temperature corresponding to the pressure, in [K] + + Returns ``None`` if pressure is not within the two-phase pressure range + """ + def __get__(self): return self.get_subcooling() - + property Prandtl: """ The Prandtl number (cp*mu/k) [-] """ def __get__(self): return self.cp * self.visc / self.k - + cpdef double get_dpdT(self) except *: return self.pAS.first_partial_deriv(iP, iT, iDmolar)/1000; property dpdT: def __get__(self): return self.get_dpdT() - + cpdef speed_test(self, int N): from time import clock cdef int i @@ -790,7 +790,7 @@ cdef class State: cdef long IT = 'T' cdef long ID = 'D' import CoolProp as CP - + print 'Call to the Python call layer (CoolProp.CoolProp.Props)' print "'M' involves basically no computational effort and is a good measure of the function call overhead" keys = ['H','P','S','U','C','O','V','L','M','d(P)/d(T)|Dmolar'] @@ -800,7 +800,7 @@ cdef class State: CP.PropsSI(key,'T',self.T_,'D',self.rho_,Fluid) t2=clock() print 'Elapsed time for {0:d} calls for "{1:s}" at {2:g} us/call'.format(N,key,(t2-t1)/N*1e6) - + print 'Direct c++ call to CoolProp without the Python call layer (_Props function)' print "'M' involves basically no computational effort and is a good measure of the function call overhead" keys = ['H','P','S','U','C','O','V','L','M','C0','d(P)/d(T)|Dmolar'] @@ -810,7 +810,7 @@ cdef class State: _PropsSI(key,'T',self.T_,'D',self.rho_,Fluid) t2=clock() print 'Elapsed time for {0:d} calls for "{1:s}" at {2:g} us/call'.format(N,key,(t2-t1)/N*1e6) - + print 'Call to the c++ layer using integers' keys = [iHmass, iP,iSmass,iUmass] for key in keys: @@ -820,15 +820,15 @@ cdef class State: self.pAS.keyed_output(key) t2=clock() print 'Elapsed time for {0:d} calls for "{1:s}" at {2:g} us/call'.format(N,paras[key],(t2-t1)/N*1e6) - + print 'Call to the AbstractState for molar mass (fast)' t1=clock() for i in range(N): self.pAS.keyed_output(imolar_mass) t2=clock() print 'Elapsed time for {0:d} calls at {1:g} us/call'.format(N, (t2-t1)/N*1e6) - -# + +# # print 'Call using TTSE with T,rho' # print "'M' involves basically no computational effort and is a good measure of the function call overhead" # for ikey in keys: @@ -838,7 +838,7 @@ cdef class State: # self.CPS.keyed_output(ikey) # t2=clock() # print 'Elapsed time for {0:d} calls for "{1:s}" at {2:g} us/call'.format(N,paras[ikey],(t2-t1)/N*1e6) -# +# # print 'Call using TTSE with p,h' # print "'M' involves basically no computational effort and is a good measure of the function call overhead" # cdef double hh = self.h @@ -849,7 +849,7 @@ cdef class State: # self.CPS.keyed_output(ikey) # t2=clock() # print 'Elapsed time for {0:d} calls for "{1:s}" at {2:g} us/call'.format(N,paras[ikey],(t2-t1)/N*1e6) -# +# # print 'Using CoolPropStateClass with T,rho with LUT' # keys = [iH,iP,iC,iO,iDpdT] # t1=clock() @@ -859,16 +859,16 @@ cdef class State: # self.CPS.keyed_output(ikey) # t2=clock() # print 'Elapsed time for {0:d} calls of iH,iP,iC,iO,iDpdT takes {1:g} us/call'.format(N,(t2-t1)/N*1e6) -# +# # if not isenabled: # _disable_TTSE_LUT(Fluid) -# +# def __str__(self): """ Return a string representation of the state """ - units={'T': 'K', - 'p': 'kPa', + units={'T': 'K', + 'p': 'kPa', 'rho': 'kg/m^3', 'Q':'kg/kg', 'h':'kJ/kg', @@ -892,7 +892,7 @@ cdef class State: else: s+=k+' = '+str(getattr(self,k))+' NO UNITS'+'\n' return s.rstrip() - + cpdef State copy(self): """ Make a copy of this State class @@ -900,8 +900,8 @@ cdef class State: cdef State S = State(self.Fluid,dict(T=self.T_,D=self.rho_)) S.phase = self.phase return S - + def rebuildState(d): S=State(d['Fluid'],{'T':d['T'],'D':d['rho']},phase=d['phase']) return S - + From abac4e57d0340c6451366f46d2c5b49f86fd0e47 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Sun, 4 Jan 2015 22:33:06 -0500 Subject: [PATCH 13/27] Nicer warning message if constants.so|py|dylib cannot be removed by python Signed-off-by: Ian Bell --- wrappers/Python/CoolProp/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wrappers/Python/CoolProp/__init__.py b/wrappers/Python/CoolProp/__init__.py index 1dc6315d..583b750e 100644 --- a/wrappers/Python/CoolProp/__init__.py +++ b/wrappers/Python/CoolProp/__init__.py @@ -1,12 +1,16 @@ from __future__ import absolute_import # If there is a constants.[pyd|so|dylib] in the main directory, it will be imported instead of the constants.py file. -# It should be removed +# It should be removed as it is from the older version of CoolProp from . import constants if constants.__file__.rsplit('.', 1)[1] not in ['pyc','pyo','py']: - print("constants shared library has been removed. Please restart your python code") + import os - os.remove(constants.__file__) + try: + os.remove(constants.__file__) + print("constants shared library has been removed. Please restart your python code") + except: + print("Unable to remove" + constants.__file__ + ". Please manually remove it") quit() try: From 75e166cd1a05f941a4edec68a032c1450ef9bc11 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Mon, 5 Jan 2015 19:41:45 +0100 Subject: [PATCH 14/27] Started to look at the new fit for water, seems like there are problems with the transport properties, see also #390 --- Web/fluid_properties/Incompressibles.bib | 13 +++ .../CPIncomp/PureFluids.py | 26 +++++ dev/incompressible_liquids/json/Water.json | 96 +++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 dev/incompressible_liquids/json/Water.json diff --git a/Web/fluid_properties/Incompressibles.bib b/Web/fluid_properties/Incompressibles.bib index 221abb60..cf9b362f 100644 --- a/Web/fluid_properties/Incompressibles.bib +++ b/Web/fluid_properties/Incompressibles.bib @@ -136,6 +136,19 @@ Timestamp = {2014.12.17} } +@Article{Wagner2002, + Title = {The IAPWS Formulation 1995 for the Thermodynamic Properties of Ordinary Water Substance for General and Scientific Use}, + Author = {W. Wagner and A. Pruss}, + Journal = {Journal of Physical and Chemical Reference Data}, + Year = {2002}, + Pages = {387--535}, + Volume = {31}, + + Doi = {10.1063/1.1461829}, + Owner = {jowr}, + Timestamp = {2014.05.28} +} + @TechReport{Zavoico2001, Title = {{Solar Power Tower Design Basis Document}}, Author = {Alexis B. Zavoico}, diff --git a/dev/incompressible_liquids/CPIncomp/PureFluids.py b/dev/incompressible_liquids/CPIncomp/PureFluids.py index 70c72901..0f9fadd4 100644 --- a/dev/incompressible_liquids/CPIncomp/PureFluids.py +++ b/dev/incompressible_liquids/CPIncomp/PureFluids.py @@ -562,3 +562,29 @@ class PNF(PureData): self.reference = "Paratherm2013" self.reshapeAll() + +class Water(PureData): + """ + This is just a fit of the full EOS from Wagner and Pruss + """ + def __init__(self): + PureData.__init__(self) + self.density.source = self.density.SOURCE_DATA + self.viscosity.source = self.viscosity.SOURCE_DATA + self.specific_heat.source = self.specific_heat.SOURCE_DATA + self.conductivity.source = self.conductivity.SOURCE_DATA + self.saturation_pressure.source = self.saturation_pressure.SOURCE_DATA + self.temperature.data = np.array([0.0000e+00, 5.1282e+00, 1.0256e+01, 1.5385e+01, 2.0513e+01, 2.5641e+01, 3.0769e+01, 3.5897e+01, 4.1026e+01, 4.6154e+01, 5.1282e+01, 5.6410e+01, 6.1538e+01, 6.6667e+01, 7.1795e+01, 7.6923e+01, 8.2051e+01, 8.7179e+01, 9.2308e+01, 9.7436e+01, 1.0256e+02, 1.0769e+02, 1.1282e+02, 1.1795e+02, 1.2308e+02, 1.2821e+02, 1.3333e+02, 1.3846e+02, 1.4359e+02, 1.4872e+02, 1.5385e+02, 1.5897e+02, 1.6410e+02, 1.6923e+02, 1.7436e+02, 1.7949e+02, 1.8462e+02, 1.8974e+02, 1.9487e+02, 2.0000e+02, ])+273.15 + self.density.data = np.array([1.0023e+03, 1.0024e+03, 1.0020e+03, 1.0013e+03, 1.0003e+03, 9.9907e+02, 9.9758e+02, 9.9587e+02, 9.9396e+02, 9.9185e+02, 9.8957e+02, 9.8713e+02, 9.8453e+02, 9.8178e+02, 9.7888e+02, 9.7585e+02, 9.7343e+02, 9.7014e+02, 9.6674e+02, 9.6321e+02, 9.5956e+02, 9.5580e+02, 9.5192e+02, 9.4793e+02, 9.4383e+02, 9.3962e+02, 9.3530e+02, 9.3086e+02, 9.2632e+02, 9.2166e+02, 9.1689e+02, 9.1200e+02, 9.0700e+02, 9.0188e+02, 8.9663e+02, 8.9127e+02, 8.8577e+02, 8.8014e+02, 8.7438e+02, 8.6848e+02, ]) + self.specific_heat.data = np.array([4.1960e+03, 4.1845e+03, 4.1768e+03, 4.1719e+03, 4.1689e+03, 4.1673e+03, 4.1668e+03, 4.1670e+03, 4.1678e+03, 4.1691e+03, 4.1707e+03, 4.1727e+03, 4.1750e+03, 4.1777e+03, 4.1807e+03, 4.1840e+03, 4.1842e+03, 4.1884e+03, 4.1930e+03, 4.1981e+03, 4.2038e+03, 4.2100e+03, 4.2168e+03, 4.2242e+03, 4.2323e+03, 4.2411e+03, 4.2507e+03, 4.2611e+03, 4.2723e+03, 4.2844e+03, 4.2974e+03, 4.3114e+03, 4.3265e+03, 4.3426e+03, 4.3600e+03, 4.3785e+03, 4.3984e+03, 4.4198e+03, 4.4427e+03, 4.4672e+03, ]) + self.conductivity.data = np.array([5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, ]) + self.viscosity.data = np.array([1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, ]) + self.saturation_pressure.data = np.array([ np.NAN, 8.8041e+02, 1.2495e+03, 1.7485e+03, 2.4147e+03, 3.2931e+03, 4.4381e+03, 5.9145e+03, 7.7984e+03, 1.0179e+04, 1.3160e+04, 1.6858e+04, 2.1410e+04, 2.6968e+04, 3.3704e+04, 4.1808e+04, 5.1493e+04, 6.2992e+04, 7.6562e+04, 9.2482e+04, 1.1106e+05, 1.3261e+05, 1.5750e+05, 1.8610e+05, 2.1882e+05, 2.5608e+05, 2.9834e+05, 3.4608e+05, 3.9979e+05, 4.6002e+05, 5.2732e+05, 6.0227e+05, 6.8548e+05, 7.7757e+05, 8.7919e+05, 9.9104e+05, 1.1138e+06, 1.2482e+06, 1.3950e+06, 1.5549e+06, ]) + self.Tmin = np.min(self.temperature.data) + self.Tmax = np.max(self.temperature.data) + self.TminPsat = np.min(self.temperature.data[~np.isnan(self.saturation_pressure.data)]) + self.name = "Water" + self.description = "Fit of the subcooled region of the full EOS from 0.5 bar to 100 bar and from 0 deg C to 200 deg C." + self.reference = "Wagner2002" + self.reshapeAll() + diff --git a/dev/incompressible_liquids/json/Water.json b/dev/incompressible_liquids/json/Water.json new file mode 100644 index 00000000..6b192ed8 --- /dev/null +++ b/dev/incompressible_liquids/json/Water.json @@ -0,0 +1,96 @@ +{ + "T_freeze": { + "coeffs": "null", + "type": "notdefined" + }, + "Tbase": 3.731500e+02, + "Tmax": 4.731500e+02, + "Tmin": 2.731500e+02, + "TminPsat": 2.782782e+02, + "conductivity": { + "coeffs": [ + [ + 5.602160e-01 + ], + [ + 1.470951e-05 + ], + [ + -4.222652e-08 + ], + [ + -9.630489e-10 + ] + ], + "type": "polynomial" + }, + "density": { + "coeffs": [ + [ + 9.615327e+02 + ], + [ + -7.059969e-01 + ], + [ + -2.541021e-03 + ], + [ + 3.442833e-06 + ] + ], + "type": "polynomial" + }, + "description": "Fit of the subcooled region of the full EOS from 0.5 bar to 100 bar and from 0 deg C to 200 deg C.", + "mass2input": { + "coeffs": "null", + "type": "notdefined" + }, + "mole2input": { + "coeffs": "null", + "type": "notdefined" + }, + "name": "Water", + "reference": "Wagner2002", + "saturation_pressure": { + "coeffs": [ + -3.863635e+03, + -4.391760e+01, + -2.326064e+01 + ], + "type": "exponential" + }, + "specific_heat": { + "coeffs": [ + [ + 4.199132e+03 + ], + [ + 1.116817e+00 + ], + [ + 1.238871e-02 + ], + [ + 2.770690e-05 + ] + ], + "type": "polynomial" + }, + "viscosity": { + "coeffs": [ + 1.752794e+00, + -9.603666e+00, + 6.336660e+00 + ], + "type": "exponential" + }, + "volume2input": { + "coeffs": "null", + "type": "notdefined" + }, + "xbase": 0.000000e+00, + "xid": "pure", + "xmax": 1.000000e+00, + "xmin": 0.000000e+00 +} \ No newline at end of file From 1a609817d62e94f53624d0588f1f39512747824b Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Tue, 6 Jan 2015 11:27:11 +0100 Subject: [PATCH 15/27] I hope this helps with #391, but it still needs testing. --- dev/scripts/release.bsh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dev/scripts/release.bsh b/dev/scripts/release.bsh index ccca39cf..bc2799d8 100755 --- a/dev/scripts/release.bsh +++ b/dev/scripts/release.bsh @@ -13,9 +13,7 @@ CPVERSION="$1" BASEDIR="$HOME/buildbot/server-master/public_html" REPODIR="$HOME/src/CoolPropFull.git" TMPSDIR="$HOME/src/CoolProp.sources" -BINFOLDER="binaries" DOCFOLDER="sphinx" -SRCFOLDER="$BASEDIR/$BINFOLDER/source" DOC4FILES="4.2.5/coolpropv425docs.zip" DOC4FOLDER="$DOCFOLDER/v4" SEPARATOR="----------------------------------" @@ -34,9 +32,12 @@ printMessage "Processing the input variables: " CPVERSION="$1" if [[ $CPVERSION == +([0-9]).+([0-9]).+([0-9]) ]]; then echo "CPVERSION = $CPVERSION" - BINFOLDER=release + BINFOLDER="release" + SRCFOLDER="$BASEDIR/$BINFOLDER/source" elif [ "$CPVERSION" == "nightly" ]; then echo "CPVERSION = $CPVERSION - which is a valid input" + BINFOLDER="binaries" + SRCFOLDER="$BASEDIR/$BINFOLDER/source" else echo "CPVERSION = $CPVERSION - not valid!" exit 1 @@ -72,8 +73,9 @@ else #rm -rf .git* find . -iwholename "*/.git*" -exec rm -rf {} \; cd .. - rm $SRCFOLDER/CoolProp_sources.zip - zip -r $SRCFOLDER/CoolProp_sources.zip $(basename $TMPSDIR) + mkdir -p $SRCFOLDER + rm -f $SRCFOLDER/CoolProp_sources.zip + zip -rq $SRCFOLDER/CoolProp_sources.zip $(basename $TMPSDIR) cd $(basename $TMPSDIR) popd rm -f "$BINFOLDER/README.rst.txt" From 7741aa8cd89c47a4b9eeef848db48b71eeac4cc1 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Tue, 6 Jan 2015 11:43:28 +0100 Subject: [PATCH 16/27] I think the permission in the docs folder are fixed, lets hope this one handles #391 --- dev/scripts/release.bsh | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/dev/scripts/release.bsh b/dev/scripts/release.bsh index bc2799d8..96ed1ed4 100755 --- a/dev/scripts/release.bsh +++ b/dev/scripts/release.bsh @@ -9,40 +9,38 @@ if [ $# != 2 ]; then exit 1 fi # -CPVERSION="$1" -BASEDIR="$HOME/buildbot/server-master/public_html" -REPODIR="$HOME/src/CoolPropFull.git" -TMPSDIR="$HOME/src/CoolProp.sources" -DOCFOLDER="sphinx" -DOC4FILES="4.2.5/coolpropv425docs.zip" -DOC4FOLDER="$DOCFOLDER/v4" +# Just a small function print messages SEPARATOR="----------------------------------" -# -SFUSER="jorritw" # ibell or jorritw -# function printMessage { echo " " echo $SEPARATOR echo "$1" return 0 } -# +# Now we use the function defined above printMessage "Processing the input variables: " # +# Process the version number and set parameters accordingly CPVERSION="$1" if [[ $CPVERSION == +([0-9]).+([0-9]).+([0-9]) ]]; then echo "CPVERSION = $CPVERSION" BINFOLDER="release" - SRCFOLDER="$BASEDIR/$BINFOLDER/source" elif [ "$CPVERSION" == "nightly" ]; then echo "CPVERSION = $CPVERSION - which is a valid input" BINFOLDER="binaries" - SRCFOLDER="$BASEDIR/$BINFOLDER/source" else echo "CPVERSION = $CPVERSION - not valid!" exit 1 fi # +BASEDIR="$HOME/buildbot/server-master/public_html" +REPODIR="$HOME/src/CoolPropFull.git" +TMPSDIR="$HOME/src/CoolProp.sources" +SRCFOLDER="$BASEDIR/$BINFOLDER/source" +DOCFOLDER="sphinx" +DOC4FILES="4.2.5/coolpropv425docs.zip" +DOC4FOLDER="$DOCFOLDER/v4" +# if [ "$2" == "release" ]; then DRYRUN=false else From 83a670a4fa142416e13444f54c95e162bb55d26b Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Tue, 6 Jan 2015 11:55:19 +0100 Subject: [PATCH 17/27] Added docs to fix permissions, should close #391 --- dev/scripts/release.bsh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/dev/scripts/release.bsh b/dev/scripts/release.bsh index 96ed1ed4..a9ac76e4 100755 --- a/dev/scripts/release.bsh +++ b/dev/scripts/release.bsh @@ -1,4 +1,23 @@ #!/bin/bash +############################################## +# CoolProp release management +############################################## +# +# Things to remember when you make a new release: +# +# * Run the script and check the logs +# * Make a tag in your git software +# * Update the default download on sourceforge to point to the new sources +# +# In case you experience problems with permissions, login to +# sourceforge by creating a new shell with +# ssh -t username,coolprop@shell.sf.net create +# and the run +# find . -type d ! -perm 0775 -exec chmod 0775 {} \; +# find . -type f ! -perm 0664 -exec chmod 0664 {} \; +# in /home/project-web/coolprop/htdocs and /home/frs/project/coolprop/ +# to reset all permissions. +# # # Make sure that only two arguments are passed to this script - the version that # will be released and the dryrun vs. release option. From 5ff28fc302372d6efbd96e174fa3b899285d177f Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Wed, 7 Jan 2015 12:16:00 +0100 Subject: [PATCH 18/27] Clears the cached transport properties and fixes #394 --- src/AbstractState.cpp | 29 ++++---- src/CoolProp.cpp | 159 ++++++++++++++++++++++-------------------- 2 files changed, 102 insertions(+), 86 deletions(-) diff --git a/src/AbstractState.cpp b/src/AbstractState.cpp index 09ec08fc..71cacf6d 100644 --- a/src/AbstractState.cpp +++ b/src/AbstractState.cpp @@ -121,7 +121,7 @@ bool AbstractState::clear() { this->_gibbsmolar.clear(); this->_logp.clear(); this->_logrhomolar.clear(); - + ///// Smoothing values //this->rhospline = -_HUGE; //this->dsplinedp = -_HUGE; @@ -154,6 +154,11 @@ bool AbstractState::clear() { this->_d2alphar_dDelta_dTau_lim.clear(); this->_d3alphar_dDelta2_dTau_lim.clear(); + /// Transport properties + this->_viscosity.clear(); + this->_conductivity.clear(); + this->_surface_tension.clear(); + return true; } double AbstractState::trivial_keyed_output(int key) @@ -419,7 +424,7 @@ void get_dT_drho(AbstractState &AS, parameters index, long double &dT, long doub R = AS.gas_constant(), delta = rho/rhor, tau = Tr/T; - + switch (index) { case iT: @@ -497,9 +502,9 @@ void get_dT_drho_second_derivatives(AbstractState &AS, int index, long double &d delta = rho/rhor, tau = Tr/T; - // Here we use T and rho as independent variables since derivations are already done by Thorade, 2013, + // Here we use T and rho as independent variables since derivations are already done by Thorade, 2013, // Partial derivatives of thermodynamic state propertiesfor dynamic simulation, DOI 10.1007/s12665-013-2394-z - + switch (index) { case iT: @@ -584,7 +589,7 @@ long double AbstractState::calc_first_partial_deriv(parameters Of, parameters Wr } long double AbstractState::calc_second_partial_deriv(parameters Of1, parameters Wrt1, parameters Constant1, parameters Wrt2, parameters Constant2) { - long double dOf1_dT, dOf1_drho, dWrt1_dT, dWrt1_drho, dConstant1_dT, dConstant1_drho, d2Of1_dT2, d2Of1_drhodT, + long double dOf1_dT, dOf1_drho, dWrt1_dT, dWrt1_drho, dConstant1_dT, dConstant1_drho, d2Of1_dT2, d2Of1_drhodT, d2Of1_drho2, d2Wrt1_dT2, d2Wrt1_drhodT, d2Wrt1_drho2, d2Constant1_dT2, d2Constant1_drhodT, d2Constant1_drho2, dWrt2_dT, dWrt2_drho, dConstant2_dT, dConstant2_drho, N, D, dNdrho__T, dDdrho__T, dNdT__rho, dDdT__rho, dderiv1_drho, dderiv1_dT, second; @@ -596,34 +601,34 @@ long double AbstractState::calc_second_partial_deriv(parameters Of1, parameters get_dT_drho_second_derivatives(*this, Of1, d2Of1_dT2, d2Of1_drhodT, d2Of1_drho2); get_dT_drho_second_derivatives(*this, Wrt1, d2Wrt1_dT2, d2Wrt1_drhodT, d2Wrt1_drho2); get_dT_drho_second_derivatives(*this, Constant1, d2Constant1_dT2, d2Constant1_drhodT, d2Constant1_drho2); - + // First derivatives of terms involved in the second derivative get_dT_drho(*this, Wrt2, dWrt2_dT, dWrt2_drho); get_dT_drho(*this, Constant2, dConstant2_dT, dConstant2_drho); - + // Numerator and denominator of first partial derivative term N = dOf1_dT*dConstant1_drho - dOf1_drho*dConstant1_dT; D = dWrt1_dT*dConstant1_drho - dWrt1_drho*dConstant1_dT; - + // Derivatives of the numerator and denominator of the first partial derivative term with respect to rho, T held constant // They are of similar form, with Of1 and Wrt1 swapped dNdrho__T = dOf1_dT*d2Constant1_drho2 + d2Of1_drhodT*dConstant1_drho - dOf1_drho*d2Constant1_drhodT - d2Of1_drho2*dConstant1_dT; dDdrho__T = dWrt1_dT*d2Constant1_drho2 + d2Wrt1_drhodT*dConstant1_drho - dWrt1_drho*d2Constant1_drhodT - d2Wrt1_drho2*dConstant1_dT; - + // Derivatives of the numerator and denominator of the first partial derivative term with respect to T, rho held constant // They are of similar form, with Of1 and Wrt1 swapped dNdT__rho = dOf1_dT*d2Constant1_drhodT + d2Of1_dT2*dConstant1_drho - dOf1_drho*d2Constant1_dT2 - d2Of1_drhodT*dConstant1_dT; dDdT__rho = dWrt1_dT*d2Constant1_drhodT + d2Wrt1_dT2*dConstant1_drho - dWrt1_drho*d2Constant1_dT2 - d2Wrt1_drhodT*dConstant1_dT; - + // First partial of first derivative term with respect to T dderiv1_drho = (D*dNdrho__T - N*dDdrho__T)/pow(D, 2); - + // First partial of first derivative term with respect to rho dderiv1_dT = (D*dNdT__rho - N*dDdT__rho)/pow(D, 2); // Complete second derivative second = (dderiv1_dT*dConstant2_drho - dderiv1_drho*dConstant2_dT)/(dWrt2_dT*dConstant2_drho - dWrt2_drho*dConstant2_dT); - + return second; } // // ---------------------------------------- diff --git a/src/CoolProp.cpp b/src/CoolProp.cpp index 570648da..0168f159 100644 --- a/src/CoolProp.cpp +++ b/src/CoolProp.cpp @@ -77,7 +77,7 @@ void extract_backend(const std::string &fluid_string, std::string &backend, std: { std::size_t i; std::string _fluid_string = fluid_string; - // For backwards compatibility reasons, if "REFPROP-" or "REFPROP-MIX:" start + // For backwards compatibility reasons, if "REFPROP-" or "REFPROP-MIX:" start // the fluid_string, replace them with "REFPROP::" if (_fluid_string.find("REFPROP-MIX:") == 0) { @@ -177,21 +177,21 @@ std::string extract_fractions(const std::string &fluid_string, std::vector &fluid_names, - const std::vector &z, +void _PropsSI_initialize(const std::string &backend, + const std::vector &fluid_names, + const std::vector &z, shared_ptr &State){ - + if (fluid_names.empty()){throw ValueError("fluid_names cannot be empty");} - + std::vector fractions(1, 1.0); // Default to one component, unity fraction const std::vector *fractions_ptr = NULL; // Pointer to the array to be used; - + if (fluid_names.size() > 1){ // Set the pointer - we are going to use the supplied fractions; they must be provided fractions_ptr = &z; @@ -220,7 +220,7 @@ void _PropsSI_initialize(const std::string &backend, State.reset(AbstractState::factory(backend, fluid_names)); } } - + // Set the fraction for the state if (State->using_mole_fractions()){ // If a predefined mixture or a pure fluid, the fractions will already be set @@ -268,25 +268,36 @@ struct output_parameter{ }; }; -void _PropsSI_outputs(shared_ptr &State, - std::vector output_parameters, - CoolProp::input_pairs input_pair, - const std::vector &in1, +void _PropsSI_outputs(shared_ptr &State, + std::vector output_parameters, + CoolProp::input_pairs input_pair, + const std::vector &in1, const std::vector &in2, std::vector > &IO){ - + // Check the inputs if (in1.size() != in2.size()){ throw ValueError(format("lengths of in1 [%d] and in2 [%d] are not the same", in1.size(), in2.size()));} bool one_input_one_output = (in1.size() == 1 && in2.size() == 1 && output_parameters.size() == 1); - + + if (get_debug_level() > 100) + { + std::cout << format("%s (%d): input pair = %d ",__FILE__,__LINE__, input_pair) << std::endl; + std::cout << format("%s (%d): in1 = %s ",__FILE__,__LINE__, vec_to_string(in1).c_str()) << std::endl; + std::cout << format("%s (%d): in2 = %s ",__FILE__,__LINE__, vec_to_string(in2).c_str()) << std::endl; + } + // Resize the output matrix std::size_t N1 = std::max(static_cast(1), in1.size()); std::size_t N2 = std::max(static_cast(1), output_parameters.size()); IO.resize(N1, std::vector(N2, _HUGE)); - + // Throw an error if at the end, there were no successes bool success = false; - + + if (get_debug_level() > 100) + { + std::cout << format("%s (%d): Iterating over %d input value pairs.",__FILE__,__LINE__,IO.size()) << std::endl; + } // Iterate over the state variable inputs for (std::size_t i = 0; i < IO.size(); ++i){ try{ @@ -301,7 +312,7 @@ void _PropsSI_outputs(shared_ptr &State, for (std::size_t j = 0; j < IO[i].size(); ++j){ IO[i][j] = _HUGE; } continue; } - + for (std::size_t j = 0; j < IO[i].size(); ++j){ try{ output_parameter &output = output_parameters[j]; @@ -328,13 +339,13 @@ void _PropsSI_outputs(shared_ptr &State, if (success == false) { IO.clear(); throw ValueError(format("No outputs were able to be calculated"));} } -void _PropsSImulti(const std::vector &Outputs, - const std::string &Name1, +void _PropsSImulti(const std::vector &Outputs, + const std::string &Name1, const std::vector &Prop1, - const std::string &Name2, - const std::vector &Prop2, - const std::string &backend, - const std::vector &fluids, + const std::string &Name2, + const std::vector &Prop2, + const std::string &backend, + const std::vector &fluids, const std::vector &fractions, std::vector > &IO) { @@ -342,7 +353,7 @@ void _PropsSImulti(const std::vector &Outputs, CoolProp::input_pairs input_pair; std::vector output_parameters; std::vector v1, v2; - + try{ // Initialize the State class _PropsSI_initialize(backend, fluids, fractions, State); @@ -362,9 +373,9 @@ void _PropsSImulti(const std::vector &Outputs, } catch (std::exception &e){ // Input parameter parsing failed. Stop - throw ValueError(format("Input pair parsing failed for Name1: \"%s\", Name2: \"%s\"; err: %s", Name1.c_str(), Name2.c_str(), e.what())); + throw ValueError(format("Input pair parsing failed for Name1: \"%s\", Name2: \"%s\"; err: %s", Name1.c_str(), Name2.c_str(), e.what())); } - + try{ output_parameters = output_parameter::get_output_parameters(Outputs); } @@ -376,34 +387,34 @@ void _PropsSImulti(const std::vector &Outputs, // Calculate the output(s). In the case of a failure, all values will be filled with _HUGE _PropsSI_outputs(State, output_parameters, input_pair, v1, v2, IO); } - -std::vector > PropsSImulti(const std::vector &Outputs, - const std::string &Name1, + +std::vector > PropsSImulti(const std::vector &Outputs, + const std::string &Name1, const std::vector &Prop1, - const std::string &Name2, - const std::vector &Prop2, - const std::string &backend, - const std::vector &fluids, + const std::string &Name2, + const std::vector &Prop2, + const std::string &backend, + const std::vector &fluids, const std::vector &fractions) { std::vector > IO; - + #if !defined(NO_ERROR_CATCHING) try{ #endif - + // Call the subfunction that can bubble errors _PropsSImulti(Outputs, Name1, Prop1, Name2, Prop2, backend, fluids, fractions, IO); - + // Return the value(s) return IO; - + #if !defined(NO_ERROR_CATCHING) } catch(const std::exception& e){ - set_error_string(e.what()); + set_error_string(e.what()); #if defined (PROPSSI_ERROR_STDOUT) - std::cout << e.what() << std::endl; + std::cout << e.what() << std::endl; #endif if (get_debug_level() > 1){std::cout << e.what() << std::endl;} } @@ -418,12 +429,12 @@ double PropsSI(const std::string &Output, const std::string &Name1, double Prop1 #if !defined(NO_ERROR_CATCHING) try{ #endif - + // BEGIN OF TRY // Here is the real code that is inside the try block - - - + + + extract_backend(Ref, backend, fluid); if (has_fractions_in_string(fluid)){ extract_fractions(fluid, fractions); @@ -432,49 +443,49 @@ double PropsSI(const std::string &Output, const std::string &Name1, double Prop1 _PropsSImulti(strsplit(Output,'&'), Name1, std::vector(1, Prop1), Name2, std::vector(1, Prop2), backend, std::vector(1, fluid), fractions, IO); if (IO.empty()){ throw ValueError(get_global_param_string("errstring").c_str()); } if (IO.size()!= 1 || IO[0].size() != 1){ throw ValueError(format("output should be 1x1; error was %s", get_global_param_string("errstring").c_str())); } - + double val = IO[0][0]; - + if (get_debug_level() > 1){ std::cout << format("_PropsSI will return %g",val) << std::endl; } return val; // END OF TRY #if !defined(NO_ERROR_CATCHING) } catch(const std::exception& e){ - set_error_string(e.what() + format(" : PropsSI(\"%s\",\"%s\",%0.10g,\"%s\",%0.10g,\"%s\")",Output.c_str(),Name1.c_str(), Prop1, Name2.c_str(), Prop2, Ref.c_str())); + set_error_string(e.what() + format(" : PropsSI(\"%s\",\"%s\",%0.10g,\"%s\",%0.10g,\"%s\")",Output.c_str(),Name1.c_str(), Prop1, Name2.c_str(), Prop2, Ref.c_str())); #if defined (PROPSSI_ERROR_STDOUT) - std::cout << e.what() << std::endl; + std::cout << e.what() << std::endl; #endif if (get_debug_level() > 1){std::cout << e.what() << std::endl;} - return _HUGE; + return _HUGE; } catch(...){ - return _HUGE; + return _HUGE; } #endif } #if defined(ENABLE_CATCH) TEST_CASE("Check inputs to PropsSI","[PropsSI]") { - SECTION("Single state, single output"){ + SECTION("Single state, single output"){ CHECK(ValidNumber(CoolProp::PropsSI("T","P",101325,"Q",0,"Water"))); }; - SECTION("Single state, single output, pure incompressible"){ + SECTION("Single state, single output, pure incompressible"){ CHECK(ValidNumber(CoolProp::PropsSI("D","P",101325,"T",300,"INCOMP::DowQ"))); }; - SECTION("Bad input pair"){ + SECTION("Bad input pair"){ CHECK(!ValidNumber(CoolProp::PropsSI("D","Q",0,"Q",0,"Water"))); }; - SECTION("Single state, single output, 40% incompressible"){ + SECTION("Single state, single output, 40% incompressible"){ CHECK(ValidNumber(CoolProp::PropsSI("D","P",101325,"T",300,"INCOMP::MEG[0.40]"))); }; - SECTION("Single state, single output, predefined CoolProp mixture"){ + SECTION("Single state, single output, predefined CoolProp mixture"){ CHECK(ValidNumber(CoolProp::PropsSI("T","Q",1,"P",3e6,"HEOS::R125[0.7]&R32[0.3]"))); }; - SECTION("Single state, single output"){ + SECTION("Single state, single output"){ CHECK(ValidNumber(CoolProp::PropsSI("T","P",101325,"Q",0,"HEOS::Water"))); }; - SECTION("Single state, single output, predefined mixture"){ + SECTION("Single state, single output, predefined mixture"){ CHECK(ValidNumber(CoolProp::PropsSI("T","P",101325,"Q",0,"R410A.mix"))); }; SECTION("Predefined mixture"){ @@ -587,7 +598,7 @@ double Props1SI(const std::string &FluidName, const std::string &Output) // They are backwards, swap std::swap(_Output, _FluidName); } - + // First input is the fluid, second input is the input parameter double val1 = PropsSI(_Output, "", 0, "", 0, _FluidName); if (!ValidNumber(val1)){ @@ -601,19 +612,19 @@ double Props1SI(const std::string &FluidName, const std::string &Output) #if defined(ENABLE_CATCH) TEST_CASE("Check inputs to Props1SI","[Props1SI],[PropsSI]") { - SECTION("Good fluid, good parameter"){ + SECTION("Good fluid, good parameter"){ CHECK(ValidNumber(CoolProp::Props1SI("Tcrit","Water"))); }; - SECTION("Good fluid, good parameter"){ + SECTION("Good fluid, good parameter"){ CHECK(ValidNumber(CoolProp::PropsSI("Tcrit","",0,"",0,"Water"))); }; - SECTION("Good fluid, good parameter, inverted"){ + SECTION("Good fluid, good parameter, inverted"){ CHECK(ValidNumber(CoolProp::Props1SI("Water","Tcrit"))); }; - SECTION("Good fluid, bad parameter"){ + SECTION("Good fluid, bad parameter"){ CHECK(!ValidNumber(CoolProp::Props1SI("Water","????????????"))); }; - SECTION("Bad fluid, good parameter"){ + SECTION("Bad fluid, good parameter"){ CHECK(!ValidNumber(CoolProp::Props1SI("?????","Tcrit"))); }; }; @@ -637,14 +648,14 @@ bool is_valid_fluid_string(std::string &input_fluid_string) } } double saturation_ancillary(const std::string &fluid_name, const std::string &output, int Q, const std::string &input, double value){ - + // Generate the state instance std::vector names(1, fluid_name); shared_ptr HEOS(new CoolProp::HelmholtzEOSMixtureBackend(names)); - + parameters iInput = get_parameter_index(input); parameters iOutput = get_parameter_index(output); - + return HEOS->saturation_ancillary(iOutput, Q, iInput, value); } void set_reference_stateS(std::string Ref, std::string reference_state) @@ -709,7 +720,7 @@ void set_reference_stateD(std::string Ref, double T, double rhomolar, double h0, shared_ptr HEOS; std::vector _comps(1, Ref); HEOS.reset(new CoolProp::HelmholtzEOSMixtureBackend(_comps)); - + HEOS->update(DmolarT_INPUTS, rhomolar, T); // Get current values for the enthalpy and entropy @@ -779,8 +790,8 @@ TEST_CASE("Check inputs to get_global_param_string","[get_global_param_string]") std::ostringstream ss3c; for (int i = 0; i INCOMP(new CoolProp::IncompressibleBackend(fluid)); - + if (!ParamName.compare("long_name")){ return INCOMP->calc_name(); } @@ -805,12 +816,12 @@ std::string get_fluid_param_string(std::string FluidName, std::string ParamName) catch(std::exception &e){ throw ValueError(format("CoolProp error: %s", e.what())); } catch(...){ throw ValueError("CoolProp error: Indeterminate error"); } } - + try{ std::vector comps(1, FluidName); shared_ptr HEOS(new CoolProp::HelmholtzEOSMixtureBackend(comps)); CoolProp::CoolPropFluid *fluid = HEOS->get_components()[0]; - + if (!ParamName.compare("aliases")){ return strjoin(fluid->aliases, ", "); } @@ -844,7 +855,7 @@ TEST_CASE("Check inputs to get_fluid_param_string", "[get_fluid_param_string]") std::ostringstream ss3c; for (int i = 0; i < num_good_inputs; ++i){ ss3c << "Test for" << good_inputs[i]; - SECTION(ss3c.str(), ""){ + SECTION(ss3c.str(), ""){ CHECK_NOTHROW(CoolProp::get_fluid_param_string("Water", good_inputs[i])); }; } @@ -886,7 +897,7 @@ std::string PhaseSI(const std::string &Name1, double Prop1, const std::string &N std::size_t Phase_int = static_cast(Phase_double); return phase_lookup_string(static_cast(Phase_int)); } - + /* std::string PhaseSI(const std::string &Name1, double Prop1, const std::string &Name2, double Prop2, const std::string &FluidName, const std::vector &z) { From 44e880de66dd664cd6ee839e62daacaf5341d2ce Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Wed, 7 Jan 2015 13:02:19 +0100 Subject: [PATCH 19/27] Added incompressible water as a fit from 1 to 100 bar --- .../CPIncomp/PureFluids.py | 18 ++++++++++-------- dev/incompressible_liquids/json/Water.json | 18 +++++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/dev/incompressible_liquids/CPIncomp/PureFluids.py b/dev/incompressible_liquids/CPIncomp/PureFluids.py index 0f9fadd4..0946bdc0 100644 --- a/dev/incompressible_liquids/CPIncomp/PureFluids.py +++ b/dev/incompressible_liquids/CPIncomp/PureFluids.py @@ -574,17 +574,19 @@ class Water(PureData): self.specific_heat.source = self.specific_heat.SOURCE_DATA self.conductivity.source = self.conductivity.SOURCE_DATA self.saturation_pressure.source = self.saturation_pressure.SOURCE_DATA - self.temperature.data = np.array([0.0000e+00, 5.1282e+00, 1.0256e+01, 1.5385e+01, 2.0513e+01, 2.5641e+01, 3.0769e+01, 3.5897e+01, 4.1026e+01, 4.6154e+01, 5.1282e+01, 5.6410e+01, 6.1538e+01, 6.6667e+01, 7.1795e+01, 7.6923e+01, 8.2051e+01, 8.7179e+01, 9.2308e+01, 9.7436e+01, 1.0256e+02, 1.0769e+02, 1.1282e+02, 1.1795e+02, 1.2308e+02, 1.2821e+02, 1.3333e+02, 1.3846e+02, 1.4359e+02, 1.4872e+02, 1.5385e+02, 1.5897e+02, 1.6410e+02, 1.6923e+02, 1.7436e+02, 1.7949e+02, 1.8462e+02, 1.8974e+02, 1.9487e+02, 2.0000e+02, ])+273.15 - self.density.data = np.array([1.0023e+03, 1.0024e+03, 1.0020e+03, 1.0013e+03, 1.0003e+03, 9.9907e+02, 9.9758e+02, 9.9587e+02, 9.9396e+02, 9.9185e+02, 9.8957e+02, 9.8713e+02, 9.8453e+02, 9.8178e+02, 9.7888e+02, 9.7585e+02, 9.7343e+02, 9.7014e+02, 9.6674e+02, 9.6321e+02, 9.5956e+02, 9.5580e+02, 9.5192e+02, 9.4793e+02, 9.4383e+02, 9.3962e+02, 9.3530e+02, 9.3086e+02, 9.2632e+02, 9.2166e+02, 9.1689e+02, 9.1200e+02, 9.0700e+02, 9.0188e+02, 8.9663e+02, 8.9127e+02, 8.8577e+02, 8.8014e+02, 8.7438e+02, 8.6848e+02, ]) - self.specific_heat.data = np.array([4.1960e+03, 4.1845e+03, 4.1768e+03, 4.1719e+03, 4.1689e+03, 4.1673e+03, 4.1668e+03, 4.1670e+03, 4.1678e+03, 4.1691e+03, 4.1707e+03, 4.1727e+03, 4.1750e+03, 4.1777e+03, 4.1807e+03, 4.1840e+03, 4.1842e+03, 4.1884e+03, 4.1930e+03, 4.1981e+03, 4.2038e+03, 4.2100e+03, 4.2168e+03, 4.2242e+03, 4.2323e+03, 4.2411e+03, 4.2507e+03, 4.2611e+03, 4.2723e+03, 4.2844e+03, 4.2974e+03, 4.3114e+03, 4.3265e+03, 4.3426e+03, 4.3600e+03, 4.3785e+03, 4.3984e+03, 4.4198e+03, 4.4427e+03, 4.4672e+03, ]) - self.conductivity.data = np.array([5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.5933e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, 5.6056e-01, ]) - self.viscosity.data = np.array([1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7811e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, 1.7776e-03, ]) - self.saturation_pressure.data = np.array([ np.NAN, 8.8041e+02, 1.2495e+03, 1.7485e+03, 2.4147e+03, 3.2931e+03, 4.4381e+03, 5.9145e+03, 7.7984e+03, 1.0179e+04, 1.3160e+04, 1.6858e+04, 2.1410e+04, 2.6968e+04, 3.3704e+04, 4.1808e+04, 5.1493e+04, 6.2992e+04, 7.6562e+04, 9.2482e+04, 1.1106e+05, 1.3261e+05, 1.5750e+05, 1.8610e+05, 2.1882e+05, 2.5608e+05, 2.9834e+05, 3.4608e+05, 3.9979e+05, 4.6002e+05, 5.2732e+05, 6.0227e+05, 6.8548e+05, 7.7757e+05, 8.7919e+05, 9.9104e+05, 1.1138e+06, 1.2482e+06, 1.3950e+06, 1.5549e+06, ]) + self.temperature.data = np.array([0.0000e+00, 5.1282e+00, 1.0256e+01, 1.5385e+01, 2.0513e+01, 2.5641e+01, 3.0769e+01, 3.5897e+01, 4.1026e+01, 4.6154e+01, 5.1282e+01, 5.6410e+01, 6.1538e+01, 6.6667e+01, 7.1795e+01, 7.6923e+01, 8.2051e+01, 8.7179e+01, 9.2308e+01, 9.7436e+01, 1.0256e+02, 1.0769e+02, 1.1282e+02, 1.1795e+02, 1.2308e+02, 1.2821e+02, 1.3333e+02, 1.3846e+02, 1.4359e+02, 1.4872e+02, 1.5385e+02, 1.5897e+02, 1.6410e+02, 1.6923e+02, 1.7436e+02, 1.7949e+02, 1.8462e+02, 1.8974e+02, 1.9487e+02, 2.0000e+02 ])+273.15 + self.density.data = np.array([1.0023e+03, 1.0024e+03, 1.0020e+03, 1.0013e+03, 1.0003e+03, 9.9907e+02, 9.9758e+02, 9.9587e+02, 9.9396e+02, 9.9185e+02, 9.8957e+02, 9.8713e+02, 9.8453e+02, 9.8178e+02, 9.7888e+02, 9.7585e+02, 9.7343e+02, 9.7014e+02, 9.6674e+02, 9.6321e+02, 9.5956e+02, 9.5580e+02, 9.5192e+02, 9.4793e+02, 9.4383e+02, 9.3962e+02, 9.3530e+02, 9.3086e+02, 9.2632e+02, 9.2166e+02, 9.1689e+02, 9.1200e+02, 9.0700e+02, 9.0188e+02, 8.9663e+02, 8.9127e+02, 8.8577e+02, 8.8014e+02, 8.7438e+02, 8.6848e+02 ]) + self.specific_heat.data = np.array([4.1960e+03, 4.1845e+03, 4.1768e+03, 4.1719e+03, 4.1689e+03, 4.1673e+03, 4.1668e+03, 4.1670e+03, 4.1678e+03, 4.1691e+03, 4.1707e+03, 4.1727e+03, 4.1750e+03, 4.1777e+03, 4.1807e+03, 4.1840e+03, 4.1842e+03, 4.1884e+03, 4.1930e+03, 4.1981e+03, 4.2038e+03, 4.2100e+03, 4.2168e+03, 4.2242e+03, 4.2323e+03, 4.2411e+03, 4.2507e+03, 4.2611e+03, 4.2723e+03, 4.2844e+03, 4.2974e+03, 4.3114e+03, 4.3265e+03, 4.3426e+03, 4.3600e+03, 4.3785e+03, 4.3984e+03, 4.4198e+03, 4.4427e+03, 4.4672e+03 ]) + self.conductivity.data = np.array([5.5933e-01, 5.7148e-01, 5.8247e-01, 5.9252e-01, 6.0177e-01, 6.1031e-01, 6.1823e-01, 6.2557e-01, 6.3240e-01, 6.3873e-01, 6.4460e-01, 6.5002e-01, 6.5501e-01, 6.5958e-01, 6.6376e-01, 6.6754e-01, 6.7095e-01, 6.7398e-01, 6.7665e-01, 6.7897e-01, 6.8187e-01, 6.8352e-01, 6.8484e-01, 6.8584e-01, 6.8652e-01, 6.8689e-01, 6.8697e-01, 6.8675e-01, 6.8624e-01, 6.8544e-01, 6.8437e-01, 6.8306e-01, 6.8169e-01, 6.8001e-01, 6.7802e-01, 6.7577e-01, 6.7326e-01, 6.7050e-01, 6.6749e-01, 6.6423e-01 ]) + self.viscosity.data = np.array([1.7811e-03, 1.5053e-03, 1.2921e-03, 1.1236e-03, 9.8781e-04, 8.7664e-04, 7.8435e-04, 7.0683e-04, 6.4103e-04, 5.8466e-04, 5.3599e-04, 4.9366e-04, 4.5661e-04, 4.2399e-04, 3.9511e-04, 3.6944e-04, 3.4650e-04, 3.2593e-04, 3.0741e-04, 2.9068e-04, 2.7595e-04, 2.6216e-04, 2.4957e-04, 2.3807e-04, 2.2752e-04, 2.1782e-04, 2.0888e-04, 2.0062e-04, 1.9297e-04, 1.8588e-04, 1.7928e-04, 1.7313e-04, 1.6739e-04, 1.6202e-04, 1.5698e-04, 1.5225e-04, 1.4780e-04, 1.4360e-04, 1.3963e-04, 1.3587e-04 ]) + self.saturation_pressure.data = np.array([ np.NAN, 8.8041e+02, 1.2495e+03, 1.7485e+03, 2.4147e+03, 3.2931e+03, 4.4381e+03, 5.9145e+03, 7.7984e+03, 1.0179e+04, 1.3160e+04, 1.6858e+04, 2.1410e+04, 2.6968e+04, 3.3704e+04, 4.1808e+04, 5.1493e+04, 6.2992e+04, 7.6562e+04, 9.2482e+04, 1.1106e+05, 1.3261e+05, 1.5750e+05, 1.8610e+05, 2.1882e+05, 2.5608e+05, 2.9834e+05, 3.4608e+05, 3.9979e+05, 4.6002e+05, 5.2732e+05, 6.0227e+05, 6.8548e+05, 7.7757e+05, 8.7919e+05, 9.9104e+05, 1.1138e+06, 1.2482e+06, 1.3950e+06, 1.5549e+06 ]) self.Tmin = np.min(self.temperature.data) self.Tmax = np.max(self.temperature.data) self.TminPsat = np.min(self.temperature.data[~np.isnan(self.saturation_pressure.data)]) self.name = "Water" - self.description = "Fit of the subcooled region of the full EOS from 0.5 bar to 100 bar and from 0 deg C to 200 deg C." - self.reference = "Wagner2002" + self.description = "Fit of the subcooled region of the full EOS from 1 bar to 100 bar" + self.reference = "Wagner2002, Transport properties from Huber et. al (2 papers)" self.reshapeAll() + # Specific heat needs special coefficiencts + # self.specific_heat.coeffs = np.zeros((5,7)) diff --git a/dev/incompressible_liquids/json/Water.json b/dev/incompressible_liquids/json/Water.json index 6b192ed8..e5d0a49a 100644 --- a/dev/incompressible_liquids/json/Water.json +++ b/dev/incompressible_liquids/json/Water.json @@ -10,16 +10,16 @@ "conductivity": { "coeffs": [ [ - 5.602160e-01 + 6.808850e-01 ], [ - 1.470951e-05 + 3.873815e-04 ], [ - -4.222652e-08 + -6.764932e-06 ], [ - -9.630489e-10 + 1.304806e-08 ] ], "type": "polynomial" @@ -41,7 +41,7 @@ ], "type": "polynomial" }, - "description": "Fit of the subcooled region of the full EOS from 0.5 bar to 100 bar and from 0 deg C to 200 deg C.", + "description": "Fit of the subcooled region of the full EOS from 1 bar to 100 bar", "mass2input": { "coeffs": "null", "type": "notdefined" @@ -51,7 +51,7 @@ "type": "notdefined" }, "name": "Water", - "reference": "Wagner2002", + "reference": "Wagner2002, Transport properties from Huber et. al (2 papers)", "saturation_pressure": { "coeffs": [ -3.863635e+03, @@ -79,9 +79,9 @@ }, "viscosity": { "coeffs": [ - 1.752794e+00, - -9.603666e+00, - 6.336660e+00 + 5.598818e+02, + -1.411882e+02, + 1.058592e+01 ], "type": "exponential" }, From fe48c7e403fcd86b1984593c0ef361f5b50b982d Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 7 Jan 2015 13:05:39 -0700 Subject: [PATCH 20/27] Fixed bugs with bad departure function names and better error message; Closes #396 Signed-off-by: Ian Bell --- include/CoolPropTools.h | 1 + src/Backends/Helmholtz/MixtureParameters.cpp | 2 ++ src/CoolProp.cpp | 9 ++++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/CoolPropTools.h b/include/CoolPropTools.h index d69beedd..7d0827ac 100644 --- a/include/CoolPropTools.h +++ b/include/CoolPropTools.h @@ -254,6 +254,7 @@ std::map > string_vectors; public: Dictionary(){}; + bool is_empty(void){return numbers.empty() && strings.empty() && double_vectors.empty() && string_vectors.empty();} void add_string(std::string s1, std::string s2){ strings.insert(std::pair(s1, s2));} void add_number(std::string s1, double d){ numbers.insert(std::pair(s1, d));} void add_double_vector(std::string s1, std::vector d){ double_vectors.insert(std::pair >(s1, d));} diff --git a/src/Backends/Helmholtz/MixtureParameters.cpp b/src/Backends/Helmholtz/MixtureParameters.cpp index 1aa735ad..7bcea918 100644 --- a/src/Backends/Helmholtz/MixtureParameters.cpp +++ b/src/Backends/Helmholtz/MixtureParameters.cpp @@ -365,6 +365,8 @@ void MixtureParameters::set_mixture_parameters(HelmholtzEOSMixtureBackend &HEOS) // Get the dictionary itself Dictionary &dict_dep = mixturedeparturefunctionslibrary.departure_function_map[Name]; + if (dict_dep.is_empty()){throw ValueError(format("Departure function name [%s] seems to be invalid",Name.c_str()));} + // These terms are common std::vector n = dict_dep.get_double_vector("n"); std::vector d = dict_dep.get_double_vector("d"); diff --git a/src/CoolProp.cpp b/src/CoolProp.cpp index 570648da..dcb8133f 100644 --- a/src/CoolProp.cpp +++ b/src/CoolProp.cpp @@ -422,14 +422,13 @@ double PropsSI(const std::string &Output, const std::string &Name1, double Prop1 // BEGIN OF TRY // Here is the real code that is inside the try block - - extract_backend(Ref, backend, fluid); - if (has_fractions_in_string(fluid)){ - extract_fractions(fluid, fractions); + std::string fluid_string = fluid; + if (has_fractions_in_string(fluid) || has_solution_concentration(fluid)){ + fluid_string = extract_fractions(fluid, fractions); } std::vector > IO; - _PropsSImulti(strsplit(Output,'&'), Name1, std::vector(1, Prop1), Name2, std::vector(1, Prop2), backend, std::vector(1, fluid), fractions, IO); + _PropsSImulti(strsplit(Output,'&'), Name1, std::vector(1, Prop1), Name2, std::vector(1, Prop2), backend, strsplit(fluid_string, '&'), fractions, IO); if (IO.empty()){ throw ValueError(get_global_param_string("errstring").c_str()); } if (IO.size()!= 1 || IO[0].size() != 1){ throw ValueError(format("output should be 1x1; error was %s", get_global_param_string("errstring").c_str())); } From fc7f20ab9c98b411b6ed5ca325ea6ca3ec31418a Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 7 Jan 2015 13:12:25 -0700 Subject: [PATCH 21/27] Fix the binary pair for Argon-CO2 Signed-off-by: Ian Bell --- dev/mixtures/mixture_binary_pairs.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/mixtures/mixture_binary_pairs.json b/dev/mixtures/mixture_binary_pairs.json index 2f443a8e..914eb632 100644 --- a/dev/mixtures/mixture_binary_pairs.json +++ b/dev/mixtures/mixture_binary_pairs.json @@ -112,7 +112,7 @@ "Name2": "Argon", "betaT": 1.027147, "betaV": 0.968781, - "function": "CarbonDioxide-Argon", + "function": "Argon-CarbonDioxide", "gammaT": 1.001378, "gammaV": 1.02971 }, From 082f365416a362e54d1a8738c6af454038854b66 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 7 Jan 2015 13:28:21 -0700 Subject: [PATCH 22/27] If all outputs are trivial, never do a state update in internal routines; closes #395 Added Catch test for this configuration Signed-off-by: Ian Bell --- src/CoolProp.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/CoolProp.cpp b/src/CoolProp.cpp index de337e6a..9d1c4f78 100644 --- a/src/CoolProp.cpp +++ b/src/CoolProp.cpp @@ -278,6 +278,13 @@ void _PropsSI_outputs(shared_ptr &State, // Check the inputs if (in1.size() != in2.size()){ throw ValueError(format("lengths of in1 [%d] and in2 [%d] are not the same", in1.size(), in2.size()));} bool one_input_one_output = (in1.size() == 1 && in2.size() == 1 && output_parameters.size() == 1); + // If all trivial outputs, never do a state update + bool all_trivial_outputs = true; + for (std::size_t j = 0; j < output_parameters.size(); ++j){ + if (output_parameters[j].type != output_parameter::OUTPUT_TYPE_TRIVIAL){ + all_trivial_outputs = false; + } + } if (get_debug_level() > 100) { @@ -301,7 +308,7 @@ void _PropsSI_outputs(shared_ptr &State, // Iterate over the state variable inputs for (std::size_t i = 0; i < IO.size(); ++i){ try{ - if (input_pair != INPUT_PAIR_INVALID){ + if (input_pair != INPUT_PAIR_INVALID && !all_trivial_outputs){ // Update the state since it is a valid set of inputs State->update(input_pair, in1[i], in2[i]); } @@ -473,6 +480,10 @@ TEST_CASE("Check inputs to PropsSI","[PropsSI]") SECTION("Single state, single output, pure incompressible"){ CHECK(ValidNumber(CoolProp::PropsSI("D","P",101325,"T",300,"INCOMP::DowQ"))); }; + SECTION("Single state, trivial output, pure incompressible"){ + CHECK(ValidNumber(CoolProp::PropsSI("Tmin","P",0,"T",0,"INCOMP::DowQ"))); + }; + std::cout << get_global_param_string("errstring"); SECTION("Bad input pair"){ CHECK(!ValidNumber(CoolProp::PropsSI("D","Q",0,"Q",0,"Water"))); }; From f7cb65305a6c098f69228369f7d336e0aa81ccde Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 7 Jan 2015 14:02:34 -0700 Subject: [PATCH 23/27] Fix bug with humid air properties; Closes #389 Signed-off-by: Ian Bell --- src/HumidAirProp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/HumidAirProp.cpp b/src/HumidAirProp.cpp index 84bf4345..3974cbe5 100644 --- a/src/HumidAirProp.cpp +++ b/src/HumidAirProp.cpp @@ -445,10 +445,10 @@ double f_factor(double T, double p) if (T>273.16) { // It is liquid water - p_ws=CoolProp::PropsSI("P","T",T,"Q",0,"Water"); - beta_H = HenryConstant(T); //[1/Pa] - Water->update(CoolProp::PT_INPUTS, p, T); + Water->update(CoolProp::QT_INPUTS, 0, T); + p_ws = Water->p(); vbar_ws = 1.0/Water->keyed_output(CoolProp::iDmolar); //[m^3/mol] + beta_H = HenryConstant(T); //[1/Pa] } else { @@ -853,7 +853,7 @@ double DewpointTemperature(double T, double p, double psi_w) // 611.65... is the triple point pressure of water in Pa if (p_w > 611.6547241637944){ Water->update(CoolProp::PQ_INPUTS, p, 1.0); - T0 = Water->keyed_output(CoolProp::iT); + T0 = Water->T()-1; } else{ T0 = 268; From fcd61a99c8fc34a3ac044f66d37bf33cc3d7ef8f Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 7 Jan 2015 15:12:35 -0700 Subject: [PATCH 24/27] Squelch some error/warning messages in the docs Signed-off-by: Ian Bell --- ...idgmanDerivatives.rst => BridgmanDerivatives._rst} | 0 Web/coolprop/wrappers/Mathematica/index.rst | 6 +++--- Web/coolprop/wrappers/Octave/index.rst | 2 +- Web/coolprop/wrappers/index.rst | 5 +++-- Web/fluid_properties/{TTSE.rst => TTSE._rst} | 0 Web/online/index_full.rst | 11 ----------- Web/online/index_light.rst | 11 ----------- 7 files changed, 7 insertions(+), 28 deletions(-) rename Web/{BridgmanDerivatives.rst => BridgmanDerivatives._rst} (100%) rename Web/fluid_properties/{TTSE.rst => TTSE._rst} (100%) delete mode 100644 Web/online/index_full.rst delete mode 100644 Web/online/index_light.rst diff --git a/Web/BridgmanDerivatives.rst b/Web/BridgmanDerivatives._rst similarity index 100% rename from Web/BridgmanDerivatives.rst rename to Web/BridgmanDerivatives._rst diff --git a/Web/coolprop/wrappers/Mathematica/index.rst b/Web/coolprop/wrappers/Mathematica/index.rst index 9003d587..98724f02 100644 --- a/Web/coolprop/wrappers/Mathematica/index.rst +++ b/Web/coolprop/wrappers/Mathematica/index.rst @@ -40,7 +40,7 @@ Once the dependencies are installed, you can run the builder and tests using:: Windows ^^^^^^^ -You need to just slightly modify the building procedure:: +You need to just slightly modify the building procedure 1. Checkout and preparation:: @@ -51,7 +51,7 @@ You need to just slightly modify the building procedure:: # Make a build folder mkdir build && cd build -2. Pick a toolchain (A or B) +2. Pick a toolchain (A or B) A: Building using Visual Studio:: @@ -65,7 +65,7 @@ You need to just slightly modify the building procedure:: # Build the makefile using CMake cmake .. -DCOOLPROP_MATHEMATICA_MODULE=ON -DCMAKE_VERBOSE_MAKEFILE=ON -G "MinGW Makefiles" -3. Actually do the build:: +3. Actually do the build:: # Make the shared library cmake --build . --config Release diff --git a/Web/coolprop/wrappers/Octave/index.rst b/Web/coolprop/wrappers/Octave/index.rst index 96f4c97e..ade137fc 100644 --- a/Web/coolprop/wrappers/Octave/index.rst +++ b/Web/coolprop/wrappers/Octave/index.rst @@ -48,7 +48,7 @@ Windows ------- For windows, the situation is ok, but not great. Only the MinGW builds are supported, and not comfortably -1. Download a MinGW build from `http://wiki.octave.org/Octave_for_Microsoft_Windows`_. +1. Download a MinGW build from `Octave for windows [...] [...] [<@listfiles...>] -For python, you should be using `Anaconda/Miniconda `_ for your python installation. Or, you can just install `Miniconda`_, which is sufficient +For python, you should be using `Anaconda/Miniconda `_ for your python installation. Or, you can just install `Miniconda `_, which is sufficient For the C++ compiler, the options are a bit more complicated. There are multiple (binary incompatible) versions of Visual Studio, as well as G++ ports for windows (MinGW). Unless you are compiling the python wrappers, you can compile with MinGW, so you should obtain the `MinGW installer `_ and run it. You should install all the packages available, and you MUST(!!) install to a path without spaces. ``C:\MinGW`` is recommended as an installation path. Be sure to add the folder ``C:\MinGw`` to your PATH variable. @@ -91,7 +91,7 @@ OSX should come with a c++ compiler (clang), for git and cmake your best bet is brew install cmake git p7zip -OSX includes a python version, but you should be using `Anaconda/Miniconda `_ for your python installation. Or, you can just install `Miniconda`_, which is sufficient +OSX includes a python version, but you should be using `Anaconda/Miniconda `_ for your python installation. Or, you can just install `Miniconda `_, which is sufficient If you have never done any command-line compilation before on OSX, chances are that you do not have the utilities needed. Thus you need to first install Xcode: see the description on the page http://guide.macports.org/#installing.xcode . After installing, you need to accept the license by running the following command in the Terminal:: @@ -117,6 +117,7 @@ and explicitly typing "agree" before closing. Then you can use the compiler from LibreOffice/index.rst Excel/index.rst Maple/index.rst + Mathematica/index.rst Scilab/index.rst SMath/index.rst StaticLibrary/index.rst diff --git a/Web/fluid_properties/TTSE.rst b/Web/fluid_properties/TTSE._rst similarity index 100% rename from Web/fluid_properties/TTSE.rst rename to Web/fluid_properties/TTSE._rst diff --git a/Web/online/index_full.rst b/Web/online/index_full.rst deleted file mode 100644 index 9a470adf..00000000 --- a/Web/online/index_full.rst +++ /dev/null @@ -1,11 +0,0 @@ - -.. _coolprop_online_full: - -************ -Full Version -************ - -The full version of CoolProp, supported by `ORCNext `_ - -.. raw:: html - :file: index_full.html \ No newline at end of file diff --git a/Web/online/index_light.rst b/Web/online/index_light.rst deleted file mode 100644 index e332ffb5..00000000 --- a/Web/online/index_light.rst +++ /dev/null @@ -1,11 +0,0 @@ - -.. _coolprop_online_light: - -************* -Light Version -************* - -The light version of CoolProp online, supported by `ORCNext `_ - -.. raw:: html - :file: index_light.html \ No newline at end of file From 1693b19a81a5c31624e8db66bf8fdf4ff07dbe10 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 7 Jan 2015 15:15:28 -0700 Subject: [PATCH 25/27] Fixed bug in HighLevelAPI.rst by a slightly better error message in PropsSI Signed-off-by: Ian Bell --- Web/coolprop/HighLevelAPI.rst | 2 +- wrappers/Python/CoolProp/CoolProp.pyx | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Web/coolprop/HighLevelAPI.rst b/Web/coolprop/HighLevelAPI.rst index bbd24ffc..983cf1e7 100644 --- a/Web/coolprop/HighLevelAPI.rst +++ b/Web/coolprop/HighLevelAPI.rst @@ -106,7 +106,7 @@ For a given fluid, the phase can be plotted in T-p coordinates: # Saturation curve # ---------------- Ts = np.linspace(273.16, Tc, 1000) - ps = CP.CoolProp.PropsSI('P','T',Ts,'Q',[0]*len(Ts),'Water',[1]) + ps = CP.CoolProp.PropsSI('P','T',Ts,'Q',0,'Water') # ------ # Labels diff --git a/wrappers/Python/CoolProp/CoolProp.pyx b/wrappers/Python/CoolProp/CoolProp.pyx index cef74783..fc970742 100644 --- a/wrappers/Python/CoolProp/CoolProp.pyx +++ b/wrappers/Python/CoolProp/CoolProp.pyx @@ -278,6 +278,8 @@ cpdef PropsSI(in1, in2, in3 = None, in4 = None, in5 = None, in6 = None, in7 = No __Props_err2("PropsSI", in1, in2, in3, in4, in5, in6) else: return val + else: + throw ValueError('input #7 cannot be provided') cpdef list FluidsList(): """ From 3c65678a8d385ce544b20d8a0c98bc5ba55186cd Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 7 Jan 2015 15:23:16 -0700 Subject: [PATCH 26/27] Fix python wrapper code Signed-off-by: Ian Bell --- wrappers/Python/CoolProp/CoolProp.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/Python/CoolProp/CoolProp.pyx b/wrappers/Python/CoolProp/CoolProp.pyx index fc970742..0238ebb1 100644 --- a/wrappers/Python/CoolProp/CoolProp.pyx +++ b/wrappers/Python/CoolProp/CoolProp.pyx @@ -279,7 +279,7 @@ cpdef PropsSI(in1, in2, in3 = None, in4 = None, in5 = None, in6 = None, in7 = No else: return val else: - throw ValueError('input #7 cannot be provided') + raise ValueError('input #7 cannot be provided') cpdef list FluidsList(): """ From 0fe389bfbfa87cbd7d44e734ceb905ffaf8e7591 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 7 Jan 2015 15:41:04 -0700 Subject: [PATCH 27/27] Fix Octave link for windows in docs Signed-off-by: Ian Bell --- Web/coolprop/wrappers/Octave/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Web/coolprop/wrappers/Octave/index.rst b/Web/coolprop/wrappers/Octave/index.rst index ade137fc..f06f57bb 100644 --- a/Web/coolprop/wrappers/Octave/index.rst +++ b/Web/coolprop/wrappers/Octave/index.rst @@ -48,7 +48,7 @@ Windows ------- For windows, the situation is ok, but not great. Only the MinGW builds are supported, and not comfortably -1. Download a MinGW build from `Octave for windows `_. 2. Extract the zip file to somewhere on your computer without any spaces in the path (c:\\octave-x.x.x is a good choice)