This commit is contained in:
Ian Bell
2014-09-27 16:08:09 +02:00
17 changed files with 272 additions and 73 deletions

View File

@@ -13,6 +13,7 @@
# serve to show the default.
import sys, os
sys.path.insert(0, os.path.abspath('_ext'))
try:
import sphinxcontrib.doxylink
@@ -20,8 +21,16 @@ except ImportError:
print('Unable to import sphinxcontrib.doxylink; try to run "pip install sphinxcontrib-doxylink"')
import glob
import subprocess
subprocess.call('python make_binary_pairs_table.py', cwd = 'fluid_properties', shell = True)
# This part finds all scripts and runs them
scripts = glob.glob(os.path.join('scripts','*.py'))
for script in scripts:
subprocess.call('python {0}'.format(os.path.basename(script)), cwd='scripts', shell=True)
#~ # If your extensions are in another directory, add it here. If the directory
#~ # is relative to the documentation root, use os.path.abspath to make it

View File

@@ -32,7 +32,7 @@ specific fluid. To get an overview over all the fits, there are also combined
documents with all the
:download:`pure fluids and all the aqueous solutions</_static/fluid_properties/incompressible/report/all_incompressibles.pdf>`.
You can read more about these reports in a dedicated
:ref:`section<FittingReports>` called :ref:`Fitting Reports<FittingReports>` below.
:ref:`section<FittingReports>` called :ref:`Fitting Reports<FittingReports>`.
All incompressible fluids have an arbitrary reference state for enthalpy and entropy.
During initialisation, the reference state is defined as a temperature of 20 °C
@@ -66,7 +66,7 @@ internally, which makes this combination by far the fastest. However, also the
other inputs should be fast compared to the full Helmholtz-based EOS implemented
for then compressible fluids.
A call to the top-level function ``PropsSI`` can provide : temperature, pressure,
A call to the top-level function ``PropsSI`` can provide: temperature, pressure,
density, heat capacity, internal energy, enthalpy, entropy, viscosity and
thermal conductivity. Hence, the available output keys are: ``T``, ``P``, ``D``,
``C``, ``U``, ``H``, ``S``, ``V``, ``L``, ``Tmin`` and ``Tmax``.
@@ -104,7 +104,7 @@ composition notation. Depending on your fluid, you have to supply either the
:ref:`mass fraction<MassMix>` or the :ref:`volume fraction<VoluMix>` as additional
parameter. This is done via the fluid name by appending a dash and the
fraction of the substance other than water. The fraction notation can be in the
form of percent, ``LiBr-23%``, or as a fraction ``LiBr[0.23]``, which
form of percent, ``LiBr-23%``, or as a fraction, ``LiBr[0.23]``, which
corresponds to the new mixture syntax in CoolProp5.
.. In addition to the properties available for the pure fluids (``D``, ``C``,
@@ -146,11 +146,11 @@ A file with all fitting reports for the incompressible fluids can be obtained
from :download:`here</_static/fluid_properties/incompressible/report/all_incompressibles.pdf>`. These reports help you to
get an overview over the different incompressible fluids
included in CoolProp. The reports start with some basic information about
the fluid. There is the name by which it can be accessed through the
interface in the title "Fitting Report for *FluidName*" as well as a description
of what the fluid actually is, this could also be a trade name or a commonly
used non-scientific name. The next item tells you where we got the data from. This
would typically be a data sheet from a manufacturers homepage, some other software
the fluid. The fluid name used in CoolProp is in the title "Fitting Report for *FluidName*"
and there is also a description of what the fluid actually consists of. The latter
could also be a trade name or a commonly used non-scientific name. The next item
tells you where we got the data from. This
would typically be a data sheet from a manufacturer's homepage, some other software
database, a scientific publication or experimental data.
.. figure:: /_static/fluid_properties/incompressible/report/report2up.jpg
@@ -161,7 +161,7 @@ database, a scientific publication or experimental data.
fluid and a binary mixture. You can also have a look at the
:download:`PDF version</_static/fluid_properties/incompressible/report/report2up.pdf>` of the reports side by side.
If all data is available, there is a graphs for each of the basic quantities
If all data are available, there is a graph for each of the basic quantities:
density :math:`\rho`, specific heat capacity :math:`c`, thermal conductivity
:math:`\lambda`, dynamic viscosity :math:`\mu`, saturation pressure
:math:`p_\text{sat}`, and freezing temperature :math:`T_\text{freeze}`. These graphs show
@@ -190,14 +190,14 @@ properties of incompressible fluids in CoolProp:
Only the last two are suitable for mixtures with the input parameter :math:`x`
denoting the fraction of component other than water. Following the works of
Melinder :cite:`Melinder2010` and Skovrup :cite:`Skovrup2013`, the exponents are
Melinder :cite:`Melinder2010` and Skovrup :cite:`Skovrup2013`, the exponents
for the polynomials are arranged in a triangular matrix to avoid overfitting.
These conditions satisfy :math:`0 \leq i \leq n`, :math:`0 \leq j \leq m`
and :math:`i + j \leq \max(n,m)`. It is only for the freezing temperature calculation
that the implemented procedures differ from what is presented in Melinder's
book :cite:`Melinder2010`. Freezing temperature is only a function of concentration
and the dependency on the fluid temperature has been removed. For mixtures, the
default values for :math:`m=5` and :math:`n=3` are chosen.
and the dependency on the fluid temperature has been removed. For mixtures,
:math:`m=5` and :math:`n=3` are assigned as default values.
Omitting the composition term with :math:`n=0` yields the pure fluid formulations
for which we selected :math:`l=1` and :math:`m=4`.
@@ -280,7 +280,7 @@ manufactures, two specific publications provided a lot of data used for the
incompressible fluids: Åke Melinder's book *Properties of Secondary Working
Fluids for Indirect Systems* :cite:`Melinder2010` has inspired both, the work on
pure fluids and aqueous solutions. The second major source of inspiration is the
`SecCool software <http://en.ipu.dk/Indhold/refrigeration-and-energy-technology/seccool.aspx>`_
`SecCool <http://en.ipu.dk/Indhold/refrigeration-and-energy-technology/seccool.aspx>`_
:cite:`Skovrup2013` software, which contains data compiled by Morten Juel
Skovrup. It is provided free of charge by his employer `IPU <http://en.ipu.dk>`_.
@@ -297,7 +297,7 @@ There are also a number of water-based mixtures implemented in CoolProp. Most of
are secondary heat transfer fluids, but there are also aqueous solutions of
ammonia :cite:`Melinder2010`, :download:`MAM<../_static/fluid_properties/incompressible/report/MAM_fitreport.pdf>`,
and lithium bromide :cite:`Patek2006`, :download:`LiBr<../_static/fluid_properties/incompressible/report/LiBr_fitreport.pdf>`,
which can be used to calculated absorption chillers.
which can be used to model absorption chillers.
.. _MassMix:

View File

@@ -20,11 +20,21 @@ The only types of inputs that are allowed for mixtures right now are
- Temperature/quality
- Temperature/pressure
.. Used in Python script later on
.. role:: raw-html(raw)
:format: html
Binary pairs
------------
.. note::
Please hover the mouse pointer over the coefficients to get the full accuracy
for the listed coefficients. You can also get more information on references
that are not in bibliography.
.. csv-table:: All binary pairs included in CoolProp
:header-rows: 1
:file: mixture_binary_pairs.csv
:file: mixture_binary_pairs.csv
Phase Envelope
--------------
@@ -46,7 +56,7 @@ Phase Envelope
plt.xlabel('Temperature [K]')
plt.ylabel('Pressure [Pa]')
plt.tight_layout()
References
----------

View File

@@ -1,32 +0,0 @@
import CoolProp
class Dossier:
def __init__(self):
self.data = {}
def add(self, key, value):
if key not in self.data:
self.data[key] = []
self.data[key].append(value)
d = Dossier()
pairs = CoolProp.get('mixture_binary_pairs_list')
for pair in pairs.split(','):
CAS1, CAS2 = pair.split('&')
d.add('CAS1', CAS1)
d.add('CAS2', CAS2)
for key in ['name1','name2','F','function','BibTeX','xi','zeta','betaT','betaV','gammaT','gammaV']:
try:
d.add(key, CoolProp.CoolProp.get_mixture_binary_pair_data(CAS1, CAS2, key))
except BaseException as BE:
d.add(key, '')
import pandas
df = pandas.DataFrame(d.data)
df = df.sort(['BibTeX','name1'], ascending = [0, 1])
with open('mixture_binary_pairs.csv','w') as fp:
fp.write('Ref.,Name1,Name2,function,F,xi,zeta,betaT,betaV,gammaT,gammaV\n')
for index, row in df.iterrows():
text = ','.join([':cite:`'+row['BibTeX']+'`', row['name1'], row['name2'], row['function'], row['F'], row['xi'], row['zeta'], row['betaT'], row['betaV'], row['gammaT'], row['gammaV']])+'\n'
fp.write(text)

View File

@@ -0,0 +1,54 @@
'''
Created on 26 Sep 2014
@author: jowr
'''
import os
from CoolProp.BibtexParser import BibTeXerClass
def getPath(filename, search=True):
# Path to root
coolprop_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),'..','..'))
# Test for file
fname = filename
if os.path.exists(fname): return os.path.abspath(fname)
# Test relative to this file
fname = os.path.join(os.path.dirname(__file__),filename)
if os.path.exists(fname): return os.path.abspath(fname)
# Test relative to root notation
fname = os.path.join(coolprop_dir,filename)
if os.path.exists(fname): return os.path.abspath(fname)
# Search in root tree
fname = os.path.basename(filename)
if search:
result = []
for root, dirs, files in os.walk(coolprop_dir):
if fname in files:
result.append(os.path.join(root, fname))
if len(result)==1:
return os.path.abspath(result[0])
elif len(result)>1:
print "Found multiple files with the name {0}. Try to specify the path as well.".format(fname)
print result
return os.path.abspath(result[0])
raise ValueError("Found no file with the name {0}. Try to specify the path as well.".format(fname))
def getBibtexParser(filename = '../../../CoolPropBibTeXLibrary.bib'):
"""Create a parser object that can be used to extract entries from a
library in Bibtex format."""
fpath = getPath(filename)
bibtexer = BibTeXerClass(fpath)
return bibtexer
def getCitationOrAlternative(bibtexer, bibtex_key):
"""Find the key in the library and convert to a citation, if it is not found,
we return a footnote string for sphinx."""
bibtex_key = bibtex_key.strip()
if bibtex_key in bibtexer.library.entries:
return u':cite:`{0}`'.format(bibtex_key)
else:
return u':raw-html:`<span title="{0}">Source</span>`'.format(bibtex_key)

