Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi numpy scipy test #157

Merged
merged 44 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
33c5f79
Typing cleanup
CalebBell Sep 2, 2024
ee9ac0a
.
CalebBell Sep 6, 2024
3f658de
Code cleanup
CalebBell Sep 7, 2024
470b486
work on typing correctness
CalebBell Sep 15, 2024
6e0f06d
Code cleanup
CalebBell Sep 18, 2024
e5a66fc
.
CalebBell Sep 18, 2024
a3e0d2b
Code cleanup
CalebBell Sep 19, 2024
3a2c1cd
Misc code cleanup
CalebBell Sep 21, 2024
f1a888b
Code cleanup
CalebBell Sep 22, 2024
0517ae0
.
CalebBell Sep 22, 2024
5b87532
cleanup
CalebBell Sep 22, 2024
0947fc1
Cleanup
CalebBell Sep 22, 2024
d9be39c
cleanup
CalebBell Sep 22, 2024
e256e07
Test and code quality cleanup
CalebBell Sep 26, 2024
f7a7c16
Work on code cleanup and typing prep
CalebBell Sep 27, 2024
1c7ee54
Numerical gammas call on base
CalebBell Sep 28, 2024
c5c229c
Test
CalebBell Sep 28, 2024
312a5a8
.
CalebBell Sep 29, 2024
5dfc0d8
Code cleanup
CalebBell Oct 1, 2024
ac259b8
Find root cause of numerical bug and fix it
CalebBell Oct 3, 2024
03bc44c
Misc changes
CalebBell Oct 5, 2024
1b7a8b0
Update
CalebBell Oct 8, 2024
e9daca2
Ability to force a constant alpha value when fitting nrtl activity co…
CalebBell Oct 14, 2024
506b99e
Ability to force a constant alpha value when fitting nrtl activity co…
CalebBell Oct 14, 2024
90386fc
Ability to force a constant alpha value when fitting nrtl activity co…
CalebBell Oct 14, 2024
00341bb
Fix for threaded access to sqlite
CalebBell Oct 16, 2024
6570733
Alcock coefficient update & rerun notebooks
CalebBell Oct 18, 2024
a3bceba
Merge branch 'master' into multi_numpy_scipy_test
CalebBell Oct 18, 2024
0a2d55f
Firist script
CalebBell Oct 19, 2024
30a5fdd
Progress
CalebBell Oct 19, 2024
7f8f00b
First pass Bondi method
CalebBell Oct 20, 2024
823e462
typo
CalebBell Oct 21, 2024
30f720a
Add some new test cases
CalebBell Oct 23, 2024
efa00ca
Cleanup
CalebBell Oct 23, 2024
483d8d2
Add FloryHuggins model
CalebBell Oct 25, 2024
69e701f
Cleanup
CalebBell Nov 2, 2024
2dad2e0
Cleanup
CalebBell Nov 4, 2024
bf7b6bf
Add hansen activity coefficient model
CalebBell Nov 6, 2024
ea82d40
Code cleanup
CalebBell Nov 7, 2024
3faf8dd
Remove one use of scipy's deprecated interp1d
CalebBell Nov 7, 2024
28e1bf6
Code cleanup - note commonality
CalebBell Nov 7, 2024
d5712e5
Clean up some constant names
CalebBell Nov 7, 2024
c2e9d3c
0.4.0
CalebBell Nov 10, 2024
5fc3a75
Test fix
CalebBell Nov 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@

### Fixed


## [0.4.0] - 2024-11-10

### Changed
- Fluids version dependency now >= 1.0.27
- Chemicals version dependency now >= 1.3.0
- General code cleanup and further documentation
- Add Flory Huggins and Hansen activity coefficient models
- Further progress on removing legacy scipy interp1d method
- Clean up in code of vapor pressure extrapolation

## [0.3.0] - 2024-07-26

