Skip to content

Commit

Permalink
fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
benranderson committed Mar 4, 2018
2 parents 3fcd7da + 74812b8 commit 2670ab1
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 71 deletions.
2 changes: 1 addition & 1 deletion wallthick/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@click.command()
@click.argument('inputs', type=click.File('rb'))
def main(inputs):
'''Console script for wallthick.'''
"""Console script for wallthick."""
data = json.load(inputs)
if all(param in data for param in req_inputs):
click.secho(
Expand Down
189 changes: 119 additions & 70 deletions wallthick/pd8010.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,103 +16,132 @@


def internal_pressure(P_d, P_h):
"""Returns internal pressure [Pa] due to combined design pressure and
pressure head.
:param P_d: Design pressure [Pa]
:param P_h: Pressure head [Pa]
"""
return P_d + P_h


def water_depths(h, H_t, H):
"""Returns minimum and maximum water depths [m] as a tuple.
:param h: Water depth [m]
:param H_t: Tide [m]
:param H: Wave height [m]
"""
d_min = h - (H/2)
d_max = h + H_t + (H/2)
return d_min, d_max


def external_pressure(rho, g, d):
"""Returns external pressure [Pa] at water depth.
:param rho: Water density [kg/m^2]
:param g: Acceleration of gravity [m/s^2]
:param d: Water depth [m]
"""
return rho * g * d


def hoop_pressure_thin(t, D_o, P_o, sig):
"""
Number [Pa], Number [Pa], Number [m], Number [Pa] -> Number [m]
Returns the internal pressure that induces a stress, sig, in a thin
"""Returns the internal pressure [Pa] that induces a stress, sig, in a thin
wall pipe of thickness t.
Equation (3)
PD 8010-2 Equation (3)
:param t: Wall thickness [m]
:param D_o: Outside diameter [m]
:param P_o: External pressure [Pa]
:param sig: Minimum yield strength [Pa]
"""
return ((sig * 2 * t) / D_o) + P_o


def hoop_pressure_thick(t, D_o, P_o, sig):
"""
Number [Pa], Number [Pa], Number [m], Number [Pa] -> Number [m]
Returns the internal pressure that induces a stress, sig, in a thick
"""Returns the internal pressure [Pa] that induces a stress, sig, in a thick
walled pipe of thickness t.
Equation (5)
PD 8010-2 Equation (5)
:param t: Wall thickness [m]
:param D_o: Outside diameter [m]
:param P_o: External pressure [Pa]
:param sig: Minimum yield strength [Pa]
"""
return ((sig * (D_o**2 - (D_o - 2 * t)**2)) / (D_o**2 + (D_o - 2 * t)**2)) + P_o


def hoop_thickness_thin(P_i, P_o, D_o, sig_y_d):
"""
Number [Pa], Number [Pa], Number [m], Number [Pa] -> Number [m]
"""Returns the minimum wall thickness [m] for internal pressure containment
for a thin walled pipe.
Returns the minimum wall thickness for internal pressure containment for a
thin walled pipe.
PD 8010-2 Equation (3)
Equation (3)
:param P_i: Internal pressure [Pa]
:param P_o: External pressure [Pa]
:param D_o: Outside diameter [m]
:param sig_y_d: Minimum yield strength [Pa]
"""
return abs(P_i - P_o) * D_o / (2 * n_s * sig_y_d)


def hoop_thickness_thick(P_i, P_o, D_o, sig_y_d):
"""
Number [Pa], Number [Pa], Number [m], Number [Pa] -> Number [m]
"""Returns the minimum wall thickness [m] for internal pressure containment
for a thick walled pipe.
Returns the minimum wall thickness for internal pressure containment for a
thick walled pipe.
PD 8010-2 Equation (5)
Equation (5)
:param P_i: Internal pressure [Pa]
:param P_o: External pressure [Pa]
:param D_o: Outside diameter [m]
:param sig_y_d: Minimum yield strength [Pa]
"""
eq = math.sqrt((((n_s*sig_y_d - abs(P_i - P_o))) * D_o**2) /
(n_s*sig_y_d + abs(P_i - P_o)))
return 0.5 * (D_o - eq)


def hoop_thickness(P_i, P_o_min, D_o, sig_y_d):
"""
Number [Pa], Number [Pa], Number [m], Number [Pa] -> Number [m]
Returns the minimum (note not nominal) wall thickness for internal pressure
containment.
def hoop_thickness(P_i, P_o, D_o, sig_y_d):
"""Returns the minimum (note not nominal) wall thickness [m] for internal
pressure containment.
Considers:
- Allowable hoop stress
- Worst case maximum pressure difference
- Appropriate wall thickness theory, i.e. thick or thin
:param P_i: Internal pressure [Pa]
:param P_o: External pressure [Pa]
:param D_o: Outside diameter [m]
:param sig_y_d: Minimum yield strength [Pa]
"""
t_min_thin = hoop_thickness_thin(P_i, P_o_min, D_o, sig_y_d)
t_min_thin = hoop_thickness_thin(P_i, P_o, D_o, sig_y_d)

# Select appropriate wall theory based on minimum thin wall thickness
if D_o / t_min_thin > 20:
t_min = t_min_thin
else:
t_min = hoop_thickness_thick(P_i, P_o_min, D_o, sig_y_d)
t_min = hoop_thickness_thick(P_i, P_o, D_o, sig_y_d)

return t_min


def req_thickness(t_min, t_corr, f_tol):
'''
Number [m], Number [m], Number [-] -> Number [m]
Returns the required wall thickness based on the following mechanical
"""Returns the required wall thickness [m] based on the following mechanical
allowances:
- Corrosion allowance
- Fabrication tolerance
Exrapolated from Equation (4)
'''
Extrapolated from Equation (4)
:param t_min: Minimum wall thickness [m]
:param t_corr: Corrosion allowance [m]
:param f_tol: Fabrication tolerance [m]
"""
try:
return (t_min + t_corr) / (1 - f_tol)
except ZeroDivisionError:
Expand All @@ -125,47 +154,47 @@ def req_thickness(t_min, t_corr, f_tol):


def collapse_thickness(P_o, sig_y_d, E, v, D_o, f_0):
"""
Number [Pa], Number [Pa], Number [Pa], Number [-], Number [m], Number [-]
-> Number [m]
Returns the nominal wall thickness for local buckling due to external
"""Returns the nominal wall thickness [m] for local buckling due to external
pressure.
Considers the worst case maximum external over pressure, i.e.:
- Minimum internal pressure (zero)
- Maximum external pressure (at water depth, d)
(Clause G.1.2)
PD 8010-2 Clause G.1.2
:param P_o: External pressure [Pa]
:param sig_y_d: Minimum yield strength [Pa]
:param E: Young's modulus [Pa]
:param v: Poisson's ratio [-]
:param D_o: Outside diameter [m]
:param f_0: Initial ovalisation [%]
"""

def P_e(t):
"""
Number [m] -> Number [Pa]
"""Returns the critical pressure [Pa] for an elastic critical tube.
Returns the critical pressure for an elastic critical tube.
PD 8010-2 Section G.2
Equation (G.2)
:param t: Wall thickness [m]
"""
return 2 * E / (1 - v**2) * (t / D_o)**3

def P_y(t):
"""
Number [m] -> Number [Pa]
"""Returns the yield pressure [Pa].
Returns the yield pressure.
PD 8010-2 Equation (G.3)
Equation (G.3)
:param t: Wall thickness [m]
"""
return 2 * sig_y_d * (t / D_o)

def char_resist(t):
"""
Number [m] -> Number [Pa]
"""Returns the characteristic resistance [m] for external pressure.
Returns the characteristic resistance for external pressure
PD 8010-2 Equation (G.1)
Equation (G.1)
:param t: Wall thickness [m]
"""
term_1 = ((P_o / P_e(t)) - 1)
term_2 = ((P_o / P_y(t))**2 - 1)
Expand All @@ -179,15 +208,15 @@ def char_resist(t):


def buckle_thickness(D_o, P_p, sig_y):
"""
Number [m], Number [Pa], Number [Pa] -> Number [m]
Returns the nominal buckle thickness based on the propagation pressure.
"""Returns the nominal buckle thickness [m] based on the propagation
pressure. Considers the worst case maximum external pressure and ignores
internal pressure.
Considers the worst case maximum external pressure and ignores internal
pressure.
PD 8010-2 Equation (G.21)
Equation (G.21)
:param D_o: Outside diameter [m]
:param P_p: Propagation pressure [Pa]
:param sig_y: Minimum yield strength [Pa]
"""
return D_o * (P_p / (10.7 * sig_y))**(4 / 9)

Expand All @@ -197,17 +226,21 @@ def buckle_thickness(D_o, P_p, sig_y):


def strength_test_pressure(t_sel, f_tol, sig_y, D_o, P_d, P_o, P_h):
"""
InputData -> Number [Pa]
Returns the strength test pressure, i.e. the minimum of:
"""Returns the strength test pressure, i.e. the minimum of:
- 1.5 * design pressure:
Note that hydrostatic head is not multiplied by 1.5 (interpreted by
last paragraph of Section 11.5.2)
- the pressure that induces a hoop stress of 90 percent SMYS at nominal
wall thickness.
(Section 11.5.1, Ref.1)
PD 8010-2 Section 11.5.1, Ref.1
:param t_sel: Selected wall thickness [m]
:param f_tol: fabrication tolerance [m]
:param sig_y: Minimum yield strength [Pa]
:param D_o: Outside diameter [m]
:param P_d: Design pressure [Pa]
:param P_h: Pressure head [Pa]
"""

# Determine nominal wall thickness (no corrosion)
Expand All @@ -229,7 +262,11 @@ def strength_test_pressure(t_sel, f_tol, sig_y, D_o, P_d, P_o, P_h):
return min(P_hoop, P_test)


class Pd8010(object):
class Pd8010:
"""PD8010-2 Wall thickness analysis class.
:param data: Input data dictionary
"""

def __init__(self, data):
self.t_sel = data['t_sel']
Expand All @@ -253,16 +290,23 @@ def __init__(self, data):

@property
def t_h(self):
"""Nominal wall thickness [m] to satisfy the internal pressure (hoop)
criterion.
"""
P_i = internal_pressure(self.P_d, self.P_h)
# min water depth
d, _ = water_depths(self.h, self.H_t, self.H)
P_o = external_pressure(self.rho_w, self.g, d)
# minimum wall thickness
t_h_min = hoop_thickness(P_i, P_o, self.D_o, self.sig_y_d)
# nominal wall thickness
return req_thickness(t_h_min, self.t_corr, self.f_tol)

@property
def t_c(self):
P_i = internal_pressure(self.P_d, self.P_h)
"""Nominal wall thickness [m] to satisfy the hydrostatic collapse
criterion.
"""
# max water depth
_, d = water_depths(self.h, self.H_t, self.H)
# include safety factor
Expand All @@ -272,6 +316,9 @@ def t_c(self):

@property
def t_b(self):
"""Nominal wall thickness [m] to satisfy the local buckle propagation
criterion.
"""
# max water depth
_, d = water_depths(self.h, self.H_t, self.H)
# propagation pressure equal to max external pressure
Expand All @@ -280,7 +327,10 @@ def t_b(self):

@property
def P_st(self):
''' Strength test pressure '''
"""Strength test pressure [Pa].
PD 8010-2 Section 11.5.2
"""
# min water depth
d, _ = water_depths(self.h, self.H_t, self.H)
P_o = external_pressure(self.rho_w, self.g, d)
Expand All @@ -289,9 +339,8 @@ def P_st(self):

@property
def P_lt(self):
"""
Return leak test pressure: 1.1 * MAOP (design pressure) at LAT
"""Leak test pressure [Pa] at LAT.
Section 11.5.3
PD 8010-2 Section 11.5.3
"""
return 1.1 * self.P_d

0 comments on commit 2670ab1

Please sign in to comment.