From 8b7c7e738fa4d2fa3dead08b6ebc8e577b7ccc69 Mon Sep 17 00:00:00 2001 From: Rod Persky Date: Tue, 9 Dec 2014 11:18:11 +1000 Subject: [PATCH 1/9] Delete .travis.yml as per #73 travis is being removed for now, might be back later if anyone knows how to make best use of the resouce --- .travis.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index df159034..00000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -language: c++ -compiler: - - gcc - - clang - -before_install: - - sudo apt-get install -qq python-numpy - -before_script: - - gcc -v - - mkdir build - - cd build - - cmake .. -DCOOLPROP_TESTING=ON -DCMAKE_BUILD_TYPE=Debug - - make - -script: - - pwd - - cd $TRAVIS_BUILD_DIR/build - - ctest -VV - -notifications: - email: - recipients: - - rodney.persky@gmail.com - on_success: never # default: change - on_failure: always # default: always - - hipchat: - rooms: - secure: "lc/2cWDFWpJ39ziUg406nHf+FZAt9bOBsBvsxpdfljs/llZeApi3lm+V9muoNJ76sBv5MGFNWsG2lotQi0XdxSplMsueS2yKnwtCesB4uGTj9w8I9C0NtE2NGc3sgZUD2WG+LSqLCKxlzonigw3aE0Kg5SFD9+M9dtzswU03Ujg=" From 1d1082d2be1316dad1ab1cdf403e26e38c18094c Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Mon, 8 Dec 2014 22:43:56 -0500 Subject: [PATCH 2/9] Added docs for the use of partial derivatives (first at least). Closes https://github.com/CoolProp/CoolProp/issues/312 Signed-off-by: Ian Bell --- Web/coolprop/HighLevelAPI.rst | 47 +++++++++++++++++++++++++++++++++-- Web/coolprop/LowLevelAPI.rst | 8 ++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/Web/coolprop/HighLevelAPI.rst b/Web/coolprop/HighLevelAPI.rst index 5d6dee11..bbd24ffc 100644 --- a/Web/coolprop/HighLevelAPI.rst +++ b/Web/coolprop/HighLevelAPI.rst @@ -4,6 +4,8 @@ High-Level Interface ******************** +.. contents:: :depth: 2 + PropsSI function ---------------- @@ -129,13 +131,52 @@ For a given fluid, the phase can be plotted in T-p coordinates: plt.ylabel('Pressure [Pa]') plt.xlabel('Temperature [K]') plt.tight_layout() + +.. _partial_derivatives_high_level: + +Partial Derivatives +------------------- + +First Partial Derivatives +^^^^^^^^^^^^^^^^^^^^^^^^^ +For some applications it can be useful to have access to partial derivatives of thermodynamic properties. A generalized first partial derivative has been implemented into CoolProp, which can be obtained using the ``PropsSI`` function by encoding the desired derivative as a string. The format of the string is ``d(OF)/d(WRT)|CONSTANT`` which is the same as + +.. math:: + + \left. \frac{\partial OF}{\partial WRT}\right|_{CONSTANT} + +At the low-level, the CoolProp code calls the function :cpapi:`AbstractState::first_partial_deriv`. Refer to the function documentation to see how the generalized derivative works. + +.. warning:: + + This derivative formulation is currently only valid for homogeneous (single-phase) states. Two phase derivatives are not defined, and are for many combinations, invalid. + +Here is an example of calculating the constant pressure specific heat, which is defined by the relation + +.. math:: + + c_p = \left.\frac{\partial h}{\partial T}\right|_{p} + +and called through python + +.. ipython:: + + In [1]: import CoolProp + + # c_p using c_p + In [5]: CoolProp.CoolProp.PropsSI('C','P',101325,'T',300,'Water') + + # c_p using derivative + In [5]: CoolProp.CoolProp.PropsSI('d(Hmass)/d(T)|P','P',101325,'T',300,'Water') + +It is also possible to call the derivatives directly using the :ref:`low-level partial derivatives functionality `. The low-level routine is in general faster because it avoids the string parsing. .. _predefined_mixtures: Predefined Mixtures ------------------- -A number of predefined mixtures are included in CoolProp. You can retrieve the list of predefined mixtures by calling ``get_global_param_string("predefined_mixtures")`` which will return a comma-separated list of predefined mixtures. In Python, to get the first 5 mixtures, you would do +A number of predefined mixtures are included in CoolProp. You can retrieve the list of predefined mixtures by calling ``get_global_param_string("predefined_mixtures")`` which will return a comma-separated list of predefined mixtures. In Python, to get the first 6 mixtures, you would do .. ipython:: @@ -151,7 +192,9 @@ and then to calculate the density of air using the mixture model at 1 atmosphere In [1]: CoolProp.CoolProp.PropsSI('D','P',101325,'T',300,'Air.mix') -Exactly the methodology can be used from other wrappers. +Exactly the same methodology can be used from other wrappers. + + C++ Sample Code --------------- diff --git a/Web/coolprop/LowLevelAPI.rst b/Web/coolprop/LowLevelAPI.rst index 9cb6bb67..e33acddb 100644 --- a/Web/coolprop/LowLevelAPI.rst +++ b/Web/coolprop/LowLevelAPI.rst @@ -8,6 +8,14 @@ At the C++ level, the code is based on the use of an :cpapi:`AbstractState` `abs To begin with, an illustrative example of using the low-level interface is shown here: +.. _partial_derivatives_low_level: + +Partial Derivatives +------------------- + +TO BE CONTINUED + + .. literalinclude:: snippets/AbstractState1.cxx :language: c++ From e0e2591d73823ed6b08653970b56edbb6d733484 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 9 Dec 2014 00:08:27 -0500 Subject: [PATCH 3/9] Fixed problems with HAPropsSI when wetbulb is an input by converting call to Brent. Slow but steady. Closes https://github.com/CoolProp/CoolProp/issues/311 Signed-off-by: Ian Bell --- src/HumidAirProp.cpp | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/HumidAirProp.cpp b/src/HumidAirProp.cpp index ea982585..cf84f321 100644 --- a/src/HumidAirProp.cpp +++ b/src/HumidAirProp.cpp @@ -1361,31 +1361,14 @@ double HAPropsSI(const std::string &OutputName, const std::string &Input1Name, d double T_min = 210; double T_max = 450; - T = -1; - - // First try to use the secant solver to find T at a few different temperatures - for (T_guess = 210; T_guess < 450; T_guess += 60) - { - try{ - T = Secant_HAProps_T(SecondaryInputName,(char *)"P",p,MainInputName,MainInputValue,SecondaryInputValue,T_guess); - double val = HAPropsSI(SecondaryInputName,(char *)"T",T,(char *)"P",p,MainInputName,MainInputValue); - if (!ValidNumber(T) || !ValidNumber(val) || !(T_min < T && T < T_max) || std::abs(val-SecondaryInputValue)>1e-3) - { - throw CoolProp::ValueError(); - } - else - { - break; - } - } - catch (std::exception &){}; - } - - if (T < 0) // No solution found using secant - { - // Use the Brent's method solver to find T - T = Brent_HAProps_T(SecondaryInputName,(char *)"P",p,MainInputName,MainInputValue,SecondaryInputValue,T_min,T_max); - } + try{ + // Use the Brent's method solver to find T. Slow but reliable + T = Brent_HAProps_T(SecondaryInputName, "P", p, MainInputName, MainInputValue, SecondaryInputValue, T_min,T_max); + } + catch(std::exception &e){ + CoolProp::set_error_string(e.what()); + return _HUGE; + } // If you want the temperature, return it if (Name2Type(OutputName)==GIVEN_T) From 8d8c39fc202afc6971a759708b920ae989db5c70 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Tue, 9 Dec 2014 12:00:03 +0100 Subject: [PATCH 4/9] Removed the source builder and added the zipping to the server in the release script. --- dev/buildbot/master/master.cfg | 23 ------------- dev/scripts/gitMirror.bsh | 43 ++++++++++++++++--------- dev/scripts/release.bsh | 59 +++++++++++++++++----------------- 3 files changed, 57 insertions(+), 68 deletions(-) diff --git a/dev/buildbot/master/master.cfg b/dev/buildbot/master/master.cfg index 5131d862..5db9718c 100644 --- a/dev/buildbot/master/master.cfg +++ b/dev/buildbot/master/master.cfg @@ -665,22 +665,6 @@ def SWIG_scilab_bin_builder(platform, gitMode = 'incremental', windows = False): compress="bz2")) return factory -def sourcezip_builder(gitMode = 'incremental', cmake_args = [], cmake_env = None): - """ Zip up all the sources (including externals) and upload """ - - # Create the factory to add the actions to - factory = getBaseFactory(gitMode=gitMode) - factory.addStep(MakeDirectory(dir='install_root/source', haltOnFailure = True)) - factory.addStep(ShellCommand(command='chmod +x git-archive-all', - workdir= "build/dev/scripts", - haltOnFailure = True)) - factory.addStep(ShellCommand(command='dev/scripts/git-archive-all ../install_root/source/coolpropsource.zip', - workdir= "build", - haltOnFailure = True)) - # Upload the files - factory.addStep(DirectoryUpload(slavesrc="../install_root",masterdest="public_html/binaries",url="binaries",compress="bz2")) - return factory - def memory_sanitizer_builder(): """ Run clang's memory sanitizer on the Catch tests to check for memory leaks """ @@ -861,13 +845,6 @@ c['builders'].append( factory = fortranFactory(platform=platformID["windows"],bitness=bitnessID["32bit"]) ) ) -c['builders'].append( - BuilderConfig( - name="source zipfile", - slavenames=["OSX-slave"], - factory = sourcezip_builder() - ) -) c['builders'].append( BuilderConfig( name="Fortran-executable-linux-32bit-GCC-ExternC", diff --git a/dev/scripts/gitMirror.bsh b/dev/scripts/gitMirror.bsh index 8d2dc816..0c2c8cdb 100644 --- a/dev/scripts/gitMirror.bsh +++ b/dev/scripts/gitMirror.bsh @@ -1,30 +1,41 @@ #!/bin/bash # -# This script relys on a modified ~/.ssh/config to specify the +# This script relys on a modified ~/.ssh/config to specify the # correct identity files to be used with the host aliases -# git.code.sf.net-ibell and git.code.sf.net-jorritw +# git.code.sf.net-ibell and git.code.sf.net-jorritw # # Work around for Cron: USER=coolprop source /home/$USER/.bash_profile # -FOLDER="/home/$USER/src/CoolProp.git" ORIGIN="https://github.com/CoolProp/CoolProp.git" MIRROR="ssh://git.code.sf.net-jorritw/p/coolprop/git" # -if [ ! -d $FOLDER ]; then # repo does not exist, clone it - BASEFOLDER=${FOLDER%/*} - REPOFOLDER=${FOLDER##*/} - mkdir -p $BASEFOLDER - pushd $BASEFOLDER - git clone --mirror $ORIGIN $REPOFOLDER - #pushd $REPOFOLDER - #git remote add sfmirror $MIRROR - #popd - popd -fi -pushd $FOLDER -git fetch --force $ORIGIN +function createRepo { + local GITOPT="$1" + local FOLDER="$2" + if [ ! -d $FOLDER ]; then # repo does not exist, clone it + local BASEFOLDER=${FOLDER%/*} + local REPOFOLDER=${FOLDER##*/} + mkdir -p $BASEFOLDER + pushd $BASEFOLDER + git clone $GITOPT $ORIGIN $REPOFOLDER + popd + fi + return 0 +} +# +CURFOLDER="/home/$USER/src/CoolProp.git" +createRepo "--mirror" "$CURFOLDER" +pushd $CURFOLDER +git fetch --force --all # $ORIGIN git push --force --mirror $MIRROR popd +# +CURFOLDER="/home/$USER/src/CoolPropFull.git" +createRepo "--recursive" "$CURFOLDER" +pushd $CURFOLDER +git pull +popd +# exit 0 diff --git a/dev/scripts/release.bsh b/dev/scripts/release.bsh index 590c0648..9f174bee 100755 --- a/dev/scripts/release.bsh +++ b/dev/scripts/release.bsh @@ -1,23 +1,32 @@ #!/bin/bash # -# Make sure that only one argument is passed to this script - the version that will be released +# Make sure that only two arguments are passed to this script - the version that +# will be released and the dryrun vs. release option. if [ $# != 2 ]; then - echo "Only two arguments should be passed to this script - the version that will be released and if you would like a dry run or a release; like \"release.bsh 5.0.0 dryrun\" or \"release.bsh nightly release\"." - exit 1 + echo "Only two arguments should be passed to this script: " + echo "The version that will be released and if you would like a dry run or a release." + echo "for example: \"release.bsh 5.0.0 dryrun\" or \"release.bsh nightly release\" " + exit 1 fi # CPVERSION="$1" BASEDIR="$HOME/buildbot/server-master/public_html" +REPODIR="$HOME/src/CoolPropFull.git" BINFOLDER="binaries" DOCFOLDER="sphinx" +SRCFOLDER="$BASEDIR/$BINFOLDER/source" SEPARATOR="----------------------------------" # -SFUSER="jorritw" # ibell or jorritw +SFUSER="jorritw" # ibell or jorritw # +function printMessage { + echo " " + echo $SEPARATOR + echo "$1" + return 0 +} # -echo " " -echo $SEPARATOR -echo "Processing the input variables: " +printMessage "Processing the input variables: " # CPVERSION="$1" if [[ $CPVERSION == +([0-9]).+([0-9]).+([0-9]) ]]; then @@ -31,56 +40,48 @@ fi # if [ "$2" == "release" ]; then DRYRUN=false -else +else DRYRUN=true fi echo "DRYRUN = $DRYRUN" -# -# Change the folder -pushd ${BASEDIR} -#echo "Fixing the permissions of directories and files" # This is not needed, just ignore the perms in rsync -#find . -type d ! -perm 0775 -exec chmod 0775 {} \; -#find . -type f ! -perm 0664 -exec chmod 0664 {} \; -# + +pushd ${BASEDIR} # Change the folder if [ "$DRYRUN" != "false" ]; then - echo " " - echo $SEPARATOR + printMessage "Dry run detected" + echo "Dry run; no zipping of the sources" echo "Dry run; no zipping of the docs" echo "Dry run; skipping python upload" echo "Dry run; skipping folder date" RSYNC_DRY_RUN=--dry-run else + pushd "$REPODIR" + git pull + python dev/scripts/git-archive-all $SRCFOLDER/CoolProp_sources.zip + popd if [ "$CPVERSION" = "nightly" ]; then RSYNC_OPTS="-a --no-perms -z --stats --delete" rm -rf "$BINFOLDER/docs" CPVERSION="$CPVERSION"/ #$(date +%F) else RSYNC_OPTS="-a --no-perms -z --stats" - echo " " - echo $SEPARATOR - echo "Zipping up the docs and moving them into the $BINFOLDER folder for staging" + printMessage "Zipping up the docs and moving them into the $BINFOLDER folder for staging" rm -f documentation.zip zip -rq documentation.zip $DOCFOLDER/* mkdir -p "$BINFOLDER/docs" cp documentation.zip "$BINFOLDER/docs" echo "Uploading the python binaries to pypi" twine upload $BINFOLDER/Python/*.whl $BINFOLDER/Python/*.tar.gz - fi + fi RSYNC_DRY_RUN= fi # -echo " " -echo $SEPARATOR -echo "Copying the binaries to SourceForge" +printMessage "Copying the binaries to SourceForge" rsync $RSYNC_DRY_RUN $RSYNC_OPTS "$BINFOLDER/" frs.sf.net-$SFUSER:/home/frs/project/coolprop/CoolProp/$CPVERSION if [ ${CPVERSION:0:7} != "nightly" ]; then - echo " " - echo $SEPARATOR - echo "Publishing the docs on SourceForge" + printMessage "Publishing the docs on SourceForge" rsync $RSYNC_DRY_RUN $RSYNC_OPTS "$DOCFOLDER/" frs.sf.net-$SFUSER:/home/project-web/coolprop/htdocs fi # Change back to where we came from popd -echo " " -echo "All done, goodbye." +printMessage "All done, goodbye." exit 0 From dd9e3bdf889525ffc917d63c12b4dc6bbb9a336e Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Tue, 9 Dec 2014 12:30:11 +0100 Subject: [PATCH 5/9] Added README to nightly builds --- Readme.rst | 2 +- dev/scripts/release.bsh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Readme.rst b/Readme.rst index 22e2803d..d2355a27 100644 --- a/Readme.rst +++ b/Readme.rst @@ -10,7 +10,7 @@ It was originally developed by Ian Bell, currently a post-doc at the University * For Python, you can get the latest release via ``pip install coolprop``. Currently |downloads| of |version| -* ... other binaries can be downloaded here: `latest release `_ and `development version `_ +* ... other binaries can be downloaded here: `latest release `_ and `development version `_ * The documentation is available for the `latest release `_ and the `development version `_ diff --git a/dev/scripts/release.bsh b/dev/scripts/release.bsh index 9f174bee..81537fdc 100755 --- a/dev/scripts/release.bsh +++ b/dev/scripts/release.bsh @@ -58,10 +58,16 @@ else git pull python dev/scripts/git-archive-all $SRCFOLDER/CoolProp_sources.zip popd + rm -f "$BINFOLDER/README.rst.txt" if [ "$CPVERSION" = "nightly" ]; then RSYNC_OPTS="-a --no-perms -z --stats --delete" rm -rf "$BINFOLDER/docs" CPVERSION="$CPVERSION"/ #$(date +%F) + echo "CoolProp nightly binaries" > "$BINFOLDER/README.rst.txt" + echo "-------------------------" >> "$BINFOLDER/README.rst.txt" + echo -n "Development binaries of the" >> "$BINFOLDER/README.rst.txt" + echo -n " \`CoolProp project \`_ " >> "$BINFOLDER/README.rst.txt" + echo "updated on $(date +%F) at $(date +%X) $(date +%Z)." >> "$BINFOLDER/README.rst.txt" else RSYNC_OPTS="-a --no-perms -z --stats" printMessage "Zipping up the docs and moving them into the $BINFOLDER folder for staging" From 127a9668f4f8eb1916cc916ad5e67c9eac39fe35 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Tue, 9 Dec 2014 15:13:30 +0100 Subject: [PATCH 6/9] Fixes #321 - a request for additonal aliases --- dev/Tickets/321.py | 20 ++++++++++++++++++++ dev/fluids/Air.json | 3 ++- dev/fluids/Argon.json | 3 ++- dev/fluids/Ethane.json | 3 ++- dev/fluids/Ethylene.json | 3 ++- dev/fluids/Helium.json | 3 ++- dev/fluids/Methane.json | 3 ++- dev/fluids/Neon.json | 3 ++- dev/fluids/Nitrogen.json | 3 ++- dev/fluids/Oxygen.json | 3 ++- dev/fluids/Propylene.json | 3 ++- dev/fluids/Water.json | 3 ++- dev/fluids/n-Butane.json | 3 ++- 13 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 dev/Tickets/321.py diff --git a/dev/Tickets/321.py b/dev/Tickets/321.py new file mode 100644 index 00000000..fdb1e94f --- /dev/null +++ b/dev/Tickets/321.py @@ -0,0 +1,20 @@ + +import CoolProp +import CoolProp.CoolProp as CP + +fluids = [ + ["R50", "Methane"], + ["R170", "Ethane"], + ["R600", "n-Butane"], + ["R704", "Helium"], + ["R718", "Water"], + ["R720", "Neon"], + ["R728", "Nitrogen"], + ["R729", "Air"], + ["R732", "Oxygen"], + ["R740", "Argon"], + ["R1150", "Ethylene"], + ["R1270", "Propylene"]] + +for f in fluids: + print "{0}:{1} - {2}:{3}".format(f[0],CP.PropsSI('Tcrit','T',0,'D',0,f[0]),CP.PropsSI('Tcrit','T',0,'D',0,f[1]),f[1]) \ No newline at end of file diff --git a/dev/fluids/Air.json b/dev/fluids/Air.json index 4db99e07..c2375963 100644 --- a/dev/fluids/Air.json +++ b/dev/fluids/Air.json @@ -1,7 +1,8 @@ { "ALIASES": [ "air", - "AIR" + "AIR", + "R729" ], "ANCILLARIES": { "hL": { diff --git a/dev/fluids/Argon.json b/dev/fluids/Argon.json index 4a0dac88..d0e9b9a7 100644 --- a/dev/fluids/Argon.json +++ b/dev/fluids/Argon.json @@ -1,7 +1,8 @@ { "ALIASES": [ "argon", - "ARGON" + "ARGON", + "R740" ], "ANCILLARIES": { "hL": { diff --git a/dev/fluids/Ethane.json b/dev/fluids/Ethane.json index d1217f0a..243bb8fd 100644 --- a/dev/fluids/Ethane.json +++ b/dev/fluids/Ethane.json @@ -1,7 +1,8 @@ { "ALIASES": [ "ethane", - "ETHANE" + "ETHANE", + "R170" ], "ANCILLARIES": { "hL": { diff --git a/dev/fluids/Ethylene.json b/dev/fluids/Ethylene.json index fc494a24..69190e85 100644 --- a/dev/fluids/Ethylene.json +++ b/dev/fluids/Ethylene.json @@ -1,7 +1,8 @@ { "ALIASES": [ "ethylene", - "ETHYLENE" + "ETHYLENE", + "R1150" ], "ANCILLARIES": { "hL": { diff --git a/dev/fluids/Helium.json b/dev/fluids/Helium.json index f33fc0d9..93a64c21 100644 --- a/dev/fluids/Helium.json +++ b/dev/fluids/Helium.json @@ -2,7 +2,8 @@ "ALIASES": [ "helium", "HELIUM", - "He" + "He", + "R704" ], "ANCILLARIES": { "hL": { diff --git a/dev/fluids/Methane.json b/dev/fluids/Methane.json index f3fefd77..36849b0f 100644 --- a/dev/fluids/Methane.json +++ b/dev/fluids/Methane.json @@ -2,7 +2,8 @@ "ALIASES": [ "CH4", "methane", - "METHANE" + "METHANE", + "R50" ], "ANCILLARIES": { "hL": { diff --git a/dev/fluids/Neon.json b/dev/fluids/Neon.json index 65104128..5d2d58fe 100644 --- a/dev/fluids/Neon.json +++ b/dev/fluids/Neon.json @@ -1,7 +1,8 @@ { "ALIASES": [ "neon", - "NEON" + "NEON", + "R720" ], "ANCILLARIES": { "hL": { diff --git a/dev/fluids/Nitrogen.json b/dev/fluids/Nitrogen.json index 2e0b6d19..2cb405dc 100644 --- a/dev/fluids/Nitrogen.json +++ b/dev/fluids/Nitrogen.json @@ -2,7 +2,8 @@ "ALIASES": [ "nitrogen", "NITROGEN", - "N2" + "N2", + "R728" ], "ANCILLARIES": { "hL": { diff --git a/dev/fluids/Oxygen.json b/dev/fluids/Oxygen.json index 8bbc17ea..fea066e3 100644 --- a/dev/fluids/Oxygen.json +++ b/dev/fluids/Oxygen.json @@ -2,7 +2,8 @@ "ALIASES": [ "oxygen", "OXYGEN", - "O2" + "O2", + "R732" ], "ANCILLARIES": { "hL": { diff --git a/dev/fluids/Propylene.json b/dev/fluids/Propylene.json index 680020c6..204fca7f 100644 --- a/dev/fluids/Propylene.json +++ b/dev/fluids/Propylene.json @@ -2,7 +2,8 @@ "ALIASES": [ "propylene", "PROPYLENE", - "PROPYLEN" + "PROPYLEN", + "R1270" ], "ANCILLARIES": { "hL": { diff --git a/dev/fluids/Water.json b/dev/fluids/Water.json index 67a8ffef..f21b70ab 100644 --- a/dev/fluids/Water.json +++ b/dev/fluids/Water.json @@ -3,7 +3,8 @@ "water", "WATER", "H2O", - "h2o" + "h2o", + "R718" ], "ANCILLARIES": { "hL": { diff --git a/dev/fluids/n-Butane.json b/dev/fluids/n-Butane.json index 545d0fd4..96d79f07 100644 --- a/dev/fluids/n-Butane.json +++ b/dev/fluids/n-Butane.json @@ -3,7 +3,8 @@ "nButane", "butane", "BUTANE", - "N-BUTANE" + "N-BUTANE", + "R600" ], "ANCILLARIES": { "hL": { From 61c2f88470e30ed3345ef602d2d8ea1c2abb7c61 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 9 Dec 2014 09:49:46 -0500 Subject: [PATCH 7/9] Properly disable TH and TU inputs, at least for now. Closes #319 Signed-off-by: Ian Bell --- .../Helmholtz/HelmholtzEOSMixtureBackend.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp index 3c829c30..edef5de3 100644 --- a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp +++ b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp @@ -803,9 +803,9 @@ void HelmholtzEOSMixtureBackend::mass_to_molar_inputs(CoolProp::input_pairs &inp switch(input_pair) { case DmassT_INPUTS: ///< Mass density in kg/m^3, Temperature in K - case HmassT_INPUTS: ///< Enthalpy in J/kg, Temperature in K + //case HmassT_INPUTS: ///< Enthalpy in J/kg, Temperature in K (NOT CURRENTLY IMPLEMENTED) case SmassT_INPUTS: ///< Entropy in J/kg/K, Temperature in K - case TUmass_INPUTS: ///< Temperature in K, Internal energy in J/kg + //case TUmass_INPUTS: ///< Temperature in K, Internal energy in J/kg (NOT CURRENTLY IMPLEMENTED) case DmassP_INPUTS: ///< Mass density in kg/m^3, Pressure in Pa case HmassP_INPUTS: ///< Enthalpy in J/kg, Pressure in Pa case PSmass_INPUTS: ///< Pressure in Pa, Entropy in J/kg/K @@ -825,9 +825,9 @@ void HelmholtzEOSMixtureBackend::mass_to_molar_inputs(CoolProp::input_pairs &inp switch(input_pair) { case DmassT_INPUTS: input_pair = DmolarT_INPUTS; value1 /= mm; break; - case HmassT_INPUTS: input_pair = HmolarT_INPUTS; value1 *= mm; break; + //case HmassT_INPUTS: input_pair = HmolarT_INPUTS; value1 *= mm; break; (NOT CURRENTLY IMPLEMENTED) case SmassT_INPUTS: input_pair = SmolarT_INPUTS; value1 *= mm; break; - case TUmass_INPUTS: input_pair = TUmolar_INPUTS; value2 *= mm; break; + //case TUmass_INPUTS: input_pair = TUmolar_INPUTS; value2 *= mm; break; (NOT CURRENTLY IMPLEMENTED) case DmassP_INPUTS: input_pair = DmolarP_INPUTS; value1 /= mm; break; case HmassP_INPUTS: input_pair = HmolarP_INPUTS; value1 *= mm; break; case PSmass_INPUTS: input_pair = PSmolar_INPUTS; value2 *= mm; break; @@ -882,10 +882,10 @@ void HelmholtzEOSMixtureBackend::update(CoolProp::input_pairs input_pair, double _rhomolar = value1; _T = value2; FlashRoutines::DHSU_T_flash(*this, iDmolar); break; case SmolarT_INPUTS: _smolar = value1; _T = value2; FlashRoutines::DHSU_T_flash(*this, iSmolar); break; - case HmolarT_INPUTS: - _hmolar = value1; _T = value2; FlashRoutines::DHSU_T_flash(*this, iHmolar); break; - case TUmolar_INPUTS: - _T = value1; _umolar = value2; FlashRoutines::DHSU_T_flash(*this, iUmolar); break; + //case HmolarT_INPUTS: + // _hmolar = value1; _T = value2; FlashRoutines::DHSU_T_flash(*this, iHmolar); break; + //case TUmolar_INPUTS: + // _T = value1; _umolar = value2; FlashRoutines::DHSU_T_flash(*this, iUmolar); break; case DmolarP_INPUTS: _rhomolar = value1; _p = value2; FlashRoutines::PHSU_D_flash(*this, iP); break; case DmolarHmolar_INPUTS: From 16ffbed7b09a8103d3547d18f0889aa879abe9a9 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 9 Dec 2014 11:16:27 -0500 Subject: [PATCH 8/9] Fixed bug when relative humidity was input, but T not provided. Closed #320 Signed-off-by: Ian Bell --- src/HumidAirProp.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/HumidAirProp.cpp b/src/HumidAirProp.cpp index cf84f321..84bf4345 100644 --- a/src/HumidAirProp.cpp +++ b/src/HumidAirProp.cpp @@ -1360,6 +1360,10 @@ double HAPropsSI(const std::string &OutputName, const std::string &Input1Name, d double T_min = 210; double T_max = 450; + + if (Name2Type(MainInputName) == GIVEN_RH){ + T_max = CoolProp::PropsSI("T","P",p,"Q",0,"Water") - 1; + } try{ // Use the Brent's method solver to find T. Slow but reliable From fe1e41f0ebba58040d96dac3a8ce6a42d8188898 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 10 Dec 2014 00:05:55 -0500 Subject: [PATCH 9/9] Expose fluid names through the AbstractState. Closes #322 Signed-off-by: Ian Bell --- include/AbstractState.h | 5 ++++- src/AbstractState.cpp | 4 ++++ src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp | 9 +++++++++ src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h | 1 + src/Backends/REFPROP/REFPROPMixtureBackend.cpp | 1 + src/Backends/REFPROP/REFPROPMixtureBackend.h | 3 +++ 6 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/AbstractState.h b/include/AbstractState.h index a635af6c..e0a4c8b8 100644 --- a/include/AbstractState.h +++ b/include/AbstractState.h @@ -259,7 +259,8 @@ protected: virtual void calc_specify_phase(phases phase){throw NotImplementedError("This backend does not implement calc_specify_phase function");}; /// Using this backend, unspecify the phase virtual void calc_unspecify_phase(void){throw NotImplementedError("This backend does not implement calc_unspecify_phase function");}; - + /// Using this backend get a vector of fluid names + virtual std::vector calc_fluid_names(void){throw NotImplementedError("This backend does not implement fluid_names function");}; /// Using this backend, calculate a phase given by the state string /// @param state A string that describes the state desired, one of "hs_anchor", "critical"/"crit", "reducing" virtual const CoolProp::SimpleState & calc_state(const std::string &state){throw NotImplementedError("calc_state is not implemented for this backend");}; @@ -311,6 +312,8 @@ protected: virtual void set_mole_fractions(const std::vector &mole_fractions) = 0; virtual void set_mass_fractions(const std::vector &mass_fractions) = 0; virtual void set_volu_fractions(const std::vector &mass_fractions){throw NotImplementedError("Volume composition has not been implemented.");} + + std::vector fluid_names(void); /// Clear all the cached values bool clear(); diff --git a/src/AbstractState.cpp b/src/AbstractState.cpp index 40876ddb..5dadebfd 100644 --- a/src/AbstractState.cpp +++ b/src/AbstractState.cpp @@ -78,6 +78,10 @@ AbstractState * AbstractState::factory(const std::string &backend, const std::st throw ValueError(format("Invalid backend name [%s] to factory function",backend.c_str())); } } +std::vector AbstractState::fluid_names(void) +{ + return calc_fluid_names(); +} bool AbstractState::clear() { // Reset all instances of CachedElement and overwrite diff --git a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp index edef5de3..fe00a834 100644 --- a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp +++ b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp @@ -571,6 +571,15 @@ std::string HelmholtzEOSMixtureBackend::calc_name(void) return components[0]->name; } } +std::vector HelmholtzEOSMixtureBackend::calc_fluid_names(void) +{ + std::vector out; + for (std::size_t i = 0; i < components.size(); ++i) + { + out.push_back(components[i]->name); + } + return out; +} long double HelmholtzEOSMixtureBackend::calc_ODP(void) { if (components.size() != 1){ diff --git a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h index d0374d92..3ce60153 100644 --- a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h +++ b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h @@ -222,6 +222,7 @@ public: long double calc_rhomolar_critical(void); std::string calc_name(void); + std::vector calc_fluid_names(void); void calc_all_alphar_deriv_cache(const std::vector &mole_fractions, const long double &tau, const long double &delta); long double calc_alphar_deriv_nocache(const int nTau, const int nDelta, const std::vector & mole_fractions, const long double &tau, const long double &delta); diff --git a/src/Backends/REFPROP/REFPROPMixtureBackend.cpp b/src/Backends/REFPROP/REFPROPMixtureBackend.cpp index b534185c..ce2d9d7a 100644 --- a/src/Backends/REFPROP/REFPROPMixtureBackend.cpp +++ b/src/Backends/REFPROP/REFPROPMixtureBackend.cpp @@ -537,6 +537,7 @@ bool REFPROPMixtureBackend::REFPROP_supported () { void REFPROPMixtureBackend::set_REFPROP_fluids(const std::vector &fluid_names) { long ierr=0; + this->fluid_names = fluid_names; char component_string[10000], herr[errormessagelength]; std::string components_joined = strjoin(fluid_names,"|"); std::string components_joined_raw = strjoin(fluid_names,"|"); diff --git a/src/Backends/REFPROP/REFPROPMixtureBackend.h b/src/Backends/REFPROP/REFPROPMixtureBackend.h index 602451c6..f9be5cfa 100644 --- a/src/Backends/REFPROP/REFPROPMixtureBackend.h +++ b/src/Backends/REFPROP/REFPROPMixtureBackend.h @@ -22,6 +22,7 @@ protected: static bool _REFPROP_supported; std::vector mole_fractions, mass_fractions; std::vector mole_fractions_liq, mole_fractions_vap; + std::vector fluid_names; public: REFPROPMixtureBackend(){}; @@ -29,6 +30,8 @@ public: /// @param fluid_names The vector of strings of the fluid components, without file ending REFPROPMixtureBackend(const std::vector& fluid_names); virtual ~REFPROPMixtureBackend(); + + std::vector calc_fluid_names(){return fluid_names;}; // REFPROP backend uses mole fractions bool using_mole_fractions(){return true;}