REFPROP 10.0 conversion

As of teqp version 0.19.0, it is possible to read in the .FLD and HMX.BNC of NIST REFPROP 10.0 and load them into teqp multifluid models. There are two approaches; either you can pass paths to the files of interest, or you can load them into JSON once, and pass the converted JSON back into teqp’s make_model function.

The conversion code is uses that of REFPROP-interop and the fluid file format of CoolProp is used.

The example is based on the interaction parameters provided in the supporting information of the paper Mixture Model for Refrigerant Pairs R-32/1234yf, R-32/1234ze(E), R-1234ze(E)/227ea, R-1234yf/152a, and R-125/1234yf by Ian Bell

[1]:
import json
import teqp
teqp.__version__
[1]:
'0.22.0'
[2]:
# The first approach, we just pass paths to the files, they live in the folder
# containing this notebook, and teqp does the conversion on the fly
jsimple = {
    'kind': 'multifluid',
    'model': {
        'HMX.BNC': 'HMX.BNC',
        'components': ['R152A.FLD', 'NEWR1234YF.FLD'],
    }
}
model = teqp.make_model(jsimple)
[3]:
%timeit teqp.make_model(jsimple)
49.8 ms ± 161 μs per loop (mean ± std. dev. of 7 runs, 10 loops each)
[4]:
# Convert each of the FLD files to JSON
FLD0 = teqp.convert_FLD('R152A.FLD', name='R152A')
FLD1 = teqp.convert_FLD('NEWR1234YF.FLD', name='R1234YF')
BIP, DEP = teqp.convert_HMXBNC('HMX.BNC')
[5]:
jconverted = {
    "kind": "multifluid",
    "model": {
        "components": [FLD0, FLD1],
        "BIP": BIP,
        "departure": DEP
    }
}
model = teqp.make_model(jconverted)
[6]:
%timeit teqp.make_model(jconverted)
622 μs ± 11.7 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)

From this example you can note that the first method is a lot slower because the FLD->JSON conversion needs to happen for each call, while in the second method it is much faster because only the JSON parsing needs to be done in teqp.

[7]:
# It is also possible to prefix the path to indicate that the
# indicated file (after the FLD::) should be converted from REFPROP format
jconverted = {
    "kind": "multifluid",
    "model": {
        "components": ["FLDPATH::R152A.FLD", 'FLDPATH::NEWR1234YF.FLD'],
        "BIP": BIP,
        "departure": DEP
    }
}
model = teqp.make_model(jconverted)
[8]:
%timeit teqp.make_model(jconverted)
45.2 ms ± 815 μs per loop (mean ± std. dev. of 7 runs, 10 loops each)