View File

@@ -0,0 +1,69 @@
'''
Created on 26 Sep 2014
@author: jowr
'''
import codecs
import csv
import cStringIO
class UTF8Recoder:
"""
Iterator that reads an encoded stream and reencodes the input to UTF-8
"""
def __init__(self, f, encoding):
self.reader = codecs.getreader(encoding)(f)
def __iter__(self):
return self
def next(self):
return self.reader.next().encode("utf-8")
class UnicodeReader:
"""
A CSV reader which will iterate over lines in the CSV file "f",
which is encoded in the given encoding.
"""
def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds):
f = UTF8Recoder(f, encoding)
self.reader = csv.reader(f, dialect=dialect, **kwds)
def next(self):
row = self.reader.next()
return [unicode(s, "utf-8") for s in row]
def __iter__(self):
return self
class UnicodeWriter:
"""
A CSV writer which will write rows to CSV file "f",
which is encoded in the given encoding.
"""
def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds):
# Redirect output to a queue
self.queue = cStringIO.StringIO()
self.writer = csv.writer(self.queue, dialect=dialect, **kwds)
self.stream = f
self.encoder = codecs.getincrementalencoder(encoding)()
def writerow(self, row):
self.writer.writerow([s.encode("utf-8") for s in row])
# Fetch UTF-8 output from the queue ...
data = self.queue.getvalue()
data = data.decode("utf-8")
# ... and reencode it into the target encoding
data = self.encoder.encode(data)
# write to the target stream
self.stream.write(data)
# empty queue
self.queue.truncate(0)
def writerows(self, rows):
for row in rows:
self.writerow(row)

