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