### Changed
Expand Down
425 changes: 425 additions & 0 deletions dev/activity_fitting/util.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
{
"data": {
"text/plain": [
"265.50610736019723"
"265.400194181466"
]
},
"execution_count": 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The actual power is 2252 W\n",
"The actual outlet temperature is 406.60 K\n"
"The actual power is 2251 W\n",
"The actual outlet temperature is 405.98 K\n"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
{
"data": {
"text/plain": [
"405.15046929861046"
"405.05615108404197"
]
},
"execution_count": 4,
Expand Down Expand Up @@ -138,7 +138,7 @@
{
"data": {
"text/plain": [
"132.00046929861048"
"131.906151084042"
]
},
"execution_count": 5,
Expand All @@ -159,7 +159,7 @@
{
"data": {
"text/plain": [
"['VDI_PPDS', 'DIPPR_PERRY_8E']"
"['HEOS_FIT', 'DIPPR_PERRY_8E']"
]
},
"execution_count": 6,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The Joule Thomson coefficient of nitrogen for the virial prediction is 9.48161e-06 K/Pa\n"
"The Joule Thomson coefficient of nitrogen for the virial prediction is 9.46155e-06 K/Pa\n"
]
}
],
Expand All @@ -80,7 +80,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The Joule Thomson coefficient of nitrogen for the SRK prediction is 2.13403e-06 K/Pa\n"
"The Joule Thomson coefficient of nitrogen for the SRK prediction is 2.13967e-06 K/Pa\n"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
"output_type": "stream",
"text": [
"With the ideal-gas EOS:\n",
"The actual power is 7991.2798 J/mol\n",
"The actual outlet temperature is 560.70 K\n"
"The actual power is 7991.3774 J/mol\n",
"The actual outlet temperature is 560.72 K\n"
]
}
],
Expand Down Expand Up @@ -90,8 +90,8 @@
"output_type": "stream",
"text": [
"With the SRK EOS:\n",
"The actual power is 8000.1749 J/mol\n",
"The actual outlet temperature is 561.06 K\n"
"The actual power is 8000.3185 J/mol\n",
"The actual outlet temperature is 561.08 K\n"
]
}
],
Expand Down Expand Up @@ -133,8 +133,8 @@
"text": [
"Using the ideal isentropic exponent 1.395\n",
"Using the ideal compressibility 1.000\n",
"The simple power is 8047.9387 J/mol\n",
"The simple outlet temperature is 572.15 K\n"
"The simple power is 8047.5136 J/mol\n",
"The simple outlet temperature is 572.10 K\n"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The outlet temperature is 150.2259 °C\n"
"The outlet temperature is 150.0933 °C\n"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,17 @@
"output_type": "stream",
"text": [
"The High-Precision EOS predicted liquid molar fraction is 0.03887228.\n",
"The PR-Pina-Martinez EOS predicted liquid molar fraction is 0.05536129.\n",
"The SRK-Pina-Martinez EOS predicted liquid molar fraction is 0.06765522.\n",
"The PR EOS predicted liquid molar fraction is 0.05963486.\n",
"The SRK EOS predicted liquid molar fraction is 0.04341557.\n",
"The PR-Pina-Martinez EOS predicted liquid molar fraction is 0.05514570.\n",
"The SRK-Pina-Martinez EOS predicted liquid molar fraction is 0.06744189.\n",
"The PR EOS predicted liquid molar fraction is 0.05852484.\n",
"The SRK EOS predicted liquid molar fraction is 0.04234207.\n",
"The VDW EOS predicted liquid molar fraction is 0.00000000.\n",
"The PRSV EOS predicted liquid molar fraction is 0.06011654.\n",
"The PRSV2 EOS predicted liquid molar fraction is 0.06011654.\n",
"The TWUPR EOS predicted liquid molar fraction is 0.05491152.\n",
"The TWUSRK EOS predicted liquid molar fraction is 0.04670591.\n",
"The PRTranslatedConsistent EOS predicted liquid molar fraction is 0.05860220.\n",
"The SRKTranslatedConsistent EOS predicted liquid molar fraction is 0.07069564.\n"
"The PRSV EOS predicted liquid molar fraction is 0.05903916.\n",
"The PRSV2 EOS predicted liquid molar fraction is 0.05903916.\n",
"The TWUPR EOS predicted liquid molar fraction is 0.05437623.\n",
"The TWUSRK EOS predicted liquid molar fraction is 0.04623410.\n",
"The PRTranslatedConsistent EOS predicted liquid molar fraction is 0.05738467.\n",
"The SRKTranslatedConsistent EOS predicted liquid molar fraction is 0.06963456.\n"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The shaft power with Peng-Robinson is 2632.7895 W\n",
"The shaft power with ideal-gas is 2639.9248 W\n"
"The shaft power with Peng-Robinson is 2632.7613 W\n",
"The shaft power with ideal-gas is 2639.8834 W\n"
]
}
],
Expand Down Expand Up @@ -138,8 +138,8 @@
"text": [
"The shaft power with ideal-gas is 2155.9263 W\n",
"The cooling duty with ideal-gas is 2155.9263 W\n",
"The shaft power with Peng-Robinson is 2139.44610002 W\n",
"The cooling duty with Peng-Robinson is 2192.57596810 W\n"
"The shaft power with Peng-Robinson is 2139.46883776 W\n",
"The cooling duty with Peng-Robinson is 2192.53835781 W\n"
]
}
],
Expand Down Expand Up @@ -184,8 +184,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The shaft power is 2322.61227046 W\n",
"The cooling duty is 2375.74213854 W\n"
"The shaft power is 2322.58403773 W\n",
"The cooling duty is 2375.65355778 W\n"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
{
"data": {
"text/plain": [
"(-17242.594866461008, 13841.52397663936, 3401.0708898216462)"
"(-17303.632306857875, 13889.615500762327, 3414.0168060955466)"
]
},
"execution_count": 1,
Expand Down Expand Up @@ -117,10 +117,10 @@
"name": "stdout",
"output_type": "stream",
"text": [
"T=303.15 K, P=746445.43 Pa, VF=0.00, S=-72.22 J/(mol*K), H=-17223.28 J/(mol)\n",
"T=253.15 K, P=152387.52 Pa, VF=0.29, S=-70.06 J/(mol*K), H=-17223.28 J/(mol)\n",
"T=253.15 K, P=152387.52 Pa, VF=1.00, S=-15.38 J/(mol*K), H=-3381.75 J/(mol)\n",
"T=312.16 K, P=746445.43 Pa, VF=1.00, S=-15.38 J/(mol*K), H=19.32 J/(mol)\n"
"T=303.15 K, P=742091.64 Pa, VF=0.00, S=-72.41 J/(mol*K), H=-17294.43 J/(mol)\n",
"T=253.15 K, P=150606.23 Pa, VF=0.29, S=-70.23 J/(mol*K), H=-17294.43 J/(mol)\n",
"T=253.15 K, P=150606.23 Pa, VF=1.00, S=-15.37 J/(mol*K), H=-3404.81 J/(mol)\n",
"T=311.88 K, P=742091.64 Pa, VF=1.00, S=-15.37 J/(mol*K), H=9.20 J/(mol)\n"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The JT coefficient at the specified conditions is 4.652e-06 K/Pa\n"
"The JT coefficient at the specified conditions is 4.644e-06 K/Pa\n"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The actual power is 3148 W/mol\n",
"The actual outlet temperature is 448.20 K\n"
"The actual power is 3149 W/mol\n",
"The actual outlet temperature is 448.32 K\n"
]
}
],
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
{
"data": {
"text/plain": [
"(3, 0.9827041561275567, [0.016838840039984482, 0.00045700383245886604])"
"(3, 0.9827001174339967, [0.01684199696498201, 0.00045788560102136424])"
]
},
"execution_count": 6,
Expand All @@ -366,11 +366,11 @@
{
"data": {
"text/plain": [
"(-1961.5089633224945,\n",
" 1989.3915447041693,\n",
"(-1963.2053449055254,\n",
" 1992.5735327290117,\n",
" 19.675910651652533,\n",
" 1.0015480015807005e-05,\n",
" 0.027074133060773903)"
" 9.897721970311116e-06,\n",
" 0.027086333772793986)"
]
},
"execution_count": 7,
Expand All @@ -391,7 +391,7 @@
{
"data": {
"text/plain": [
"(769.2525386053419, 599.2086838769081)"
"(769.8630408908615, 599.1883986490054)"
]
},
"execution_count": 8,
Expand Down
4 changes: 2 additions & 2 deletions docs/Examples/Validating Flash Calculations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"output_type": "stream",
"text": [
"There are 2 phases present\n",
"Mass densities of each liquid are 527.867861 and 527.867861 kg/m^3\n"
"Mass densities of each liquid are 530.582725 and 530.582725 kg/m^3\n"
]
}
],
Expand Down Expand Up @@ -99,7 +99,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The maximum relative difference in fugacity is 2.773985e-07.\n"
"The maximum relative difference in fugacity is 2.790164e-07.\n"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/home/caleb/.local/lib/python3.11/site-packages/scipy/optimize/_minpack_py.py:492: RuntimeWarning: Number of calls to function has reached maxfev = 500.\n",
" warnings.warn(errors[info][0], RuntimeWarning)\n"
"/home/caleb/.local/lib/python3.11/site-packages/fluids/numerics/__init__.py:4201: RuntimeWarning: Number of calls to function has reached maxfev = 500.\n",
" return sp_leastsq(*args, **kwargs)\n"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/activity_coefficients.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Initializing the object for the first time is a not a high performance operation
Note also that the :obj:`__repr__ <thermo.activity.GibbsExcess.__repr__>` string for each model is designed to allow lossless reconstruction of the model. This is very useful when building test cases.

>>> GE.to_T_xs(T=400.0, xs=[.1, .9])
UNIFAC(T=400.0, xs=[0.1, 0.9], rs=[4.4998000000000005, 3.2479], qs=[3.856, 2.876], Qs=[0.848, 0.54, 1.488], vs=[[2, 1], [4, 1], [0, 1]], psi_abc=([[0.0, 0.0, 476.4], [0.0, 0.0, 476.4], [26.76, 26.76, 0.0]], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]), version=0)
UNIFAC(T=400.0, xs=[0.1, 0.9], rs=[4.4998000000000005, 3.2479], qs=[3.856, 2.876], Qs=[0.848, 0.54, 1.488], vs=[[2.0, 1.0], [4.0, 1.0], [0.0, 1.0]], psi_a=[[0.0, 0.0, 476.4], [0.0, 0.0, 476.4], [26.76, 26.76, 0.0]], psi_b=[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], psi_c=[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], version=0)

