Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebBell committed Jun 20, 2023
1 parent 46fb1b4 commit 90e0a74
Show file tree
Hide file tree
Showing 30 changed files with 414 additions and 257 deletions.
3 changes: 2 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import platform
import sys

is_pypy = 'PyPy' in sys.version

def pytest_ignore_collect(path):
Expand Down
12 changes: 7 additions & 5 deletions dev/prerelease.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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__)))
Expand All @@ -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)
Expand All @@ -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"])
22 changes: 11 additions & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -59,12 +58,12 @@
'sphinxcontrib.katex',
'sphinx_sitemap',
]
#
#

katex_css_path = \
'https://cdn.jsdelivr.net/npm/[email protected]/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/'
Expand All @@ -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
Expand All @@ -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__
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions docs/plots/Nu_external_cylinder.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)')
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
'''Chemical Engineering Design Library (ChEDL). Utilities for process modeling.
Copyright (C) 2016, Caleb Bell <[email protected]>
Expand All @@ -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

Expand Down
5 changes: 2 additions & 3 deletions tests/make_test_stubs.py
Original file line number Diff line number Diff line change
@@ -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']
Expand All @@ -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')
Expand Down
7 changes: 4 additions & 3 deletions tests/manual_runner.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]

Expand Down
31 changes: 20 additions & 11 deletions tests/test_air_cooler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
'''Chemical Engineering Design Library (ChEDL). Utilities for process modeling.
Copyright (C) 2016, 2017, 2018, 2019, Caleb Bell <[email protected]>
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
27 changes: 13 additions & 14 deletions tests/test_boiling_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
'''Chemical Engineering Design Library (ChEDL). Utilities for process modeling.
Copyright (C) 2016, 2017, 2018, 2019, Caleb Bell <[email protected]>
Expand All @@ -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():
Expand All @@ -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:
Expand All @@ -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():
Expand All @@ -61,15 +60,15 @@ 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:
>>> from sympy import *
>>> 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)
Expand All @@ -85,15 +84,15 @@ 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:
>>> from sympy import *
>>> 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)
Expand All @@ -120,15 +119,15 @@ 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:
>>> from sympy import *
>>> 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)
Expand Down
Loading

0 comments on commit 90e0a74

Please sign in to comment.