View File

@@ -0,0 +1,21 @@
"""
CPWeb - A collection of commonly used routines to produce CoolProp's online documentation
=====
"""
from __future__ import division, absolute_import, print_function
import codecs
import csv
import cStringIO
def get_version():
return 5.0
if __name__ == "__main__":
print('You are using version %s of the Python package for creating CoolProp\' online documentation.'%(get_version()))
print()

View File

@@ -0,0 +1,68 @@
from CPWeb.BibtexTools import getCitationOrAlternative, getBibtexParser
import CoolProp
import os.path
web_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),'..'))
csvfile = os.path.join(web_dir,'fluid_properties','mixture_binary_pairs.csv')
def merge_args(*args):
return " :raw-html:`<br/>` ".join(list(args))
def printCoeff(number):
if number is None or \
len(str(number).strip())<1:
return " "
number = float(number)
short = "{0:.4e}".format(number)
long = "{0:.14e}".format(number)
return u':raw-html:`<span title="{1}">{0}</span>`'.format(short,long)
class Dossier:
def __init__(self):
self.data = {}
def add(self, key, value):
if key not in self.data:
self.data[key] = []
self.data[key].append(value)
d = Dossier()
pairs = CoolProp.get('mixture_binary_pairs_list')
for pair in pairs.split(','):
CAS1, CAS2 = pair.split('&')
d.add('CAS1', CAS1)
d.add('CAS2', CAS2)
for key in ['name1','name2','F','function','BibTeX','xi','zeta','betaT','betaV','gammaT','gammaV']:
try:
d.add(key, CoolProp.CoolProp.get_mixture_binary_pair_data(CAS1, CAS2, key))
except BaseException as BE:
d.add(key, '')
import pandas
df = pandas.DataFrame(d.data)
df = df.sort(['BibTeX','name1'], ascending = [0, 1])
bibtexer = getBibtexParser()#filename = '../../../CoolPropBibTeXLibrary.bib')
with open(csvfile,'w') as fp:
header = 'Ref.,Name1,Name2,function,F,'
header += merge_args("xi","zeta,")
header += merge_args("betaT","betaV,")
header += merge_args("gammaT","gammaV")
header += '\n'
fp.write(header)
for index, row in df.iterrows():
text = ','.join([ \
getCitationOrAlternative(bibtexer,row['BibTeX']),
row['name1'],
row['name2'],
row['function'],
row['F'],
merge_args(printCoeff(row['xi']),printCoeff(row['zeta'])),
merge_args(printCoeff(row['betaT']),printCoeff(row['betaV'])),
merge_args(printCoeff(row['gammaT']),printCoeff(row['gammaV']))
])+'\n'
fp.write(text)