When working with small numbers of components (5 or under), PyPy offers the best performance and using the model with Python lists as inputs is the fastest way to perform the calculations even in CPython.

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
intersphinx_mapping = {'python': ('https://docs.python.org/3', None),
'numpy': ('http://docs.scipy.org/doc/numpy', None),
'scipy': ('http://docs.scipy.org/doc/scipy/reference', None),
'matplotlib': ('http://matplotlib.sourceforge.net', None),
'matplotlib': ('http://matplotlib.org/stable/', None),
'chemicals': ('https://chemicals.readthedocs.io/', None),
'fluids': ('https://fluids.readthedocs.io/', None)}

Expand Down
8 changes: 4 additions & 4 deletions docs/property_objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ When extrapolation is turned on, it is used automatically if a property is reque
>>> ethanol_psat(100.0), ethanol_psat(1000)
(1.047582e-11, 1779196575.4962692)

The default extrapolation methods may be changed in the future, but can be manually specified also by changing the value of the :obj:`extrapolation <thermo.utils.TDependentProperty.extrapolation>` attribute. For example, if the `linear` extrapolation method is set, extrapolation will be linear instead of using those fit equations. Because not all properties are suitable for linear extrapolation, some methods have a default `transform` to make the property behave as linearly as possible. This is also used in tabular interpolation:
The default extrapolation methods may be changed in the future, but can be manually specified also by changing the value of the :obj:`extrapolation <thermo.utils.TDependentProperty.extrapolation>` attribute. For example, if the `Arrhenius` extrapolation method is set, extrapolation will be Arrhenius instead of using those fit equations.

