diff --git a/.github/workflows/docs_docker-run.yml b/.github/workflows/docs_docker-run.yml index 308325c8..ce580346 100644 --- a/.github/workflows/docs_docker-run.yml +++ b/.github/workflows/docs_docker-run.yml @@ -16,11 +16,6 @@ on: pull_request: branches: [ 'master', 'main', 'develop' ] -env: - DAILY: ${{ github.event.schedule == '0 2 * * *' }} - WEEKLY: ${{ github.event.schedule == '0 4 * * 1' }} - TAGGED: ${{ contains(github.ref, 'refs/tags') }} - jobs: build: runs-on: ubuntu-latest @@ -37,6 +32,7 @@ jobs: submodules: recursive - uses: actions/cache@v3 + if: ${{ !env.ACT }} # skip during local actions testing id: cached-props # steps.cached-props.outputs.cache-hit != 'true' with: path: | @@ -52,19 +48,27 @@ jobs: #restore-keys: | # cached-props- + - name: Schedule calculations + id: schedule_calculation + shell: bash + run: | + set -x + echo ${{ github.event.schedule }} + echo "COOLPROP_DAILY=${{ github.event.schedule == '0 2 * * *' }}" >> $GITHUB_ENV + echo "COOLPROP_WEEKLY=${{ github.event.schedule == '0 4 * * 1' }}" >> $GITHUB_ENV + echo ${{ github.ref }} + echo "COOLPROP_TAGGED=${{ contains(github.ref, 'refs/tags') }}" >> $GITHUB_ENV + cat $GITHUB_ENV + - name: Variable calculations id: variable_calculation shell: bash - # echo "EXPENSIVE_TRIGGERED=${{ inputs.expensive || env.TAGGED || env.WEEKLY }}" >> $GITHUB_ENV run: | set -x - echo "expensive_triggered=${{ inputs.expensive || env.TAGGED || env.WEEKLY }}" >> $GITHUB_OUTPUT - echo "expensive_cached=${{ steps.cached-props.outputs.cache-hit != 'true' }}" >> $GITHUB_OUTPUT - echo "expensive=${{ (steps.cached-props.outputs.cache-hit != 'true') || inputs.expensive || env.TAGGED || env.WEEKLY }}" >> $GITHUB_OUTPUT - cat $GITHUB_OUTPUT conda install -y packaging - COOLPROP_VERSION=$(python dev/extract_version.py --cmake-only) - echo COOLPROP_VERSION=$COOLPROP_VERSION >> $GITHUB_ENV + echo "COOLPROP_VERSION=$(python dev/extract_version.py --cmake-only)" >> $GITHUB_ENV + echo "COOLPROP_EXPENSIVE=${{ (steps.cached-props.outputs.cache-hit != 'true') || inputs.expensive || env.COOLPROP_TAGGED || env.COOLPROP_WEEKLY }}" >> $GITHUB_ENV + cat $GITHUB_ENV - name: Build and install wheel using bdist_wheel working-directory: ./wrappers/Python/ @@ -87,8 +91,8 @@ jobs: shell: bash run: | source activate docs - echo "Calling: python -u __init__.py ${{ steps.variable_calculation.outputs.expensive }}" - python -u __init__.py ${{ steps.variable_calculation.outputs.expensive }} + echo "Calling: python -u __init__.py ${{ env.COOLPROP_EXPENSIVE }}" + python -u __init__.py ${{ env.COOLPROP_EXPENSIVE }} - name: Build documentation with Doxygen shell: bash @@ -106,6 +110,7 @@ jobs: make html - name: Upload GitHub Pages artifact + if: ${{ !env.ACT }} # skip during local actions testing uses: actions/upload-pages-artifact@v1 with: path: ./Web/_build/html/ @@ -118,6 +123,7 @@ jobs: # zip -rq CoolProp-${{ env.COOLPROP_VERSION }}-documentation-html.zip html/* - name: Archive TGZ or ZIP artifacts + if: ${{ !env.ACT }} # skip during local actions testing uses: actions/upload-artifact@v3 with: name: docs @@ -157,5 +163,6 @@ jobs: steps: - name: Deploy to GitHub Pages #if: contains(github.ref, 'refs/tags') + if: ${{ !env.ACT }} # skip during local actions testing id: deployment uses: actions/deploy-pages@v1 \ No newline at end of file diff --git a/.github/workflows/javascript_builder.yml b/.github/workflows/javascript_builder.yml new file mode 100644 index 00000000..09cddae5 --- /dev/null +++ b/.github/workflows/javascript_builder.yml @@ -0,0 +1,53 @@ +name: Javascript library + +on: + push: + branches: [ 'master', 'main', 'develop', 'actions_javascript' ] + tags: [ 'v*' ] + pull_request: + branches: [ 'master', 'main', 'develop' ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + + runs-on: ubuntu-latest + container: + image: emscripten/emsdk + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Configure CMake + shell: bash + run: | + cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCOOLPROP_JAVASCRIPT_MODULE:BOOL=ON -DEMSCRIPTEN_INIT_FLAG:BOOL=OFF -DCMAKE_BUILD_TYPE=$BUILD_TYPE + # cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCOOLPROP_JAVASCRIPT_MODULE:BOOL=ON -DEMSCRIPTEN_INIT_FLAG:BOOL=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo + + - name: Build + shell: bash + run: | + set -x + cmake --build build --target install -j $(nproc) --config $BUILD_TYPE + + - name: Archive artifacts + if: ${{ !env.ACT }} # skip during local actions testing + uses: actions/upload-artifact@v3 + with: + name: Javascript + path: install_root/Javascript + + # - name: Upload TGZ or ZIP to release + # if: contains(github.ref, 'refs/tags') + # uses: svenstaro/upload-release-action@v2 + # with: + # repo_token: ${{ secrets.GITHUB_TOKEN }} + # dir: install_root/Javascript + # tag: ${{ github.ref }} + # overwrite: true + # file_glob: false diff --git a/.github/workflows/library_shared.yml b/.github/workflows/library_shared.yml index 144630ad..e8225cc5 100644 --- a/.github/workflows/library_shared.yml +++ b/.github/workflows/library_shared.yml @@ -41,20 +41,30 @@ jobs: set -x COOLPROP_VERSION=$(python dev/extract_version.py --cmake-only) echo COOLPROP_VERSION=$COOLPROP_VERSION >> $GITHUB_ENV - # Create the build directory too - mkdir build - name: Configure CMake - working-directory: ./build - shell: bash - run: cmake -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE -DCOOLPROP_SHARED_LIBRARY:BOOL=ON .. + run: cmake -B build -S . -DCMAKE_BUILD_TYPE:STRING=${{ env.BUILD_TYPE }} -DCOOLPROP_SHARED_LIBRARY:BOOL=ON - name: Build - working-directory: ./build - shell: bash - run: | - set -x - cmake --build . --target install -j $(nproc) --config $BUILD_TYPE + run: cmake --build build --target install -j $(nproc) --config ${{ env.BUILD_TYPE }} + + # Create a special case for Windows since we also need 2 flavours of 32bit binaries + - name: Configure CMake for 32bit Windows stdcall + if: startsWith(matrix.os, 'windows') + run: cmake -B build_stdc -S . -DCMAKE_BUILD_TYPE:STRING=${{ env.BUILD_TYPE }} -DCOOLPROP_SHARED_LIBRARY:BOOL=ON -DCOOLPROP_STDCALL_LIBRARY:BOOL=ON -A Win32 + + - name: Build with CMake for 32bit Windows stdcall + if: startsWith(matrix.os, 'windows') + run: cmake --build build_stdc --target install -j $(nproc) --config ${{ env.BUILD_TYPE }} + + - name: Configure CMake for 32bit Windows cdecl + if: startsWith(matrix.os, 'windows') + run: cmake -B build_cdecl -S . -DCMAKE_BUILD_TYPE:STRING=${{ env.BUILD_TYPE }} -DCOOLPROP_SHARED_LIBRARY:BOOL=ON -DCOOLPROP_CDECL_LIBRARY:BOOL=ON -A Win32 + + - name: Build with CMake for 32bit Windows cdecl + if: startsWith(matrix.os, 'windows') + run: cmake --build build_cdecl --target install -j $(nproc) --config ${{ env.BUILD_TYPE }} + # - name: Tar.gz the shared library to maintain case sensitivy and file permissions # working-directory: ./install_root/shared_library/ diff --git a/.github/workflows/mathcad_builder.yml b/.github/workflows/mathcad_builder.yml new file mode 100644 index 00000000..ef2999f8 --- /dev/null +++ b/.github/workflows/mathcad_builder.yml @@ -0,0 +1,40 @@ +name: Mathcad wrapper + +on: + push: + branches: [ 'master', 'main', 'develop', 'actions_mathcad' ] + tags: [ 'v*' ] + pull_request: + branches: [ 'master', 'main', 'develop' ] + +jobs: + build: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Get dependencies + shell: bash + run: | + mkdir "Custom Functions" + cd "Custom Functions" + curl -H "Authorization: token ${{ secrets.COOLPROP_ORG_REPO_TOKEN }}" https://raw.githubusercontent.com/CoolProp/PRIVATE_DEPENDENCIES/main/MathcadPrime/Custom%20Functions/mcadincl.h --output mcadincl.h + curl -H "Authorization: token ${{ secrets.COOLPROP_ORG_REPO_TOKEN }}" https://raw.githubusercontent.com/CoolProp/PRIVATE_DEPENDENCIES/main/MathcadPrime/Custom%20Functions/mcaduser.lib --output mcaduser.lib + + - name: Configure CMake + run: cmake -DCOOLPROP_PRIME_MODULE:BOOL=ON -DCOOLPROP_PRIME_ROOT:STRING="${{ github.workspace }}" -B build -S . + + - name: Build + run: | + cmake --build build --target CoolPropMathcadWrapper -j $(nproc) --config Release + cmake --build build --target install --config Release + + - name: Archive artifacts + uses: actions/upload-artifact@v3 + with: + name: MathcadPrime + path: install_root/MathcadPrime diff --git a/.github/workflows/python_buildwheels.yml b/.github/workflows/python_buildwheels.yml index d0dc15bb..196efb4e 100644 --- a/.github/workflows/python_buildwheels.yml +++ b/.github/workflows/python_buildwheels.yml @@ -41,7 +41,7 @@ jobs: fail-fast: false matrix: os: [ubuntu] - python-version: [36, 37, 38, 39, 310, 311] + python-version: [36, 37, 38, 39, 310, 311, 312] arch: [i686, x86_64, aarch64, ppc64le, s390x] exclude: - os: ubuntu @@ -62,7 +62,7 @@ jobs: fail-fast: false matrix: os: [windows] - python-version: [36, 37, 38, 39, 310, 311] + python-version: [36, 37, 38, 39, 310, 311, 312] arch: [AMD64, x86, ARM64] exclude: - os: windows @@ -88,7 +88,7 @@ jobs: fail-fast: false matrix: os: [macos] - python-version: [36, 37, 38, 39, 310, 311] + python-version: [36, 37, 38, 39, 310, 311, 312] arch: [x86_64, arm64, universal2] exclude: - os: macos diff --git a/.github/workflows/python_cibuildwheel.yml b/.github/workflows/python_cibuildwheel.yml index 1da66e51..7adc1d76 100644 --- a/.github/workflows/python_cibuildwheel.yml +++ b/.github/workflows/python_cibuildwheel.yml @@ -49,11 +49,12 @@ jobs: platforms: all - name: Build and test wheels - uses: pypa/cibuildwheel@v2.11.3 + uses: pypa/cibuildwheel@v2.16.2 env: MACOSX_DEPLOYMENT_TARGET: 10.9 CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=10.9 SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk - CIBW_BEFORE_BUILD: pip install setuptools wheel Cython requests jinja2 pyyaml + CIBW_BEFORE_BUILD: > + pip install setuptools wheel Cython requests jinja2 pyyaml CIBW_ENVIRONMENT_LINUX: COOLPROP_CMAKE=default,NATIVE CIBW_BUILD: cp${{ inputs.python-version }}-* CIBW_ARCHS_MACOS: ${{ inputs.arch }} # x86_64 arm64 # universal2 is redundant diff --git a/.github/workflows/release_all_files.yml b/.github/workflows/release_all_files.yml index c7de5ecf..b0bcc124 100644 --- a/.github/workflows/release_all_files.yml +++ b/.github/workflows/release_all_files.yml @@ -47,20 +47,21 @@ jobs: webdir: ${{ steps.propagate_vars.outputs.webdir }} steps: - - run: echo "BRANCH=${{ (inputs.branch == '' && 'master') || inputs.branch }}" >> $GITHUB_ENV - - run: echo "TARGET=${{ (env.BRANCH == 'master' && 'nightly') || env.BRANCH }}" >> $GITHUB_ENV - - run: echo "WEBDIR=${{ (env.BRANCH == 'master' && 'dev') || '.' }}" >> $GITHUB_ENV - - run: echo ${{ env.BRANCH }} - - run: echo ${{ env.TARGET }} - - run: echo ${{ env.WEBDIR }} - - run: echo ${BRANCH} - - run: echo ${TARGET} - - run: echo ${WEBDIR} + # Start with the branch or tag for the source code + - run: echo "BRANCH=${{ (inputs.branch == '' && 'master') || inputs.branch }}" >> $GITHUB_ENV + # Try to parse the branch as a version number + - run: | + set +e + echo "TARGET=$(echo ${{ env.BRANCH }} | grep -Eo '[0-9]+(\.[0-9]+)*')" >> $GITHUB_ENV + # Check whether we could parse it or not, use branch or nightly otherwise + - if: "${{ env.TARGET == '' }}" + run: echo "TARGET=${{ (env.BRANCH == 'master' && 'nightly') || env.BRANCH }}" >> $GITHUB_ENV + - run: echo "WEBDIR=${{ (env.TARGET == 'nightly' && 'dev') || '.' }}" >> $GITHUB_ENV - id: propagate_vars run: | - echo "branch=${{ (inputs.branch == '' && 'master') || inputs.branch }}" >> $GITHUB_OUTPUT - echo "target=${{ (env.BRANCH == 'master' && 'nightly') || env.BRANCH }}" >> $GITHUB_OUTPUT - echo "webdir=${{ (env.BRANCH == 'master' && 'dev') || '.' }}" >> $GITHUB_OUTPUT + echo "branch=${{ env.BRANCH }}" >> $GITHUB_OUTPUT + echo "target=${{ env.TARGET }}" >> $GITHUB_OUTPUT + echo "webdir=${{ env.WEBDIR }}" >> $GITHUB_OUTPUT collect_binaries: @@ -69,7 +70,7 @@ jobs: fail-fast: false matrix: os: [ubuntu] - workflow: [library_shared.yml, windows_installer.yml, docs_docker-run.yml] # , python_buildwheels.yml] + workflow: [javascript_builder.yml, library_shared.yml, windows_installer.yml, docs_docker-run.yml] # , python_buildwheels.yml] uses: ./.github/workflows/release_get_artifact.yml with: branch: ${{ needs.set_vars.outputs.branch }} diff --git a/.gitignore b/.gitignore index cf242f79..28803a05 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,4 @@ bld/ compile_commands.json cppcheck.txt +**.pyd diff --git a/.gitmodules b/.gitmodules index 573f5206..72f5553b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -30,11 +30,10 @@ path = externals/msgpack-c url = https://github.com/msgpack/msgpack-c branch = master -[submodule "externals/pybind11"] - path = externals/pybind11 - url = https://github.com/pybind/pybind11.git - branch = master [submodule "externals/rapidjson"] path = externals/rapidjson url = https://github.com/Tencent/rapidjson.git branch = master +[submodule "externals/pybind11"] + path = externals/pybind11 + url = https://github.com/pybind/pybind11.git diff --git a/CITATION.bib b/CITATION.bib new file mode 100644 index 00000000..f56cc1c6 --- /dev/null +++ b/CITATION.bib @@ -0,0 +1,13 @@ +@article{doi:10.1021/ie4033999, + author = {Bell, Ian H. and Wronski, Jorrit and Quoilin, Sylvain and Lemort, Vincent}, + title = {Pure and Pseudo-pure Fluid Thermophysical Property Evaluation and + the Open-Source Thermophysical Property Library CoolProp}, + journal = {Industrial \& Engineering Chemistry Research}, + volume = {53}, + number = {6}, + pages = {2498--2508}, + year = {2014}, + doi = {10.1021/ie4033999}, + URL = {http://pubs.acs.org/doi/abs/10.1021/ie4033999}, + eprint = {http://pubs.acs.org/doi/pdf/10.1021/ie4033999} + } diff --git a/CMakeLists.txt b/CMakeLists.txt index 10038ef0..64853b58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,8 +148,8 @@ project(${project_name}) # Project version set(COOLPROP_VERSION_MAJOR 6) set(COOLPROP_VERSION_MINOR 5) -set(COOLPROP_VERSION_PATCH 0) -set(COOLPROP_VERSION_REVISION dev) +set(COOLPROP_VERSION_PATCH 1) +set(COOLPROP_VERSION_REVISION pre) set(COOLPROP_VERSION "${COOLPROP_VERSION_MAJOR}.${COOLPROP_VERSION_MINOR}.${COOLPROP_VERSION_PATCH}${COOLPROP_VERSION_REVISION}" ) @@ -778,7 +778,7 @@ if(COOLPROP_PRIME_MODULE) if("${COOLPROP_PRIME_ROOT}" STREQUAL "") message( FATAL_ERROR - "You must provide the path to MathCAD Prime Root directory using something like -DCOOLPROP_PRIME_ROOT=\"C:/Program Files/PTC/Mathcad Prime 3.1\"" + "You must provide the path to Mathcad Prime Root directory using something like -DCOOLPROP_PRIME_ROOT=\"C:/Program Files/PTC/Mathcad Prime 3.1\"" ) else() message(STATUS "COOLPROP_PRIME_ROOT: ${COOLPROP_PRIME_ROOT}") @@ -796,11 +796,11 @@ if(COOLPROP_PRIME_MODULE) set_target_properties(CoolPropMathcadWrapper PROPERTIES SUFFIX ".dll" PREFIX "") install(TARGETS CoolPropMathcadWrapper - DESTINATION "${COOLPROP_INSTALL_PREFIX}/MathCADPrime") + DESTINATION "${COOLPROP_INSTALL_PREFIX}/MathcadPrime") install( FILES "${CMAKE_CURRENT_SOURCE_DIR}/wrappers/MathCAD/Prime/CoolPropFluidProperties.mcdx" - DESTINATION MathCADPrime) + DESTINATION MathcadPrime) endif() if(COOLPROP_MATHCAD15_MODULE) diff --git a/CoolPropBibTeXLibrary.bib b/CoolPropBibTeXLibrary.bib index 7db1eeff..d21b82a9 100644 --- a/CoolPropBibTeXLibrary.bib +++ b/CoolPropBibTeXLibrary.bib @@ -104,6 +104,18 @@ Timestamp = {2013.04.10} } +@Article{Akasaka-IJT-2023, + Title = {{A Helmholtz Energy Equation of State for trans-1,1,1,4,4,4-Hexafluoro-2-butene [R-1336mzz(E)]}}, + Author = {Ryo Akasaka and Marcia L. Huber and Luke Simoni and Eric W. Lemmon}, + Journal = {International Journal of Thermophysics}, + Year = {2023}, + Pages = {1003-1013}, + Volume = {44}, + + Doi = {10.1007/s10765-022-03143-5}, + Timestamp = {2023.10.24} +} + @Article{Akasaka-JPCRD-2015-R245fa, Title = {{A Fundamental Equation of State for 1,1,1,3,3-Pentafluoropropane (R-245fa)}}, Author = {Ryo Akasaka and Yong Zhou and Eric W. Lemmon}, @@ -169,6 +181,18 @@ Timestamp = {2014.09.17} } +@InBook{ASHRAE2006, + Title = {{2006 ASHRAE Handbook: Refrigeration}}, + Author = {{American Society of Heating, Refrigerating and Air-Conditioning Engineers}}, + Chapter = {9 Thermal Properties of Foods}, + Publisher = {{ASHRAE}}, + Year = {2006}, + + ISBN = {9781931862875}, + Owner = {jowr}, + Timestamp = {2023.11.24} +} + @TechReport{Arp-NIST-1998, Title = {{Thermophysical Properties of Helium-4 from 0.8 to 1500 K with Pressures to 2000 MPa - NIST Technical Note 1334 (revised)}}, Author = {V.D. Arp and R.D. McCarty and D.G Friend}, @@ -3258,4 +3282,24 @@ Year = {1994} } +@article{Huber-JPCRD-2016-CO2, + title = {{Reference Correlation of the Thermal Conductivity of Carbon Dioxide from the Triple Point to 1100 K and up to 200 MPa}}, + volume = {45}, + doi = {10.1063/1.4940892}, + number = {1}, + year = {2016}, + journal = {Journal of Physical and Chemical Reference Data}, + author = {M. L. Huber and E. A. Sykioti and M. J. Assael and R. A. Perkins}, +} + +@article{Laesecke-JPCRD-2017-CO2, + title = {{Reference Correlation for the Viscosity of Carbon Dioxide}}, + volume = {46}, + doi = {10.1063/1.4977429}, + number = {1}, + journal = {Journal of Physical and Chemical Reference Data}, + author = {A. Laesecke and C. D. Muzny}, + year = {2017}, +} + @Comment{jabref-meta: databaseType:bibtex;} diff --git a/Readme.rst b/Readme.rst index 6004b8bc..664f0d4e 100644 --- a/Readme.rst +++ b/Readme.rst @@ -16,7 +16,7 @@ It was originally developed by Ian Bell, at the time a post-doc at the Universit * The documentation is available for the `latest release `_ and the `development version `_ -* For any kind of question regarding CoolProp and its usage, you can ask the `CoolProp user group `_ +* For any kind of question regarding CoolProp and its usage, you can ask the `CoolProp Discussions `_ * ... you might also find answers in our `FAQ `_ diff --git a/Web/coolprop/changelog.rst b/Web/coolprop/changelog.rst index eb35c070..1649e32e 100644 --- a/Web/coolprop/changelog.rst +++ b/Web/coolprop/changelog.rst @@ -1,6 +1,43 @@ Changelog for CoolProp ====================== +6.5.0 +----- + +Highlights: + +* Mostly small bugfixes and dependency updates +* Added ability to add predefined mixtures at runtime +* Updated transport models for CO2 +* Fixed a bug in the hexane models + +Issues closed: + +* `#2051 `_ : Cyclopentane EOS needs to be updated +* `#2142 `_ : R1233zd does not work in the saturation region close to the bubble point +* `#2200 `_ : CoolProp pure Hexane bug +* `#2201 `_ : N-heptane has repeated IdealGasHelmholtzCP0AlyLee +* `#2205 `_ : Python silently crashes when calling trivial_keyed_output on binary mixtures without specified mole fractions +* `#2251 `_ : Unable to compile with fmt 10.0.0 +* `#2265 `_ : Sharp non-differentiable changes in thermal conductivity of CO2 and other gases +* `#2277 `_ : Update State class + +Pull requests merged: + +* `#2203 `_ : Provide better feedback for bad DQ inputs +* `#2207 `_ : Verify that mole fractions are set before using them +* `#2214 `_ : Change links from Google group to GitHub discussions +* `#2223 `_ : Topic 2142 +* `#2225 `_ : update cyclopentane.json +* `#2230 `_ : Topic-2200: Correct typo in n-Hexane rhoV auxilliary +* `#2238 `_ : Incomp liqna +* `#2241 `_ : Update index.rst +* `#2252 `_ : Update fmt submodule to 10.0.0 +* `#2261 `_ : Create CITATION.bib +* `#2267 `_ : implemented TCX Huber-JPCRD-2016 for CO2 +* `#2268 `_ : implemented VISC LAESECKE-JPCRD-2017-CO2 + + 6.4.3 ----- diff --git a/Web/coolprop/wrappers/Javascript/index.rst b/Web/coolprop/wrappers/Javascript/index.rst index 1e47f7f6..c7067365 100644 --- a/Web/coolprop/wrappers/Javascript/index.rst +++ b/Web/coolprop/wrappers/Javascript/index.rst @@ -8,7 +8,7 @@ Javascript Wrapper Pre-Compiled Binaries ===================== -* Download the precompiled binaries from :sfdownloads:`Javascript`, or the development versions from the buildbot server at :sfnightly:`Javascript`. Remember to get both files, ``coolprop.js`` and ``coolprop.js.mem``. +* Download the precompiled binaries from :sfdownloads:`Javascript`, or the development versions from the buildbot server at :sfnightly:`Javascript`. Remember to get both files, ``coolprop.js`` and ``coolprop.wasm``. * You can load your js file into your website, following the structure of `the example here `_, which is also included at the above download. @@ -16,7 +16,6 @@ Pre-Compiled Binaries * A live demo of the Javascript library in action can also be found `online `_. -* There is a bug in emscripten causing problems when a ``Release`` build of CMake is used. Switching to ``RelWithDebInfo`` config seems to solve it, just delete the generated .wast file. Serving the JS ============== @@ -41,8 +40,14 @@ On Apache, you need to `setup the server appropriately `_, which is also the script that generates the official downloads. + + +Linux (deprecated) +------------------ We are following the instructions from `emscripten.org `_ - download the portable emscripten SDK `emsdk` for linux. 1. First download node.js, clang++ and llvm using:: @@ -79,8 +84,8 @@ We are following the instructions from `emscripten.org `_, run the web download installer, that will install everything, and get you ready. 2. In the ``%HOME%/.emscripten`` file, make sure that there is only one entry for NODE_JS and it points to the right place. Mine looks like:: diff --git a/Web/coolprop/wrappers/MathCAD/MATHCAD15.rst b/Web/coolprop/wrappers/MathCAD/LegacyMathcad.rst similarity index 65% rename from Web/coolprop/wrappers/MathCAD/MATHCAD15.rst rename to Web/coolprop/wrappers/MathCAD/LegacyMathcad.rst index 554f5297..b4dbf054 100644 --- a/Web/coolprop/wrappers/MathCAD/MATHCAD15.rst +++ b/Web/coolprop/wrappers/MathCAD/LegacyMathcad.rst @@ -1,16 +1,16 @@ .. _mathcad15: -**************************************** -CoolProp Wrapper for MathCAD 15 (32-bit) -**************************************** +*********************************************************** +CoolProp Wrapper for Legacy Mathcad (32-bit) - Discontinued +*********************************************************** | By Scott Polak and Ian Bell, 2013. | Updated by Jeff Henning, 2016. -Pre-compiled binaries -===================== +Pre-compiled binaries (up to CoolProp v6.4.1) +============================================= -Pre-compiled binaries can be downloaded from :sfdownloads:`MathCAD15`. Development binaries coming from the buildbot server can be found at :sfnightly:`MathCAD15`. +Pre-compiled binaries can be downloaded from :sfdownloads:`MathCAD15`. These binaries are no longer generated as of CoolProp version 6.4.2 and there are no nightly builds. If you have a perpetual Legacy Mathcad license, you can attempt to build your own User-Compiled Binary using the instructions further below. To Use ------ @@ -19,7 +19,7 @@ To Use * Copy CoolProp_EN.xml to C:\\Program Files (x86)\\Mathcad\\Mathcad 15\\doc\\funcdoc -* Open the CoolPropFluidProperties.xmcdz file in MathCAD, all CoolProp functions should evaluate properly. If not, press -F9 to force recalculation of the entire workbook. +* Open the CoolPropFluidProperties.xmcdz file in Mathcad, all CoolProp functions should evaluate properly. If not, press -F9 to force recalculation of the entire workbook. * CoolProp functions can be inserted from the Mathcad Insert Functions panel under the function category: CoolProp. Input parameters and a brief description of each function will be shown. @@ -30,9 +30,9 @@ User-compiled binaries Common Requirements ------------------- -* Compilation of the MathCAD 15 wrapper requires a few :ref:`common wrapper pre-requisites ` +* Compilation of the Legacy Mathcad wrapper requires a few :ref:`common wrapper pre-requisites ` -* You will need to have Microsoft Visual Studio 2010 or later installed (Express version is fine), but 2008 version crashes when trying to compile. +* You will need to have Microsoft Visual Studio 2015 or later installed (Express or Community version is fine). To Build -------- @@ -68,6 +68,6 @@ To Use * Copy CoolProp\\wrapper\\Mathcad\\CoolProp_EN.xml to C:\\Program Files (x86)\\Mathcad\\Mathcad 15\\doc\\funcdoc -* Open the CoolPropFluidProperties.xmcdz file in MathCAD, all CoolProp functions should evaluate properly. If not, press -F9 to force recalculation of the entire workbook. +* Open the CoolPropFluidProperties.xmcdz file in Legacy Mathcad, all CoolProp functions should evaluate properly. If not, press -F9 to force recalculation of the entire workbook. * CoolProp functions can be inserted from the Mathcad Insert Functions panel under the function category: CoolProp. Input parameters and a brief description of each function will be shown. \ No newline at end of file diff --git a/Web/coolprop/wrappers/MathCAD/MATHCADPrime.rst b/Web/coolprop/wrappers/MathCAD/MathcadPrime.rst similarity index 51% rename from Web/coolprop/wrappers/MathCAD/MATHCADPrime.rst rename to Web/coolprop/wrappers/MathCAD/MathcadPrime.rst index 678f2173..d6fa4dc5 100644 --- a/Web/coolprop/wrappers/MathCAD/MATHCADPrime.rst +++ b/Web/coolprop/wrappers/MathCAD/MathcadPrime.rst @@ -1,7 +1,7 @@ .. _mathcadprime: ******************************************************** -CoolProp Wrapper for MathCAD Prime 3.x or later (64-bit) +CoolProp Wrapper for Mathcad Prime 7.0 or later (64-bit) ******************************************************** | Copyright Scott Polak and Ian Bell, 2013 @@ -10,14 +10,14 @@ CoolProp Wrapper for MathCAD Prime 3.x or later (64-bit) Pre-compiled binaries ===================== -Pre-compiled binaries can be downloaded from :sfdownloads:`MathCADPrime`. Development binaries coming from the buildbot server can be found at :sfnightly:`MathCADPrime`. +Pre-compiled binaries can be downloaded from :sfdownloads:`MathcadPrime`. Development binaries coming from the buildbot server can be found at :sfnightly:`MathcadPrime`. To Use ------ -* Copy CoolPropMathcadWrapper.dll file to C:\\Program Files\\PTC\\Mathcad Prime 3.1\\Custom Functions +* Copy CoolPropMathcadWrapper.dll file to C:\\Program Files\\PTC\\Mathcad Prime 7.0.0.0\\Custom Functions; where x.0.0.0 is the Mathcad Prime version being used. -* Open the CoolPropFluidProperties.xmcd file in MathCAD, all CoolProp functions should evaluate properly. If not, press -F9 to force recalculation of the entire workbook. +* Open the CoolPropFluidProperties.xmcd file in Mathcad Prime, all CoolProp functions should evaluate properly. If not, press -F5 to force recalculation of the entire workbook. User-compiled binaries ====================== @@ -25,9 +25,9 @@ User-compiled binaries Common Requirements ------------------- -* Compilation of the MathCAD 15 wrapper requires a few :ref:`common wrapper pre-requisites ` +* Compilation of the Mathcad Prime wrapper requires a few :ref:`common wrapper pre-requisites ` -* You will need to have Visual Studio 2008 or later installed. You will need the professional version of Visual Studio C++, or at least Visual Studio Express 2013 or later, as Mathcad Prime libraries are 64-bit and require the 64-bit compiler. +* You will need to have Visual Studio 2015 or later installed. You will need the professional or community version of Visual Studio C++, or at least Visual Studio Express 2015 or later, as Mathcad Prime libraries are 64-bit and require the 64-bit compiler. To Build -------- @@ -48,8 +48,8 @@ To Build * Build the makefile using CMake (adjust root string for correct version of Prime):: cmake .. -DCOOLPROP_PRIME_MODULE=ON - -DCOOLPROP_PRIME_ROOT="C:/Program Files/PTC/Mathcad Prime 3.1" - -G "Visual Studio 10 2010 Win64" + -DCOOLPROP_PRIME_ROOT="C:/Program Files/PTC/Mathcad Prime 7.0.0.0" + -G "Visual Studio 14 2015 Win64" -DCMAKE_VERBOSE_MAKEFILE=ON ( *Note: Mathcad Prime is 64-bit, so the 'Win64' option is necessary in the Visual Studio string.* ) @@ -61,6 +61,6 @@ To Build To Use ------ -* Copy CoolProp\\buildprime\\Release\\CoolPropMathcadWrapper.dll file to C:\\Program Files\\PTC\\Mathcad Prime 3.1\\Custom Functions +* Copy CoolProp\\buildprime\\Release\\CoolPropMathcadWrapper.dll file to C:\\Program Files\\PTC\\Mathcad Prime 7.0.0.0\\Custom Functions (or your current version) -* Open the CoolPropFluidProperties.xmcd file in MathCAD, all CoolProp functions should evaluate properly. If not, press -F9 to force recalculation of the entire workbook. \ No newline at end of file +* Open the CoolPropFluidProperties.xmcd file in Mathcad Prime, all CoolProp functions should evaluate properly. If not, press -F5 to force recalculation of the entire workbook. diff --git a/Web/coolprop/wrappers/MathCAD/index.rst b/Web/coolprop/wrappers/MathCAD/index.rst index e4572f2d..de2f54b2 100644 --- a/Web/coolprop/wrappers/MathCAD/index.rst +++ b/Web/coolprop/wrappers/MathCAD/index.rst @@ -1,13 +1,18 @@ .. _mathcad: *************** -MathCAD Wrapper +Mathcad Wrapper *************** -MathCAD comes in two mutually-incompatible flavors, MathCAD 15 and MathCAD PRIME. Please select your version from below: +This wrapper is for PTC Mathcad Prime v7.0 and higher. Files are maintained to be compatible with version 7.0, but are tested and supported on the latest available version of PTC Mathcad Prime. Any pre-compiled binaries should run on versions 7.0 or higher. + +.. note:: + Legacy Mathad (up through Mathcad 15) and Mathcad Prime 1.0 through 6.0 have been discontinued by PTC and are no longer being distributed or licensed. Some users may still have perpetual licenses of Legacy Mathcad and are free to attempt to compile their own add-in (there is no change in the C++ source code). The only requirement is that Legacy Mathcad must still be installed on the machine on which the new binary is being built. + +Please select your version from below: .. toctree:: :maxdepth: 1 - MATHCAD15.rst - MATHCADPrime.rst \ No newline at end of file + MathcadPrime.rst + LegacyMathcad.rst diff --git a/Web/coolprop/wrappers/index.rst b/Web/coolprop/wrappers/index.rst index 168a3372..10bfd200 100644 --- a/Web/coolprop/wrappers/index.rst +++ b/Web/coolprop/wrappers/index.rst @@ -29,7 +29,7 @@ Target Operating Systems :ref:`Javascript ` cross-platform Works in all internet browsers :ref:`Labview ` Windows only :ref:`Maple ` linux, OSX, win CoolProp is included in Maple 2016 -:ref:`Mathcad ` Windows only +:ref:`Mathcad ` Windows only :ref:`SMath Studio ` linux, OSX, win :ref:`Mathematica ` :ref:`FORTRAN ` linux, OSX, win @@ -125,7 +125,7 @@ and explicitly typing "agree" before closing. Then you can use the compiler from Octave/index.rst Csharp/index.rst MATLAB/index.rst - MathCAD/index.rst + Mathcad/index.rst FORTRAN/index.rst PHP/index.rst EES/index.rst diff --git a/Web/develop/release.rst b/Web/develop/release.rst index 29cc13e0..39078c09 100644 --- a/Web/develop/release.rst +++ b/Web/develop/release.rst @@ -45,8 +45,11 @@ the CoolProp library. * **Push to master**: Merge your changes to the *master* branch and wait for the CI system to complete the work. Only proceed if all builds finish successfully. + Just to be on the safe side, you may want to trigger the regeneration of the + expensive documentation graphs manually. If anything goes wrong, you should be + able to debug the workflows locally using act (https://github.com/nektos/act/). * **Tag a release**: Tag the master branch for using ``vX.X.X`` and wait once more - for all CI actions to complete. Make sure that the Pythpon wheels get uploaded + for all CI actions to complete. Make sure that the Python wheels get uploaded to PyPi automatically. * **Release**: Wait for all actions to finish and manually launch the release action with the version number vX.X.X as input. This updates the homepage and uploads the diff --git a/Web/index.rst b/Web/index.rst index 3b1ca1d0..671cb252 100644 --- a/Web/index.rst +++ b/Web/index.rst @@ -52,7 +52,7 @@ See more examples of PropsSI usage at :ref:`High-Level interface `_ +* (**General Discussion**) Create a new discussion at `Github CoolProp Discussions `_ * (**Bugs, feature requests**) File a `Github issue `_ * `Docs for v4 of CoolProp `_ * `Docs for development version of CoolProp `_ @@ -67,8 +67,9 @@ Projects Using CoolProp * `StateCalc `_ * `SmoWeb `_ * `T-Props `_ -* `PropiedadesDeFluidos `_ +* `PropiedadesDeFluidos `_ (FluidProperties) * `CoolPropJavascriptDemo `_ +* `pSolver `_ Main Developers --------------- diff --git a/Web/scripts/__init__.py b/Web/scripts/__init__.py index 307a27bf..f8314329 100644 --- a/Web/scripts/__init__.py +++ b/Web/scripts/__init__.py @@ -59,6 +59,7 @@ def run_script(path): subprocess.check_call('python -u {0}'.format(file_name), cwd=file_path, shell=True) elif file_extension.lower() == "sh" or file_extension.lower() == "bsh": subprocess.check_call('chmod +x {0}'.format(file_name), cwd=file_path, shell=True) + subprocess.check_call('sed -i "s/\r//g" {0}'.format(file_name), cwd=file_path, shell=True) subprocess.check_call('./{0}'.format(file_name), cwd=file_path, shell=True) else: print("Unknown file extension in {0}".format(path)) diff --git a/Web/scripts/fluid_properties.Incompressibles.py b/Web/scripts/fluid_properties.Incompressibles.py index ae87da17..b68f7885 100644 --- a/Web/scripts/fluid_properties.Incompressibles.py +++ b/Web/scripts/fluid_properties.Incompressibles.py @@ -92,11 +92,18 @@ for fluid in CoolProp.__incompressibles_pure__ + CoolProp.__incompressibles_solu Tmax = state.Tmax() T = np.linspace(Tmin, Tmax, N) for i, Ti in enumerate(T): - state.update(CoolProp.PT_INPUTS, p, Ti) - Pr[i] = state.Prandtl() - la[i] = state.conductivity() - mu[i] = state.viscosity() - cp[i] = state.cpmass() + try: + state.update(CoolProp.PT_INPUTS, p, Ti) + Pr[i] = state.Prandtl() + la[i] = state.conductivity() + mu[i] = state.viscosity() + cp[i] = state.cpmass() + except Exception as e: + print(e) + Pr[i] = np.NaN + la[i] = np.NaN + mu[i] = np.NaN + cp[i] = np.NaN #print(np.min(Pr), np.max(Pr)) Pr_axis.plot(T - 273.15, Pr) la_axis.plot(T - 273.15, la) diff --git a/dev/Tickets/2295.py b/dev/Tickets/2295.py new file mode 100644 index 00000000..f49d81ed --- /dev/null +++ b/dev/Tickets/2295.py @@ -0,0 +1,32 @@ +import CoolProp as CP + + +p = 1e6 +for fluid in ["PHE", "Water", "TVP1", "DowQ"]: + CP.CoolProp.set_debug_level(0) + + state = CP.AbstractState("INCOMP", fluid) + + Tmax = state.trivial_keyed_output(CP.iT_max) + Tmin = state.trivial_keyed_output(CP.iT_min) + Tbase = (Tmax + Tmin) * 0.5 + + state.update(CP.PT_INPUTS, p, Tbase + 1e-6) + h_hi = state.hmass() + s_hi = state.smass() + state.update(CP.PT_INPUTS, p, Tbase - 1e-6) + h_lo = state.hmass() + s_lo = state.smass() + + state.update(CP.PT_INPUTS, p, Tbase) + try: + print(state.hmass(), "J/kg vs", (h_hi + h_lo) * 0.5, "J/kg") + print(state.smass(), "J/kg/K vs", (s_hi + s_lo) * 0.5, "J/kg/K") + except ValueError as e: + # msg = ( + # "Exactly the middle between maximum and minimum temperature does " + # f"not work for {fluid}." + # ) + # print(msg) + print(str(e)) + print((h_hi + h_lo) * 0.5, "J/kg and", (s_hi + s_lo) * 0.5, "J/kg/K") diff --git a/dev/fluids/CarbonDioxide.json b/dev/fluids/CarbonDioxide.json index e07c63d9..041e21fe 100644 --- a/dev/fluids/CarbonDioxide.json +++ b/dev/fluids/CarbonDioxide.json @@ -615,172 +615,106 @@ }, "TRANSPORT": { "conductivity": { - "BibTeX": "Scalabrin-JPCRD-2006-CO2", + "BibTeX": "Huber-JPCRD-2016-CO2", "critical": { - "hardcoded": "CarbonDioxideScalabrinJPCRD2006" + "GAMMA": 0.052, + "R0": 1.02, + "T_ref": 456.19, + "gamma": 1.239, + "nu": 0.63, + "qD": 2500000000.0, + "zeta0": 1.5e-10, + "type": "simplified_Olchowy_Sengers" }, "dilute": { - "hardcoded": "none" + "hardcoded": "CarbonDioxideHuberJPCRD2016" }, "residual": { - "A": [ - 0.0370597124660408, - 0.0007696647124242399, - 0.0075538113451464, - -0.032416436589336, - 0.078894098855904, - 0.0177830586854928, - 0.10744756315137599, - 0.31839746259479995, - -0.00082691726160072, - 2.0846013855224798e-05 + "B": [ + 0.0100128, + 0.0560488, + -0.0811620, + 0.0624337, + -0.0206336, + 0.00253248, + 0.00430829, + -0.0358563, + 0.0671480, + -0.0522855, + 0.0174571, + -0.00196414 ], "T_reducing": 304.1282, "T_reducing_units": "K", "d": [ 1.0, + 2.0, + 3.0, + 4.0, 5.0, - 1.0, + 6.0, 1.0, 2.0, - 0.0, + 3.0, + 4.0, 5.0, - 9.0, - 0.0, - 0.0 - ], - "gamma": [ - 0, - 0, - 0, - 5, - 5, - 5, - 5, - 5, - 5, - 5 - ], - "l": [ - 0, - 0, - 0, - 2, - 2, - 2, - 2, - 2, - 2, - 2 + 6.0 ], "rhomass_reducing": 467.6, "rhomass_reducing_units": "kg/m^3", "t": [ 0.0, 0.0, - -1.5, + 0.0, + 0.0, + 0.0, 0.0, -1.0, - -1.5, - -1.5, - -1.5, - -3.5, - -5.5 + -1.0, + -1.0, + -1.0, + -1.0, + -1.0 ], - "type": "polynomial_and_exponential" + "type": "polynomial" } }, "viscosity": { - "BibTeX": "Fenghour-JPCRD-1998", - "_note": "sigma set to 1 nm in since sigma wrapped into constant in equation in Fenghour", + "BibTeX": "Laesecke-JPCRD-2017-CO2", "dilute": { - "C": 1.5178953643112785e-07, - "_note": "Leading coefficient was back calculated from 1.00697e-6/(44.0098)**0.5 (using sigma = 1 nm)", - "a": [ - 0.235156, - -0.491266, - 0.05211155, - 0.05347906, - -0.01537102 - ], - "molar_mass": 0.0440098, - "molar_mass_units": "kg/mol", - "t": [ - 0, - 1, - 2, - 3, - 4 - ], - "type": "collision_integral" + "hardcoded": "CarbonDioxideLaeseckeJPCRD2017" }, - "epsilon_over_k": 251.196, + "initial_density": { + "type": "Rainwater-Friend", + "b": [ + -19.572881, + 219.73999, + -1015.3226, + 2471.0125, + -3375.1717, + 2491.6597, + -787.26086, + 14.085455, + -0.34664158 + ], + "t": [ + 0.0, + -0.25, + -0.5, + -0.75, + -1.0, + -1.25, + -1.5, + -2.5, + -5.5 + ] + }, + "epsilon_over_k": 200.760, "epsilon_over_k_units": "K", "higher_order": { - "T_reduce": 304.1282, - "T_reduce_units": "K", - "_note": "All of the coefficients for higher order viscosity contribution were converted to be in terms of delta and tau", - "a": [ - 1.9036541208525784e-06, - 1.57384720473354e-05, - 1.4207809578440784e-07, - 6.79058431241662e-08, - -3.0732988514867565e-08 - ], - "d1": [ - 1, - 2, - 6, - 8, - 8 - ], - "d2": [ - 1 - ], - "f": [ - 0 - ], - "g": [ - 1 - ], - "gamma": [ - 0, - 0, - 0, - 0, - 0 - ], - "h": [ - 0 - ], - "l": [ - 1, - 1, - 1, - 1, - 0 - ], - "p": [ - 1 - ], - "q": [ - 0 - ], - "rhomolar_reduce": 10624.9, - "rhomolar_reduce_units": "mol/m^3", - "t1": [ - 0, - 0, - 3, - 0, - 1 - ], - "t2": [ - 0 - ], - "type": "modified_Batschinski_Hildebrand" + "hardcoded": "CarbonDioxideLaeseckeJPCRD2017" }, - "sigma_eta": 1e-09, + "sigma_eta": 0.378421e-09, "sigma_eta_units": "m" } } diff --git a/dev/fluids/Cyclopentane.json b/dev/fluids/Cyclopentane.json index 5a12d17d..ccf8c58f 100644 --- a/dev/fluids/Cyclopentane.json +++ b/dev/fluids/Cyclopentane.json @@ -200,9 +200,9 @@ "T_units": "K", "hmolar": 38057.35612816187, "hmolar_units": "J/mol", - "p": 4571200, + "p": 4582800, "p_units": "Pa", - "rhomolar": 3820.000000000001, + "rhomolar": 3920.000000000001, "rhomolar_units": "mol/m^3", "smolar": 87.99746047649523, "smolar_units": "J/mol/K" @@ -240,26 +240,26 @@ "acentric_units": "-", "alpha0": [ { - "a1": 3.2489131288, - "a2": 2.6444166315, + "a1": -0.3946233253, + "a2": 2.4918910143, "type": "IdealGasHelmholtzLead" }, { - "a": 0.96, + "a": 3.0, "type": "IdealGasHelmholtzLogTau" }, { "n": [ - 3.34, - 18.6, - 13.9, - 4.86 + 1.34, + 13.4, + 17.4, + 6.65 ], "t": [ - 0.2345032439615415, - 2.540451809583366, - 5.276322989134683, - 10.35722660830141 + 0.4494645509262878, + 2.3059485656218244, + 4.299226139294927, + 10.161807238333463 ], "type": "IdealGasHelmholtzPlanckEinstein" } @@ -291,73 +291,79 @@ 1 ], "n": [ - 0.0536938, - 1.60394, - -2.41244, - -0.474009, - 0.203482, - -0.965616, - -0.344543, - 0.353975, - -0.231373, - -0.0379099 + 0.0630928, + 1.50365, + -2.37099, + -0.484886, + 0.191843, + -0.835582, + -0.435929, + 0.545607, + -0.209741, + -0.0387635 ], "t": [ - 1, + 1.0, 0.29, - 0.8, - 1.14, - 0.5, - 2, + 0.85, + 1.185, + 0.45, + 2.28, + 1.8, 1.5, - 1, - 3.36, - 0.95 - ], + 2.9, + 0.93], "type": "ResidualHelmholtzPower" }, { "beta": [ - 1.15, - 1.61, - 0.66, - 2.72 + 0.63, + 2.8, + 0.5, + 0.95, + 0.23 ], "d": [ 1, 1, 3, - 3 + 3, + 2 ], "epsilon": [ - 0.68, - 0.97, - 0.84, - 0.66 + 0.684, + 0.7, + 0.77, + 0.625, + 0.42 ], "eta": [ - 0.82, - 1.19, - 0.79, - 1.52 + 0.86, + 0.85, + 0.86, + 1.53, + 5.13 ], "gamma": [ - 1.08, - 0.36, - 0.09, - 1.48 + 1.22, + 0.32, + 0.22, + 1.94, + 1.21 ], "n": [ - 0.867586, - -0.381827, - -0.108741, - -0.0976984 + 0.677674, + -0.137043, + -0.0852862, + -0.128085, + -0.00389381 ], "t": [ - 1, - 2.5, - 2.5, - 1.5 + 1.05, + 4.0, + 2.33, + 1.5, + 1.0 ], "type": "ResidualHelmholtzGaussian" } @@ -557,4 +563,4 @@ "type": "Chung" } } -} \ No newline at end of file +} diff --git a/dev/fluids/R1233zd(E).json b/dev/fluids/R1233zd(E).json index af40cdc8..734c40b8 100644 --- a/dev/fluids/R1233zd(E).json +++ b/dev/fluids/R1233zd(E).json @@ -1,27 +1,5 @@ { "ANCILLARIES": { - "hL": { - "A": [ - -59081.90149961518, - -56.71632899355515, - 3.4601929994947436, - -0.022382015166099334, - 7.983388457665615e-05, - -1.6902202857616328e-07, - 1.9661600933963034e-10, - -9.735546908737005e-14 - ], - "B": [ - 1, - -0.0022550755060008 - ], - "Tmax": 439.5, - "Tmin": 195.15, - "_note": "coefficients are in increasing order; input in K, output in J/mol; value is enthalpy minus hs_anchor enthalpy", - "max_abs_error": 271.53420989192637, - "max_abs_error_units": "J/mol", - "type": "rational_polynomial" - }, "hLV": { "A": [ -5135.181894492507, diff --git a/dev/fluids/R1336mzz(E).json b/dev/fluids/R1336mzz(E).json new file mode 100644 index 00000000..0988bdce --- /dev/null +++ b/dev/fluids/R1336mzz(E).json @@ -0,0 +1,330 @@ +{ + "ANCILLARIES": { + "pS": { + "T_r": 403.53, + "Tmax": 403.53, + "Tmin": 0.0, + "description": "P=Pc*EXP[SUM(Ni*Theta^ti)*Tc/T]", + "n": [ + -8.2611, + 3.9076, + -3.9675, + -6.1565 + ], + "reducing_value": 2779000.0, + "t": [ + 1.0, + 1.5, + 1.88, + 4.47 + ], + "type": "pL", + "using_tau_r": true + }, + "rhoL": { + "T_r": 403.53, + "Tmax": 403.53, + "Tmin": 0.0, + "description": "D=Dc*[1+SUM(Ni*Theta^ti)]", + "n": [ + 2.1958, + 6.4706, + -13.191, + 7.7906 + ], + "reducing_value": 3129.0, + "t": [ + 0.347, + 1.42, + 1.82, + 2.232 + ], + "type": "rhoLnoexp", + "using_tau_r": false + }, + "rhoV": { + "T_r": 403.53, + "Tmax": 403.53, + "Tmin": 0.0, + "description": "D=Dc*EXP[SUM(Ni*Theta^ti)]", + "n": [ + -3.1511, + -9.2173, + -32.976, + -86.791 + ], + "reducing_value": 3129.0, + "t": [ + 0.387, + 1.34, + 3.77, + 7.85 + ], + "type": "rhoV", + "using_tau_r": false + } + }, + "EOS": [ + { + "BibTeX_CP0": "", + "BibTeX_EOS": "Akasaka-IJT-2023", + "STATES": { + "reducing": { + "T": 403.53, + "T_units": "K", + "hmolar": -99999999999, + "hmolar_units": "J/mol", + "p": 2779000.0, + "p_units": "Pa", + "rhomolar": 3129.0, + "rhomolar_units": "mol/m^3", + "smolar": 999999999999999, + "smolar_units": "J/mol/K" + }, + "sat_min_liquid": { + "T": 200.15, + "T_units": "K", + "hmolar": -999999999999, + "hmolar_units": "J/mol", + "p": 649.2750000000001, + "p_units": "Pa", + "rhomolar": 5681.7471741845075, + "rhomolar_units": "mol/m^3", + "smolar": 99999999999999999999, + "smolar_units": "J/mol/K" + }, + "sat_min_vapor": { + "T": 200.15, + "T_units": "K", + "hmolar": 9999999999999, + "hmolar_units": "J/mol", + "p": 649.2750000000001, + "p_units": "Pa", + "rhomolar": 1e-10, + "rhomolar_units": "mol/m^3", + "smolar": 9999999999999999999, + "smolar_units": "J/mol/K" + } + }, + "T_max": 410.0, + "T_max_units": "K", + "Ttriple": 200.15, + "Ttriple_units": "K", + "acentric": 0.413, + "acentric_units": "-", + "alpha0": [ + { + "a1": 0.0, + "a2": 0.0, + "type": "IdealGasHelmholtzLead" + }, + { + "a": 3.0, + "type": "IdealGasHelmholtzLogTau" + }, + { + "n": [ + -17.583859885194016, + 11.524417012948918 + ], + "t": [ + 0.0, + 1.0 + ], + "type": "IdealGasHelmholtzPower" + }, + { + "n": [ + 15.891, + 14.143 + ], + "t": [ + 1.3629717740936238, + 8.609025351275 + ], + "type": "IdealGasHelmholtzPlanckEinstein" + } + ], + "alphar": [ + { + "d": [ + 4.0, + 1.0, + 1.0, + 2.0, + 3.0, + 1.0, + 3.0, + 2.0, + 2.0, + 7.0 + ], + "l": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 2.0, + 1.0, + 2.0, + 1.0 + ], + "n": [ + 0.08297005, + 1.1213658, + -2.0279038680756, + -0.3486706213113, + 0.13227952, + -1.3751844, + -1.3939029, + 0.11190839, + -0.90635088, + -0.050014594 + ], + "t": [ + 1.0, + 0.117, + 1.0, + 1.0, + 0.413, + 2.44, + 2.51, + 0.535, + 1.927, + 1.186 + ], + "type": "ResidualHelmholtzPower" + }, + { + "beta": [ + 1.237, + 0.384, + 1.24, + 0.46, + 1.326 + ], + "d": [ + 1.0, + 1.0, + 3.0, + 2.0, + 2.0 + ], + "epsilon": [ + 1.23, + 0.751, + 0.522, + 0.32, + 1.22 + ], + "eta": [ + 1.234, + 1.34, + 1.13, + 1.15, + 1.3 + ], + "gamma": [ + 1.21, + 2.0, + 1.216, + 2.27, + 1.26 + ], + "n": [ + 1.7953748, + 2.0579712, + -1.0433081, + -1.2459808, + -0.49712249 + ], + "t": [ + 0.876, + 1.23, + 0.875, + 0.5181, + 0.86 + ], + "type": "ResidualHelmholtzGaussian" + } + ], + "gas_constant": 8.314462618, + "gas_constant_units": "J/mol/K", + "molar_mass": 0.1640491, + "molar_mass_units": "kg/mol", + "p_max": 5700000.0, + "p_max_units": "Pa", + "pseudo_pure": false + } + ], + "INFO": { + "2DPNG_URL": "http://www.chemspider.com/ImagesHandler.ashx?id=-1", + "ALIASES": [ + "(E)-1,1,1,4,4,4-HEXAFLUORO-2-BUTENE", + "r1336mzz(e)", + "R1336mzz(E)", + "(E)-1,1,1,4,4,4-Hexafluoro-2-butene", + "R1336MZZ(E)", + "(e)-1,1,1,4,4,4-hexafluoro-2-butene" + ], + "CAS": "66711-86-2", + "CHEMSPIDER_ID": -1, + "ENVIRONMENTAL": { + "ASHRAE34": "A1", + "FH": 0, + "GWP100": 1.0, + "GWP20": 0.0, + "GWP500": 0.0, + "HH": 0, + "Name": "R1336MZZE", + "ODP": 0.0, + "PH": 1e+30 + }, + "FORMULA": "C_{4}H_{2}F_{6}", + "INCHI_KEY": "NLOLSXYRJFEOTA-OWOJBTEDSA-N", + "INCHI_STRING": "InChI=1S/C4H2F6/c5-3(6,7)1-2-4(8,9)10/h1-2H/b2-1+", + "NAME": "R1336MZZE", + "REFPROP_NAME": "R1336MZZE", + "SMILES": "?" + }, + "STATES": { + "critical": { + "T": 403.53, + "T_units": "K", + "hmolar": -99999999999, + "hmolar_units": "J/mol", + "p": 2779000.0, + "p_units": "Pa", + "rhomolar": 3129.0, + "rhomolar_units": "mol/m^3", + "smolar": 999999999999999, + "smolar_units": "J/mol/K" + }, + "triple_liquid": { + "T": 200.15, + "T_units": "K", + "hmolar": -999999999999, + "hmolar_units": "J/mol", + "p": 649.2750000000001, + "p_units": "Pa", + "rhomolar": 5681.7471741845075, + "rhomolar_units": "mol/m^3", + "smolar": 99999999999999999999, + "smolar_units": "J/mol/K" + }, + "triple_vapor": { + "T": 200.15, + "T_units": "K", + "hmolar": 9999999999999, + "hmolar_units": "J/mol", + "p": 649.2750000000001, + "p_units": "Pa", + "rhomolar": 1e-10, + "rhomolar_units": "mol/m^3", + "smolar": 9999999999999999999, + "smolar_units": "J/mol/K" + } + } +} diff --git a/dev/fluids/n-Hexane.json b/dev/fluids/n-Hexane.json index 6d60ff21..bad0a583 100644 --- a/dev/fluids/n-Hexane.json +++ b/dev/fluids/n-Hexane.json @@ -96,7 +96,7 @@ "T_r": 507.82, "Tmax": 507.82, "Tmin": 177.83, - "description": "rho'' = rhoc*exp(Tc/T*sum(n_i*theta^t_i))", + "description": "rho'' = rhoc*exp(sum(n_i*theta^t_i))", "max_abserror_percentage": 1.0104195769602642, "n": [ -3.4056, @@ -116,7 +116,7 @@ 30.0 ], "type": "rhoV", - "using_tau_r": true + "using_tau_r": false }, "sL": { "A": [ diff --git a/dev/incompressible_liquids/CPIncomp/CoefficientFluids.py b/dev/incompressible_liquids/CPIncomp/CoefficientFluids.py index f5dc6b71..726716c6 100644 --- a/dev/incompressible_liquids/CPIncomp/CoefficientFluids.py +++ b/dev/incompressible_liquids/CPIncomp/CoefficientFluids.py @@ -39,3 +39,192 @@ class NitrateSalt(PureData, CoefficientData): self.viscosity.type = self.viscosity.INCOMPRESSIBLE_POLYNOMIAL self.viscosity.source = self.viscosity.SOURCE_COEFFS self.viscosity.coeffs = np.array([[22.714], [-0.120], [2.281 * 1e-4], [-1.474 * 1e-7]]) / 1e3 + + +class FoodProtein(PureData, CoefficientData): + + def __init__(self): + CoefficientData.__init__(self) + PureData.__init__(self) + self.name = "FoodProtein" + self.description = "Food protein model from the 2006 ASHRAE Handbook based on data from Choi and Okos (1986)" + self.reference = "ASHRAE2006" + + self.Tmin = -40 + 273.15 + self.Tmax = 150 + 273.15 + self.TminPsat = self.Tmax + self.Tbase = 0.00 + 273.15 + + self.conductivity.source = self.conductivity.SOURCE_COEFFS + self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL + self.conductivity.coeffs = np.array([[1.7881e-1], [1.1958e-3], [-2.7178e-6]]) + + self.density.source = self.density.SOURCE_COEFFS + self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL + self.density.coeffs = np.array([[1.3299e3], [-5.1840e-1]]) + + self.specific_heat.source = self.specific_heat.SOURCE_COEFFS + self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL + self.specific_heat.coeffs = np.array([[2.0082], [1.2089e-3], [-1.3129e-6]]) * 1e3 + + +class FoodFat(PureData, CoefficientData): + + def __init__(self): + CoefficientData.__init__(self) + PureData.__init__(self) + self.name = "FoodFat" + self.description = "Food fat model from the 2006 ASHRAE Handbook based on data from Choi and Okos (1986)" + self.reference = "ASHRAE2006" + + self.Tmin = -40 + 273.15 + self.Tmax = 150 + 273.15 + self.TminPsat = self.Tmax + self.Tbase = 0.00 + 273.15 + + self.conductivity.source = self.conductivity.SOURCE_COEFFS + self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL + self.conductivity.coeffs = np.array([[1.8071e-1], [-2.7604e-4], [-1.7749e-7]]) + + self.density.source = self.density.SOURCE_COEFFS + self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL + self.density.coeffs = np.array([[9.2559e2], [-4.1757e-1]]) + + self.specific_heat.source = self.specific_heat.SOURCE_COEFFS + self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL + self.specific_heat.coeffs = np.array([[1.9842], [1.4733e-3], [-4.8008e-6]]) * 1e3 + + +class FoodCarbohydrate(PureData, CoefficientData): + + def __init__(self): + CoefficientData.__init__(self) + PureData.__init__(self) + self.name = "FoodCarbohydrate" + self.description = "Food carbohydrate model from the 2006 ASHRAE Handbook based on data from Choi and Okos (1986)" + self.reference = "ASHRAE2006" + + self.Tmin = -40 + 273.15 + self.Tmax = 150 + 273.15 + self.TminPsat = self.Tmax + self.Tbase = 0.00 + 273.15 + + self.conductivity.source = self.conductivity.SOURCE_COEFFS + self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL + self.conductivity.coeffs = np.array([[2.0141e-1], [1.3874e-3], [-4.3312e-6]]) + + self.density.source = self.density.SOURCE_COEFFS + self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL + self.density.coeffs = np.array([[1.5991e3], [-3.1046e-1]]) + + self.specific_heat.source = self.specific_heat.SOURCE_COEFFS + self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL + self.specific_heat.coeffs = np.array([[1.5488], [1.9625e-3], [-5.9399e-6]]) * 1e3 + + +class FoodFiber(PureData, CoefficientData): + + def __init__(self): + CoefficientData.__init__(self) + PureData.__init__(self) + self.name = "FoodFiber" + self.description = "Food fiber model from the 2006 ASHRAE Handbook based on data from Choi and Okos (1986)" + self.reference = "ASHRAE2006" + + self.Tmin = -40 + 273.15 + self.Tmax = 150 + 273.15 + self.TminPsat = self.Tmax + self.Tbase = 0.00 + 273.15 + + self.conductivity.source = self.conductivity.SOURCE_COEFFS + self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL + self.conductivity.coeffs = np.array([[1.8331e-1], [1.2497e-3], [-3.1683e-6]]) + + self.density.source = self.density.SOURCE_COEFFS + self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL + self.density.coeffs = np.array([[1.3115e3], [-3.6589e-1]]) + + self.specific_heat.source = self.specific_heat.SOURCE_COEFFS + self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL + self.specific_heat.coeffs = np.array([[1.8459], [1.8306e-3], [-4.6509e-6]]) * 1e3 + + +class FoodAsh(PureData, CoefficientData): + + def __init__(self): + CoefficientData.__init__(self) + PureData.__init__(self) + self.name = "FoodAsh" + self.description = "Food ash model from the 2006 ASHRAE Handbook based on data from Choi and Okos (1986)" + self.reference = "ASHRAE2006" + + self.Tmin = -40 + 273.15 + self.Tmax = 150 + 273.15 + self.TminPsat = self.Tmax + self.Tbase = 0.00 + 273.15 + + self.conductivity.source = self.conductivity.SOURCE_COEFFS + self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL + self.conductivity.coeffs = np.array([[3.2962e-1], [1.4011e-3], [-2.9069e-6]]) + + self.density.source = self.density.SOURCE_COEFFS + self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL + self.density.coeffs = np.array([[2.4238e3], [-2.8063e-1]]) + + self.specific_heat.source = self.specific_heat.SOURCE_COEFFS + self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL + self.specific_heat.coeffs = np.array([[1.0926], [1.8896e-3], [-3.6817e-6]]) * 1e3 + + +class FoodWater(PureData, CoefficientData): + + def __init__(self): + CoefficientData.__init__(self) + PureData.__init__(self) + self.name = "FoodWater" + self.description = "Food water model from the 2006 ASHRAE Handbook based on data from Choi and Okos (1986)" + self.reference = "ASHRAE2006" + + self.Tmin = -40 + 273.15 + self.Tmax = 150 + 273.15 + self.TminPsat = self.Tmax + self.Tbase = 0.00 + 273.15 + + self.conductivity.source = self.conductivity.SOURCE_COEFFS + self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL + self.conductivity.coeffs = np.array([[5.7109e-1], [1.7625e-3], [-6.7036e-6]]) + + self.density.source = self.density.SOURCE_COEFFS + self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL + self.density.coeffs = np.array([[9.9718e2], [3.1439e-3], [-3.7574e-3]]) + + self.specific_heat.source = self.specific_heat.SOURCE_COEFFS + self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL + self.specific_heat.coeffs = np.array([[4.1289], [-9.0864e-5], [5.4731e-6]]) * 1e3 + + +class FoodIce(PureData, CoefficientData): + + def __init__(self): + CoefficientData.__init__(self) + PureData.__init__(self) + self.name = "FoodIce" + self.description = "Food ice model from the 2006 ASHRAE Handbook based on data from Choi and Okos (1986)" + self.reference = "ASHRAE2006" + + self.Tmin = -40 + 273.15 + self.Tmax = 150 + 273.15 + self.TminPsat = self.Tmax + self.Tbase = 0.00 + 273.15 + + self.conductivity.source = self.conductivity.SOURCE_COEFFS + self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL + self.conductivity.coeffs = np.array([[2.2196], [-6.2489e-3], [1.0154e-4]]) + + self.density.source = self.density.SOURCE_COEFFS + self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL + self.density.coeffs = np.array([[9.1689e2], [-1.3071e-1]]) + + self.specific_heat.source = self.specific_heat.SOURCE_COEFFS + self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL + self.specific_heat.coeffs = np.array([[2.0623], [6.0769e-3]]) * 1e3 diff --git a/dev/incompressible_liquids/CPIncomp/DigitalFluids.py b/dev/incompressible_liquids/CPIncomp/DigitalFluids.py index 635ca090..00be982a 100644 --- a/dev/incompressible_liquids/CPIncomp/DigitalFluids.py +++ b/dev/incompressible_liquids/CPIncomp/DigitalFluids.py @@ -218,3 +218,104 @@ class HyCool50(PureData, DigitalData): self.viscosity.xData, self.viscosity.yData, self.viscosity.data = self.getArray(dataID=key, func=funcMu, x_in=self.temperature.data, y_in=self.concentration.data, DEBUG=self.viscosity.DEBUG) self.viscosity.source = self.viscosity.SOURCE_EQUATION funcMu = None + +try: + import CoolProp.CoolProp as CP + + def get_coolprop_class_Tp(fluid_name: str, fluid_desc: str, backend_str: str, fluid_str: str, p_ref: float, T_min: float, T_max: float): + + class NewClass(PureData, DigitalData): + def __init__(self): + DigitalData.__init__(self) + PureData.__init__(self) + + self.name = fluid_name + self.description = fluid_desc + + cp_state = CP.AbstractState(backend_str, fluid_str) + + references = [] + references.append(CP.get_BibTeXKey(fluid_str, "EOS")) + references.append(CP.get_BibTeXKey(fluid_str, "CP0")) + references.append(CP.get_BibTeXKey(fluid_str, "VISCOSITY")) + references.append(CP.get_BibTeXKey(fluid_str, "CONDUCTIVITY")) + # references.append(CP.get_BibTeXKey(fluid_str, "ECS_LENNARD_JONES")) + # references.append(CP.get_BibTeXKey(fluid_str, "ECS_FITS")) + # references.append(CP.get_BibTeXKey(fluid_str, "SURFACE_TENSION")) + # references.append(CP.get_BibTeXKey(fluid_str, "MELTING_LINE")) + + self.reference = "; ".join(references) + + self.Tmax = min(cp_state.Tmax(), T_max) + self.Tmin = max(cp_state.Tmin(), T_min) + + if p_ref < cp_state.p_critical():# and p_ref > cp_state.p_triple(): + cp_state.update(CP.PQ_INPUTS, p_ref, 0.0) + # prefer the liquid phase + if self.Tmin < cp_state.T(): + self.Tmax = min(self.Tmax, cp_state.T() - 1e-3) + elif self.Tmax > cp_state.T(): + self.Tmin = max(self.Tmin, cp_state.T() + 1e-3) + + self.TminPsat = self.Tmax + self.Tbase = (self.Tmax + self.Tmin) / 2.0 + self.temperature.data = self.getTrange() + self.concentration.data = self.getxrange() + + def funcRho(T, x): + cp_state.update(CP.PT_INPUTS, p_ref, T) + return cp_state.rhomass() + + self.density.xData, self.density.yData, self.density.data = self.getArray(dataID='Rho', func=funcRho, x_in=self.temperature.data, y_in=self.concentration.data, DEBUG=self.density.DEBUG) + self.density.source = self.density.SOURCE_EQUATION + + + def funcCp(T, x): + cp_state.update(CP.PT_INPUTS, p_ref, T) + return cp_state.cpmass() + + self.specific_heat.xData, self.specific_heat.yData, self.specific_heat.data = self.getArray(dataID='Cp', func=funcCp, x_in=self.temperature.data, y_in=self.concentration.data, DEBUG=self.specific_heat.DEBUG) + self.specific_heat.source = self.specific_heat.SOURCE_EQUATION + + try: + def funcMu(T, x): + cp_state.update(CP.PT_INPUTS, p_ref, T) + return cp_state.viscosity() + + self.viscosity.xData, self.viscosity.yData, self.viscosity.data = self.getArray(dataID='Mu', func=funcMu, x_in=self.temperature.data, y_in=self.concentration.data, DEBUG=self.viscosity.DEBUG) + self.viscosity.source = self.viscosity.SOURCE_EQUATION + except: + pass + + + try: + def funcCond(T, x): + cp_state.update(CP.PT_INPUTS, p_ref, T) + return cp_state.conductivity() + + self.conductivity.xData, self.conductivity.yData, self.conductivity.data = self.getArray(dataID='Cond', func=funcCond, x_in=self.temperature.data, y_in=self.concentration.data, DEBUG=self.conductivity.DEBUG) + self.conductivity.source = self.conductivity.SOURCE_EQUATION + except: + pass + + return NewClass + + class Air(get_coolprop_class_Tp(fluid_name="Air", fluid_desc="Air, gaseous phase at 1 atm (101325 Pa)", backend_str="HEOS", fluid_str="Air", p_ref=101325.0, T_min=-75 + 273.15, T_max=250 + 273.15)): + pass + + class Ethanol(get_coolprop_class_Tp(fluid_name="Ethanol", fluid_desc="Ethanol, liquid phase at 10 bar", backend_str="HEOS", fluid_str="Ethanol", p_ref=10e5, T_min=-75 + 273.15, T_max=250 + 273.15)): + pass + + class Acetone(get_coolprop_class_Tp(fluid_name="Acetone", fluid_desc="Acetone, liquid phase at 10 bar", backend_str="HEOS", fluid_str="Acetone", p_ref=10e5, T_min=-75 + 273.15, T_max=250 + 273.15)): + pass + + class Hexane(get_coolprop_class_Tp(fluid_name="Hexane", fluid_desc="Hexane, liquid phase at 10 bar", backend_str="HEOS", fluid_str="Hexane", p_ref=10e5, T_min=-75 + 273.15, T_max=250 + 273.15)): + pass + + + + + +except ImportError: + # Do not handle cases where CoolProp is not installed + pass \ No newline at end of file diff --git a/dev/incompressible_liquids/CPIncomp/PureFluids.py b/dev/incompressible_liquids/CPIncomp/PureFluids.py index fb9cbb54..409a3c03 100644 --- a/dev/incompressible_liquids/CPIncomp/PureFluids.py +++ b/dev/incompressible_liquids/CPIncomp/PureFluids.py @@ -3,6 +3,32 @@ import numpy as np from .DataObjects import PureData +class LiquidSodium(PureData): + """ + Heat transfer fluid Liquid Sodium + """ + + def __init__(self): + PureData.__init__(self) + self.density.source = self.density.SOURCE_DATA + self.specific_heat.source = self.specific_heat.SOURCE_DATA + self.conductivity.source = self.conductivity.SOURCE_DATA + self.viscosity.source = self.viscosity.SOURCE_DATA + self.saturation_pressure.source = self.saturation_pressure.SOURCE_DATA + self.temperature.data = np.array([400.0,500.0,600.0,700.0,800.0,900.0,1000.0,1100.0,1200.0,1300.0,1400.0,1500.0,1600.0,1700.0,1800.0,1900.0,2000.0,2100.0,2200.0,2300.0,2400.0,2500.0]) # kelvin + self.density.data = np.array([919.0,897.0,874.0,852.0,828.0,805.0,781.0,756.0,732.0,706.0,680.0,653.0,626.0,597.0,568.0,537.0,504.0,469.0,431.0,387.0,335.0,239.0]) # kg/m3 + self.specific_heat.data = np.array([1372.0,1334.0,1301.0,1277.0,1260.0,1252.0,1252.0,np.NAN,np.NAN,np.NAN,np.NAN,np.NAN,np.NAN,np.NAN,np.NAN,np.NAN,np.NAN,np.NAN,np.NAN,np.NAN,np.NAN,np.NAN]) # J/kg-K + self.conductivity.data = np.array([87.22, 80.09, 73.70, 68.00, 62.90, 58.34, 54.24, 50.54, 47.16, 44.03, 41.08, 38.24, 35.44, 32.61, 29.68, 26.57, 23.21, 19.54, 15.48, 10.97, 5.92, 0.27]) # W/m-K + self.viscosity.data = np.array([5.99, 4.15, 3.21, 2.64, 2.27, 2.01, 1.81, 1.66, 1.53, 1.43, 1.35, 1.28, 1.22, 1.17, 1.12, 1.08, 1.04, 1.01, 0.98, 0.95, 0.92, np.NAN]) * 1.E-4 # Pa-s + self.saturation_pressure.data = np.array([1.8E-10, 8.99E-8, 5.57E-6, 1.05E-4, 9.41E-4, 5.147E-3, 1.995E-2, 6.016E-2, 0.1504, 0.3257, 0.6298, 1.113, 1.828, 2.828, 4.161, 5.870, 7.991, 10.55, 13.57, 17.06, 21.03, 25.47]) * 1000000. # MPa + self.Tmin = np.min(self.temperature.data) + self.Tmax = np.max(self.temperature.data) + self.TminPsat = self.Tmin + self.name = "LiqNa" + self.description = "LiqNa" + self.reference = "LiqNa" + self.reshapeAll() + class TherminolD12(PureData): """ Heat transfer fluid Therminol D12 by Solutia diff --git a/dev/incompressible_liquids/CPIncomp/SecCoolFluids.py b/dev/incompressible_liquids/CPIncomp/SecCoolFluids.py index 78c8124a..3d965686 100644 --- a/dev/incompressible_liquids/CPIncomp/SecCoolFluids.py +++ b/dev/incompressible_liquids/CPIncomp/SecCoolFluids.py @@ -266,7 +266,7 @@ class SecCoolSolutionData(DigitalData): for j in range(c): nu = np.NAN try: - nu = np.float(res[i, j]) + nu = float(res[i, j]) if i == 0: nu *= 1e-2 # Percent to fraction if j == 0: nu += 273.15 # Celsius to Kelvin if not self.allowNegativeData and nu < 0: @@ -493,7 +493,7 @@ class SecCoolIceData(SecCoolSolutionData): for j in range(c): nu = np.NAN try: - nu = np.float(res[i, j]) + nu = float(res[i, j]) if i == 0: nu *= 1e-2 # Percent to fraction if not self.allowNegativeData and nu < 0: nu = np.NAN # invalid entries diff --git a/dev/incompressible_liquids/CPIncomp/data/Acetone_Cp.txt b/dev/incompressible_liquids/CPIncomp/data/Acetone_Cp.txt new file mode 100644 index 00000000..22f7fba0 --- /dev/null +++ b/dev/incompressible_liquids/CPIncomp/data/Acetone_Cp.txt @@ -0,0 +1,21 @@ +nan 0.000000e+00 +1.981500e+02 1.999439e+03 +2.096411e+02 2.006772e+03 +2.211322e+02 2.015648e+03 +2.326233e+02 2.026689e+03 +2.441143e+02 2.040256e+03 +2.556054e+02 2.056532e+03 +2.670965e+02 2.075583e+03 +2.785876e+02 2.097407e+03 +2.900787e+02 2.121970e+03 +3.015698e+02 2.149234e+03 +3.130609e+02 2.179183e+03 +3.245520e+02 2.211845e+03 +3.360430e+02 2.247317e+03 +3.475341e+02 2.285788e+03 +3.590252e+02 2.327585e+03 +3.705163e+02 2.373223e+03 +3.820074e+02 2.423498e+03 +3.934985e+02 2.479648e+03 +4.049896e+02 2.543642e+03 +4.164807e+02 2.618767e+03 diff --git a/dev/incompressible_liquids/CPIncomp/data/Acetone_Rho.txt b/dev/incompressible_liquids/CPIncomp/data/Acetone_Rho.txt new file mode 100644 index 00000000..cd7c0831 --- /dev/null +++ b/dev/incompressible_liquids/CPIncomp/data/Acetone_Rho.txt @@ -0,0 +1,21 @@ +nan 0.000000e+00 +1.981500e+02 8.924816e+02 +2.096411e+02 8.802745e+02 +2.211322e+02 8.681302e+02 +2.326233e+02 8.560100e+02 +2.441143e+02 8.438777e+02 +2.556054e+02 8.316981e+02 +2.670965e+02 8.194367e+02 +2.785876e+02 8.070583e+02 +2.900787e+02 7.945267e+02 +3.015698e+02 7.818033e+02 +3.130609e+02 7.688462e+02 +3.245520e+02 7.556091e+02 +3.360430e+02 7.420389e+02 +3.475341e+02 7.280743e+02 +3.590252e+02 7.136422e+02 +3.705163e+02 6.986531e+02 +3.820074e+02 6.829952e+02 +3.934985e+02 6.665230e+02 +4.049896e+02 6.490413e+02 +4.164807e+02 6.302745e+02 diff --git a/dev/incompressible_liquids/CPIncomp/data/Air_Cond.txt b/dev/incompressible_liquids/CPIncomp/data/Air_Cond.txt new file mode 100644 index 00000000..4181512b --- /dev/null +++ b/dev/incompressible_liquids/CPIncomp/data/Air_Cond.txt @@ -0,0 +1,21 @@ +nan 0.000000e+00 +1.981500e+02 1.834724e-02 +2.152553e+02 1.977036e-02 +2.323605e+02 2.116141e-02 +2.494658e+02 2.252236e-02 +2.665711e+02 2.385505e-02 +2.836763e+02 2.516123e-02 +3.007816e+02 2.644249e-02 +3.178868e+02 2.770033e-02 +3.349921e+02 2.893614e-02 +3.520974e+02 3.015119e-02 +3.692026e+02 3.134667e-02 +3.863079e+02 3.252368e-02 +4.034132e+02 3.368323e-02 +4.205184e+02 3.482626e-02 +4.376237e+02 3.595365e-02 +4.547289e+02 3.706620e-02 +4.718342e+02 3.816468e-02 +4.889395e+02 3.924979e-02 +5.060447e+02 4.032218e-02 +5.231500e+02 4.138247e-02 diff --git a/dev/incompressible_liquids/CPIncomp/data/Air_Cp.txt b/dev/incompressible_liquids/CPIncomp/data/Air_Cp.txt new file mode 100644 index 00000000..53fe4873 --- /dev/null +++ b/dev/incompressible_liquids/CPIncomp/data/Air_Cp.txt @@ -0,0 +1,21 @@ +nan 0.000000e+00 +1.981500e+02 1.006903e+03 +2.152553e+02 1.006157e+03 +2.323605e+02 1.005721e+03 +2.494658e+02 1.005544e+03 +2.665711e+02 1.005601e+03 +2.836763e+02 1.005887e+03 +3.007816e+02 1.006403e+03 +3.178868e+02 1.007152e+03 +3.349921e+02 1.008141e+03 +3.520974e+02 1.009375e+03 +3.692026e+02 1.010856e+03 +3.863079e+02 1.012584e+03 +4.034132e+02 1.014557e+03 +4.205184e+02 1.016768e+03 +4.376237e+02 1.019209e+03 +4.547289e+02 1.021870e+03 +4.718342e+02 1.024737e+03 +4.889395e+02 1.027796e+03 +5.060447e+02 1.031031e+03 +5.231500e+02 1.034427e+03 diff --git a/dev/incompressible_liquids/CPIncomp/data/Air_Mu.txt b/dev/incompressible_liquids/CPIncomp/data/Air_Mu.txt new file mode 100644 index 00000000..f1d2b6af --- /dev/null +++ b/dev/incompressible_liquids/CPIncomp/data/Air_Mu.txt @@ -0,0 +1,21 @@ +nan 0.000000e+00 +1.981500e+02 1.322896e-05 +2.152553e+02 1.418308e-05 +2.323605e+02 1.510960e-05 +2.494658e+02 1.601041e-05 +2.665711e+02 1.688722e-05 +2.836763e+02 1.774160e-05 +3.007816e+02 1.857498e-05 +3.178868e+02 1.938866e-05 +3.349921e+02 2.018384e-05 +3.520974e+02 2.096162e-05 +3.692026e+02 2.172300e-05 +3.863079e+02 2.246891e-05 +4.034132e+02 2.320022e-05 +4.205184e+02 2.391770e-05 +4.376237e+02 2.462209e-05 +4.547289e+02 2.531407e-05 +4.718342e+02 2.599427e-05 +4.889395e+02 2.666326e-05 +5.060447e+02 2.732160e-05 +5.231500e+02 2.796979e-05 diff --git a/dev/incompressible_liquids/CPIncomp/data/Air_Rho.txt b/dev/incompressible_liquids/CPIncomp/data/Air_Rho.txt new file mode 100644 index 00000000..b0b1bec5 --- /dev/null +++ b/dev/incompressible_liquids/CPIncomp/data/Air_Rho.txt @@ -0,0 +1,21 @@ +nan 0.000000e+00 +1.981500e+02 1.785834e+00 +2.152553e+02 1.642844e+00 +2.323605e+02 1.521169e+00 +2.494658e+02 1.416350e+00 +2.665711e+02 1.325097e+00 +2.836763e+02 1.244926e+00 +3.007816e+02 1.173929e+00 +3.178868e+02 1.110612e+00 +3.349921e+02 1.053789e+00 +3.520974e+02 1.002508e+00 +3.692026e+02 9.559953e-01 +3.863079e+02 9.136135e-01 +4.034132e+02 8.748350e-01 +4.205184e+02 8.392184e-01 +4.376237e+02 8.063916e-01 +4.547289e+02 7.760389e-01 +4.718342e+02 7.478905e-01 +4.889395e+02 7.217143e-01 +5.060447e+02 6.973100e-01 +5.231500e+02 6.745033e-01 diff --git a/dev/incompressible_liquids/CPIncomp/data/Ethanol_Cond.txt b/dev/incompressible_liquids/CPIncomp/data/Ethanol_Cond.txt new file mode 100644 index 00000000..1c31ff12 --- /dev/null +++ b/dev/incompressible_liquids/CPIncomp/data/Ethanol_Cond.txt @@ -0,0 +1,21 @@ +nan 0.000000e+00 +1.981500e+02 1.959026e-01 +2.100286e+02 1.902778e-01 +2.219072e+02 1.852932e-01 +2.337859e+02 1.808659e-01 +2.456645e+02 1.769306e-01 +2.575431e+02 1.734261e-01 +2.694217e+02 1.702968e-01 +2.813003e+02 1.674903e-01 +2.931789e+02 1.649551e-01 +3.050576e+02 1.626413e-01 +3.169362e+02 1.605005e-01 +3.288148e+02 1.584870e-01 +3.406934e+02 1.565583e-01 +3.525720e+02 1.546755e-01 +3.644506e+02 1.528028e-01 +3.763293e+02 1.509071e-01 +3.882079e+02 1.489588e-01 +4.000865e+02 1.469345e-01 +4.119651e+02 1.448221e-01 +4.238437e+02 1.426260e-01 diff --git a/dev/incompressible_liquids/CPIncomp/data/Ethanol_Cp.txt b/dev/incompressible_liquids/CPIncomp/data/Ethanol_Cp.txt new file mode 100644 index 00000000..dac0b204 --- /dev/null +++ b/dev/incompressible_liquids/CPIncomp/data/Ethanol_Cp.txt @@ -0,0 +1,21 @@ +nan 0.000000e+00 +1.981500e+02 1.950514e+03 +2.100286e+02 1.973321e+03 +2.219072e+02 2.006417e+03 +2.337859e+02 2.050226e+03 +2.456645e+02 2.103274e+03 +2.575431e+02 2.164353e+03 +2.694217e+02 2.233139e+03 +2.813003e+02 2.309922e+03 +2.931789e+02 2.395078e+03 +3.050576e+02 2.488671e+03 +3.169362e+02 2.590334e+03 +3.288148e+02 2.699410e+03 +3.406934e+02 2.815300e+03 +3.525720e+02 2.937890e+03 +3.644506e+02 3.067814e+03 +3.763293e+02 3.206244e+03 +3.882079e+02 3.354101e+03 +4.000865e+02 3.511019e+03 +4.119651e+02 3.674770e+03 +4.238437e+02 3.842180e+03 diff --git a/dev/incompressible_liquids/CPIncomp/data/Ethanol_Mu.txt b/dev/incompressible_liquids/CPIncomp/data/Ethanol_Mu.txt new file mode 100644 index 00000000..0f466b64 --- /dev/null +++ b/dev/incompressible_liquids/CPIncomp/data/Ethanol_Mu.txt @@ -0,0 +1,21 @@ +nan 0.000000e+00 +1.981500e+02 1.568411e-02 +2.100286e+02 1.024214e-02 +2.219072e+02 6.976053e-03 +2.337859e+02 4.910291e-03 +2.456645e+02 3.551421e-03 +2.575431e+02 2.629412e-03 +2.694217e+02 1.987624e-03 +2.813003e+02 1.531001e-03 +2.931789e+02 1.199747e-03 +3.050576e+02 9.551347e-04 +3.169362e+02 7.714592e-04 +3.288148e+02 6.313111e-04 +3.406934e+02 5.226881e-04 +3.525720e+02 4.371861e-04 +3.644506e+02 3.688351e-04 +3.763293e+02 3.133382e-04 +3.882079e+02 2.675696e-04 +4.000865e+02 2.292432e-04 +4.119651e+02 1.966927e-04 +4.238437e+02 1.687144e-04 diff --git a/dev/incompressible_liquids/CPIncomp/data/Ethanol_Rho.txt b/dev/incompressible_liquids/CPIncomp/data/Ethanol_Rho.txt new file mode 100644 index 00000000..16c88474 --- /dev/null +++ b/dev/incompressible_liquids/CPIncomp/data/Ethanol_Rho.txt @@ -0,0 +1,21 @@ +nan 0.000000e+00 +1.981500e+02 8.716721e+02 +2.100286e+02 8.610936e+02 +2.219072e+02 8.507043e+02 +2.337859e+02 8.404614e+02 +2.456645e+02 8.303304e+02 +2.575431e+02 8.202776e+02 +2.694217e+02 8.102665e+02 +2.813003e+02 8.002547e+02 +2.931789e+02 7.901913e+02 +3.050576e+02 7.800153e+02 +3.169362e+02 7.696549e+02 +3.288148e+02 7.590268e+02 +3.406934e+02 7.480358e+02 +3.525720e+02 7.365721e+02 +3.644506e+02 7.245068e+02 +3.763293e+02 7.116838e+02 +3.882079e+02 6.979115e+02 +4.000865e+02 6.829566e+02 +4.119651e+02 6.665425e+02 +4.238437e+02 6.483479e+02 diff --git a/dev/incompressible_liquids/CPIncomp/data/Hexane_Cond.txt b/dev/incompressible_liquids/CPIncomp/data/Hexane_Cond.txt new file mode 100644 index 00000000..9fab9507 --- /dev/null +++ b/dev/incompressible_liquids/CPIncomp/data/Hexane_Cond.txt @@ -0,0 +1,21 @@ +nan 0.000000e+00 +1.981500e+02 1.574829e-01 +2.107833e+02 1.520003e-01 +2.234166e+02 1.467680e-01 +2.360499e+02 1.417755e-01 +2.486832e+02 1.370128e-01 +2.613165e+02 1.324708e-01 +2.739498e+02 1.281403e-01 +2.865831e+02 1.240301e-01 +2.992164e+02 1.201130e-01 +3.118497e+02 1.163809e-01 +3.244830e+02 1.128257e-01 +3.371163e+02 1.094382e-01 +3.497496e+02 1.062081e-01 +3.623829e+02 1.031243e-01 +3.750162e+02 1.001741e-01 +3.876495e+02 9.734351e-02 +4.002828e+02 9.461558e-02 +4.129161e+02 9.196959e-02 +4.255494e+02 8.937826e-02 +4.381827e+02 8.680254e-02 diff --git a/dev/incompressible_liquids/CPIncomp/data/Hexane_Cp.txt b/dev/incompressible_liquids/CPIncomp/data/Hexane_Cp.txt new file mode 100644 index 00000000..6f0fa153 --- /dev/null +++ b/dev/incompressible_liquids/CPIncomp/data/Hexane_Cp.txt @@ -0,0 +1,21 @@ +nan 0.000000e+00 +1.981500e+02 1.985550e+03 +2.107833e+02 2.004488e+03 +2.234166e+02 2.028873e+03 +2.360499e+02 2.058554e+03 +2.486832e+02 2.093261e+03 +2.613165e+02 2.132633e+03 +2.739498e+02 2.176251e+03 +2.865831e+02 2.223679e+03 +2.992164e+02 2.274501e+03 +3.118497e+02 2.328351e+03 +3.244830e+02 2.384944e+03 +3.371163e+02 2.444102e+03 +3.497496e+02 2.505789e+03 +3.623829e+02 2.570158e+03 +3.750162e+02 2.637613e+03 +3.876495e+02 2.708936e+03 +4.002828e+02 2.785498e+03 +4.129161e+02 2.869714e+03 +4.255494e+02 2.966061e+03 +4.381827e+02 3.083537e+03 diff --git a/dev/incompressible_liquids/CPIncomp/data/Hexane_Mu.txt b/dev/incompressible_liquids/CPIncomp/data/Hexane_Mu.txt new file mode 100644 index 00000000..66f64e1a --- /dev/null +++ b/dev/incompressible_liquids/CPIncomp/data/Hexane_Mu.txt @@ -0,0 +1,21 @@ +nan 0.000000e+00 +1.981500e+02 1.224207e-03 +2.107833e+02 9.439586e-04 +2.234166e+02 7.565371e-04 +2.360499e+02 6.231877e-04 +2.486832e+02 5.239429e-04 +2.613165e+02 4.475055e-04 +2.739498e+02 3.870200e-04 +2.865831e+02 3.380927e-04 +2.992164e+02 2.977819e-04 +3.118497e+02 2.640453e-04 +3.244830e+02 2.354220e-04 +3.371163e+02 2.108386e-04 +3.497496e+02 1.894881e-04 +3.623829e+02 1.707503e-04 +3.750162e+02 1.541379e-04 +3.876495e+02 1.392590e-04 +4.002828e+02 1.257884e-04 +4.129161e+02 1.134451e-04 +4.255494e+02 1.019682e-04 +4.381827e+02 9.108429e-05 diff --git a/dev/incompressible_liquids/CPIncomp/data/Hexane_Rho.txt b/dev/incompressible_liquids/CPIncomp/data/Hexane_Rho.txt new file mode 100644 index 00000000..879befd5 --- /dev/null +++ b/dev/incompressible_liquids/CPIncomp/data/Hexane_Rho.txt @@ -0,0 +1,21 @@ +nan 0.000000e+00 +1.981500e+02 7.418186e+02 +2.107833e+02 7.311925e+02 +2.234166e+02 7.205522e+02 +2.360499e+02 7.098703e+02 +2.486832e+02 6.991204e+02 +2.613165e+02 6.882757e+02 +2.739498e+02 6.773085e+02 +2.865831e+02 6.661891e+02 +2.992164e+02 6.548850e+02 +3.118497e+02 6.433599e+02 +3.244830e+02 6.315718e+02 +3.371163e+02 6.194718e+02 +3.497496e+02 6.070007e+02 +3.623829e+02 5.940858e+02 +3.750162e+02 5.806348e+02 +3.876495e+02 5.665273e+02 +4.002828e+02 5.515997e+02 +4.129161e+02 5.356205e+02 +4.255494e+02 5.182403e+02 +4.381827e+02 4.988839e+02 diff --git a/dev/incompressible_liquids/json/Acetone.json b/dev/incompressible_liquids/json/Acetone.json new file mode 100644 index 00000000..4afb0136 --- /dev/null +++ b/dev/incompressible_liquids/json/Acetone.json @@ -0,0 +1,125 @@ +{ + "T_freeze": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "Tbase": 307.31532668493253, + "Tmax": 416.4806533698651, + "Tmin": 198.14999999999998, + "TminPsat": 416.4806533698651, + "conductivity": { + "NRMS": null, + "coeffs": [ + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ] + ], + "type": "polynomial" + }, + "density": { + "NRMS": 0.001003907946811843, + "coeffs": [ + [ + 775.6208141702908 + ], + [ + -1.123377606406917 + ], + [ + -0.0011550084818358675 + ], + [ + -6.411257141128393e-06 + ] + ], + "type": "polynomial" + }, + "description": "Acetone, liquid phase at 10 bar", + "mass2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "mole2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "name": "Acetone", + "reference": "Lemmon-JCED-2006; ; ; ", + "saturation_pressure": { + "NRMS": null, + "coeffs": [ + -5000.0, + 60.0, + -10.0 + ], + "type": "exponential" + }, + "specific_heat": { + "NRMS": 0.004496558569769559, + "coeffs": [ + [ + 2161.290999517797 + ], + [ + 2.5429347441222636 + ], + [ + 0.012005532887008652 + ], + [ + 2.3020582795756997e-05 + ] + ], + "type": "polynomial" + }, + "viscosity": { + "NRMS": null, + "coeffs": [ + 500.0, + -60.0, + 10.0 + ], + "type": "exponential" + }, + "volume2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "xbase": 0.0, + "xid": "pure", + "xmax": 1.0, + "xmin": 0.0 +} \ No newline at end of file diff --git a/dev/incompressible_liquids/json/Air.json b/dev/incompressible_liquids/json/Air.json new file mode 100644 index 00000000..2b328802 --- /dev/null +++ b/dev/incompressible_liquids/json/Air.json @@ -0,0 +1,105 @@ +{ + "T_freeze": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "Tbase": 360.65, + "Tmax": 523.15, + "Tmin": 198.14999999999998, + "TminPsat": 523.15, + "conductivity": { + "NRMS": 0.00011341350214211215, + "coeffs": [ + [ + 0.030754271682824127 + ], + [ + 6.98795213954844e-05 + ], + [ + -3.35034769348712e-08 + ], + [ + 3.7728711330538117e-11 + ] + ], + "type": "polynomial" + }, + "density": { + "NRMS": 0.004810727683739646, + "coeffs": [ + [ + 0.9731377204938464 + ], + [ + -0.002673260039587141 + ], + [ + 9.363176076421318e-06 + ], + [ + -2.7779101420879868e-08 + ] + ], + "type": "polynomial" + }, + "description": "Air, gaseous phase at 1 atm (101325 Pa)", + "mass2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "mole2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "name": "Air", + "reference": "Lemmon-JPCRD-2000; ; Lemmon-IJT-2004; Lemmon-IJT-2004", + "saturation_pressure": { + "NRMS": null, + "coeffs": [ + -5000.0, + 60.0, + -10.0 + ], + "type": "exponential" + }, + "specific_heat": { + "NRMS": 0.0015192579258026188, + "coeffs": [ + [ + 1010.1381836670001 + ], + [ + 0.08724844745590299 + ], + [ + 0.00040064968051053973 + ], + [ + -8.867789581359177e-08 + ] + ], + "type": "polynomial" + }, + "viscosity": { + "NRMS": 0.0017310189869592459, + "coeffs": [ + -700.879168909965, + 216.13711261844045, + 9.538652479388192 + ], + "type": "exponential" + }, + "volume2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "xbase": 0.0, + "xid": "pure", + "xmax": 1.0, + "xmin": 0.0 +} \ No newline at end of file diff --git a/dev/incompressible_liquids/json/Ethanol.json b/dev/incompressible_liquids/json/Ethanol.json new file mode 100644 index 00000000..1a28a485 --- /dev/null +++ b/dev/incompressible_liquids/json/Ethanol.json @@ -0,0 +1,105 @@ +{ + "T_freeze": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "Tbase": 310.99686247599425, + "Tmax": 423.84372495198846, + "Tmin": 198.14999999999998, + "TminPsat": 423.84372495198846, + "conductivity": { + "NRMS": 0.0017107297656890421, + "coeffs": [ + [ + 0.16145307059173794 + ], + [ + -0.00018048281492797662 + ], + [ + 5.99907854419271e-07 + ], + [ + -4.371086297200755e-09 + ] + ], + "type": "polynomial" + }, + "density": { + "NRMS": 0.002103015441363321, + "coeffs": [ + [ + 775.3701378025174 + ], + [ + -0.8677162816607029 + ], + [ + -0.0011392277863346845 + ], + [ + -9.46879152535528e-06 + ] + ], + "type": "polynomial" + }, + "description": "Ethanol, liquid phase at 10 bar", + "mass2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "mole2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "name": "Ethanol", + "reference": "Schroeder-JPCRD-2014; ; Kiselev-IECR-2005; Assael-JPCRD-2013-Ethanol", + "saturation_pressure": { + "NRMS": null, + "coeffs": [ + -5000.0, + 60.0, + -10.0 + ], + "type": "exponential" + }, + "specific_heat": { + "NRMS": 0.0009046693742307961, + "coeffs": [ + [ + 2536.987743975746 + ], + [ + 8.492882698702205 + ], + [ + 0.028073656822581228 + ], + [ + -7.904033055905353e-06 + ] + ], + "type": "polynomial" + }, + "viscosity": { + "NRMS": 0.002344080405126311, + "coeffs": [ + 2770.886375961777, + 79.03716121480323, + 14.166763789113702 + ], + "type": "exponential" + }, + "volume2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "xbase": 0.0, + "xid": "pure", + "xmax": 1.0, + "xmin": 0.0 +} \ No newline at end of file diff --git a/dev/incompressible_liquids/json/FoodAsh.json b/dev/incompressible_liquids/json/FoodAsh.json new file mode 100644 index 00000000..faf9cac8 --- /dev/null +++ b/dev/incompressible_liquids/json/FoodAsh.json @@ -0,0 +1,85 @@ +{ + "T_freeze": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "Tbase": 273.15, + "Tmax": 423.15, + "Tmin": 233.14999999999998, + "TminPsat": 423.15, + "conductivity": { + "NRMS": null, + "coeffs": [ + [ + 0.32962 + ], + [ + 0.0014011 + ], + [ + -2.9069e-06 + ] + ], + "type": "polynomial" + }, + "density": { + "NRMS": null, + "coeffs": [ + [ + 2423.8 + ], + [ + -0.28063 + ] + ], + "type": "polynomial" + }, + "description": "Food ash model from the 2006 ASHRAE Handbook based on data from Choi and Okos (1986)", + "mass2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "mole2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "name": "FoodAsh", + "reference": "ASHRAE2006", + "saturation_pressure": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "specific_heat": { + "NRMS": null, + "coeffs": [ + [ + 1092.6 + ], + [ + 1.8896 + ], + [ + -0.0036817 + ] + ], + "type": "polynomial" + }, + "viscosity": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "volume2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "xbase": 0.0, + "xid": "pure", + "xmax": 1.0, + "xmin": 0.0 +} \ No newline at end of file diff --git a/dev/incompressible_liquids/json/FoodCarbohydrate.json b/dev/incompressible_liquids/json/FoodCarbohydrate.json new file mode 100644 index 00000000..8f04b959 --- /dev/null +++ b/dev/incompressible_liquids/json/FoodCarbohydrate.json @@ -0,0 +1,85 @@ +{ + "T_freeze": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "Tbase": 273.15, + "Tmax": 423.15, + "Tmin": 233.14999999999998, + "TminPsat": 423.15, + "conductivity": { + "NRMS": null, + "coeffs": [ + [ + 0.20141 + ], + [ + 0.0013874 + ], + [ + -4.3312e-06 + ] + ], + "type": "polynomial" + }, + "density": { + "NRMS": null, + "coeffs": [ + [ + 1599.1 + ], + [ + -0.31046 + ] + ], + "type": "polynomial" + }, + "description": "Food carbohydrate model from the 2006 ASHRAE Handbook based on data from Choi and Okos (1986)", + "mass2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "mole2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "name": "FoodCarbohydrate", + "reference": "ASHRAE2006", + "saturation_pressure": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "specific_heat": { + "NRMS": null, + "coeffs": [ + [ + 1548.8 + ], + [ + 1.9625 + ], + [ + -0.0059399 + ] + ], + "type": "polynomial" + }, + "viscosity": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "volume2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "xbase": 0.0, + "xid": "pure", + "xmax": 1.0, + "xmin": 0.0 +} \ No newline at end of file diff --git a/dev/incompressible_liquids/json/FoodFat.json b/dev/incompressible_liquids/json/FoodFat.json new file mode 100644 index 00000000..995fc6b3 --- /dev/null +++ b/dev/incompressible_liquids/json/FoodFat.json @@ -0,0 +1,85 @@ +{ + "T_freeze": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "Tbase": 273.15, + "Tmax": 423.15, + "Tmin": 233.14999999999998, + "TminPsat": 423.15, + "conductivity": { + "NRMS": null, + "coeffs": [ + [ + 0.18071 + ], + [ + -0.00027604 + ], + [ + -1.7749e-07 + ] + ], + "type": "polynomial" + }, + "density": { + "NRMS": null, + "coeffs": [ + [ + 925.59 + ], + [ + -0.41757 + ] + ], + "type": "polynomial" + }, + "description": "Food fat model from the 2006 ASHRAE Handbook based on data from Choi and Okos (1986)", + "mass2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "mole2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "name": "FoodFat", + "reference": "ASHRAE2006", + "saturation_pressure": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "specific_heat": { + "NRMS": null, + "coeffs": [ + [ + 1984.2 + ], + [ + 1.4733 + ], + [ + -0.0048008 + ] + ], + "type": "polynomial" + }, + "viscosity": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "volume2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "xbase": 0.0, + "xid": "pure", + "xmax": 1.0, + "xmin": 0.0 +} \ No newline at end of file diff --git a/dev/incompressible_liquids/json/FoodFiber.json b/dev/incompressible_liquids/json/FoodFiber.json new file mode 100644 index 00000000..ff4d47f8 --- /dev/null +++ b/dev/incompressible_liquids/json/FoodFiber.json @@ -0,0 +1,85 @@ +{ + "T_freeze": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "Tbase": 273.15, + "Tmax": 423.15, + "Tmin": 233.14999999999998, + "TminPsat": 423.15, + "conductivity": { + "NRMS": null, + "coeffs": [ + [ + 0.18331 + ], + [ + 0.0012497 + ], + [ + -3.1683e-06 + ] + ], + "type": "polynomial" + }, + "density": { + "NRMS": null, + "coeffs": [ + [ + 1311.5 + ], + [ + -0.36589 + ] + ], + "type": "polynomial" + }, + "description": "Food fiber model from the 2006 ASHRAE Handbook based on data from Choi and Okos (1986)", + "mass2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "mole2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "name": "FoodFiber", + "reference": "ASHRAE2006", + "saturation_pressure": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "specific_heat": { + "NRMS": null, + "coeffs": [ + [ + 1845.9 + ], + [ + 1.8306 + ], + [ + -0.0046508999999999995 + ] + ], + "type": "polynomial" + }, + "viscosity": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "volume2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "xbase": 0.0, + "xid": "pure", + "xmax": 1.0, + "xmin": 0.0 +} \ No newline at end of file diff --git a/dev/incompressible_liquids/json/FoodIce.json b/dev/incompressible_liquids/json/FoodIce.json new file mode 100644 index 00000000..580d9c54 --- /dev/null +++ b/dev/incompressible_liquids/json/FoodIce.json @@ -0,0 +1,82 @@ +{ + "T_freeze": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "Tbase": 273.15, + "Tmax": 423.15, + "Tmin": 233.14999999999998, + "TminPsat": 423.15, + "conductivity": { + "NRMS": null, + "coeffs": [ + [ + 2.2196 + ], + [ + -0.0062489 + ], + [ + 0.00010154 + ] + ], + "type": "polynomial" + }, + "density": { + "NRMS": null, + "coeffs": [ + [ + 916.89 + ], + [ + -0.13071 + ] + ], + "type": "polynomial" + }, + "description": "Food ice model from the 2006 ASHRAE Handbook based on data from Choi and Okos (1986)", + "mass2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "mole2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "name": "FoodIce", + "reference": "ASHRAE2006", + "saturation_pressure": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "specific_heat": { + "NRMS": null, + "coeffs": [ + [ + 2062.3 + ], + [ + 6.076899999999999 + ] + ], + "type": "polynomial" + }, + "viscosity": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "volume2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "xbase": 0.0, + "xid": "pure", + "xmax": 1.0, + "xmin": 0.0 +} \ No newline at end of file diff --git a/dev/incompressible_liquids/json/FoodProtein.json b/dev/incompressible_liquids/json/FoodProtein.json new file mode 100644 index 00000000..d01aa160 --- /dev/null +++ b/dev/incompressible_liquids/json/FoodProtein.json @@ -0,0 +1,85 @@ +{ + "T_freeze": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "Tbase": 273.15, + "Tmax": 423.15, + "Tmin": 233.14999999999998, + "TminPsat": 423.15, + "conductivity": { + "NRMS": null, + "coeffs": [ + [ + 0.17881 + ], + [ + 0.0011958 + ], + [ + -2.7178e-06 + ] + ], + "type": "polynomial" + }, + "density": { + "NRMS": null, + "coeffs": [ + [ + 1329.9 + ], + [ + -0.5184 + ] + ], + "type": "polynomial" + }, + "description": "Food protein model from the 2006 ASHRAE Handbook based on data from Choi and Okos (1986)", + "mass2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "mole2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "name": "FoodProtein", + "reference": "ASHRAE2006", + "saturation_pressure": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "specific_heat": { + "NRMS": null, + "coeffs": [ + [ + 2008.2 + ], + [ + 1.2088999999999999 + ], + [ + -0.0013128999999999999 + ] + ], + "type": "polynomial" + }, + "viscosity": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "volume2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "xbase": 0.0, + "xid": "pure", + "xmax": 1.0, + "xmin": 0.0 +} \ No newline at end of file diff --git a/dev/incompressible_liquids/json/FoodWater.json b/dev/incompressible_liquids/json/FoodWater.json new file mode 100644 index 00000000..bfbdb823 --- /dev/null +++ b/dev/incompressible_liquids/json/FoodWater.json @@ -0,0 +1,88 @@ +{ + "T_freeze": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "Tbase": 273.15, + "Tmax": 423.15, + "Tmin": 233.14999999999998, + "TminPsat": 423.15, + "conductivity": { + "NRMS": null, + "coeffs": [ + [ + 0.57109 + ], + [ + 0.0017625 + ], + [ + -6.7036e-06 + ] + ], + "type": "polynomial" + }, + "density": { + "NRMS": null, + "coeffs": [ + [ + 997.18 + ], + [ + 0.0031439 + ], + [ + -0.0037574 + ] + ], + "type": "polynomial" + }, + "description": "Food water model from the 2006 ASHRAE Handbook based on data from Choi and Okos (1986)", + "mass2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "mole2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "name": "FoodWater", + "reference": "ASHRAE2006", + "saturation_pressure": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "specific_heat": { + "NRMS": null, + "coeffs": [ + [ + 4128.9 + ], + [ + -0.090864 + ], + [ + 0.0054731 + ] + ], + "type": "polynomial" + }, + "viscosity": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "volume2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "xbase": 0.0, + "xid": "pure", + "xmax": 1.0, + "xmin": 0.0 +} \ No newline at end of file diff --git a/dev/incompressible_liquids/json/Hexane.json b/dev/incompressible_liquids/json/Hexane.json new file mode 100644 index 00000000..e4a570a1 --- /dev/null +++ b/dev/incompressible_liquids/json/Hexane.json @@ -0,0 +1,105 @@ +{ + "T_freeze": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "Tbase": 318.16633879825787, + "Tmax": 438.18267759651576, + "Tmin": 198.14999999999998, + "TminPsat": 438.18267759651576, + "conductivity": { + "NRMS": 0.0003995287768641099, + "coeffs": [ + [ + 0.11460695989107247 + ], + [ + -0.000280949681521805 + ], + [ + 5.268383548268454e-07 + ], + [ + -9.302005284028526e-10 + ] + ], + "type": "polynomial" + }, + "density": { + "NRMS": 0.0020068251251058222, + "coeffs": [ + [ + 637.9711865489224 + ], + [ + -0.9260678954131932 + ], + [ + -0.001160934482237086 + ], + [ + -5.821455250071555e-06 + ] + ], + "type": "polynomial" + }, + "description": "Hexane, liquid phase at 10 bar", + "mass2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "mole2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "name": "Hexane", + "reference": "Thol-FPE-2019-alkanes-hexane; ; Michailidou-JPCRD-2013-Hexane; Assael-JPCRD-2013-Hexane", + "saturation_pressure": { + "NRMS": null, + "coeffs": [ + -5000.0, + 60.0, + -10.0 + ], + "type": "exponential" + }, + "specific_heat": { + "NRMS": 0.006369860782711523, + "coeffs": [ + [ + 2349.776382891306 + ], + [ + 4.3744660425540465 + ], + [ + 0.011937393898858062 + ], + [ + 1.1383498278355362e-05 + ] + ], + "type": "polynomial" + }, + "viscosity": { + "NRMS": 0.010406255683524131, + "coeffs": [ + 2270.150232010228, + 165.13945679929213, + 13.008092538765817 + ], + "type": "exponential" + }, + "volume2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "xbase": 0.0, + "xid": "pure", + "xmax": 1.0, + "xmin": 0.0 +} \ No newline at end of file diff --git a/dev/incompressible_liquids/json/LiqNa.json b/dev/incompressible_liquids/json/LiqNa.json new file mode 100644 index 00000000..2847ef53 --- /dev/null +++ b/dev/incompressible_liquids/json/LiqNa.json @@ -0,0 +1,105 @@ +{ + "T_freeze": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "Tbase": 1450.0, + "Tmax": 2500.0, + "Tmin": 400.0, + "TminPsat": 400.0, + "conductivity": { + "NRMS": 2.703067851958419e-05, + "coeffs": [ + [ + 39.652357954542296 + ], + [ + -0.0283520543358315 + ], + [ + 3.7129446640339625e-06 + ], + [ + -1.1838256708252004e-08 + ] + ], + "type": "polynomial" + }, + "density": { + "NRMS": 0.012510245084014686, + "coeffs": [ + [ + 672.0767045454262 + ], + [ + -0.2524942259559509 + ], + [ + -6.885234330888945e-05 + ], + [ + -5.679564524241343e-08 + ] + ], + "type": "polynomial" + }, + "description": "LiqNa", + "mass2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "mole2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "name": "LiqNa", + "reference": "LiqNa", + "saturation_pressure": { + "NRMS": 0.0007472008004592615, + "coeffs": [ + -11758.328842732395, + -14.056138686870915, + -21.815692362749207 + ], + "type": "exponential" + }, + "specific_heat": { + "NRMS": 0.0027059884319416837, + "coeffs": [ + [ + 1376.6592261522192 + ], + [ + 0.5205059522205394 + ], + [ + 0.0005791666665749348 + ], + [ + 8.33333333449815e-08 + ] + ], + "type": "polynomial" + }, + "viscosity": { + "NRMS": 0.006087518657847591, + "coeffs": [ + 1477.5936204092418, + 217.0383167635442, + 9.835135835300713 + ], + "type": "exponential" + }, + "volume2input": { + "NRMS": null, + "coeffs": "null", + "type": "notdefined" + }, + "xbase": 0.0, + "xid": "pure", + "xmax": 1.0, + "xmin": 0.0 +} \ No newline at end of file diff --git a/externals/fmtlib b/externals/fmtlib index 135ab5cf..a0b8a92e 160000 --- a/externals/fmtlib +++ b/externals/fmtlib @@ -1 +1 @@ -Subproject commit 135ab5cf71ed731fc9fa0653051e7d4884a3652f +Subproject commit a0b8a92e3d1532361c2f7feb63babc5c18d00ef2 diff --git a/externals/pybind11 b/externals/pybind11 index 8edc147d..76b7f536 160000 --- a/externals/pybind11 +++ b/externals/pybind11 @@ -1 +1 @@ -Subproject commit 8edc147d67ca85a93ed1f53628004528dc36a04d +Subproject commit 76b7f53649580b66b559752de6a39d98477ff1da diff --git a/include/CPstrings.h b/include/CPstrings.h index 711981cd..5885b0b0 100644 --- a/include/CPstrings.h +++ b/include/CPstrings.h @@ -6,6 +6,7 @@ #include #include #include +#include #if !defined(NO_FMTLIB) # ifndef FMT_HEADER_ONLY @@ -74,17 +75,16 @@ inline bool endswith(const std::string& s1, const std::string& s2) { #if defined(NO_FMTLIB) // Missing string formatting function, this old guy is needed for ancient gcc compilers on PowerPC for VxWorks inline std::string format(const char* fmt, ...); +#elif FMT_VERSION >= 50000 +template +inline std::string format(const char* format_str, const Args&... args) { + return fmt::sprintf(format_str, args...); +} #else -// Missing std::string formatting function - provided by the fmtlib library inline std::string format(const char* format, fmt::ArgList args) { return fmt::sprintf(format, args); } FMT_VARIADIC(std::string, format, const char*) -// For latest FMTLIB -/*template - inline std::string format(const char *format_str, const Args & ... args) { - return fmt::sprintf(format_str, args); - }*/ #endif // Missing string split - like in Python diff --git a/include/CoolPropFluid.h b/include/CoolPropFluid.h index 80fb9ff3..9523a80b 100644 --- a/include/CoolPropFluid.h +++ b/include/CoolPropFluid.h @@ -134,6 +134,7 @@ struct ConductivityDiluteVariables CONDUCTIVITY_DILUTE_RATIO_POLYNOMIALS, CONDUCTIVITY_DILUTE_ETA0_AND_POLY, CONDUCTIVITY_DILUTE_CO2, + CONDUCTIVITY_DILUTE_CO2_HUBER_JPCRD_2016, CONDUCTIVITY_DILUTE_ETHANE, CONDUCTIVITY_DILUTE_NONE, CONDUCTIVITY_DILUTE_NOT_SET @@ -245,6 +246,7 @@ struct ViscosityDiluteVariables VISCOSITY_DILUTE_KINETIC_THEORY, ///< Use \ref TransportRoutines::viscosity_dilute_kinetic_theory VISCOSITY_DILUTE_ETHANE, ///< Use \ref TransportRoutines::viscosity_dilute_ethane VISCOSITY_DILUTE_CYCLOHEXANE, ///< Use \ref TransportRoutines::viscosity_dilute_cyclohexane + VISCOSITY_DILUTE_CO2_LAESECKE_JPCRD_2017, ///< Use \ref TransportRoutines::viscosity_dilute_CO2_LaeseckeJPCRD2017 VISCOSITY_DILUTE_POWERS_OF_T, ///< Use \ref TransportRoutines::viscosity_dilute_powers_of_T VISCOSITY_DILUTE_POWERS_OF_TR, ///< Use \ref TransportRoutines::viscosity_dilute_powers_of_Tr VISCOSITY_DILUTE_NOT_SET @@ -308,6 +310,7 @@ struct ViscosityHigherOrderVariables VISCOSITY_HIGHER_ORDER_ETHANE, ///< Use \ref TransportRoutines::viscosity_ethane_higher_order_hardcoded VISCOSITY_HIGHER_ORDER_BENZENE, ///< Use \ref TransportRoutines::viscosity_benzene_higher_order_hardcoded VISCOSITY_HIGHER_ORDER_TOLUENE, ///< Use \ref TransportRoutines::viscosity_toluene_higher_order_hardcoded + VISCOSITY_HIGHER_ORDER_CO2_LAESECKE_JPCRD_2017,///< Use \ref TransportRoutines::viscosity_CO2_higher_order_hardcoded_LaeseckeJPCRD2017 VISCOSITY_HIGHER_ORDER_FRICTION_THEORY, ///< Use \ref TransportRoutines::viscosity_higher_order_friction_theory VISCOSITY_HIGHER_ORDER_NOT_SET }; @@ -562,5 +565,19 @@ class CoolPropFluid }; }; +#if !defined(NO_FMTLIB) && FMT_VERSION >= 90000 +inline int format_as(ViscosityDiluteVariables::ViscosityDiluteType type) { + return fmt::underlying(type); +} + +inline int format_as(TransportPropertyData::ViscosityHardcodedEnum viscosity) { + return fmt::underlying(viscosity); +} + +inline int format_as(TransportPropertyData::ConductivityHardcodedEnum conductivity) { + return fmt::underlying(conductivity); +} +#endif + } /* namespace CoolProp */ #endif /* COOLPROPFLUID_H_ */ diff --git a/include/CoolPropLib.h b/include/CoolPropLib.h index 33936f2f..24f73889 100644 --- a/include/CoolPropLib.h +++ b/include/CoolPropLib.h @@ -370,6 +370,28 @@ EXPORT_CODE void CONVENTION AbstractState_get_mole_fractions(const long handle, EXPORT_CODE void CONVENTION AbstractState_get_mole_fractions_satState(const long handle, const char* saturated_state, double* fractions, const long maxN, long* N, long* errcode, char* message_buffer, const long buffer_length); +/** + * @brief Return the fugacity of the i-th component of the mixture. + * @param handle The integer handle for the state class stored in memory + * @param i i-th component of the mixture + * @param errcode The errorcode that is returned (0 = no error, !0 = error) + * @param message_buffer A buffer for the error code + * @param buffer_length The length of the buffer for the error code + * @return + */ +EXPORT_CODE double CONVENTION AbstractState_get_fugacity(const long handle, const long i, long* errcode, char* message_buffer, + const long buffer_length); +/** + * @brief Return the fugacity coefficient of the i-th component of the mixture. + * @param handle The integer handle for the state class stored in memory + * @param i i-th component of the mixture + * @param errcode The errorcode that is returned (0 = no error, !0 = error) + * @param message_buffer A buffer for the error code + * @param buffer_length The length of the buffer for the error code + * @return + */ +EXPORT_CODE double CONVENTION AbstractState_get_fugacity_coefficient(const long handle, const long i, long* errcode, char* message_buffer, + const long buffer_length); /** * @brief Update the state of the AbstractState * @param handle The integer handle for the state class stored in memory @@ -442,6 +464,72 @@ EXPORT_CODE double CONVENTION AbstractState_first_saturation_deriv(const long ha EXPORT_CODE double CONVENTION AbstractState_first_partial_deriv(const long handle, const long Of, const long Wrt, const long Constant, long* errcode, char* message_buffer, const long buffer_length); +/** + * @brief Calculate the second partial derivative in homogeneous phases from the AbstractState using integer values for the desired parameters + * @param handle The integer handle for the state class stored in memory + * @param Of1 The parameter of which the derivative is being taken + * @param Wrt1 The parameter that the derivative is taken with respect to in the first derivative + * @param Constant1 The parameter that is held constant in the first derivative + * @param Wrt2 The parameter that the derivative is taken with respect to in the second derivative + * @param Constant2 The parameter that is held constant in the second derivative + * @param errcode The errorcode that is returned (0 = no error, !0 = error) + * @param message_buffer A buffer for the error code + * @param buffer_length The length of the buffer for the error code + * @return + */ + +EXPORT_CODE double CONVENTION AbstractState_second_two_phase_deriv(const long handle, const long Of1, const long Wrt1, const long Constant1, + const long Wrt2, const long Constant2, long* errcode, char* message_buffer, + const long buffer_length); +/** + * @brief Calculate the second partial derivative int two-phase region from the AbstractState using integer values for the desired parameters + * @param handle The integer handle for the state class stored in memory + * @param Of1 The parameter of which the derivative is being taken + * @param Wrt1 The parameter that the derivative is taken with respect to in the first derivative + * @param Constant1 The parameter that is held constant in the first derivative + * @param Wrt2 The parameter that the derivative is taken with respect to in the second derivative + * @param Constant2 The parameter that is held constant in the second derivative + * @param errcode The errorcode that is returned (0 = no error, !0 = error) + * @param message_buffer A buffer for the error code + * @param buffer_length The length of the buffer for the error code + * @return + */ + +EXPORT_CODE double CONVENTION AbstractState_second_partial_deriv(const long handle, const long Of1, const long Wrt1, const long Constant1, + const long Wrt2, const long Constant2, long* errcode, char* message_buffer, + const long buffer_length); + +/** + * @brief Calculate the first partial derivative in two-phase region with Spline - Approach from the AbstractState using integer values for the desired parameters + Spline Approach "Methods to Increase the Robustness of Finite-Volume FlowModels in Thermodynamic Systems: Sylvain Quoilin, Ian Bell, Adriano Desideri, Pierre Dewallef and Vincent Lemort" + * @param handle The integer handle for the state class stored in memory + * @x_end constant parameter for defining range of the spline, (usually 0.1 is used, 0..1 is possible) + * @param Of The parameter of which the derivative is being taken + * @param Wrt The derivative with with respect to this parameter + * @param Constant The parameter that is not affected by the derivative + * @param errcode The errorcode that is returned (0 = no error, !0 = error) + * @param message_buffer A buffer for the error code + * @param buffer_length The length of the buffer for the error code + * @return + */ + + +EXPORT_CODE double CONVENTION AbstractState_first_two_phase_deriv_splined(const long handle, const long Of, const long Wrt, const long Constant, + const double x_end,long* errcode, char* message_buffer, const long buffer_length); +/** + * @brief Calculate the first partial derivative in homogeneous phases from the AbstractState using integer values for the desired parameters + * @param handle The integer handle for the state class stored in memory + * @param Of The parameter of which the derivative is being taken + * @param Wrt The derivative with with respect to this parameter + * @param Constant The parameter that is not affected by the derivative + * @param errcode The errorcode that is returned (0 = no error, !0 = error) + * @param message_buffer A buffer for the error code + * @param buffer_length The length of the buffer for the error code + * @return + */ + +EXPORT_CODE double CONVENTION AbstractState_first_two_phase_deriv(const long handle, const long Of, const long Wrt, const long Constant, + long* errcode, char* message_buffer, const long buffer_length); /** * @brief Update the state of the AbstractState and get an output value five common outputs (temperature, pressure, molar density, molar enthalpy and molar entropy) * @brief from the AbstractState using pointers as inputs and output to allow array computation. @@ -685,6 +773,31 @@ EXPORT_CODE double CONVENTION AbstractState_keyed_output_satState(const long han */ EXPORT_CODE void CONVENTION AbstractState_backend_name(const long handle, char* backend, long* errcode, char* message_buffer, const long buffer_length); + +/** + * +*/ +EXPORT_CODE void CONVENTION AbstractState_fluid_param_string(const long handle, const char* param, char* return_buffer, + const long return_buffer_length, long* errcode, char* message_buffer, + const long buffer_length); + +/** + * +*/ +EXPORT_CODE int CONVENTION AbstractState_phase(const long handle, long* errcode, char* message_buffer, const long buffer_length); + +/** + * +*/ +EXPORT_CODE double CONVENTION AbstractState_saturated_liquid_keyed_output(const long handle, const long param, long* errcode, char* message_buffer, + const long buffer_length); + +/** + * +*/ +EXPORT_CODE double CONVENTION AbstractState_saturated_vapor_keyed_output(const long handle, const long param, long* errcode, char* message_buffer, + const long buffer_length); + /** * \brief Add fluids as a JSON-formatted string * @param backend The backend to which these should be added; e.g. "HEOS", "SRK", "PR" @@ -695,6 +808,17 @@ EXPORT_CODE void CONVENTION AbstractState_backend_name(const long handle, char* EXPORT_CODE void CONVENTION add_fluids_as_JSON(const char* backend, const char* fluidstring, long* errcode, char* message_buffer, const long buffer_length); +/** + * +*/ +EXPORT_CODE int CONVENTION C_is_valid_fluid_string(const char* fluidName); + +/** + * +*/ +EXPORT_CODE int CONVENTION C_extract_backend(const char* fluid_string, char* backend, const long backend_length, char* fluid, + const long fluid_length); + // ************************************************************************************* // ************************************************************************************* // ***************************** DEPRECATED ******************************************* diff --git a/include/DataStructures.h b/include/DataStructures.h index e7b7f1b3..007da23a 100644 --- a/include/DataStructures.h +++ b/include/DataStructures.h @@ -474,5 +474,40 @@ void extract_backend_families(const std::string& backend_string, backend_familie void extract_backend_families_string(const std::string& backend_string, backend_families& f1, std::string& f2); std::string get_backend_string(backends backend); +#if !defined(NO_FMTLIB) && FMT_VERSION >= 90000 +/// Allows enums to be formatted +inline int format_as(parameters parameter) { + return fmt::underlying(parameter); +} + +inline int format_as(phases phase) { + return fmt::underlying(phase); +} + +inline int format_as(schemes scheme) { + return fmt::underlying(scheme); +} + +inline int format_as(composition_types type) { + return fmt::underlying(type); +} + +inline int format_as(fluid_types type) { + return fmt::underlying(type); +} + +inline int format_as(input_pairs pair) { + return fmt::underlying(pair); +} + +inline int format_as(backend_families family) { + return fmt::underlying(family); +} + +inline int format_as(backends backend) { + return fmt::underlying(backend); +} +#endif + } /* namespace CoolProp */ #endif /* DATASTRUCTURES_H_ */ diff --git a/include/Helmholtz.h b/include/Helmholtz.h index 0ad6d7d5..69646521 100644 --- a/include/Helmholtz.h +++ b/include/Helmholtz.h @@ -1152,7 +1152,7 @@ class IdealHelmholtzGERG2004Sinh : public BaseHelmholtzTerm /// Constructor with std::vectors IdealHelmholtzGERG2004Sinh(const std::vector& n, const std::vector& theta, double Tc) - : n(n), theta(theta), Tc(Tc), N(n.size()), _Tr(_HUGE), enabled(true) { + : n(n), theta(theta), Tc(Tc), _Tr(_HUGE), N(n.size()), enabled(true) { assert(n.size() == theta.size()); } @@ -1184,7 +1184,7 @@ class IdealHelmholtzGERG2004Cosh : public BaseHelmholtzTerm /// Constructor with std::vectors IdealHelmholtzGERG2004Cosh(const std::vector& n, const std::vector& theta, double Tc) - : n(n), theta(theta), Tc(Tc), N(n.size()), _Tr(_HUGE), enabled(true) { + : n(n), theta(theta), Tc(Tc), _Tr(_HUGE), N(n.size()), enabled(true) { assert(n.size() == theta.size()); } diff --git a/include/IncompressibleFluid.h b/include/IncompressibleFluid.h index 1ea41775..35b12f35 100644 --- a/include/IncompressibleFluid.h +++ b/include/IncompressibleFluid.h @@ -44,6 +44,12 @@ struct IncompressibleData }; }; +#if !defined(NO_FMTLIB) && FMT_VERSION >= 90000 +inline int format_as(IncompressibleData::IncompressibleTypeEnum type) { + return fmt::underlying(type); +} +#endif + /// A property provider for incompressible solutions and pure fluids /** This fluid instance is populated using an entry from a JSON file diff --git a/src/Backends/Cubics/CubicBackend.cpp b/src/Backends/Cubics/CubicBackend.cpp index fdf16cc4..09f89492 100644 --- a/src/Backends/Cubics/CubicBackend.cpp +++ b/src/Backends/Cubics/CubicBackend.cpp @@ -17,10 +17,8 @@ void CoolProp::AbstractCubicBackend::setup(bool generate_SatL_and_SatV) { // If pure, set the mole fractions to be unity if (is_pure_or_pseudopure) { mole_fractions = std::vector(1, 1.0); - mole_fractions_double = std::vector(1, 1.0); } else { mole_fractions.clear(); - mole_fractions_double.clear(); } // Now set the reducing function for the mixture Reducing.reset(new ConstantReducingFunction(cubic->get_Tr(), cubic->get_rhor())); @@ -339,7 +337,7 @@ void CoolProp::AbstractCubicBackend::update(CoolProp::input_pairs input_pair, do void CoolProp::AbstractCubicBackend::rho_Tp_cubic(CoolPropDbl T, CoolPropDbl p, int& Nsolns, double& rho0, double& rho1, double& rho2) { AbstractCubic* cubic = get_cubic().get(); double R = cubic->get_R_u(); - double am = cubic->am_term(cubic->get_Tr() / T, mole_fractions_double, 0); + double am = cubic->am_term(cubic->get_Tr() / T, mole_fractions, 0); double bm = cubic->bm_term(mole_fractions); double cm = cubic->cm_term(); diff --git a/src/Backends/Cubics/VTPRBackend.cpp b/src/Backends/Cubics/VTPRBackend.cpp index 4e933e15..f8c0abb9 100644 --- a/src/Backends/Cubics/VTPRBackend.cpp +++ b/src/Backends/Cubics/VTPRBackend.cpp @@ -24,7 +24,6 @@ void CoolProp::VTPRBackend::setup(const std::vector& names, bool ge // If pure, set the mole fractions to be unity if (is_pure_or_pseudopure) { mole_fractions = std::vector(1, 1.0); - mole_fractions_double = std::vector(1, 1.0); } // Now set the reducing function for the mixture diff --git a/src/Backends/Cubics/VTPRBackend.h b/src/Backends/Cubics/VTPRBackend.h index 35e51b45..2976b1e7 100644 --- a/src/Backends/Cubics/VTPRBackend.h +++ b/src/Backends/Cubics/VTPRBackend.h @@ -84,7 +84,6 @@ class VTPRBackend : public PengRobinsonBackend void set_mole_fractions(const std::vector& z) { mole_fractions = z; - mole_fractions_double = z; VTPRCubic* _cubic = static_cast(cubic.get()); _cubic->get_unifaq().set_mole_fractions(z); }; diff --git a/src/Backends/Helmholtz/FlashRoutines.cpp b/src/Backends/Helmholtz/FlashRoutines.cpp index c65c36ec..5e915b91 100644 --- a/src/Backends/Helmholtz/FlashRoutines.cpp +++ b/src/Backends/Helmholtz/FlashRoutines.cpp @@ -260,6 +260,10 @@ void FlashRoutines::DQ_flash(HelmholtzEOSMixtureBackend& HEOS) { double Tmin = HEOS.Tmin() + 0.1; double rhomolar = HEOS._rhomolar; double Q = HEOS._Q; + const double eps = 1e-12; // small tolerance to allow for slop in iterative calculations + if (rhomolar >= (HEOS.rhomolar_critical() + eps) && Q > (0 + eps)){ + throw CoolProp::OutOfRangeError(format("DQ inputs are not defined for density (%g) above critical density (%g) and Q>0", rhomolar, HEOS.rhomolar_critical()).c_str()); + } DQ_flash_residual resid(HEOS, rhomolar, Q); Brent(resid, Tmin, Tmax, DBL_EPSILON, 1e-10, 100); HEOS._p = HEOS.SatV->p(); @@ -1549,7 +1553,7 @@ void FlashRoutines::HSU_P_flash(HelmholtzEOSMixtureBackend& HEOS, parameters oth if (saturation_called) { Tmin = HEOS.SatV->T(); } else { - Tmin = HEOS._TVanc.pt() + 0.01; + Tmin = HEOS._TVanc.pt() - 0.01; } } break; @@ -1558,7 +1562,7 @@ void FlashRoutines::HSU_P_flash(HelmholtzEOSMixtureBackend& HEOS, parameters oth if (saturation_called) { Tmax = HEOS.SatL->T(); } else { - Tmax = HEOS._TLanc.pt(); + Tmax = HEOS._TLanc.pt() + 0.01; } // Sometimes the minimum pressure for the melting line is a bit above the triple point pressure diff --git a/src/Backends/Helmholtz/Fluids/FluidLibrary.h b/src/Backends/Helmholtz/Fluids/FluidLibrary.h index 67986ffe..209fcfa6 100644 --- a/src/Backends/Helmholtz/Fluids/FluidLibrary.h +++ b/src/Backends/Helmholtz/Fluids/FluidLibrary.h @@ -446,6 +446,9 @@ class JSONFluidLibrary } else if (!target.compare("Cyclohexane")) { fluid.transport.viscosity_dilute.type = CoolProp::ViscosityDiluteVariables::VISCOSITY_DILUTE_CYCLOHEXANE; return; + } else if (!target.compare("CarbonDioxideLaeseckeJPCRD2017")) { + fluid.transport.viscosity_dilute.type = CoolProp::ViscosityDiluteVariables::VISCOSITY_DILUTE_CO2_LAESECKE_JPCRD_2017; + return; } else { throw ValueError(format("hardcoded dilute viscosity [%s] is not understood for fluid %s", target.c_str(), fluid.name.c_str())); } @@ -552,6 +555,9 @@ class JSONFluidLibrary } else if (!target.compare("Benzene")) { fluid.transport.viscosity_higher_order.type = CoolProp::ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_BENZENE; return; + } else if (!target.compare("CarbonDioxideLaeseckeJPCRD2017")) { + fluid.transport.viscosity_higher_order.type = CoolProp::ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_CO2_LAESECKE_JPCRD_2017; + return; } else { throw ValueError( format("hardcoded higher order viscosity term [%s] is not understood for fluid %s", target.c_str(), fluid.name.c_str())); @@ -774,6 +780,10 @@ class JSONFluidLibrary if (!target.compare("CO2")) { fluid.transport.conductivity_dilute.type = CoolProp::ConductivityDiluteVariables::CONDUCTIVITY_DILUTE_CO2; return; + } + else if (!target.compare("CarbonDioxideHuberJPCRD2016")) { + fluid.transport.conductivity_dilute.type = CoolProp::ConductivityDiluteVariables::CONDUCTIVITY_DILUTE_CO2_HUBER_JPCRD_2016; + return; } else if (!target.compare("Ethane")) { fluid.transport.conductivity_dilute.type = CoolProp::ConductivityDiluteVariables::CONDUCTIVITY_DILUTE_ETHANE; return; diff --git a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp index 14f8a446..57e4e686 100644 --- a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp +++ b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp @@ -118,15 +118,13 @@ void HelmholtzEOSMixtureBackend::set_components(const std::vector linked_states.push_back(SatV); } } -void HelmholtzEOSMixtureBackend::set_mole_fractions(const std::vector& mole_fractions) { - if (mole_fractions.size() != N) { - throw ValueError(format("size of mole fraction vector [%d] does not equal that of component vector [%d]", mole_fractions.size(), N)); +void HelmholtzEOSMixtureBackend::set_mole_fractions(const std::vector& mf) { + if (mf.size() != N) { + throw ValueError(format("size of mole fraction vector [%d] does not equal that of component vector [%d]", mf.size(), N)); } // Copy values without reallocating memory - this->mole_fractions = mole_fractions; // Most effective copy + this->mole_fractions = mf; // Most effective copy this->resize(N); // No reallocation of this->mole_fractions happens - // Also store the mole fractions as doubles - this->mole_fractions_double = std::vector(mole_fractions.begin(), mole_fractions.end()); clear_comp_change(); }; void HelmholtzEOSMixtureBackend::sync_linked_states(const HelmholtzEOSMixtureBackend* const source) { @@ -167,7 +165,6 @@ void HelmholtzEOSMixtureBackend::set_mass_fractions(const std::vectormole_fractions.resize(N); - this->mole_fractions_double.resize(N); this->K.resize(N); this->lnK.resize(N); for (std::vector>::iterator it = linked_states.begin(); it != linked_states.end(); ++it) { @@ -587,6 +584,9 @@ CoolPropDbl HelmholtzEOSMixtureBackend::calc_viscosity_dilute(void) { case ViscosityDiluteVariables::VISCOSITY_DILUTE_CYCLOHEXANE: eta_dilute = TransportRoutines::viscosity_dilute_cyclohexane(*this); break; + case ViscosityDiluteVariables::VISCOSITY_DILUTE_CO2_LAESECKE_JPCRD_2017: + eta_dilute = TransportRoutines::viscosity_dilute_CO2_LaeseckeJPCRD2017(*this); + break; default: throw ValueError( format("dilute viscosity type [%d] is invalid for fluid %s", components[0].transport.viscosity_dilute.type, name().c_str())); @@ -606,7 +606,7 @@ CoolPropDbl HelmholtzEOSMixtureBackend::calc_viscosity_background(CoolPropDbl et case ViscosityInitialDensityVariables::VISCOSITY_INITIAL_DENSITY_RAINWATER_FRIEND: { CoolPropDbl B_eta_initial = TransportRoutines::viscosity_initial_density_dependence_Rainwater_Friend(*this); CoolPropDbl rho = rhomolar(); - initial_density = eta_dilute * B_eta_initial * rho; + initial_density = eta_dilute * B_eta_initial * rho; //TODO: Check units once AMTG break; } case ViscosityInitialDensityVariables::VISCOSITY_INITIAL_DENSITY_EMPIRICAL: { @@ -644,6 +644,9 @@ CoolPropDbl HelmholtzEOSMixtureBackend::calc_viscosity_background(CoolPropDbl et case ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_BENZENE: residual = TransportRoutines::viscosity_benzene_higher_order_hardcoded(*this); break; + case ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_CO2_LAESECKE_JPCRD_2017: + residual = TransportRoutines::viscosity_CO2_higher_order_hardcoded_LaeseckeJPCRD2017(*this); + break; default: throw ValueError( format("higher order viscosity type [%d] is invalid for fluid %s", components[0].transport.viscosity_dilute.type, name().c_str())); @@ -829,6 +832,9 @@ void HelmholtzEOSMixtureBackend::calc_conductivity_contributions(CoolPropDbl& di case ConductivityDiluteVariables::CONDUCTIVITY_DILUTE_CO2: dilute = TransportRoutines::conductivity_dilute_hardcoded_CO2(*this); break; + case ConductivityDiluteVariables::CONDUCTIVITY_DILUTE_CO2_HUBER_JPCRD_2016: + dilute = TransportRoutines::conductivity_dilute_hardcoded_CO2_HuberJPCRD2016(*this); + break; case ConductivityDiluteVariables::CONDUCTIVITY_DILUTE_ETHANE: dilute = TransportRoutines::conductivity_dilute_hardcoded_ethane(*this); break; @@ -2410,11 +2416,11 @@ CoolPropDbl HelmholtzEOSMixtureBackend::solver_rho_Tp_global(CoolPropDbl T, Cool // Vapor root found, return it return rho_vap; } else { - throw CoolProp::ValueError(format("No density solutions for T=%g,p=%g,z=%s", T, p, vec_to_string(mole_fractions, "%0.12g").c_str())); + throw CoolProp::ValueError(format("No density solutions for T=%g,p=%g,z=%s", T, p, vec_to_string(static_cast>(mole_fractions), "%0.12g").c_str())); } } else { throw CoolProp::ValueError( - format("One stationary point (not good) for T=%g,p=%g,z=%s", T, p, vec_to_string(mole_fractions, "%0.12g").c_str())); + format("One stationary point (not good) for T=%g,p=%g,z=%s", T, p, vec_to_string(static_cast>(mole_fractions), "%0.12g").c_str())); } }; diff --git a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h index 927318fc..cab60d37 100644 --- a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h +++ b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h @@ -19,6 +19,42 @@ class FlashRoutines; class ResidualHelmholtz; +// This class contains the mole fractions for a given mixture. +class MoleFractions{ + private: + std::vector mole_fractions; ///< The bulk mole fractions of the mixture + template + bool verify_mole_fractions_set(T i) const { + if (i >= mole_fractions.size()){ + throw CoolProp::ValueError("mole fractions are not set for all components"); + } + return true; + } + public: + template + void resize(T N){ + return mole_fractions.resize(N); + } + std::size_t size() const { + return mole_fractions.size(); + } + void clear() { + mole_fractions.clear(); + } + // operator overloads + template + MoleFractions& operator=(const std::vector& values){ + mole_fractions = values; + return *this; + } + template + CoolPropDbl operator[](T i) const { + verify_mole_fractions_set(i); + return mole_fractions[i]; + } + operator std::vector& () { return mole_fractions; } +}; + class HelmholtzEOSMixtureBackend : public AbstractState { @@ -57,8 +93,7 @@ class HelmholtzEOSMixtureBackend : public AbstractState std::vector components; ///< The components that are in use bool is_pure_or_pseudopure; ///< A flag for whether the substance is a pure or pseudo-pure fluid (true) or a mixture (false) - std::vector mole_fractions; ///< The bulk mole fractions of the mixture - std::vector mole_fractions_double; ///< A copy of the bulk mole fractions of the mixture stored as doubles + MoleFractions mole_fractions; ///< The bulk mole fractions of the mixture std::vector K, ///< The K factors for the components lnK; ///< The natural logarithms of the K factors of the components @@ -338,7 +373,7 @@ class HelmholtzEOSMixtureBackend : public AbstractState * * @param mole_fractions The vector of mole fractions of the components */ - void set_mole_fractions(const std::vector& mole_fractions); + void set_mole_fractions(const std::vector& mf); const std::vector& get_mole_fractions() { return mole_fractions; @@ -347,7 +382,7 @@ class HelmholtzEOSMixtureBackend : public AbstractState return mole_fractions; }; std::vector& get_mole_fractions_doubleref(void) { - return mole_fractions_double; + return mole_fractions; } /** \brief Set the mass fractions diff --git a/src/Backends/Helmholtz/MixtureParameters.cpp b/src/Backends/Helmholtz/MixtureParameters.cpp index 56f6990f..3e8fe8ae 100644 --- a/src/Backends/Helmholtz/MixtureParameters.cpp +++ b/src/Backends/Helmholtz/MixtureParameters.cpp @@ -16,13 +16,23 @@ class PredefinedMixturesLibrary std::map predefined_mixture_map; PredefinedMixturesLibrary() { + load_from_string(predefined_mixtures_JSON); + } + + void load_from_string(const std::string& str) { rapidjson::Document doc; - - doc.Parse<0>(predefined_mixtures_JSON.c_str()); + doc.Parse<0>(str.c_str()); if (doc.HasParseError()) { - throw ValueError(); + std::cout << str << std::endl; + throw ValueError("Unable to parse predefined mixture string"); } + load_from_JSON(doc); + } + void load_from_JSON(rapidjson::Document & doc){ + if (!doc.IsArray() || !doc[0].IsObject()){ + throw ValueError("You must provide an array of objects"); + } // Iterate over the papers in the listing for (rapidjson::Value::ValueIterator itr = doc.Begin(); itr != doc.End(); ++itr) { // Instantiate the empty dictionary to be filled @@ -61,6 +71,11 @@ bool is_predefined_mixture(const std::string& name, Dictionary& dict) { } } +void set_predefined_mixtures(const std::string& string_data) { + // JSON-encoded string for binary interaction parameters + predefined_mixtures_library.load_from_string(string_data); +} + /** \brief A library of binary pair parameters for the mixture * * Each entry in the binary pair library includes reducing parameters as well as the name of the reducing function to be used and diff --git a/src/Backends/Helmholtz/MixtureParameters.h b/src/Backends/Helmholtz/MixtureParameters.h index 62314a4a..d89f1b08 100644 --- a/src/Backends/Helmholtz/MixtureParameters.h +++ b/src/Backends/Helmholtz/MixtureParameters.h @@ -21,6 +21,13 @@ bool is_predefined_mixture(const std::string& name, Dictionary& dict); */ std::string get_csv_predefined_mixtures(); +/** + * @brief Set predefined mixtures at runtime + * @param string_data The predefined mixtures, as a JSON-formatted string + * + */ +void set_predefined_mixtures(const std::string& string_data); + /** \brief Get a string for the given binary pair * * diff --git a/src/Backends/Helmholtz/TransportRoutines.cpp b/src/Backends/Helmholtz/TransportRoutines.cpp index 074357f9..645f11d0 100644 --- a/src/Backends/Helmholtz/TransportRoutines.cpp +++ b/src/Backends/Helmholtz/TransportRoutines.cpp @@ -340,6 +340,17 @@ CoolPropDbl TransportRoutines::viscosity_heptane_higher_order_hardcoded(Helmholt + c[4] * rhor / (c[5] + c[6] * Tr + c[7] * rhor + rhor * rhor + c[8] * rhor * Tr)); } +CoolPropDbl TransportRoutines::viscosity_CO2_higher_order_hardcoded_LaeseckeJPCRD2017(HelmholtzEOSMixtureBackend& HEOS) { + double c1 = 0.360603235428487, c2 = 0.121550806591497, gamma = 8.06282737481277; + double Tt = HEOS.Ttriple(), rho_tL = 1178.53; + double Tr = HEOS.T() / Tt, rhor = HEOS.rhomass() / rho_tL; + // Eq. (9) from Laesecke, JPCRD, 2017 + double eta_tL = pow(rho_tL, 2.0/3.0) * sqrt(HEOS.gas_constant() * Tt) / (pow(HEOS.molar_mass(), 1.0/6.0) * 84446887.43579945); + // Eq. (8) from Laesecke, JPCRD, 2017 + double residual = eta_tL * (c1 * Tr * pow(rhor, 3) + (pow(rhor, 2) + pow(rhor, gamma)) / (Tr - c2)); + return residual; +} + CoolPropDbl TransportRoutines::viscosity_higher_order_friction_theory(HelmholtzEOSMixtureBackend& HEOS) { if (HEOS.is_pure_or_pseudopure) { CoolProp::ViscosityFrictionTheoryData& F = HEOS.components[0].transport.viscosity_higher_order.friction_theory; @@ -581,6 +592,21 @@ CoolPropDbl TransportRoutines::viscosity_dilute_cyclohexane(HelmholtzEOSMixtureB CoolPropDbl S_eta = exp(-1.5093 + 364.87 / T - 39537 / pow(T, 2)); //[nm^2] return 0.19592 * sqrt(T) / S_eta / 1e6; //[Pa-s] } + +CoolPropDbl TransportRoutines::viscosity_dilute_CO2_LaeseckeJPCRD2017(HelmholtzEOSMixtureBackend& HEOS) { + // From Laesecke, JPRCD, 2016 + double eta0, eta1, DELTAetar, den, Bstar; + double T = HEOS.T(); + + double a[] = { + 1749.354893188350, -369.069300007128, 5423856.34887691, -2.21283852168356, -269503.247933569, 73145.021531826, 5.34368649509278}; + + // Eq. (4) from Laesecke, JPRCD, 2016 + den = a[0] + a[1] * pow(T, 1.0/6.0) + a[2] * exp(a[3] * pow(T, 1.0/3.0)) + (a[4] + a[5] * pow(T, 1.0/3.0)) / exp(pow(T, 1.0 / 3.0)) + a[6] * sqrt(T); + eta0 = 0.0010055 * sqrt(T) / den; // [Pa-s] + return eta0; +} + CoolPropDbl TransportRoutines::viscosity_ethane_higher_order_hardcoded(HelmholtzEOSMixtureBackend& HEOS) { double r[] = {0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 1, 1}; double s[] = {0, 0, 1, 0, 1, 1.5, 0, 2, 0, 1, 0, 1}; @@ -797,6 +823,16 @@ CoolPropDbl TransportRoutines::conductivity_dilute_hardcoded_CO2(HelmholtzEOSMix return lambda_0; } +CoolPropDbl TransportRoutines::conductivity_dilute_hardcoded_CO2_HuberJPCRD2016(HelmholtzEOSMixtureBackend& HEOS) { + + double tau = HEOS.tau(); + double l[]={0.0151874307, 0.0280674040, 0.0228564190, -0.00741624210}; + // Huber 2016 Eq. (3) + double lambda_0 = pow(tau, -0.5)/(l[0] + l[1] * tau + l[2] * pow(tau, 2) + l[3] * pow(tau, 3)); // [mW/m/K] + + return lambda_0/1000; +} + CoolPropDbl TransportRoutines::conductivity_dilute_hardcoded_ethane(HelmholtzEOSMixtureBackend& HEOS) { double e_k = 245.0; diff --git a/src/Backends/Helmholtz/TransportRoutines.h b/src/Backends/Helmholtz/TransportRoutines.h index 575e748b..5c831b32 100644 --- a/src/Backends/Helmholtz/TransportRoutines.h +++ b/src/Backends/Helmholtz/TransportRoutines.h @@ -105,6 +105,8 @@ class TransportRoutines static CoolPropDbl viscosity_dilute_ethane(HelmholtzEOSMixtureBackend& HEOS); static CoolPropDbl viscosity_dilute_cyclohexane(HelmholtzEOSMixtureBackend& HEOS); + static CoolPropDbl viscosity_dilute_CO2_LaeseckeJPCRD2017(HelmholtzEOSMixtureBackend& HEOS); + /** \brief Viscosity hardcoded for Methanol * @@ -126,6 +128,7 @@ class TransportRoutines static CoolPropDbl viscosity_benzene_higher_order_hardcoded(HelmholtzEOSMixtureBackend& HEOS); static CoolPropDbl viscosity_hexane_higher_order_hardcoded(HelmholtzEOSMixtureBackend& HEOS); static CoolPropDbl viscosity_heptane_higher_order_hardcoded(HelmholtzEOSMixtureBackend& HEOS); + static CoolPropDbl viscosity_CO2_higher_order_hardcoded_LaeseckeJPCRD2017(HelmholtzEOSMixtureBackend& HEOS); /** * @brief Higher-order viscosity term from friction theory of Sergio Quinones-Cisneros @@ -237,6 +240,8 @@ class TransportRoutines static CoolPropDbl conductivity_critical_hardcoded_CO2_ScalabrinJPCRD2006(HelmholtzEOSMixtureBackend& HEOS); static CoolPropDbl conductivity_critical_hardcoded_R123(HelmholtzEOSMixtureBackend& HEOS); static CoolPropDbl conductivity_dilute_hardcoded_CO2(HelmholtzEOSMixtureBackend& HEOS); + static CoolPropDbl conductivity_dilute_hardcoded_CO2_HuberJPCRD2016(HelmholtzEOSMixtureBackend& HEOS); + static CoolPropDbl conductivity_dilute_hardcoded_ethane(HelmholtzEOSMixtureBackend& HEOS); static CoolPropDbl conductivity_dilute_eta0_and_poly(HelmholtzEOSMixtureBackend& HEOS); diff --git a/src/Backends/Helmholtz/VLERoutines.h b/src/Backends/Helmholtz/VLERoutines.h index e13c0295..983bf98c 100644 --- a/src/Backends/Helmholtz/VLERoutines.h +++ b/src/Backends/Helmholtz/VLERoutines.h @@ -97,6 +97,12 @@ struct saturation_PHSU_pure_options } }; +#if !defined(NO_FMTLIB) && FMT_VERSION >= 90000 +inline int format_as(saturation_PHSU_pure_options::specified_variable_options option) { + return fmt::underlying(option); +} +#endif + void saturation_PHSU_pure(HelmholtzEOSMixtureBackend& HEOS, CoolPropDbl specified_value, saturation_PHSU_pure_options& options); /* \brief This is a backup saturation_p solver for the case where the Newton solver cannot approach closely enough the solution diff --git a/src/Backends/Incompressible/IncompressibleFluid.cpp b/src/Backends/Incompressible/IncompressibleFluid.cpp index 9cdd4323..228f1b0e 100644 --- a/src/Backends/Incompressible/IncompressibleFluid.cpp +++ b/src/Backends/Incompressible/IncompressibleFluid.cpp @@ -7,6 +7,9 @@ #include "PolyMath.h" #include +constexpr double INCOMP_EPSILON = DBL_EPSILON * 100.0; +constexpr double INCOMP_DELTA = INCOMP_EPSILON * 10.0; + namespace CoolProp { /// A thermophysical property provider for all properties @@ -34,18 +37,52 @@ bool IncompressibleFluid::is_pure() { double IncompressibleFluid::baseExponential(IncompressibleData data, double y, double ybase) { Eigen::VectorXd coeffs = makeVector(data.coeffs); size_t r = coeffs.rows(), c = coeffs.cols(); - if (strict && (r != 3 || c != 1)) + if (strict && (r != 3 || c != 1)) { throw ValueError(format("%s (%d): You have to provide a 3,1 matrix of coefficients, not (%d,%d).", __FILE__, __LINE__, r, c)); - return exp((double)(coeffs[0] / ((y - ybase) + coeffs[1]) - coeffs[2])); + } + + // Guard the function against zero denominators in exp((double)(coeffs[0] / ((y - ybase) + coeffs[1]) - coeffs[2])) + auto fnc = [&](double x) { return exp((double)(coeffs[0] / (x) - coeffs[2])); } ; + double x_den = (y - ybase) + coeffs[1]; + double x_lo = -INCOMP_EPSILON; + double x_hi = +INCOMP_EPSILON; + if (x_den < x_lo || x_den > x_hi) { + return fnc(x_den); + } + // ... now we know that we are in the danger zone + // step away from the zero-crossing + x_lo -= INCOMP_DELTA; + x_hi += INCOMP_DELTA; + const double f_lo = fnc(x_lo); + const double f_hi = fnc(x_hi); + // Linearize around the zero-crossing + return (f_hi - f_lo) / (x_hi - x_lo) * (x_den - x_lo) + f_lo; } + /// Base exponential function with logarithmic term double IncompressibleFluid::baseLogexponential(IncompressibleData data, double y, double ybase) { Eigen::VectorXd coeffs = makeVector(data.coeffs); size_t r = coeffs.rows(), c = coeffs.cols(); - if (strict && (r != 3 || c != 1)) + if (strict && (r != 3 || c != 1)) { throw ValueError(format("%s (%d): You have to provide a 3,1 matrix of coefficients, not (%d,%d).", __FILE__, __LINE__, r, c)); - return exp( - (double)(log((double)(1.0 / ((y - ybase) + coeffs[0]) + 1.0 / ((y - ybase) + coeffs[0]) / ((y - ybase) + coeffs[0]))) * coeffs[1] + coeffs[2])); + } + + // Guard the function against zero denominators in exp((double)(log((double)(1.0 / ((y - ybase) + coeffs[0]) + 1.0 / ((y - ybase) + coeffs[0]) / ((y - ybase) + coeffs[0]))) * coeffs[1] + coeffs[2])) + auto fnc = [&](double x) { return exp((double)(log((double)(1.0 / (x) + 1.0 / (x) / (x))) * coeffs[1] + coeffs[2])); } ; + double x_den = (y - ybase) + coeffs[0]; + double x_lo = -INCOMP_EPSILON; + double x_hi = +INCOMP_EPSILON; + if (x_den < x_lo || x_den > x_hi) { + return fnc(x_den); + } + // ... now we know that we are in the danger zone + // step away from the zero-crossing + x_lo -= INCOMP_DELTA; + x_hi += INCOMP_DELTA; + const double f_lo = fnc(x_lo); + const double f_hi = fnc(x_hi); + // Linearize around the zero-crossing + return (f_hi - f_lo) / (x_hi - x_lo) * (x_den - x_lo) + f_lo; } double IncompressibleFluid::basePolyOffset(IncompressibleData data, double y, double z) { diff --git a/src/Backends/REFPROP/REFPROPMixtureBackend.cpp b/src/Backends/REFPROP/REFPROPMixtureBackend.cpp index 2fa882a8..d4d539b9 100644 --- a/src/Backends/REFPROP/REFPROPMixtureBackend.cpp +++ b/src/Backends/REFPROP/REFPROPMixtureBackend.cpp @@ -369,7 +369,7 @@ void REFPROPMixtureBackend::set_REFPROP_fluids(const std::vector& f } return; } else { - if (get_debug_level() > 0) { + if (CoolProp::get_debug_level() > 0) { std::cout << format("%s:%d Unable to load predefined mixture [%s] with ierr: [%d] and herr: [%s]\n", __FILE__, __LINE__, mix, ierr, herr); } @@ -1932,7 +1932,7 @@ void REFPROPMixtureBackend::update_with_guesses(CoolProp::input_pairs input_pair } else { throw ValueError(format("For PQ w/ guesses, Q must be either 0 or 1")); } - if (get_debug_level() > 9) { + if (CoolProp::get_debug_level() > 9) { std::cout << format("guesses.T: %g\n", guesses.T); } if (!ValidNumber(guesses.T)) { diff --git a/src/CoolProp.cpp b/src/CoolProp.cpp index fb497c4c..c39ca7aa 100644 --- a/src/CoolProp.cpp +++ b/src/CoolProp.cpp @@ -729,6 +729,7 @@ bool add_fluids_as_JSON(const std::string& backend, const std::string& fluidstri throw ValueError(format("You have provided an invalid backend [%s] to add_fluids_as_JSON; valid options are SRK, PR, HEOS", backend.c_str())); } } + #if defined(ENABLE_CATCH) TEST_CASE("Check inputs to PropsSI", "[PropsSI]") { SECTION("Single state, single output") { diff --git a/src/CoolProp.i b/src/CoolProp.i index 1ca5e5c7..eddcea89 100644 --- a/src/CoolProp.i +++ b/src/CoolProp.i @@ -52,6 +52,7 @@ #include "Configuration.h" #undef SWIG #include "HumidAirProp.h" +#include "Backends/Helmholtz/MixtureParameters.h" %} %include "DataStructures.h" @@ -59,4 +60,7 @@ %include "CoolProp.h" %include "PhaseEnvelope.h" %include "Configuration.h" -%include "HumidAirProp.h" \ No newline at end of file +%include "HumidAirProp.h" +namespace CoolProp { +void apply_simple_mixing_rule(const std::string& identifier1, const std::string& identifier2, const std::string& rule); +} diff --git a/src/CoolPropLib.cpp b/src/CoolPropLib.cpp index 596fc261..f516219a 100644 --- a/src/CoolPropLib.cpp +++ b/src/CoolPropLib.cpp @@ -610,6 +610,28 @@ EXPORT_CODE void CONVENTION AbstractState_get_mole_fractions_satState(const long HandleException(errcode, message_buffer, buffer_length); } } +EXPORT_CODE double CONVENTION AbstractState_get_fugacity(const long handle, const long i, long* errcode, char* message_buffer, + const long buffer_length) { + *errcode = 0; + try { + shared_ptr& AS = handle_manager.get(handle); + return AS->fugacity(i); + } catch (...) { + HandleException(errcode, message_buffer, buffer_length); + } + return _HUGE; +} +EXPORT_CODE double CONVENTION AbstractState_get_fugacity_coefficient(const long handle, const long i, long* errcode, char* message_buffer, + const long buffer_length) { + *errcode = 0; + try { + shared_ptr& AS = handle_manager.get(handle); + return AS->fugacity_coefficient(i); + } catch (...) { + HandleException(errcode, message_buffer, buffer_length); + } + return _HUGE; +} EXPORT_CODE void CONVENTION AbstractState_update(const long handle, const long input_pair, const double value1, const double value2, long* errcode, char* message_buffer, const long buffer_length) { *errcode = 0; @@ -676,6 +698,64 @@ EXPORT_CODE double CONVENTION AbstractState_first_partial_deriv(const long handl return _HUGE; } +EXPORT_CODE double CONVENTION AbstractState_second_partial_deriv(const long handle, const long Of1, const long Wrt1, const long Constant1, + const long Wrt2, const long Constant2, long* errcode, char* message_buffer, + const long buffer_length) { + *errcode = 0; + try { + shared_ptr& AS = handle_manager.get(handle); + return AS->second_partial_deriv(static_cast(Of1), static_cast(Wrt1), + static_cast(Constant1), static_cast(Wrt2), + static_cast(Constant2)); + } catch (...) { + HandleException(errcode, message_buffer, buffer_length); + } + return _HUGE; +} + +EXPORT_CODE double CONVENTION AbstractState_second_two_phase_deriv(const long handle, const long Of1, const long Wrt1, const long Constant1, + const long Wrt2, const long Constant2, long* errcode, char* message_buffer, + const long buffer_length) { + *errcode = 0; + try { + shared_ptr& AS = handle_manager.get(handle); + return AS->second_two_phase_deriv(static_cast(Of1), static_cast(Wrt1), + static_cast(Constant1), static_cast(Wrt2), + static_cast(Constant2)); + } catch (...) { + HandleException(errcode, message_buffer, buffer_length); + } + return _HUGE; +} + +EXPORT_CODE double CONVENTION AbstractState_first_two_phase_deriv(const long handle, const long Of, const long Wrt, const long Constant, + long* errcode, char* message_buffer, const long buffer_length) { + *errcode = 0; + try { + shared_ptr& AS = handle_manager.get(handle); + return AS->first_two_phase_deriv(static_cast(Of), static_cast(Wrt), + static_cast(Constant)); + } catch (...) { + HandleException(errcode, message_buffer, buffer_length); + } + return _HUGE; +} + +EXPORT_CODE double CONVENTION AbstractState_first_two_phase_deriv_splined(const long handle, const long Of, const long Wrt, const long Constant, + const double x_end, long* errcode, char* message_buffer, + const long buffer_length) { + *errcode = 0; + try { + shared_ptr& AS = handle_manager.get(handle); + return AS->first_two_phase_deriv_splined(static_cast(Of), static_cast(Wrt), + static_cast(Constant), x_end); + } catch (...) { + HandleException(errcode, message_buffer, buffer_length); + } + return _HUGE; +} + + EXPORT_CODE void CONVENTION AbstractState_update_and_common_out(const long handle, const long input_pair, const double* value1, const double* value2, const long length, double* T, double* p, double* rhomolar, double* hmolar, double* smolar, long* errcode, char* message_buffer, const long buffer_length) { @@ -943,6 +1023,58 @@ EXPORT_CODE void CONVENTION AbstractState_backend_name(const long handle, char* } } +EXPORT_CODE int CONVENTION AbstractState_phase(const long handle, long* errcode, char* message_buffer, const long buffer_length) { + *errcode = 0; + try { + shared_ptr& AS = handle_manager.get(handle); + return AS->phase(); + } catch (...) { + HandleException(errcode, message_buffer, buffer_length); + } + return -1; +} + +EXPORT_CODE void CONVENTION AbstractState_fluid_param_string(const long handle, const char* param, char* return_buffer, + const long return_buffer_length, long* errcode, char* message_buffer, + const long buffer_length) { + *errcode = 0; + try { + shared_ptr& AS = handle_manager.get(handle); + std::string temp = AS->fluid_param_string(param); + if (temp.size() < static_cast(return_buffer_length)) { + strcpy(return_buffer, temp.c_str()); + } else { + *errcode = 2; + } + } catch (...) { + HandleException(errcode, message_buffer, buffer_length); + } +} + +EXPORT_CODE double CONVENTION AbstractState_saturated_liquid_keyed_output(const long handle, const long param, long* errcode, char* message_buffer, + const long buffer_length) { + *errcode = 0; + try { + shared_ptr& AS = handle_manager.get(handle); + return AS->saturated_liquid_keyed_output(static_cast(param)); + } catch (...) { + HandleException(errcode, message_buffer, buffer_length); + } + return _HUGE; +} + +EXPORT_CODE double CONVENTION AbstractState_saturated_vapor_keyed_output(const long handle, const long param, long* errcode, char* message_buffer, + const long buffer_length) { + *errcode = 0; + try { + shared_ptr& AS = handle_manager.get(handle); + return AS->saturated_vapor_keyed_output(static_cast(param)); + } catch (...) { + HandleException(errcode, message_buffer, buffer_length); + } + return _HUGE; +} + EXPORT_CODE void CONVENTION add_fluids_as_JSON(const char* backend, const char* fluidstring, long* errcode, char* message_buffer, const long buffer_length) { *errcode = 0; @@ -953,3 +1085,24 @@ EXPORT_CODE void CONVENTION add_fluids_as_JSON(const char* backend, const char* HandleException(errcode, message_buffer, buffer_length); } } + +EXPORT_CODE int CONVENTION C_is_valid_fluid_string(const char* fluidName) { + return CoolProp::is_valid_fluid_string(fluidName); +} + +EXPORT_CODE int CONVENTION C_extract_backend(const char* fluid_string, char* backend, const long backend_length, char* fluid, + const long fluid_length) { + std::string _fluid, _backend; + CoolProp::extract_backend(fluid_string, _backend, _fluid); + if (_backend.size() < static_cast(backend_length)) { + strcpy(backend, _backend.c_str()); + } else { + return -1; + } + if (_fluid.size() < static_cast(fluid_length)) { + strcpy(fluid, _fluid.c_str()); + } else { + return -1; + } + return 0; +} diff --git a/src/CoolPropLib.def b/src/CoolPropLib.def index f8e6bb5d..a5a4f058 100644 --- a/src/CoolPropLib.def +++ b/src/CoolPropLib.def @@ -10,6 +10,10 @@ EXPORTS AbstractState_update = _AbstractState_update@36 AbstractState_first_saturation_deriv = _AbstractState_first_saturation_deriv@24 AbstractState_first_partial_deriv = _AbstractState_first_partial_deriv@28 + AbstractState_second_partial_deriv = _AbstractState_second_partial_deriv@28 + AbstractState_second_two_phase_deriv = _AbstractState_second_two_phase_deriv@28 + AbstractState_first_two_phase_deriv= _AbstractState_first_two_phase_deriv@28 + AbstractState_first_two_phase_deriv_splined= _AbstractState_first_two_phase_deriv_splined@28 AbstractState_specify_phase = _AbstractState_specify_phase@20 AbstractState_unspecify_phase = _AbstractState_unspecify_phase@16 AbstractState_update_and_1_out = _AbstractState_update_and_1_out@40 diff --git a/src/HumidAirProp.cpp b/src/HumidAirProp.cpp index 666f2fd9..32e8f8ef 100644 --- a/src/HumidAirProp.cpp +++ b/src/HumidAirProp.cpp @@ -81,6 +81,12 @@ enum givens GIVEN_ISENTROPIC_EXPONENT }; +#if !defined(NO_FMTLIB) && FMT_VERSION >= 90000 +int format_as(givens given) { + return fmt::underlying(given); +} +#endif + void _HAPropsSI_inputs(double p, const std::vector& input_keys, const std::vector& input_vals, double& T, double& psi_w); double _HAPropsSI_outputs(givens OutputType, double p, double T, double psi_w); // TODO: reserved name double MoleFractionWater(double T, double p, int HumInput, double InVal); diff --git a/src/PolyMath.cpp b/src/PolyMath.cpp index 1e2b2423..ddfc04c7 100644 --- a/src/PolyMath.cpp +++ b/src/PolyMath.cpp @@ -17,6 +17,9 @@ namespace CoolProp { +constexpr double CPPOLY_EPSILON = DBL_EPSILON * 100.0; +constexpr double CPPOLY_DELTA = CPPOLY_EPSILON * 10.0; + /// Basic checks for coefficient vectors. /** Starts with only the first coefficient dimension * and checks the matrix size against the parameters rows and columns. @@ -496,9 +499,13 @@ double Polynomial2DFrac::evaluate(const Eigen::MatrixXd& coefficients, const dou throw ValueError(format("%s (%d): You have a 2D coefficient matrix (%d,%d), please use the 2D functions. ", __FILE__, __LINE__, coefficients.rows(), coefficients.cols())); } - if ((firstExponent < 0) && (std::abs(x_in - x_base) < DBL_EPSILON)) { - throw ValueError( - format("%s (%d): A fraction cannot be evaluated with zero as denominator, x_in-x_base=%f ", __FILE__, __LINE__, x_in - x_base)); + if ((firstExponent < 0) && (std::abs(x_in - x_base) < CPPOLY_EPSILON)) { + //throw ValueError(format("%s (%d): A fraction cannot be evaluated with zero as denominator, x_in-x_base=%f ", __FILE__, __LINE__, x_in - x_base)); + const double x_lo = x_base - CPPOLY_DELTA; + const double x_hi = x_base + CPPOLY_DELTA; + const double y_lo = evaluate(coefficients, x_lo, firstExponent, x_base); + const double y_hi = evaluate(coefficients, x_hi, firstExponent, x_base); + return (y_hi - y_lo)/(x_hi - x_lo) * (x_in - x_lo) + y_lo; } Eigen::MatrixXd tmpCoeffs(coefficients); @@ -542,13 +549,23 @@ double Polynomial2DFrac::evaluate(const Eigen::MatrixXd& coefficients, const dou /// @param y_base double value that represents the base value for a centred fit in the 2nd dimension double Polynomial2DFrac::evaluate(const Eigen::MatrixXd& coefficients, const double& x_in, const double& y_in, const int& x_exp, const int& y_exp, const double& x_base, const double& y_base) { - if ((x_exp < 0) && (std::abs(x_in - x_base) < DBL_EPSILON)) { - throw ValueError( - format("%s (%d): A fraction cannot be evaluated with zero as denominator, x_in-x_base=%f ", __FILE__, __LINE__, x_in - x_base)); + if ((x_exp < 0) && (std::abs(x_in - x_base) < CPPOLY_EPSILON)) { + // throw ValueError(format("%s (%d): A fraction cannot be evaluated with zero as denominator, x_in-x_base=%f ", __FILE__, __LINE__, x_in - x_base)); + if (this->do_debug()) std::cout << "Interpolating in x-direction for base " << x_base << " and input " << x_in << std::endl; + const double x_lo = x_base - CPPOLY_DELTA; + const double x_hi = x_base + CPPOLY_DELTA; + const double z_lo = evaluate(coefficients, x_lo, y_in, x_exp, y_exp, x_base, y_base); + const double z_hi = evaluate(coefficients, x_hi, y_in, x_exp, y_exp, x_base, y_base); + return (z_hi - z_lo)/(x_hi - x_lo) * (x_in - x_lo) + z_lo; } - if ((y_exp < 0) && (std::abs(y_in - y_base) < DBL_EPSILON)) { - throw ValueError( - format("%s (%d): A fraction cannot be evaluated with zero as denominator, y_in-y_base=%f ", __FILE__, __LINE__, y_in - y_base)); + if ((y_exp < 0) && (std::abs(y_in - y_base) < CPPOLY_EPSILON)) { + // throw ValueError(format("%s (%d): A fraction cannot be evaluated with zero as denominator, y_in-y_base=%f ", __FILE__, __LINE__, y_in - y_base)); + if (this->do_debug()) std::cout << "Interpolating in y-direction for base " << y_base << " and input " << y_in << std::endl; + const double y_lo = y_base - CPPOLY_DELTA; + const double y_hi = y_base + CPPOLY_DELTA; + const double z_lo = evaluate(coefficients, x_in, y_lo, x_exp, y_exp, x_base, y_base); + const double z_hi = evaluate(coefficients, x_in, y_hi, x_exp, y_exp, x_base, y_base); + return (z_hi - z_lo)/(y_hi - y_lo) * (y_in - y_lo) + z_lo; } Eigen::MatrixXd tmpCoeffs(coefficients); diff --git a/wrappers/MathCAD/CoolPropFluidProperties.pdf b/wrappers/MathCAD/LegacyMathcad/CoolPropFluidProperties.pdf similarity index 100% rename from wrappers/MathCAD/CoolPropFluidProperties.pdf rename to wrappers/MathCAD/LegacyMathcad/CoolPropFluidProperties.pdf diff --git a/wrappers/MathCAD/CoolPropFluidProperties.xmcdz b/wrappers/MathCAD/LegacyMathcad/CoolPropFluidProperties.xmcdz similarity index 100% rename from wrappers/MathCAD/CoolPropFluidProperties.xmcdz rename to wrappers/MathCAD/LegacyMathcad/CoolPropFluidProperties.xmcdz diff --git a/wrappers/MathCAD/LegacyMathcad/README.rst b/wrappers/MathCAD/LegacyMathcad/README.rst new file mode 100644 index 00000000..57424bba --- /dev/null +++ b/wrappers/MathCAD/LegacyMathcad/README.rst @@ -0,0 +1,88 @@ +CoolProp Wrapper for Mathcad 15 (32-bit) +========================================== + +| Copyright Scott Polak and Ian Bell, 2013. +| Updated by Jeff Henning, 2016. + + .. + + > NOTE: Legacy Mathcad (through version 15) is no longer supported. PTC has discontinued distribution and licensing of Legacy Mathcad. Users should now be using only the top level of this wrapper to compile and develop the Mathcad Prime wrapper. Users who may still have a perpetual license may still be able to compile this wrapper for Legacy Mathcad, but it is not being actively developed or tested and binaries on SourForge ceased with CoolProp 6.4.1. + +There are two ways to get the CoolProp wrapper add-in for Legacy Mathcad. Download the pre-compiled binary from SourceForge or Compile your own. + +Precompiled Binaries +=================== +The binary DLL file (up through v6.4.1) can be downloaded and placed in the Mathcad installation directory. + +1. Goto the [SourceForge CoolProp](https://sourceforge.net/projects/coolprop/files/) web page. + +2. Browse to the desired version (6.4.1 or older). + +3. Under the MathCAD15 folder, download all three files + + * Place the ``CoolPropMathcadWrapper.DLL`` file in the Mathcad 15 installation directory under the ``usrefi`` directory. + + * Copy the ``CoolProp_EN.xml`` file to the ``doc\\funcdoc`` folder. + +4. Restart Mathcad 15. The add-in, ``CoolPropMathcadWrapper.DLL`` will automatically load the from the ``usrefi`` directory. + +5. Open the ``CoolPropFluidProperties.xmcdz`` file in Legacy Mathcad for examples on how to use the functions. + +6. The CoolProp functions will be added to the Insert Functions menu under the CoolProp category for easy insertion into your workbooks. + + +Build Your Own +============== + + +Prerequisites +-------------- + +* You will need to have Microsoft Visual Studio 2008 or later installed (Express version is fine). + +* You will need CMake version 2.8.12 or later from https://cmake.org/download/ + +* You will need to install Git-SCM for Windows. You can install this from https://git-for-windows.github.io + +* You will need Anaconda/Miniconda Python, which you can get from https://store.continuum.io/cshop/anaconda + + +To Build +-------- + +* **Recursively clone the CoolProp library to a local repository.**:: + + git clone https://github.com/CoolProp/CoolProp --recursive + +* **Change directory (cd) to the CoolProp directory you just created.**:: + + cd CoolProp + +* **Go to the top level CoolProp directory and make a build directory** (something like \build15):: + + mkdir build15 + cd build15 + +* **Build the makefile using CMake** (Note: Mathcad 15 is 32-bit):: + + cmake .. -DCOOLPROP_MATHCAD15_MODULE=ON + -DCOOLPROP_MATHCAD15_ROOT="C:/Program Files (x86)/Mathcad/Mathcad 15" + -G "Visual Studio 10 2010" + -DCMAKE_VERBOSE_MAKEFILE=ON + +* **Make the dynamic library (DLL)**:: + + cmake --build . --config Release + + +To Use +------ + +* Copy CoolProp\\build15\\Release\\CoolPropMathcadWrapper.dll to C:\\Program Files (x86)\\Mathcad\\Mathcad 15\\userefi + +* Copy CoolProp\\wrapper\\Mathcad\\CoolProp_EN.xml to C:\\Program Files (x86)\\Mathcad\\Mathcad 15\\doc\\funcdoc + +* Open the CoolPropFluidProperties.xmcd file in MathCAD, all CoolProp functions should evaluate properly. If not, press -F9 to force recalculation of the entire workbook. + +* CoolProp functions can be inserted from the Mathcad Insert Functions panel under the function category: CoolProp. Input parameters and a brief description of each function will be shown. + diff --git a/wrappers/MathCAD/Prime/README.rst b/wrappers/MathCAD/Prime/README.rst index e1847e2f..0dc57764 100644 --- a/wrappers/MathCAD/Prime/README.rst +++ b/wrappers/MathCAD/Prime/README.rst @@ -1,55 +1,21 @@ -CoolProp Wrapper for MathCAD Prime 3.x or later (64-bit) +CoolProp Wrapper for MathCAD Prime 7.0 or later (64-bit) ========================================================== | Copyright Scott Polak and Ian Bell, 2013 | Updated by Jeff Henning, 2016 -Prerequisites -============== - -* You will need to have Visual Studio 2008 or later installed. You will need the professional version of Visual Studio C++, or at least Visual Studio Express 2013 or later, as Mathcad Prime libraries are 64-bit and require the 64-bit compiler. - -* You will need CMake version 2.8.12 or later from https://cmake.org/download/ - -* You will need to install Git-SCM for Windows. You can install this from https://git-for-windows.github.io - -* You will need Anaconda/Miniconda Python, which you can get from https://store.continuum.io/cshop/anaconda - - -To Build +Examples ======== -* **Recursively clone the CoolProp library to a local repository.**:: - - git clone https://github.com/CoolProp/CoolProp --recursive - -* **Change directory (cd) to the CoolProp directory you just created.**:: - - cd CoolProp - -* **Go to the top level CoolProp directory and make a build directory** (something like \buildprime):: - - mkdir buildprime - cd buildprime - -* **Build the makefile using CMake (adjust root string for correct version of Prime)**:: - - cmake .. -DCOOLPROP_PRIME_MODULE=ON - -DCOOLPROP_PRIME_ROOT="C:/Program Files/PTC/Mathcad Prime 3.1" - -G "Visual Studio 10 2010 Win64" - -DCMAKE_VERBOSE_MAKEFILE=ON - - ( *Note: Mathcad Prime is 64-bit, so the 'Win64' option is necessary in the Visual Studio string.* ) - -* **Make the dynamic library (DLL)**:: - - cmake --build . --config Release +This Mathcad Prime file ``CoolPropFluidProperties.mcdx`` demonstrates how to use the CoolProp high-level and some low-level API calls from Mathcad Prime. The file is saved in Prime 7.0 format so that it can be read in any versions from 7.0 onward. There is also a PDF of the file for viewing without Mathcad Prime. To Use ====== -* Copy CoolProp\\buildprime\\Release\\CoolPropMathcadWrapper.dll file to C:\\Program Files\\PTC\\Mathcad Prime 3.1\\Custom Functions +* Copy the CoolPropMathcadWrapper.dll file built in the parent directory or downlaoded from SourceForge to C:\\Program Files\\PTC\\Mathcad Prime ``x.0.0.0``\\Custom Functions -* Open the CoolPropFluidProperties.xmcd file in MathCAD, all CoolProp functions should evaluate properly. If not, press -F9 to force recalculation of the entire workbook. +* Restart Mathcad Prime. + +* Open the CoolPropFluidProperties.mcdx file in Mathcad Prime; all CoolProp functions should revaluate properly. If not, press -F5 to force recalculation of the entire workbook. diff --git a/wrappers/MathCAD/README.rst b/wrappers/MathCAD/README.rst index 5cc8b4c4..60e44feb 100644 --- a/wrappers/MathCAD/README.rst +++ b/wrappers/MathCAD/README.rst @@ -1,23 +1,52 @@ -CoolProp Wrapper for MathCAD 15 (32-bit) -========================================== +CoolProp Wrapper for PTC Mathcad Prime 7.0 or later (64-bit) +========================================================== -| Copyright Scott Polak and Ian Bell, 2013. -| Updated by Jeff Henning, 2016. +| Copyright Scott Polak and Ian Bell, 2013 +| Updated by Jeff Henning, 2016 -Prerequisites + .. + +There are two ways to get the CoolProp wrapper add-in for Mathcad Prime; download the pre-compiled binary from SourceForge or Compile your own. + + +Precompiled Binaries +==================== +The binary DLL file (including nightly builds and release versions) can be downloaded and placed in the Mathcad Prime installation directory. + +1. Goto the [SourceForge CoolProp](https://sourceforge.net/projects/coolprop/files/) web page. + +2. Browse to the desired version. + +3. Under the MathCADPrime folder, download all three files + + * The README.txt files contains these instructions. + + * Place the ``CoolPropMathcadWrapper.DLL`` file in the Mathcad Prime installation directory under the ``Custom Functions`` directory. + + * Copy the ``CoolProp_EN.xml`` file to the ``Custom Functions\docs`` folder, creating it if it doesn't exist (this file is optional and for features in development). + +4. Restart Mathcad Prime. The add-in, ``CoolPropMathcadWrapper.DLL`` will automatically load the from the ``Custom Functions`` directory. +5. Open the ``CoolPropFluidProperties.mcdx`` file (*also found in the Prime folder of this repository*) in Mathcad Prime for function usage examples. +6. The CoolProp functions will _**not**_ be added to the internal Functions menu as this functionality has not been implemented in PTC Mathcad Prime as of version 9.0.0.0. Users should refer to the usage ``.mcdx`` file referenced above and/or the companion PDF of that file. + + +Build Your Own ============== -* You will need to have Microsoft Visual Studio 2008 or later installed (Express version is fine). +Prerequisites +------------- -* You will need CMake version 2.8.12 or later from https://cmake.org/download/ +* You will need to have Visual Studio 2015 or later installed. You will need the professional version of Visual Studio C++, or at least Visual Studio Express 2015 or later, as Mathcad Prime libraries are 64-bit and require the 64-bit compiler. The community edition of Visual Studio will also work. -* You will need to install Git-SCM for Windows. You can install this from https://git-for-windows.github.io +* You will need CMake version 2.8.12 or later from https://cmake.org/download/. -* You will need Anaconda/Miniconda Python, which you can get from https://store.continuum.io/cshop/anaconda +* You will need to install Git-SCM for Windows. You can install this from https://git-for-windows.github.io or https://www.git-scm.com. +* You will need Anaconda/Miniconda Python, which you can get from https://store.continuum.io/cshop/anaconda. This is needed because the CMake process runs some python scripts that build the fluids and mixtures libraries. + To Build -======== +-------- * **Recursively clone the CoolProp library to a local repository.**:: @@ -27,31 +56,32 @@ To Build cd CoolProp -* **Go to the top level CoolProp directory and make a build directory** (something like \build15):: +* **In the top level CoolProp directory and make a build directory** (something like \buildprime):: - mkdir build15 - cd build15 + mkdir buildprime + cd buildprime -* **Build the makefile using CMake** (Note: Mathcad 15 is 32-bit):: +* **Build the makefile using CMake (adjust root string for correct version of Prime)**:: - cmake .. -DCOOLPROP_MATHCAD15_MODULE=ON - -DCOOLPROP_MATHCAD15_ROOT="C:/Program Files (x86)/Mathcad/Mathcad 15" - -G "Visual Studio 10 2010" - -DCMAKE_VERBOSE_MAKEFILE=ON + cmake .. -DCOOLPROP_PRIME_MODULE=ON + -DCOOLPROP_PRIME_ROOT="C:/Program Files/PTC/Mathcad Prime x.0.0.0" + -G "Visual Studio 14 2015 Win64" + -DCMAKE_VERBOSE_MAKEFILE=ON + ( Note: Replace 'x.0.0.0' with your latest version. ) + ( Note: Replace 'Visual Studio 14 2015 Win64' with your current Visual Studio version. ) + ( Note: Mathcad Prime is 64-bit, so the 'Win64' option is necessary in the Visual Studio string. ) + * **Make the dynamic library (DLL)**:: - cmake --build . --config Release + cmake --build . --config Release + (*Alternatively, open the VS solution created in the build directory with Visual Studio, set the config to Release and x64, and compile the DLL under the Build menu.*) To Use -====== +------ -* Copy CoolProp\\build15\\Release\\CoolPropMathcadWrapper.dll to C:\\Program Files (x86)\\Mathcad\\Mathcad 15\\userefi - -* Copy CoolProp\\wrapper\\Mathcad\\CoolProp_EN.xml to C:\\Program Files (x86)\\Mathcad\\Mathcad 15\\doc\\funcdoc - -* Open the CoolPropFluidProperties.xmcd file in MathCAD, all CoolProp functions should evaluate properly. If not, press -F9 to force recalculation of the entire workbook. +* Copy CoolProp\\buildprime\\Release\\CoolPropMathcadWrapper.dll file to C:\\Program Files\\PTC\\Mathcad Prime ``x.0.0.0``\\Custom Functions (replace ``x.0.0.0`` with your current version) -* CoolProp functions can be inserted from the Mathcad Insert Functions panel under the function category: CoolProp. Input parameters and a brief description of each function will be shown. +* Open the CoolPropFluidProperties.xmcd file in MathCAD, all CoolProp functions should evaluate properly. If not, press -F9 to force recalculation of the entire workbook. diff --git a/wrappers/Python/CoolProp/AbstractState.pxd b/wrappers/Python/CoolProp/AbstractState.pxd index ecb53156..26c40db6 100644 --- a/wrappers/Python/CoolProp/AbstractState.pxd +++ b/wrappers/Python/CoolProp/AbstractState.pxd @@ -27,22 +27,22 @@ ctypedef fused string_or_size_t: long cdef class PyPhaseEnvelopeData: - cpdef public bool TypeI - cpdef public size_t iTsat_max, ipsat_max, icrit - cpdef public list T, p, lnT, lnp, rhomolar_liq, rhomolar_vap, lnrhomolar_liq, lnrhomolar_vap, hmolar_liq, hmolar_vap, smolar_liq, smolar_vap, Q - cpdef public list x, y, K + cdef public bool TypeI + cdef public size_t iTsat_max, ipsat_max, icrit + cdef public list T, p, lnT, lnp, rhomolar_liq, rhomolar_vap, lnrhomolar_liq, lnrhomolar_vap, hmolar_liq, hmolar_vap, smolar_liq, smolar_vap, Q + cdef public list x, y, K cdef class PyGuessesStructure: - cpdef public double T, p, rhomolar, hmolar, smolar - cpdef public double rhomolar_liq, rhomolar_vap - cpdef public list x, y + cdef public double T, p, rhomolar, hmolar, smolar + cdef public double rhomolar_liq, rhomolar_vap + cdef public list x, y cdef class PyCriticalState: - cpdef public double T, p, rhomolar, hmolar, smolar - cpdef public bool stable + cdef public double T, p, rhomolar, hmolar, smolar + cdef public bool stable cdef class PySpinodalData: - cpdef public vector[double] tau, delta, M1 + cdef public vector[double] tau, delta, M1 cdef class AbstractState: cdef cAbstractState.AbstractState *thisptr # hold a C++ instance which we're wrapping diff --git a/wrappers/Python/CoolProp/CoolProp.pxd b/wrappers/Python/CoolProp/CoolProp.pxd index ff1168be..9230fc4a 100644 --- a/wrappers/Python/CoolProp/CoolProp.pxd +++ b/wrappers/Python/CoolProp/CoolProp.pxd @@ -9,7 +9,7 @@ from .typedefs cimport * include "AbstractState.pxd" cdef class State: - cdef AbstractState pAS + cdef public AbstractState pAS cdef readonly bytes Fluid, phase cdef int iFluid,iParam1,iParam2,iOutput cdef double T_, rho_, p_ diff --git a/wrappers/Python/CoolProp/CoolProp.pyx b/wrappers/Python/CoolProp/CoolProp.pyx index 18086b98..976db340 100644 --- a/wrappers/Python/CoolProp/CoolProp.pyx +++ b/wrappers/Python/CoolProp/CoolProp.pyx @@ -98,6 +98,7 @@ cdef extern from "Backends/Helmholtz/MixtureParameters.h" namespace "CoolProp": void _apply_simple_mixing_rule "CoolProp::apply_simple_mixing_rule"(const string &CAS1, const string &CAS2, const string &rule) except + void _set_departure_functions "CoolProp::set_departure_functions"(const string &functions) except + void _set_interaction_parameters "CoolProp::set_interaction_parameters"(const string &data) except + + void _set_predefined_mixtures "CoolProp::set_predefined_mixtures"(const string &data) except + cdef extern from "Backends/PCSAFT/PCSAFTLibrary.h" namespace "CoolProp": string _get_mixture_binary_pair_pcsaft "CoolProp::get_mixture_binary_pair_pcsaft"(const string CAS1, const string CAS2, const string key) except + @@ -330,7 +331,13 @@ cpdef set_interaction_parameters(data): """ Specify the binary interaction terms as JSON. Python wrapper of C++ function :cpapi:`CoolProp::set_interaction_parameters` """ - _set_interaction_parameters(data) + _set_interaction_parameters(data) + +cpdef set_predefined_mixtures(data): + """ + Specify predefined mixtures as JSON. Python wrapper of C++ function :cpapi:`CoolProp::set_predefined_mixtures` + """ + _set_predefined_mixtures(data) cpdef double saturation_ancillary(string name, string output, int Q, string input, double value): """ @@ -700,21 +707,21 @@ cdef class State: self.set_Fluid(_Fluid, backend) self.Fluid = Fluid - # Parse the inputs provided - if StateDict is not None: - self.update(StateDict) - if phase is None: self.phase = b'??' else: self.phase = phase.encode('ascii') # Set the phase flag - if self.phase.lower() == 'gas': + if self.phase.lower() == b'gas': self.pAS.specify_phase(constants_header.iphase_gas) - elif self.phase.lower() == 'liquid': + elif self.phase.lower() == b'liquid': self.pAS.specify_phase(constants_header.iphase_liquid) + # Parse the inputs provided + if StateDict is not None: + self.update(StateDict) + # def __reduce__(self): # d={} # d['Fluid']=self.Fluid @@ -1118,6 +1125,7 @@ cdef class State: 'MM': 'kg/kmol' } s = 'phase = '+self.phase.decode('ascii')+'\n' + s += 'Fluid = '+self.Fluid.decode('ascii')+'\n' for k in ['T','p','rho','Q','h','u','s','visc','k','cp','cp0','cv','dpdT','Prandtl','superheat','subcooling','MM']: if k in units: s += k + ' = '+str(getattr(self,k))+' '+units[k]+'\n' @@ -1129,8 +1137,9 @@ cdef class State: """ Make a copy of this State class """ - cdef State S = State(self.Fluid,dict(T=self.T_,D=self.rho_)) - S.phase = self.phase + cdef State S = State(self.Fluid, None, phase=self.phase.decode('ascii')) # None is for the state variables, which we leave empty in order to set the phase + # Now we update the state + S.update(dict(T=self.T_,D=self.rho_)) return S def rebuildState(d): diff --git a/wrappers/Python/setup.py b/wrappers/Python/setup.py index e86a5fdb..5c339c09 100644 --- a/wrappers/Python/setup.py +++ b/wrappers/Python/setup.py @@ -21,7 +21,7 @@ def copy_files(): for jsonfile in glob.glob(os.path.join('CoolProp', 'include', '*_JSON.h')): print('removing', jsonfile) os.remove(jsonfile) - copytree(os.path.join(CProot, 'externals/fmtlib/fmt'), os.path.join('CoolProp', 'include', 'fmt')) # Should be deprecated + copytree(os.path.join(CProot, 'externals/fmtlib/include/fmt'), os.path.join('CoolProp', 'include', 'fmt')) # Should be deprecated #copytree(os.path.join(CProot, 'externals/fmtlib/include/fmt'), os.path.join('CoolProp','include','fmt')) copy2(os.path.join(CProot, 'CoolPropBibTeXLibrary.bib'), os.path.join('CoolProp', 'CoolPropBibTeXLibrary.bib')) print('files copied.') @@ -341,6 +341,8 @@ if __name__ == '__main__': def get_shared_ptr_setter(base_class): """ Get the setter class with the appropriate base class + + DEPRECATED!! shared_ptr is no longer found in weird places after standardization """ # See https://stackoverflow.com/a/54518348 @@ -393,13 +395,13 @@ if __name__ == '__main__': from Cython.Build import cythonize from Cython.Distutils import build_ext - setup_kwargs['cmdclass'] = dict(build_ext=get_shared_ptr_setter(build_ext)) + # setup_kwargs['cmdclass'] = dict(build_ext=get_shared_ptr_setter(build_ext)) # This will always generate HTML to show where there are still pythonic bits hiding out Cython.Compiler.Options.annotate = True else: print('Cython will not be used; cy_ext is ' + cy_ext) - setup_kwargs['cmdclass'] = dict(build_ext=get_shared_ptr_setter(build_ext)) + # setup_kwargs['cmdclass'] = dict(build_ext=get_shared_ptr_setter(build_ext)) def find_cpp_sources(root=os.path.join('..', '..', 'src'), extensions=['.cpp'], skip_files=None): file_listing = [] @@ -419,8 +421,8 @@ if __name__ == '__main__': os.path.join(CProot, 'include'), os.path.join(CProot, 'src'), os.path.join(CProot, 'externals', 'Eigen'), - os.path.join(CProot, 'externals', 'fmtlib'), # should be deprecated - #os.path.join(CProot, 'externals', 'fmtlib','include'), + # os.path.join(CProot, 'externals', 'fmtlib'), # should be deprecated + os.path.join(CProot, 'externals', 'fmtlib','include'), os.path.join(CProot, 'externals', 'msgpack-c', 'include')] # If the file is run directly without any parameters, clean, build and install