diff --git a/conftest.py b/conftest.py index 5ed0b9a..87dade1 100644 --- a/conftest.py +++ b/conftest.py @@ -1,5 +1,6 @@ -import sys import platform +import sys + is_pypy = 'PyPy' in sys.version def pytest_ignore_collect(path): diff --git a/dev/prerelease.py b/dev/prerelease.py index 282d65a..612cf9c 100644 --- a/dev/prerelease.py +++ b/dev/prerelease.py @@ -1,7 +1,6 @@ -import sys import os import shutil -import importlib.util +import sys if sys.version_info.major != 3 and sys.version_info.minor != 11: raise ValueError("""This prerelease script will only run on Python 3.11. @@ -11,12 +10,15 @@ the notebooks and doctests only run on one paltform.""") +import os +import sys from datetime import datetime -import os, sys + + def set_file_modification_time(filename, mtime): atime = os.stat(filename).st_atime os.utime(filename, times=(atime, mtime.timestamp())) - + now = datetime.now() main_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) @@ -41,7 +43,6 @@ def set_file_modification_time(filename, mtime): os.remove(full_path) -import ht main_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) test_dir = os.path.join(main_dir, 'tests') os.chdir(test_dir) @@ -51,5 +52,6 @@ def set_file_modification_time(filename, mtime): #mod_spec.loader.exec_module(make_test_stubs) import pytest + os.chdir(main_dir) pytest.main(["--doctest-glob='*.rst'", "--doctest-modules", "--nbval", "-n", "8", "--dist", "loadscope", "-v"]) diff --git a/docs/conf.py b/docs/conf.py index 7bcc641..8749ecb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Heat Transfer documentation build configuration file, created by # sphinx-quickstart on Sat Jan 2 17:15:23 2016. @@ -59,12 +58,12 @@ 'sphinxcontrib.katex', 'sphinx_sitemap', ] -# +# katex_css_path = \ 'https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css' katex_js_path = 'katex.min.js' -katex_autorender_path = 'auto-render.min.js' +katex_autorender_path = 'auto-render.min.js' html_baseurl = 'https://ht.readthedocs.io/' @@ -86,14 +85,14 @@ master_doc = 'index' # General information about the project. -project = u'Heat Transfer' +project = 'Heat Transfer' import datetime build_date = datetime.datetime.utcfromtimestamp( int(os.environ.get('SOURCE_DATE_EPOCH', time.time())) ) -copyright = u'2016 - %s, Caleb Bell and contributors' %build_date.year +copyright = '2016 - %s, Caleb Bell and contributors' %build_date.year # The version info for the project you're documenting, acts as replacement for @@ -102,6 +101,7 @@ # # The short X.Y version. import ht + version = ht.__version__ # The full version, including alpha/beta/rc tags. release = ht.__version__ @@ -247,8 +247,8 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'Heat Transfer.tex', u'Heat Transfer Documentation', - u'Caleb Bell', 'manual'), + ('index', 'Heat Transfer.tex', 'Heat Transfer Documentation', + 'Caleb Bell', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -277,8 +277,8 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'ht', u'Heat Transfer Documentation', - [u'Caleb Bell'], 1) + ('index', 'ht', 'Heat Transfer Documentation', + ['Caleb Bell'], 1) ] # If true, show URL addresses after external links. @@ -291,8 +291,8 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'Heat Transfer', u'Heat Transfer Documentation', - u'Caleb Bell', 'Heat Transfer', 'One line description of project.', + ('index', 'Heat Transfer', 'Heat Transfer Documentation', + 'Caleb Bell', 'Heat Transfer', 'One line description of project.', 'Miscellaneous'), ] nbsphinx_requirejs_path = '' # fixes katex not working diff --git a/docs/plots/Nu_external_cylinder.py b/docs/plots/Nu_external_cylinder.py index f51ec8c..b7d8c03 100644 --- a/docs/plots/Nu_external_cylinder.py +++ b/docs/plots/Nu_external_cylinder.py @@ -1,6 +1,8 @@ import matplotlib.pyplot as plt import numpy as np -from ht.conv_external import conv_external_cylinder_methods, Nu_external_cylinder + +from ht.conv_external import Nu_external_cylinder, conv_external_cylinder_methods + styles = ['--', '-.', '-', ':', '.', ',', 'o', 'v', '^', '<', '>', '1', '2', '3', '4'] Res = np.logspace(np.log10(10), np.log10(1E6), 1000) @@ -16,14 +18,14 @@ for method, style in zip(conv_external_cylinder_methods, styles): Nus = [Nu_external_cylinder(Re=Re, Pr=Pr, Method=method) for Re in Res] axes.semilogx(Res, Nus, label=method) # + ', angle = ' + str(angle) - + axes.set_title(r'Pr = %g' %Pr) for item in ([axes.title, axes.xaxis.label, axes.yaxis.label] + axes.get_xticklabels() + axes.get_yticklabels()): item.set_fontsize(6.5) - + ttl = axes.title.set_position([.5, .98]) - + plt.subplots_adjust(wspace=.35, hspace=.35) f.suptitle('Comparison of available methods for external convection\n Reynolds Number (x) vs. Nusselt Number (y)') diff --git a/setup.py b/setup.py index 02f1947..2332e96 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, Caleb Bell @@ -18,7 +17,8 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' from setuptools import setup diff --git a/tests/make_test_stubs.py b/tests/make_test_stubs.py index 78bfff4..b2a2024 100644 --- a/tests/make_test_stubs.py +++ b/tests/make_test_stubs.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import os tests = ['test_air_cooler', 'test_boiling_flow', 'test_boiling_nucleic', 'test_boiling_plate', 'test_condensation', 'test_conduction', 'test_conv_external', 'test_conv_free_immersed', 'test_conv_free_enclosed', 'test_conv_internal', 'test_conv_jacket', 'test_conv_packed_bed', 'test_conv_plate', 'test_conv_supercritical', 'test_conv_tube_bank', 'test_conv_two_phase', 'test_core', 'test_hx', 'test_radiation'] @@ -12,9 +11,9 @@ os.system("python3 -m monkeytype run manual_runner.py %s" %t) for t in tests: mod = t[5:] - os.system("python3 -m monkeytype stub ht.%s > ../ht/%s.pyi" %(mod, mod)) + os.system(f"python3 -m monkeytype stub ht.{mod} > ../ht/{mod}.pyi") type_hit_path = "../ht/%s.pyi" %mod - dat = open(type_hit_path, 'r').read() + dat = open(type_hit_path).read() imports = 'from typing import List\n' dat = '# DO NOT EDIT - AUTOMATICALLY GENERATED BY tests/make_test_stubs.py!\n' + imports + dat dat = dat.replace('Union[int, float]', 'float') diff --git a/tests/manual_runner.py b/tests/manual_runner.py index ff05a47..b96176a 100644 --- a/tests/manual_runner.py +++ b/tests/manual_runner.py @@ -1,20 +1,20 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import sys + try: import test_air_cooler except Exception as e: print('run this from the tests directory') print(e) - exit() + sys.exit() import test_boiling_flow import test_boiling_nucleic import test_boiling_plate import test_condensation import test_conduction import test_conv_external -import test_conv_free_immersed import test_conv_free_enclosed +import test_conv_free_immersed import test_conv_internal import test_conv_jacket import test_conv_packed_bed @@ -25,6 +25,7 @@ import test_core import test_hx import test_radiation + # dynamically generated code - numba, units, vectorize - not part of this test suite to_test = [test_air_cooler, test_boiling_flow, test_boiling_nucleic, test_boiling_plate, test_condensation, test_conduction, test_conv_external, test_conv_free_immersed, test_conv_free_enclosed, test_conv_internal, test_conv_jacket, test_conv_packed_bed, test_conv_plate, test_conv_supercritical, test_conv_tube_bank, test_conv_two_phase, test_core, test_hx, test_radiation] diff --git a/tests/test_air_cooler.py b/tests/test_air_cooler.py index b50928f..236882c 100644 --- a/tests/test_air_cooler.py +++ b/tests/test_air_cooler.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017, 2018, 2019, Caleb Bell @@ -18,15 +17,25 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division -from ht import (Ft_aircooler, air_cooler_noise_GPSA, air_cooler_noise_Mukherjee, dP_ESDU_high_fin, - dP_ESDU_low_fin, h_Briggs_Young, h_ESDU_high_fin, h_ESDU_low_fin, h_Ganguli_VDI) +import pytest +from fluids.constants import foot, hp, inch, minute from fluids.geometry import AirCooledExchanger from fluids.numerics import assert_close, assert_close2d -from fluids.constants import minute, hp, inch, foot -import pytest + +from ht import ( + Ft_aircooler, + air_cooler_noise_GPSA, + air_cooler_noise_Mukherjee, + dP_ESDU_high_fin, + dP_ESDU_low_fin, + h_Briggs_Young, + h_ESDU_high_fin, + h_ESDU_low_fin, + h_Ganguli_VDI, +) ### Air Cooler @@ -48,7 +57,7 @@ def test_air_cooler_noise_GPSA(): def test_air_cooler_noise_Mukherjee(): - ''' # Confirmed to be log10's because of example tip speed reduction + '''# Confirmed to be log10's because of example tip speed reduction # of 60 m/s to 40 m/s saves 5.3 dB. # hp in shaft horse power # d in meters @@ -213,10 +222,10 @@ def test_AirCooledExchangerPermutations(): tube_passes_options = range(1, 20) tubes_per_row_options = range(1, 40) - from ht.hx import HTRI_Ls, HEDH_pitches - from ht.air_cooler import fin_densities, fin_heights, ODs + from ht.air_cooler import ODs, fin_densities, fin_heights + from ht.hx import HEDH_pitches, HTRI_Ls angles = [30, 45, 60, 90] - pitches = sorted((set([j for k in HEDH_pitches.values() for j in k]))) + pitches = sorted({j for k in HEDH_pitches.values() for j in k}) pitches = [1.25, 1.312, 1.33, 1.375, 1.4, 1.5] fin_thicknesses = [3E-4, 4E-4, 5E-4, 6E-4, 7E-4] # made up diff --git a/tests/test_boiling_flow.py b/tests/test_boiling_flow.py index d6a2265..45294fe 100644 --- a/tests/test_boiling_flow.py +++ b/tests/test_boiling_flow.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017, 2018, 2019, Caleb Bell @@ -18,13 +17,13 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division -from ht.boiling_flow import (Chen_Bennett, Chen_Edelstein, Lazarek_Black, Li_Wu, Liu_Winterton, - Sun_Mishima, Thome, Yun_Heo_Kim) -from fluids.numerics import assert_close import pytest +from fluids.numerics import assert_close + +from ht.boiling_flow import Chen_Bennett, Chen_Edelstein, Lazarek_Black, Li_Wu, Liu_Winterton, Sun_Mishima, Thome, Yun_Heo_Kim def test_Lazarek_Black(): @@ -37,7 +36,7 @@ def test_Lazarek_Black(): with pytest.raises(Exception): Lazarek_Black(m=10, D=0.3, mul=1E-3, kl=0.6, Hvap=2E6) - ''' + """ The code to derive the form with `Te` specified is as follows: @@ -47,7 +46,7 @@ def test_Lazarek_Black(): >>> solve(Eq(h, 30*Relo**Rational(857,1000)*(Bgish*h*Te)**Rational(714, ... 1000)*kl/D), h) [27000*30**(71/143)*Bgish**(357/143)*Relo**(857/286)*Te**(357/143)*kl**(500/143)/D**(500/143)] - ''' + """ def test_Li_Wu(): @@ -61,7 +60,7 @@ def test_Li_Wu(): with pytest.raises(Exception): Li_Wu(m=1, x=0.2, D=0.3, rhol=567., rhog=18.09, kl=0.086, mul=156E-6, sigma=0.02, Hvap=9E5) - ''' + """ The code to derive the form with `Te` specified is as follows: @@ -69,7 +68,7 @@ def test_Li_Wu(): >>> h, A, Te, G, Hvap = symbols('h, A, Te, G, Hvap', positive=True, real=True) >>> solve(Eq(h, A*(h*Te/G/Hvap)**0.3), h) [A**(10/7)*Te**(3/7)/(G**(3/7)*Hvap**(3/7))] - ''' + """ def test_Sun_Mishima(): h = Sun_Mishima(m=1.0, D=0.3, rhol=567., rhog=18.09, kl=0.086, mul=156E-6, sigma=0.02, Hvap=9E5, Te=10) @@ -85,7 +84,7 @@ def test_Sun_Mishima(): with pytest.raises(Exception): Sun_Mishima(m=1, D=0.3, rhol=567., rhog=18.09, kl=0.086, mul=156E-6, sigma=0.02, Hvap=9E5) - ''' + """ The code to derive the form with `Te` specified is as follows: @@ -93,7 +92,7 @@ def test_Sun_Mishima(): >>> h, A, Te, G, Hvap = symbols('h, A, Te, G, Hvap', positive=True, real=True) >>> solve(Eq(h, A*(h*Te/G/Hvap)**0.54), h) [A**(50/23)*Te**(27/23)/(G**(27/23)*Hvap**(27/23))] - ''' + """ def test_Thome(): h = Thome(m=1.0, x=0.4, D=0.3, rhol=567., rhog=18.09, kl=0.086, kg=0.2, mul=156E-6, mug=1E-5, Cpl=2300.0, Cpg=1400, sigma=0.02, Hvap=9E5, Psat=1E5, Pc=22E6, q=1E5) @@ -120,7 +119,7 @@ def test_Yun_Heo_Kim(): with pytest.raises(Exception): Yun_Heo_Kim(m=1, x=0.4, D=0.3, rhol=567., mul=156E-6, sigma=0.02, Hvap=9E5) - ''' + """ The code to derive the form with `Te` specified is as follows: @@ -128,7 +127,7 @@ def test_Yun_Heo_Kim(): >>> h, A = symbols('h, A', positive=True, real=True) >>> solve(Eq(h, A*(h)**0.1993), h) [A**(10000/8707)] - ''' + """ def test_Liu_Winterton(): h = Liu_Winterton(m=1.0, x=0.4, D=0.3, rhol=567., rhog=18.09, kl=0.086, mul=156E-6, Cpl=2300.0, P=1E6, Pc=22E6, MW=44.02, Te=7.0) diff --git a/tests/test_boiling_nucleic.py b/tests/test_boiling_nucleic.py index b265744..31ba1be 100644 --- a/tests/test_boiling_nucleic.py +++ b/tests/test_boiling_nucleic.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017, 2018, 2019, Caleb Bell @@ -18,14 +17,30 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division -from ht import (Bier, Cooper, Forster_Zuber, Gorenflo, HEDH_Montinsky, HEDH_Taborek, McNelly, - Montinsky, Rohsenow, Serth_HEDH, Stephan_Abdelsalam, Zuber, h_nucleic, - h_nucleic_methods, qmax_boiling, qmax_boiling_methods) -from fluids.numerics import assert_close, assert_close1d import pytest +from fluids.numerics import assert_close, assert_close1d + +from ht import ( + Bier, + Cooper, + Forster_Zuber, + Gorenflo, + HEDH_Montinsky, + HEDH_Taborek, + McNelly, + Montinsky, + Rohsenow, + Serth_HEDH, + Stephan_Abdelsalam, + Zuber, + h_nucleic, + h_nucleic_methods, + qmax_boiling, + qmax_boiling_methods, +) ### Nucleic boiling @@ -282,4 +297,4 @@ def test_qmax_nucleic(): methods = qmax_boiling_methods(P=310.3E3, Pc=2550E3, D=0.0127, sigma=8.2E-3, Hvap=272E3, rhol=567, rhog=18.09) - assert len(methods) == 3 \ No newline at end of file + assert len(methods) == 3 diff --git a/tests/test_boiling_plate.py b/tests/test_boiling_plate.py index 1514844..9387a59 100644 --- a/tests/test_boiling_plate.py +++ b/tests/test_boiling_plate.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2017, 2018, 2019, Caleb Bell @@ -18,13 +17,14 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division -from ht import (h_boiling_Amalfi, h_boiling_Han_Lee_Kim, h_boiling_Huang_Sheer, - h_boiling_Lee_Kang_Kim, h_boiling_Yan_Lin) from fluids.numerics import assert_close +from ht import h_boiling_Amalfi, h_boiling_Han_Lee_Kim, h_boiling_Huang_Sheer, h_boiling_Lee_Kang_Kim, h_boiling_Yan_Lin + + def test_h_boiling_Amalfi(): h = h_boiling_Amalfi(m=3E-5, x=.4, Dh=0.00172, rhol=567., rhog=18.09, kl=0.086, mul=156E-6, mug=7.11E-6, sigma=0.02, Hvap=9E5, q=1E5, A_channel_flow=0.0003) assert_close(h, 776.0781179096225) @@ -57,4 +57,4 @@ def test_h_boiling_Huang_Sheer(): def test_h_boiling_Yan_Lin(): h = h_boiling_Yan_Lin(m=3E-5, x=.4, Dh=0.002, rhol=567., rhog=18.09, kl=0.086, Cpl=2200.0, mul=156E-6, Hvap=9E5, q=1E5, A_channel_flow=0.0003) - assert_close(h, 318.7228565961241) \ No newline at end of file + assert_close(h, 318.7228565961241) diff --git a/tests/test_condensation.py b/tests/test_condensation.py index c7e446c..2eb659a 100644 --- a/tests/test_condensation.py +++ b/tests/test_condensation.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017, 2018, 2019, Caleb Bell @@ -18,17 +17,15 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division -from fluids import Prandtl from math import pi -from ht import (Akers_Deans_Crosser, Boyko_Kruzhilin, Cavallini_Smith_Zecchin, Nusselt_laminar, - Shah, h_kinetic) -from fluids.numerics import linspace -from fluids.numerics import assert_close, assert_close1d +from fluids import Prandtl +from fluids.numerics import assert_close, assert_close1d, linspace +from ht import Akers_Deans_Crosser, Boyko_Kruzhilin, Cavallini_Smith_Zecchin, Nusselt_laminar, Shah, h_kinetic ### Condensation diff --git a/tests/test_conduction.py b/tests/test_conduction.py index 7456180..e7189e9 100644 --- a/tests/test_conduction.py +++ b/tests/test_conduction.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017, 2018, 2019, Caleb Bell @@ -18,18 +17,38 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' - -from __future__ import division -from ht import (ASHRAE, ASHRAE_k, Cp_material, R_cylinder, R_to_k, R_value_to_k, - S_isothermal_pipe_eccentric_to_isothermal_pipe, S_isothermal_pipe_normal_to_plane, - S_isothermal_pipe_to_isothermal_pipe, S_isothermal_pipe_to_plane, - S_isothermal_pipe_to_two_planes, S_isothermal_sphere_to_plane, building_materials, - cylindrical_heat_transfer, k_material, k_to_R, k_to_R_value, - k_to_thermal_resistivity, materials_dict, nearest_material, refractory_VDI_Cp, - refractory_VDI_k, rho_material, thermal_resistivity_to_k) -from fluids.numerics import assert_close, assert_close1d +SOFTWARE. +''' + import pytest +from fluids.numerics import assert_close, assert_close1d + +from ht import ( + ASHRAE, + ASHRAE_k, + Cp_material, + R_cylinder, + R_to_k, + R_value_to_k, + S_isothermal_pipe_eccentric_to_isothermal_pipe, + S_isothermal_pipe_normal_to_plane, + S_isothermal_pipe_to_isothermal_pipe, + S_isothermal_pipe_to_plane, + S_isothermal_pipe_to_two_planes, + S_isothermal_sphere_to_plane, + building_materials, + cylindrical_heat_transfer, + k_material, + k_to_R, + k_to_R_value, + k_to_thermal_resistivity, + materials_dict, + nearest_material, + refractory_VDI_Cp, + refractory_VDI_k, + rho_material, + thermal_resistivity_to_k, +) ### Conduction # Nothing is necessary, it's all in doctests diff --git a/tests/test_conv_external.py b/tests/test_conv_external.py index 412790a..9a934ae 100644 --- a/tests/test_conv_external.py +++ b/tests/test_conv_external.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017, 2018, 2019, Caleb Bell @@ -18,18 +17,30 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' - -from __future__ import division -from ht import (Nu_cylinder_Churchill_Bernstein, Nu_cylinder_Fand, Nu_cylinder_McAdams, - Nu_cylinder_Perkins_Leppert_1962, Nu_cylinder_Perkins_Leppert_1964, - Nu_cylinder_Sanitjai_Goldstein, Nu_cylinder_Whitaker, Nu_cylinder_Zukauskas, - Nu_external_cylinder, Nu_external_cylinder_methods, Nu_external_horizontal_plate, - Nu_external_horizontal_plate_methods, Nu_horizontal_plate_laminar_Baehr, - Nu_horizontal_plate_laminar_Churchill_Ozoe, Nu_horizontal_plate_turbulent_Kreith, - Nu_horizontal_plate_turbulent_Schlichting) +SOFTWARE. +''' + import pytest from fluids.numerics import assert_close, assert_close1d, logspace + +from ht import ( + Nu_cylinder_Churchill_Bernstein, + Nu_cylinder_Fand, + Nu_cylinder_McAdams, + Nu_cylinder_Perkins_Leppert_1962, + Nu_cylinder_Perkins_Leppert_1964, + Nu_cylinder_Sanitjai_Goldstein, + Nu_cylinder_Whitaker, + Nu_cylinder_Zukauskas, + Nu_external_cylinder, + Nu_external_cylinder_methods, + Nu_external_horizontal_plate, + Nu_external_horizontal_plate_methods, + Nu_horizontal_plate_laminar_Baehr, + Nu_horizontal_plate_laminar_Churchill_Ozoe, + Nu_horizontal_plate_turbulent_Kreith, + Nu_horizontal_plate_turbulent_Schlichting, +) from ht.conv_external import conv_horizontal_plate_laminar_methods, conv_horizontal_plate_turbulent_methods ### Conv external diff --git a/tests/test_conv_free_enclosed.py b/tests/test_conv_free_enclosed.py index 20bb8a3..0b34b5c 100644 --- a/tests/test_conv_free_enclosed.py +++ b/tests/test_conv_free_enclosed.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2019, Caleb Bell @@ -18,16 +17,24 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' - -from __future__ import division -from ht import (Nu_Nusselt_Rayleigh_Hollands, Nu_Nusselt_Rayleigh_Probert, - Nu_Nusselt_vertical_Thess, Nu_vertical_helical_coil_Ali, Rac_Nusselt_Rayleigh, - Rac_Nusselt_Rayleigh_disk) +SOFTWARE. +''' + +from fluids.numerics import assert_close, assert_close1d +from fluids.numerics import numpy as np + +from ht import ( + Nu_Nusselt_Rayleigh_Hollands, + Nu_Nusselt_Rayleigh_Probert, + Nu_Nusselt_vertical_Thess, + Nu_vertical_helical_coil_Ali, + Rac_Nusselt_Rayleigh, + Rac_Nusselt_Rayleigh_disk, +) from ht.conv_free_enclosed import Nu_Nusselt_Rayleigh_Holling_Herwig -from fluids.numerics import assert_close, assert_close1d, numpy as np + try: - from scipy.interpolate import bisplrep, UnivariateSpline + from scipy.interpolate import UnivariateSpline, bisplrep except: pass @@ -98,7 +105,7 @@ def test_Nu_Nusselt_Rayleigh_Hollands(): assert_close(Nu_Nusselt_Rayleigh_Hollands(.7, 3.21e6, buoyancy=True, Rac=Rac_Nusselt_Rayleigh(H=1, L=1, W=1, insulated=False)), 8.786362614129537) def test_Rac_Nusselt_Rayleigh_fit_uninsulated(): - from ht.conv_free_enclosed import tck_uninstulated_Catton, ratios_uninsulated_Catton, Racs_uninstulated_Catton + from ht.conv_free_enclosed import Racs_uninstulated_Catton, ratios_uninsulated_Catton, tck_uninstulated_Catton all_zs = [] all_xs = [] all_ys = [] @@ -151,6 +158,7 @@ def test_Rac_Nusselt_Rayleigh_fit_insulated(): def test_Rac_Nusselt_Rayleigh_disk_fits(): from fluids.optional import pychebfun + from ht.conv_free_enclosed import insulated_disk_coeffs, uninsulated_disk_coeffs ratios = [0.4, 0.5, 0.7, 1.0, 1.4, 2.0, 3.0, 4.0, 6] Ras_uninsulated = [151200, 66600, 21300, 8010, 4350, 2540, 2010, 1880, 1708] @@ -182,4 +190,4 @@ def test_Rac_Nusselt_Rayleigh_disk_fits(): def test_Nu_vertical_helical_coil_Ali(): Nu = Nu_vertical_helical_coil_Ali(4.4, 1E11) - assert_close(Nu, 1808.5774997297106) \ No newline at end of file + assert_close(Nu, 1808.5774997297106) diff --git a/tests/test_conv_free_immersed.py b/tests/test_conv_free_immersed.py index b26f6ca..a146d9c 100644 --- a/tests/test_conv_free_immersed.py +++ b/tests/test_conv_free_immersed.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017, 2018, 2019, Caleb Bell @@ -18,27 +17,42 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' - -from __future__ import division -from ht import (Nu_coil_Xin_Ebadian, Nu_free_horizontal_plate, Nu_free_horizontal_plate_methods, - Nu_free_vertical_plate, Nu_free_vertical_plate_methods, Nu_horizontal_cylinder, - Nu_horizontal_cylinder_Churchill_Chu, Nu_horizontal_cylinder_Kuehn_Goldstein, - Nu_horizontal_cylinder_Morgan, Nu_horizontal_cylinder_methods, - Nu_horizontal_plate_McAdams, Nu_horizontal_plate_Rohsenow, Nu_horizontal_plate_VDI, - Nu_sphere_Churchill, Nu_vertical_cylinder, Nu_vertical_cylinder_Al_Arabi_Khamis, - Nu_vertical_cylinder_Carne_Morgan, Nu_vertical_cylinder_Eigenson_Morgan, - Nu_vertical_cylinder_Griffiths_Davis_Morgan, - Nu_vertical_cylinder_Hanesian_Kalish_Morgan, - Nu_vertical_cylinder_Jakob_Linke_Morgan, Nu_vertical_cylinder_Kreith_Eckert, - Nu_vertical_cylinder_McAdams_Weiss_Saunders, Nu_vertical_cylinder_Popiel_Churchill, - Nu_vertical_cylinder_Touloukian_Morgan, Nu_vertical_cylinder_methods, - Nu_vertical_helical_coil_Prabhanjan_Rennie_Raghavan, Nu_vertical_plate_Churchill) -from fluids.numerics import assert_close, assert_close1d, assert_close2d, logspace -import pytest - +SOFTWARE. +''' +import pytest +from fluids.numerics import assert_close, assert_close1d, assert_close2d, logspace +from ht import ( + Nu_coil_Xin_Ebadian, + Nu_free_horizontal_plate, + Nu_free_horizontal_plate_methods, + Nu_free_vertical_plate, + Nu_free_vertical_plate_methods, + Nu_horizontal_cylinder, + Nu_horizontal_cylinder_Churchill_Chu, + Nu_horizontal_cylinder_Kuehn_Goldstein, + Nu_horizontal_cylinder_methods, + Nu_horizontal_cylinder_Morgan, + Nu_horizontal_plate_McAdams, + Nu_horizontal_plate_Rohsenow, + Nu_horizontal_plate_VDI, + Nu_sphere_Churchill, + Nu_vertical_cylinder, + Nu_vertical_cylinder_Al_Arabi_Khamis, + Nu_vertical_cylinder_Carne_Morgan, + Nu_vertical_cylinder_Eigenson_Morgan, + Nu_vertical_cylinder_Griffiths_Davis_Morgan, + Nu_vertical_cylinder_Hanesian_Kalish_Morgan, + Nu_vertical_cylinder_Jakob_Linke_Morgan, + Nu_vertical_cylinder_Kreith_Eckert, + Nu_vertical_cylinder_McAdams_Weiss_Saunders, + Nu_vertical_cylinder_methods, + Nu_vertical_cylinder_Popiel_Churchill, + Nu_vertical_cylinder_Touloukian_Morgan, + Nu_vertical_helical_coil_Prabhanjan_Rennie_Raghavan, + Nu_vertical_plate_Churchill, +) ### Free convection immersed @@ -220,4 +234,4 @@ def test_Nu_coil_Xin_Ebadian(): def test_Nu_vertical_helical_coil_Prabhanjan_Rennie_Raghavan(): Nu = Nu_vertical_helical_coil_Prabhanjan_Rennie_Raghavan(4.4, 1E11) - assert_close(Nu, 720.6211067718227) \ No newline at end of file + assert_close(Nu, 720.6211067718227) diff --git a/tests/test_conv_internal.py b/tests/test_conv_internal.py index 361402e..749149d 100644 --- a/tests/test_conv_internal.py +++ b/tests/test_conv_internal.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017, 2018, 2019, Caleb Bell @@ -18,26 +17,50 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' - -from __future__ import division -from ht.conv_internal import (Morimoto_Hotta, Nu_conv_internal, Nu_conv_internal_methods, - Nu_laminar_rectangular_Shan_London, conv_tube_methods, - helical_turbulent_Nu_Mori_Nakayama, helical_turbulent_Nu_Schmidt, - helical_turbulent_Nu_Xin_Ebadian, laminar_Q_const, laminar_T_const, - laminar_entry_Baehr_Stephan, laminar_entry_Seider_Tate, - laminar_entry_thermal_Hausen, turbulent_Bhatti_Shah, - turbulent_Churchill_Zajic, turbulent_Colburn, - turbulent_Dipprey_Sabersky, turbulent_Dittus_Boelter, - turbulent_Drexel_McAdams, turbulent_ESDU, turbulent_Friend_Metzner, - turbulent_Gnielinski, turbulent_Gnielinski_smooth_1, - turbulent_Gnielinski_smooth_2, turbulent_Gowen_Smith, - turbulent_Kawase_De, turbulent_Kawase_Ulbrecht, turbulent_Martinelli, - turbulent_Nunner, turbulent_Petukhov_Kirillov_Popov, - turbulent_Prandtl, turbulent_Sandall, turbulent_Sieder_Tate, - turbulent_Webb, turbulent_entry_Hausen, turbulent_von_Karman) -from fluids.numerics import assert_close, assert_close1d, linspace +SOFTWARE. +''' + import pytest +from fluids.numerics import assert_close, assert_close1d, linspace + +from ht.conv_internal import ( + Morimoto_Hotta, + Nu_conv_internal, + Nu_conv_internal_methods, + Nu_laminar_rectangular_Shan_London, + conv_tube_methods, + helical_turbulent_Nu_Mori_Nakayama, + helical_turbulent_Nu_Schmidt, + helical_turbulent_Nu_Xin_Ebadian, + laminar_entry_Baehr_Stephan, + laminar_entry_Seider_Tate, + laminar_entry_thermal_Hausen, + laminar_Q_const, + laminar_T_const, + turbulent_Bhatti_Shah, + turbulent_Churchill_Zajic, + turbulent_Colburn, + turbulent_Dipprey_Sabersky, + turbulent_Dittus_Boelter, + turbulent_Drexel_McAdams, + turbulent_entry_Hausen, + turbulent_ESDU, + turbulent_Friend_Metzner, + turbulent_Gnielinski, + turbulent_Gnielinski_smooth_1, + turbulent_Gnielinski_smooth_2, + turbulent_Gowen_Smith, + turbulent_Kawase_De, + turbulent_Kawase_Ulbrecht, + turbulent_Martinelli, + turbulent_Nunner, + turbulent_Petukhov_Kirillov_Popov, + turbulent_Prandtl, + turbulent_Sandall, + turbulent_Sieder_Tate, + turbulent_von_Karman, + turbulent_Webb, +) ### conv_internal @@ -236,4 +259,4 @@ def test_Nu_conv_internal(): l = Nu_conv_internal_methods(1E5, .7) assert len(l) == 21 -test_Nu_conv_internal() \ No newline at end of file +test_Nu_conv_internal() diff --git a/tests/test_conv_jacket.py b/tests/test_conv_jacket.py index 1cc77df..4b4dca8 100644 --- a/tests/test_conv_jacket.py +++ b/tests/test_conv_jacket.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017, 2018, 2019, Caleb Bell @@ -18,12 +17,13 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division -from ht import Lehrer, Stein_Schmidt from fluids.numerics import assert_close +from ht import Lehrer, Stein_Schmidt + def test_conv_jacket(): # actual example @@ -71,4 +71,4 @@ def test_conv_jacket(): assert_close(h, 5685.532991556428) h = Stein_Schmidt(.1, 0.6, 0.65, 0.6, 0.025, 971.8, 4178.1, 0.615, 798E-6) - assert_close(h, 151.78819106776797) \ No newline at end of file + assert_close(h, 151.78819106776797) diff --git a/tests/test_conv_packed_bed.py b/tests/test_conv_packed_bed.py index f3c7c1e..822016e 100644 --- a/tests/test_conv_packed_bed.py +++ b/tests/test_conv_packed_bed.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017, 2018, 2019, Caleb Bell @@ -18,12 +17,13 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division -from ht import Nu_Achenbach, Nu_KTA, Nu_Wakao_Kagei, Nu_packed_bed_Gnielinski from fluids.numerics import assert_close +from ht import Nu_Achenbach, Nu_KTA, Nu_packed_bed_Gnielinski, Nu_Wakao_Kagei + def test_Nu_packed_bed_Gnielinski(): Nu = Nu_packed_bed_Gnielinski(8E-4, 0.4, 1.0, 1E3, 1E-3, 0.7) @@ -44,4 +44,4 @@ def test_Nu_Achenbach(): def test_Nu_KTA(): Nu = Nu_KTA(2000., 0.7, 0.4) - assert_close(Nu, 102.08516480718129) \ No newline at end of file + assert_close(Nu, 102.08516480718129) diff --git a/tests/test_conv_plate.py b/tests/test_conv_plate.py index 90b4141..b5011d1 100644 --- a/tests/test_conv_plate.py +++ b/tests/test_conv_plate.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2018 Caleb Bell @@ -18,14 +17,13 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division -from ht.conv_plate import (Nu_plate_Khan_Khan, Nu_plate_Kumar, Nu_plate_Martin, - Nu_plate_Muley_Manglik) -from fluids.numerics import assert_close import pytest +from fluids.numerics import assert_close +from ht.conv_plate import Nu_plate_Khan_Khan, Nu_plate_Kumar, Nu_plate_Martin, Nu_plate_Muley_Manglik @pytest.mark.numpy diff --git a/tests/test_conv_supercritical.py b/tests/test_conv_supercritical.py index 08f038d..38ae6dc 100644 --- a/tests/test_conv_supercritical.py +++ b/tests/test_conv_supercritical.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017, 2018, 2019, Caleb Bell @@ -18,14 +17,32 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division -from ht import (Nu_Bishop, Nu_Bringer_Smith, Nu_Gorban, Nu_Griem, Nu_Gupta, Nu_Jackson, Nu_Kitoh, - Nu_Krasnoshchekov, Nu_Krasnoshchekov_Protopopov, Nu_McAdams, Nu_Mokry, Nu_Ornatsky, - Nu_Petukhov, Nu_Shitsman, Nu_Swenson, Nu_Xu, Nu_Yamagata, Nu_Zhu) from fluids.numerics import assert_close, assert_close1d +from ht import ( + Nu_Bishop, + Nu_Bringer_Smith, + Nu_Gorban, + Nu_Griem, + Nu_Gupta, + Nu_Jackson, + Nu_Kitoh, + Nu_Krasnoshchekov, + Nu_Krasnoshchekov_Protopopov, + Nu_McAdams, + Nu_Mokry, + Nu_Ornatsky, + Nu_Petukhov, + Nu_Shitsman, + Nu_Swenson, + Nu_Xu, + Nu_Yamagata, + Nu_Zhu, +) + def test_Nu_McAdams(): Nu = Nu_McAdams(1E5, 1.2) @@ -156,4 +173,4 @@ def test_Nu_Krasnoshchekov(): assert_close(Nu_3, 192.2579518680533) Nu = Nu_Krasnoshchekov(1E5, 1.2) - assert_close(Nu, 234.82855185610364) \ No newline at end of file + assert_close(Nu, 234.82855185610364) diff --git a/tests/test_conv_tube_bank.py b/tests/test_conv_tube_bank.py index a09bcd9..0ccd122 100644 --- a/tests/test_conv_tube_bank.py +++ b/tests/test_conv_tube_bank.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017 Caleb Bell @@ -18,21 +17,33 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' - -from __future__ import division -from ht import (ESDU_tube_angle_correction, ESDU_tube_row_correction, Nu_ESDU_73031, - Nu_Grimison_tube_bank, Nu_HEDH_tube_bank, Nu_Zukauskas_Bejan, - Zukauskas_tube_row_correction, baffle_correction_Bell, baffle_leakage_Bell, - bundle_bypassing_Bell, dP_Kern, dP_Zukauskas, laminar_correction_Bell, - unequal_baffle_spacing_Bell) -import numpy as np +SOFTWARE. +''' -from scipy.interpolate import RectBivariateSpline, UnivariateSpline, interp1d, splrep +import numpy as np from fluids.numerics import assert_close, assert_close1d, assert_close2d, linspace +from scipy.interpolate import RectBivariateSpline, UnivariateSpline, interp1d, splrep + +from ht import ( + ESDU_tube_angle_correction, + ESDU_tube_row_correction, + Nu_ESDU_73031, + Nu_Grimison_tube_bank, + Nu_HEDH_tube_bank, + Nu_Zukauskas_Bejan, + Zukauskas_tube_row_correction, + baffle_correction_Bell, + baffle_leakage_Bell, + bundle_bypassing_Bell, + dP_Kern, + dP_Zukauskas, + laminar_correction_Bell, + unequal_baffle_spacing_Bell, +) + def test_Nu_Grimison_tube_bank_tcks(): - from ht.conv_tube_bank import Grimison_ST_aligned, Grimison_SL_aligned, Grimison_C1_aligned, Grimison_C1_aligned_tck + from ht.conv_tube_bank import Grimison_C1_aligned, Grimison_C1_aligned_tck, Grimison_SL_aligned, Grimison_ST_aligned Grimison_C1_aligned_interp = RectBivariateSpline(Grimison_ST_aligned, Grimison_SL_aligned, np.array(Grimison_C1_aligned)) @@ -40,7 +51,7 @@ def test_Nu_Grimison_tube_bank_tcks(): tck_recalc = Grimison_C1_aligned_interp.tck [assert_close1d(i, j) for i, j in zip(Grimison_C1_aligned_tck, tck_recalc)] - from ht.conv_tube_bank import Grimison_m_aligned_tck, Grimison_m_aligned + from ht.conv_tube_bank import Grimison_m_aligned, Grimison_m_aligned_tck Grimison_m_aligned_interp = RectBivariateSpline(Grimison_ST_aligned, Grimison_SL_aligned, np.array(Grimison_m_aligned)) @@ -205,7 +216,8 @@ def test_Zukauskas_tube_row_correction(): def test_Zukauskas_tube_row_correction_refit(): from scipy.interpolate import UnivariateSpline - from ht.conv_tube_bank import Zukauskas_Czs_low_Re_staggered, Zukauskas_Czs_high_Re_staggered, Zukauskas_Czs_inline + + from ht.conv_tube_bank import Zukauskas_Czs_high_Re_staggered, Zukauskas_Czs_inline, Zukauskas_Czs_low_Re_staggered # Commands used to obtain the fitted data: Zukauskas_Cz_Zs = [0.968219, 1.01968, 1.04164, 1.04441, 1.07539, 1.09332, 1.13914, 1.16636, 1.23636, 1.2394, 1.24505, 1.3125, 1.33358, 1.38554, 1.43141, 1.48282, 1.4876, 1.55352, 1.58004, 1.60466, 1.65726, 1.67493, 1.70188, 1.79682, 1.91823, 1.99323, 1.99665, 2.04002, 2.16306, 2.18556, 2.19045, 2.30691, 2.3086, 2.36006, 2.45272, 2.45413, 2.57543, 2.59826, 2.72341, 2.7451, 2.8896, 2.91482, 2.98759, 3.1572, 3.23203, 3.25334, 3.3511, 3.42295, 3.4499, 3.52072, 3.6168, 3.83565, 3.9076, 3.9826, 4.02939, 4.17411, 4.20042, 4.44242, 4.48937, 4.61023, 4.82811, 4.95071, 5.07038, 5.28825, 5.31232, 5.3621, 5.50606, 5.53014, 5.60405, 5.74801, 5.74807, 5.82181, 5.99012, 5.99017, 6.13636, 6.23207, 6.23212, 6.37826, 6.44983, 6.44988, 6.62015, 6.69183, 6.69188, 6.95807, 6.95812, 6.98312, 7.1767, 7.20001, 7.41772, 7.41848, 7.65967, 7.87743, 7.90156, 7.95003, 7.97416, 7.97476, 8.21606, 8.2166, 8.45795, 8.60365, 8.67571, 8.79712, 8.91809, 8.96597, 9.18368, 9.20824, 9.42551, 9.45013, 9.66741, 9.69197, 10.0786, 10.3208, 10.5623, 10.5626, 10.7803, 10.9737, 10.9978, 11.2398, 11.2399, 11.4574, 11.4575, 11.6993, 11.7478, 11.9653, 11.9896, 12.2072, 12.2315, 12.4491, 12.691, 12.7152, 12.9812, 13.2231, 13.2715, 13.465, 13.7068, 13.9246, 13.9487, 14.1905, 14.4324, 14.6743, 14.9161, 14.9887, 15.2305, 15.4724, 15.7142, 15.787, 15.811, 15.8835, 16.0046, 16.0287, 16.2465, 16.3673, 16.4883, 16.5124, 16.706, 16.7301, 16.9477, 16.9479, 17.1897, 17.2138, 17.4315, 17.6734, 17.9152, 17.9636, 18.2054, 18.2055, 18.4473, 18.6891, 18.9068, 18.931, 18.9793, 19.2212, 19.4631, 19.5599, 19.7049, 19.9467, 19.9952] low_Re_staggered_Cz = [0.828685, 0.831068, 0.832085, 0.832213, 0.833647, 0.834478, 0.836599, 0.83786, 0.8411, 0.841241, 0.841503, 0.845561, 0.84683, 0.849956, 0.852715, 0.855808, 0.856096, 0.859148, 0.860376, 0.861516, 0.863952, 0.864828, 0.866165, 0.870874, 0.876897, 0.880617, 0.880787, 0.882293, 0.886566, 0.887348, 0.887517, 0.89214, 0.892207, 0.894249, 0.897396, 0.897444, 0.901563, 0.902338, 0.906589, 0.907258, 0.911719, 0.912497, 0.914744, 0.91998, 0.92229, 0.922729, 0.92474, 0.926218, 0.926772, 0.928561, 0.930987, 0.936514, 0.938332, 0.940226, 0.940947, 0.943179, 0.943584, 0.946941, 0.947769, 0.9499, 0.95374, 0.955902, 0.957529, 0.960492, 0.96082, 0.961497, 0.962826, 0.963048, 0.96373, 0.965208, 0.965208, 0.965965, 0.967759, 0.96776, 0.969318, 0.969757, 0.969758, 0.970428, 0.970757, 0.970757, 0.971538, 0.972422, 0.972422, 0.975703, 0.975704, 0.976012, 0.978249, 0.978139, 0.977115, 0.977111, 0.977585, 0.978013, 0.97806, 0.978155, 0.978202, 0.978204, 0.97819, 0.97819, 0.979578, 0.980416, 0.980411, 0.980405, 0.981521, 0.981333, 0.980478, 0.980382, 0.981379, 0.981492, 0.981479, 0.981478, 0.982147, 0.982566, 0.982553, 0.982553, 0.98254, 0.981406, 0.98171, 0.98476, 0.984762, 0.98475, 0.98475, 0.984736, 0.984733, 0.985732, 0.985843, 0.986842, 0.986953, 0.985817, 0.986825, 0.986926, 0.986911, 0.987834, 0.988018, 0.988008, 0.987994, 0.991353, 0.991148, 0.98909, 0.9902, 0.990187, 0.991297, 0.991293, 0.991279, 0.991266, 0.992054, 0.992292, 0.99237, 0.992366, 0.992359, 0.992358, 0.993068, 0.993463, 0.993456, 0.993454, 0.994443, 0.994566, 0.994553, 0.994553, 0.99454, 0.994539, 0.996774, 0.99676, 0.996746, 0.996744, 0.99673, 0.99673, 0.997466, 0.998201, 0.998863, 0.998936, 0.99902, 0.999439, 0.999857, 1.00002, 1.00002, 1, 1] @@ -691,4 +703,4 @@ def test_laminar_correction_Bell(): Jr = laminar_correction_Bell(30.0, 80) assert_close(Jr, 0.7267995454361379) - assert_close(0.4, laminar_correction_Bell(30, 80000)) \ No newline at end of file + assert_close(0.4, laminar_correction_Bell(30, 80000)) diff --git a/tests/test_conv_two_phase.py b/tests/test_conv_two_phase.py index 9672822..23f0588 100644 --- a/tests/test_conv_two_phase.py +++ b/tests/test_conv_two_phase.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017 Caleb Bell @@ -18,13 +17,13 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division -from ht import (Aggour, Davis_David, Elamvaluthi_Srinivas, Groothuis_Hendal, Hughmark, Knott, - Kudirka_Grosh_McFadden, Martin_Sims, Ravipudi_Godbold, h_two_phase) from fluids.numerics import assert_close +from ht import Aggour, Davis_David, Elamvaluthi_Srinivas, Groothuis_Hendal, Hughmark, Knott, Kudirka_Grosh_McFadden, Martin_Sims, Ravipudi_Godbold, h_two_phase + def test_Davis_David(): h = Davis_David(m=1., x=.9, D=.3, rhol=1000., rhog=2.5, Cpl=2300., kl=.6, mul=1E-3) diff --git a/tests/test_core.py b/tests/test_core.py index aaba761..20b5a60 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017 Caleb Bell @@ -18,14 +17,14 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division -from ht import LMTD, countercurrent_hx_temperature_check, fin_efficiency_Kern_Kraus, wall_factor -from fluids.numerics import assert_close -from ht.core import is_heating_temperature, is_heating_property import pytest -from ht.core import WALL_FACTOR_PRANDTL, WALL_FACTOR_TEMPERATURE, WALL_FACTOR_VISCOSITY +from fluids.numerics import assert_close + +from ht import LMTD, countercurrent_hx_temperature_check, fin_efficiency_Kern_Kraus, wall_factor +from ht.core import WALL_FACTOR_PRANDTL, WALL_FACTOR_TEMPERATURE, WALL_FACTOR_VISCOSITY, is_heating_property, is_heating_temperature def test_core(): @@ -36,7 +35,7 @@ def test_core(): assert LMTD(100., 60., 20., 60) == 40 assert LMTD(100., 60., 20., 60, counterflow=False) == 0 - '''Test code for limits + """Test code for limits from sympy import * Thi, Tho, Tci, Tco = symbols('Thi, Tho, Tci, Tco') Thi = 100 @@ -58,7 +57,7 @@ def test_core(): N(limit(expression, Tco, Rational('60')-Rational('1e-50000'))) limit(expression, Tco, 60) # evaluates to zero - ''' + """ def test_is_heating_temperature(): @@ -122,7 +121,7 @@ def test_fin_efficiency_Kern_Kraus(): eta = fin_efficiency_Kern_Kraus(0.0254, 0.05715, 3.8E-4, 200, 58) assert_close(eta, 0.8412588620231153) - '''Code for comparing against several formulas: + """Code for comparing against several formulas: def fin_efficiency_Kern_Kraus(Do, Dfin, fin_thickness, kfin, h): # Should now be about 50/50 function vs special function kf = kfin @@ -156,8 +155,8 @@ def fin_efficiency_Kern_Kraus(Do, Dfin, fin_thickness, kfin, h): return eta # Confirmed with Introduction to Heat Transfer # To create a pade approximation of this, it would require f(m, re, ro). Not worth it. - ''' - + """ + def test_countercurrent_hx_temperature_check(): assert not countercurrent_hx_temperature_check(T0i=500, T0o=466, T1i=348, T1o=329) assert not countercurrent_hx_temperature_check(T0i=453, T0o=466, T1i=310, T1o=329) diff --git a/tests/test_documentation.py b/tests/test_documentation.py index 411c6a5..4342322 100644 --- a/tests/test_documentation.py +++ b/tests/test_documentation.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2021 Caleb Bell @@ -18,15 +17,18 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -import pytest import os -''' + +import pytest + +""" Tests that run aspects of the documentation should go in here. The only bit included right now are the plots, which should run without an error; no contents checking is performed. -''' +""" plots_folder = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'docs', 'plots') plot_files = [i for i in os.listdir(plots_folder) if i.endswith('.py')] print(plot_files) @@ -36,4 +38,4 @@ def test_documentation_plots(file): import matplotlib matplotlib.use('Agg') exec(open(os.path.join(plots_folder, file)).read(), globals()) -# \ No newline at end of file +# diff --git a/tests/test_hx.py b/tests/test_hx.py index 5807e2b..6fd6c7f 100644 --- a/tests/test_hx.py +++ b/tests/test_hx.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017 Caleb Bell @@ -18,24 +17,51 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division from math import exp, factorial, isnan, sqrt, tanh -from ht import (DBundle_for_Ntubes_HEDH, DBundle_for_Ntubes_Phadkeb, DBundle_min, D_for_Ntubes_VDI, - F_LMTD_Fakheri, LMTD, L_unsupported_max, NTU_from_P_E, NTU_from_P_G, NTU_from_P_H, - NTU_from_P_J, NTU_from_P_basic, NTU_from_P_plate, NTU_from_effectiveness, Ntubes, - Ntubes_HEDH, Ntubes_Perrys, Ntubes_Phadkeb, Ntubes_VDI, P_NTU_method, - effectiveness_NTU_method, effectiveness_from_NTU, shell_clearance, - size_bundle_from_tubecount, temperature_effectiveness_TEMA_E, - temperature_effectiveness_TEMA_G, temperature_effectiveness_TEMA_H, - temperature_effectiveness_TEMA_J, temperature_effectiveness_air_cooler, - temperature_effectiveness_basic, temperature_effectiveness_plate) -import ht +from random import choice, randint, seed, uniform + import numpy as np -from fluids.numerics import assert_close, assert_close1d, assert_close2d import pytest -from random import uniform, randint, seed, choice +from fluids.numerics import assert_close, assert_close1d, assert_close2d + +import ht +from ht import ( + LMTD, + D_for_Ntubes_VDI, + DBundle_for_Ntubes_HEDH, + DBundle_for_Ntubes_Phadkeb, + DBundle_min, + F_LMTD_Fakheri, + L_unsupported_max, + NTU_from_effectiveness, + NTU_from_P_basic, + NTU_from_P_E, + NTU_from_P_G, + NTU_from_P_H, + NTU_from_P_J, + NTU_from_P_plate, + Ntubes, + Ntubes_HEDH, + Ntubes_Perrys, + Ntubes_Phadkeb, + Ntubes_VDI, + P_NTU_method, + effectiveness_from_NTU, + effectiveness_NTU_method, + shell_clearance, + size_bundle_from_tubecount, + temperature_effectiveness_air_cooler, + temperature_effectiveness_basic, + temperature_effectiveness_plate, + temperature_effectiveness_TEMA_E, + temperature_effectiveness_TEMA_G, + temperature_effectiveness_TEMA_H, + temperature_effectiveness_TEMA_J, +) + seed(0) @@ -130,8 +156,9 @@ def test_Phadkeb_numbers(): # One pain point of this code is that it takes 880 kb to store the results # in memory as a list ht.hx._load_coeffs_Phadkeb() - from ht.hx import triangular_Ns, triangular_C1s, square_Ns, square_C1s - from math import floor, ceil, sqrt + from math import ceil, floor, sqrt + + from ht.hx import square_C1s, square_Ns, triangular_C1s, triangular_Ns # Triangular Ns # https://oeis.org/A003136 # Translated expression originally in Wolfram Mathematica @@ -158,7 +185,7 @@ def test_Phadkeb_numbers(): # Tested with the online interpreter http://pari.math.u-bordeaux.fr/gp.html # This one is very slow, 300 seconds+ # Used to be 300 + seconds, now 50+ seconds - + def a(n): tot = 0 for k in range(0, int(ceil(n/3.))): @@ -212,7 +239,7 @@ def a2(n): tot += rtf(n - k*k) return 1 + 4*tot - ans = set([a2(i) for i in range(35000)]) + ans = {a2(i) for i in range(35000)} ans = sorted(list(ans)) nums = ans[0:len(square_C1s)] assert_close1d(nums, square_C1s) @@ -931,7 +958,7 @@ def test_P_NTU_method_backwards(): def test_Pp(): - from ht.hx import Pp, Pc + from ht.hx import Pc, Pp # randomly chosen test value ans = Pp(5, .4) assert_close(ans, 0.713634370024604) @@ -1717,8 +1744,8 @@ def test_L_unsupported_max(): # Terribly pessimistic assert_close(L_unsupported_max(Do=10, material='CS'), 3.175) - - + + def test_issue_6(): at_error = P_NTU_method(m1=3, m2=3, Cp1=1860., Cp2=1860, subtype='counterflow', Ntp=4, T2i=15, T1i=130, UA=3041.75) @@ -1726,7 +1753,7 @@ def test_issue_6(): subtype='counterflow', Ntp=4, T2i=15, T1i=130, UA=3041.75) for k, v in at_error.items(): assert_close(v, before_error[k], rtol=1e-8) - + Flowh = 5 Flowc = 5 Cph = 4000 diff --git a/tests/test_numba.py b/tests/test_numba.py index 0eeaddd..af24d53 100644 --- a/tests/test_numba.py +++ b/tests/test_numba.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2020, 2021, 2022 Caleb Bell @@ -18,23 +17,27 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division +import pytest from fluids import AirCooledExchanger -from ht import Nu_external_horizontal_plate_methods, h_Ganguli_VDI -import ht.vectorized from fluids.constants import foot, inch from fluids.numerics import assert_close -import pytest + +import ht.vectorized +from ht import Nu_external_horizontal_plate_methods, h_Ganguli_VDI + try: import numba + import ht.numba import ht.numba_vectorized except: numba = None import numpy as np + def mark_as_numba(func): func = pytest.mark.numba(func) # func = pytest.mark.slow(func) @@ -438,4 +441,4 @@ def test_conv_plate(): assert_close(ht.numba.Nu_plate_Kumar(**kwargs), ht.Nu_plate_Kumar(**kwargs)) kwargs = dict(Re=2000, Pr=.7, chevron_angle=30.0) - assert_close(ht.numba.Nu_plate_Martin(**kwargs), ht.Nu_plate_Martin(**kwargs)) \ No newline at end of file + assert_close(ht.numba.Nu_plate_Martin(**kwargs), ht.Nu_plate_Martin(**kwargs)) diff --git a/tests/test_radiation.py b/tests/test_radiation.py index 23906d3..cb34bab 100644 --- a/tests/test_radiation.py +++ b/tests/test_radiation.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2016, 2017 Caleb Bell @@ -18,14 +17,15 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division -from ht import blackbody_spectral_radiance, grey_transmittance, q_rad, solar_spectrum import numpy as np import pytest from fluids.numerics import assert_close, assert_close1d +from ht import blackbody_spectral_radiance, grey_transmittance, q_rad, solar_spectrum + def test_radiation(): assert_close(q_rad(1., 400), 1451.613952, rtol=1e-05) @@ -49,4 +49,4 @@ def test_solar_spectrum(): def test_grey_transmittance(): tau = grey_transmittance(3.8e-4, molar_density=55300, length=1e-2) - assert_close(tau, 0.8104707721191062) \ No newline at end of file + assert_close(tau, 0.8104707721191062) diff --git a/tests/test_units.py b/tests/test_units.py index 52462d5..71e077a 100644 --- a/tests/test_units.py +++ b/tests/test_units.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2017 Caleb Bell @@ -18,17 +17,18 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division import types -from fluids.numerics import assert_close + import pytest +from fluids.numerics import assert_close + import ht from ht.units import P_NTU_method, R_to_k, R_value_to_k, effectiveness_NTU_method, k_to_R_value, u - def assert_pint_allclose(value, magnitude, units, rtol=1e-7): assert_close(value.to_base_units().magnitude, magnitude, rtol=rtol) assert dict(value.dimensionality) == units @@ -99,7 +99,7 @@ def test_custom_wraps(): def test_check_signatures(): from fluids.units import check_args_order - bad_names = set(['__getattr__']) + bad_names = {'__getattr__'} for name in dir(ht): if name in bad_names: continue diff --git a/tests/test_vectorized.py b/tests/test_vectorized.py index 0768d58..3319673 100644 --- a/tests/test_vectorized.py +++ b/tests/test_vectorized.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- '''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. Copyright (C) 2017 Caleb Bell @@ -18,10 +17,11 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.''' +SOFTWARE. +''' -from __future__ import division from fluids.numerics import assert_close1d + import ht import ht.vectorized