>>> ethanol_psat.extrapolation = 'linear'
>>> ethanol_psat.extrapolation = 'Arrhenius'
>>> ethanol_psat(100.0), ethanol_psat(1000)
(1.0475e-11, 385182009.4)
(1.04758e-11, 385272476.5)

The low-temperature linearly extrapolated value is actually the same as before, because it performs a 1/T transform and a log(P) transform on the output, which results in the fit being the same as the default equation for vapor pressure.

Expand Down Expand Up @@ -473,7 +473,7 @@ The same temperature limits and low-pressure extrapolation methods are available
>>> water_mu.valid_methods(T=480) # doctest: +SKIP
['DIPPR_PERRY_8E', 'COOLPROP', 'VDI_PPDS', 'LETSOU_STIEL']
>>> water_mu.extrapolation
'linear'
'Arrhenius'

To better understand what methods are available, the :obj:`valid_methods_P <thermo.utils.TDependentProperty.valid_methods_P>` method checks all available high-pressure correlations against their temperature and pressure limits.

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ numpy
scipy>=1.6.0
pandas
coolprop
fluids>=1.0.26
chemicals>=1.2.0
fluids>=1.0.27
chemicals>=1.3.0
2 changes: 1 addition & 1 deletion requirements_docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ scipy
numpydoc
pint
nbsphinx
fluids>=1.0.26
fluids>=1.0.27
chemicals>=1.2.0
IPython
ipython
Expand Down
4 changes: 2 additions & 2 deletions requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ numpy
scipy
pandas
sympy
fluids>=1.0.26
chemicals>=1.2.0
fluids>=1.0.27
chemicals>=1.3.0
pytest
pytest-cov
coveralls
Expand Down
4 changes: 2 additions & 2 deletions requirements_test_multiarch.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sympy
fluids>=1.0.26
chemicals>=1.2.0
fluids>=1.0.27
chemicals>=1.3.0
pytest
pint
IPython
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
version = '0.3.0',
description = 'Chemical properties component of Chemical Engineering Design Library (ChEDL)',
author = 'Caleb Bell',
install_requires=['fluids>=1.0.26', "scipy>=1.6.0", 'pandas', 'chemicals>=1.2.0'],
install_requires=['fluids>=1.0.27', "scipy>=1.6.0", 'pandas', 'chemicals>=1.3.0'],
extras_require = {
'Coverage documentation': ['wsgiref>=0.1.2', 'coverage>=4.0.3']
},
Expand Down
2 changes: 1 addition & 1 deletion tests/test_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_IdealSolution():


assert_close(GE.gammas(), [1]*4, atol=0)
assert_close(GE._gammas_dGE_dxs(), [1]*4, atol=0)
assert_close(GE.gammas_dGE_dxs(), [1]*4, atol=0)
assert_close(GE.gammas_infinite_dilution(), [1]*4, atol=0)


Expand Down
Loading
Loading