View File

@@ -30,7 +30,7 @@ class DEBLiquidClass(CoefficientData,PureData):
_,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([3.5503,-0.0566396,7.03331e-05]))
self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0.000189132,-2.06364e-07]))
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0000.189132,-2.06364e-04]))
self.density.source = self.density.SOURCE_COEFFS
self.specific_heat.source = self.specific_heat.SOURCE_COEFFS
@@ -64,7 +64,7 @@ class HCMLiquidClass(CoefficientData,PureData):
_,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([18.3237,-0.14706,0.000209096]))
self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0.000153716,-1.51212e-07]))
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0000.153716,-1.51212e-04]))
self.density.source = self.density.SOURCE_COEFFS
self.specific_heat.source = self.specific_heat.SOURCE_COEFFS
@@ -98,7 +98,7 @@ class HFELiquidClass(CoefficientData,PureData):
_,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([-4.22878,-0.0114765,7.39823e-06]))
self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([9.92958e-05,-8.33333e-08]))
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([9.92958e-01,-8.33333e-05]))
self.density.source = self.density.SOURCE_COEFFS
self.specific_heat.source = self.specific_heat.SOURCE_COEFFS
@@ -132,7 +132,7 @@ class PMS1LiquidClass(CoefficientData,PureData):
_,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([6.36183,-0.0636352,7.51428e-05]))
self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0.000207526,-2.84167e-07]))
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0000.207526,-2.84167e-04]))
self.density.source = self.density.SOURCE_COEFFS
self.specific_heat.source = self.specific_heat.SOURCE_COEFFS
@@ -166,7 +166,7 @@ class PMS2LiquidClass(CoefficientData,PureData):
_,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([5.66926,-0.065582,8.09988e-05]))
self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0.000172305,-2.11212e-07]))
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0000.172305,-2.11212e-04]))
self.density.source = self.density.SOURCE_COEFFS
self.specific_heat.source = self.specific_heat.SOURCE_COEFFS
@@ -200,7 +200,7 @@ class SABLiquidClass(CoefficientData,PureData):
_,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([5.21288,-0.0665792,8.5066e-05]))
self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0.000208374,-2.61667e-07]))
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0000.208374,-2.61667e-04]))
self.density.source = self.density.SOURCE_COEFFS
self.specific_heat.source = self.specific_heat.SOURCE_COEFFS
@@ -234,7 +234,7 @@ class HCBLiquidClass(CoefficientData,PureData):
_,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([7.16819,-0.0863212,0.000130604]))
self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0.000203186,-2.3869e-07]))
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0000.203186,-2.3869e-04]))
self.density.source = self.density.SOURCE_COEFFS
self.specific_heat.source = self.specific_heat.SOURCE_COEFFS
@@ -268,7 +268,7 @@ class TCOLiquidClass(CoefficientData,PureData):
_,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([-3.47971,-0.0107031,1.14086e-06]))
self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0.000174156,-1.85052e-07]))
_,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0000.174156,-1.85052e-04]))
self.density.source = self.density.SOURCE_COEFFS
self.specific_heat.source = self.specific_heat.SOURCE_COEFFS

