Skip to content

Commit

Permalink
Rerun CI
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebBell committed Oct 18, 2024
1 parent 354809e commit 8478d66
Show file tree
Hide file tree
Showing 9 changed files with 508 additions and 35 deletions.
449 changes: 449 additions & 0 deletions docs/Data/Pipe Schedules.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"output_type": "stream",
"text": [
"Density = 11.98501086830739 kilogram / meter ** 3\n",
"Viscosity = 2.6514617050585653e-05 pascal * second\n"
"Viscosity = 2.6514617050585646e-05 pascal * second\n"
]
}
],
Expand Down Expand Up @@ -62,12 +62,12 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Crane elbow term = 0.63; calculated = 0.605916144054614 dimensionless\n",
"Crane globe valve term = 1.44; calculated = 7.971314885893425 dimensionless\n",
"Crane gate valve term = 1.22; calculated = 1.1715215649427928 dimensionless\n",
"Crane friction term = 12.3; calculated = 12.522683061833046 dimensionless\n",
"Darcy friction factor = 0.01527349910774904 dimensionless\n",
"Pressure drop = 405252.21811837837 pascal\n"
"Crane elbow term = 0.63; calculated = 0.6059161440546141 dimensionless\n",
"Crane globe valve term = 1.44; calculated = 7.971314885893429 dimensionless\n",
"Crane gate valve term = 1.22; calculated = 1.171521564942793 dimensionless\n",
"Crane friction term = 12.3; calculated = 12.522683061833051 dimensionless\n",
"Darcy friction factor = 0.015273499107749047 dimensionless\n",
"Pressure drop = 405252.2181183786 pascal\n"
]
}
],
Expand Down
16 changes: 1 addition & 15 deletions docs/Samples/Tank.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -684,22 +684,8 @@
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
"name": "python"
}
},
"nbformat": 4,
Expand Down
12 changes: 8 additions & 4 deletions fluids/fittings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2895,14 +2895,18 @@ def diffuser_conical(Di1, Di2, l=None, angle=None, fd=None, Re=None,
if Re is None:
raise ValueError("Method `Hooper` requires Reynolds number")
if Re < 4000.0:
return 2.0*(1.0 - beta*beta*beta*beta) # Not the same formula as Rennels
K_sharp = 2.0*(1.0 - beta*beta*beta*beta) # Not the same formula as Rennels
if angle_rad > 0.25*pi:
return K_sharp
return K_sharp*2.6*sin(0.5*angle_rad)

if fd is None:
fd = Clamond(Re=Re, eD=roughness/Di1)
x = 1.0 - beta*beta
K = (1.0 + 0.8*fd)*x*x
K_sharp = (1.0 + 0.8*fd)*x*x
if angle_rad > 0.25*pi:
return K
return K*2.6*sin(0.5*angle_rad)
return K_sharp
return K_sharp*2.6*sin(0.5*angle_rad)
else:
raise ValueError(diffuser_conical_method_unknown)

Expand Down
6 changes: 3 additions & 3 deletions fluids/friction.py
Original file line number Diff line number Diff line change
Expand Up @@ -3457,7 +3457,7 @@ def friction_plate_Martin_VDI(Re, chevron_angle):
Chevron-style plate heat exchanger according to [1]_.
.. math::
\frac{1}{\sqrt{f_d}} = \frac{\cos \phi}{\sqrt{0.28\tan\phi
\frac{1}{\sqrt{f_d}} = \frac{\cos \phi}{\sqrt{0.18\tan\phi
+ 0.36\sin\phi + f_0/\cos(\phi)}} + \frac{1-\cos\phi}{\sqrt{3.8f_1}}
.. math::
Expand Down Expand Up @@ -3515,7 +3515,7 @@ def friction_plate_Martin_VDI(Re, chevron_angle):
Examples
--------
>>> friction_plate_Martin_VDI(Re=20000, chevron_angle=45)
0.93076451142552
0.781589041624
References
----------
Expand All @@ -3531,7 +3531,7 @@ def friction_plate_Martin_VDI(Re, chevron_angle):
f0 = (1.8*log10(Re) - 1.5)**-2
f1 = 39.*Re**-0.289

a, b, c = 3.8, 0.28, 0.36
a, b, c = 3.8, 0.18, 0.36

rhs = cos(phi)*1.0/sqrt(b*tan(phi) + c*sin(phi) + f0/cos(phi))
rhs += (1. - cos(phi))*1.0/sqrt(a*f1)
Expand Down
9 changes: 6 additions & 3 deletions fluids/numerics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,10 +970,11 @@ def hessian(f, x0, scalar=True, perturbation=1e-9, zero_offset=1e-7, full=True,

fs_perturb_i = []
for i in range(nx):
tmp = x_perturb[i]
x_perturb[i] += deltas[i]
f_perturb_i = f(x_perturb, *args, **kwargs)
fs_perturb_i.append(f_perturb_i)
x_perturb[i] -= deltas[i]
x_perturb[i] = tmp # specifically set the same value back - floating point prec can't add and subtract to get the exact same value always

if full:
hessian = [[None]*nx for _ in range(nx)]
Expand All @@ -984,10 +985,12 @@ def hessian(f, x0, scalar=True, perturbation=1e-9, zero_offset=1e-7, full=True,
if not full:
row = []
f_perturb_i = fs_perturb_i[i]
tmp_i = x_perturb[i]
x_perturb[i] += deltas[i]

for j in range(i+1):
f_perturb_j = fs_perturb_i[j]
tmp_j = x_perturb[j]
x_perturb[j] += deltas[j]
f_perturb_ij = f(x_perturb, *args, **kwargs)

Expand All @@ -1008,10 +1011,10 @@ def hessian(f, x0, scalar=True, perturbation=1e-9, zero_offset=1e-7, full=True,
else:
hessian[i][j] = hessian[j][i] = dij

x_perturb[j] -= deltas[j]
x_perturb[j] = tmp_j
if not full:
hessian.append(row)
x_perturb[i] -= deltas[i]
x_perturb[i] = tmp_i
return hessian


Expand Down
23 changes: 23 additions & 0 deletions fluids/piping.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,24 @@
SDR325i_F2619IPS = [107.2896, 132.6134, 157.9118, 205.613, 256.2352, 303.9364, 333.7052, 381.4064, 429.0568, 476.758, 524.4084, 572.1096, 619.76, 667.4104, 715.1116, 762.762, 810.4632, 858.1136, 1001.1664, 1144.1684, 1287.1704, 1501.7496, 1549.4]
SDR325i_F2619SI = [107.28, 132.6, 157.92, 205.62, 256.23, 303.93, 333.7, 381.4, 429.06, 476.76, 524.4, 572.1, 619.76, 667.42, 715.12, 762.76, 810.46, 858.12, 1001.16, 1144.16, 1287.18, 1501.76, 1549.4]

# BS-1387 Light Class. Max diameters used from the standard.
DN_LIGHT_BS1387 = [8, 10, 15, 20, 25, 32, 40, 50, 65, 80, 100]
LIGHTo_BS1387 = [13.6, 17.1, 21.4, 26.9, 33.8, 42.5, 48.4, 60.2, 76, 88.7, 113.9]
LIGHTi_BS1387 = [10, 13.5, 17.4, 22.3, 28.6, 37.3, 42.6, 54.4, 69.6, 82.3, 106.7]
LIGHTt_BS1387 = [1.8, 1.8, 2, 2.3, 2.6, 2.6, 2.9, 2.9, 3.2, 3.2, 3.6]

# BS-1387 Medium Class
DN_MEDIUM_BS1387 = [8, 10, 15, 20, 25, 32, 40, 50, 65, 80, 100, 125, 150]
MEDIUMo_BS1387 = [13.9, 17.4, 21.7, 27.2, 34.2, 42.9, 48.8, 60.8, 76.6, 89.5, 114.9, 140.6, 166.1]
MEDIUMi_BS1387 = [9.3, 12.8, 16.5, 22, 27.8, 36.5, 42.4, 53.6, 69.4, 81.5, 105.9, 130.6, 156.1]
MEDIUMt_BS1387 = [2.3, 2.3, 2.6, 2.6, 3.2, 3.2, 3.2, 3.6, 3.6, 4, 4.5, 5, 5]

# BS-1387 Heavy Class
DN_HEAVY_BS1387 = [8, 10, 15, 20, 25, 32, 40, 50, 65, 80, 100, 125, 150]
HEAVYo_BS1387 = [13.9, 17.4, 21.7, 27.2, 34.2, 42.9, 48.8, 60.8, 76.6, 89.5, 114.9, 140.6, 166.1]
HEAVYi_BS1387 = [8.1, 11.6, 15.3, 20.8, 26.2, 34.9, 40.8, 51.8, 67.6, 79.5, 104.1, 129.8, 155.3]
HEAVYt_BS1387 = [2.9, 2.9, 3.2, 3.2, 4, 4, 4, 4.5, 4.5, 5, 5.4, 5.4, 5.4]

schedule_lookup = { '40': (NPS40, S40i, S40o, S40t),
'5': (NPS5, S5i, S5o, S5t),
'10': (NPS10, S10i, S10o, S10t),
Expand Down Expand Up @@ -568,6 +586,10 @@
'DR9F2619IPS': (NPSDR9_F2619, SDR9i_F2619IPS, SDR9o_F2619IPS, SDR9t_F2619IPS),
'DR73F2619IPS': (NPSDR73_F2619, SDR73i_F2619IPS, SDR73o_F2619IPS, SDR73t_F2619IPS),
'DR7F2619IPS': (NPSDR7_F2619, SDR7i_F2619IPS, SDR7o_F2619IPS, SDR7t_F2619IPS),

'BS1387LIGHT': (DN_LIGHT_BS1387, LIGHTi_BS1387, LIGHTo_BS1387, LIGHTt_BS1387),
'BS1387MEDIUM': (DN_MEDIUM_BS1387, MEDIUMi_BS1387, MEDIUMo_BS1387, MEDIUMt_BS1387),
'BS1387HEAVY': (DN_HEAVY_BS1387, HEAVYi_BS1387, HEAVYo_BS1387, HEAVYt_BS1387),
}

def Di_lookup(Di, NPSes, Dis, Dos, ts):
Expand Down Expand Up @@ -624,6 +646,7 @@ def nearest_pipe(Do=None, Di=None, NPS=None, schedule='40'):
'S40F441IPS', 'S80F441IPS', 'S40F441SI', 'S80F441SI'
'DR325F2619SI', 'DR26F2619SI', 'DR21F2619SI', 'DR17F2619SI', 'DR135F2619SI', 'DR11F2619SI', 'DR9F2619SI', 'DR73F2619SI', 'DR7F2619SI',
'DR325F2619IPS', 'DR26F2619IPS', 'DR21F2619IPS', 'DR17F2619IPS', 'DR135F2619IPS', 'DR11F2619IPS', 'DR9F2619IPS', 'DR73F2619IPS', 'DR7F2619IPS',
'BS1387LIGHT', 'BS1387MEDIUM', 'BS1387HEAVY'
Parameters
----------
Expand Down
10 changes: 9 additions & 1 deletion tests/test_fittings.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,15 @@ def test_diffuser_conical():
assert_close(K, 0.26814269611625413)

K = diffuser_conical(Di1=1/3., Di2=1.0, angle=15.0, Re=100, method='Hooper')
assert_close(K, 1.9753086419753085)
assert_close(K, 0.6703567402906352)

K = diffuser_conical(Di1=1/3., Di2=1.0, angle=50.0, Re=1e6, method='Hooper')
assert_close(K, 0.79748427282836)

# The two equations don't actually converge, there may be a case for interpolating here in the future
# to produce smooth results
assert_close(diffuser_conical(Di1=1/3., Di2=1.0, angle=45*(1+1e-13), Re=1e6, method='Hooper'),
diffuser_conical(Di1=1/3., Di2=1.0, angle=45*(1-1e-13), Re=1e6, method='Hooper'), rtol=1e-2)

with pytest.raises(Exception):
diffuser_conical(Di1=1/3., Di2=1.0, angle=15.0, method='Hooper')
Expand Down
4 changes: 2 additions & 2 deletions tests/test_friction.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,10 @@ def test_friction_plate():
assert_close(fd, 0.8346709330530173)

fd = friction_plate_Martin_VDI(Re=20000., chevron_angle=45)
assert_close(fd, 0.93076451142552)
assert_close(fd, 0.7815890416247431)

fd = friction_plate_Martin_VDI(Re=1999., chevron_angle=45)
assert_close(fd, 0.9952660732533454)
assert_close(fd, 0.8346777166415049)

fd = friction_plate_Muley_Manglik(Re=2000., chevron_angle=45., plate_enlargement_factor=1.2)
assert_close(fd, 1.0880870804075413)
Expand Down

0 comments on commit 8478d66

Please sign in to comment.