View File

@@ -10,10 +10,10 @@
"conductivity": {
"coeffs": [
[
1.891320e-04
1.891320e-01
],
[
-2.063640e-07
-2.063640e-04
]
],
"type": "polynomial"

View File

@@ -10,10 +10,10 @@
"conductivity": {
"coeffs": [
[
2.031860e-04
2.031860e-01
],
[
-2.386900e-07
-2.386900e-04
]
],
"type": "polynomial"

View File

@@ -10,10 +10,10 @@
"conductivity": {
"coeffs": [
[
1.537160e-04
1.537160e-01
],
[
-1.512120e-07
-1.512120e-04
]
],
"type": "polynomial"

View File

@@ -10,10 +10,10 @@
"conductivity": {
"coeffs": [
[
9.929580e-05
9.929580e-01
],
[
-8.333330e-08
-8.333330e-05
]
],
"type": "polynomial"

View File

@@ -10,10 +10,10 @@
"conductivity": {
"coeffs": [
[
2.075260e-04
2.075260e-01
],
[
-2.841670e-07
-2.841670e-04
]
],
"type": "polynomial"

View File

@@ -10,10 +10,10 @@
"conductivity": {
"coeffs": [
[
1.723050e-04
1.723050e-01
],
[
-2.112120e-07
-2.112120e-04
]
],
"type": "polynomial"

View File

@@ -10,10 +10,10 @@
"conductivity": {
"coeffs": [
[
2.083740e-04
2.083740e-01
],
[
-2.616670e-07
-2.616670e-04
]
],
"type": "polynomial"

View File

@@ -10,10 +10,10 @@
"conductivity": {
"coeffs": [
[
1.741560e-04
1.741560e-01
],
[
-1.850520e-07
-1.850520e-04
]
],
"type": "polynomial"