Skip to content

Instantly share code, notes, and snippets.

@flare9x
Last active May 5, 2019 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flare9x/5ceff31e8db08433f406ed9628937ac9 to your computer and use it in GitHub Desktop.
Save flare9x/5ceff31e8db08433f406ed9628937ac9 to your computer and use it in GitHub Desktop.
First Pass B31.3 Pressure Tmin and API 574 Structural Tmin Assessment
# Step 1 - Calculate B31.3 Pressure Tmin
# Step 2 - Obtain API 574 Structural Tmin From Table 7
# Step 3 - Calculate remaining wall thickness at the area of interest
# Step 4 - Check that the remaining wall thickness is above pressure and/or structural tmin
# Step 5 - Assess how much corrosion allowance has been lost / how much remains
# Step 1 - Calculate B31.3 Pressure Tmin
# ASME B31.3 - 304.1.2 Straight Pipe Under Internal Pressure
P = 2220 # Shell specification D, Design Pressure 2220psig @ 100F
D = 2.375 # Outside Diameter
Y = .4 # Values of Coefficient Y for t < D/6 Table 304.1.1
E = 1.0 # Weld joint efficiency, 1.0 seamless
W = 1.0 # Weld Joint Strength Reduction Factor, W, Table 302.3.5
S = 20000 # ASTM A106 Grade B, Seamless @100F
c = 0.05 # Shell specification D, Corrosion allowance
t = (P * D) / (2*((S * E * W) + (P * Y)))
t = 0.126
tm = t + c # Note t = exclusive of corrosion allowance while tm is inclusive of corrosion allowance
tm = 0.176
# Check that the tmin calculation can be applied
if t < D/6
print("Pressure design calculation 304.1.2 (3a) applies")
else
print("Pressure design calculation 304.1.2 (3a) doesnt apply")
end
"Pressure design calculation 304.1.2 (3a) applies"
# Step 2 - Obtain API 574 Structural Tmin From Table 7
Tstructural = 0.07 # API 574 - Table 7—Minimum Thicknesses for Carbon and Low-alloy Steel Pipe
# Step 3 - Calculate remaining wall thickness at the area of interest
# External Wall Loss Assessment
UT_adjacent = .218
Pit_d = .050 # Pit Depth (As measured with pit gauge, bare metal pipe to bottom of pit)
Rwt = UT_adjacent - Pit_d # Remaining Wall Thickness = (Tnominal - Pit)
# Step 4 - Check that the remaining wall thickness is above pressure and/or structural tmin
if (Rwt < t) # Check if remaining wall thickness is below pressure tmin
print(" Fail - Remaining Wall Thickness is Below Pressure Design Thickness")
elseif (Rwt > t) && (Rwt < Tstructural) # Check if remaining wall thickness is above pressure tmin and below structural tmin
print("Fail - Remaining Wall Thickness is Above Pressure Design Thickness But Below Structural Minimum Thickness")
elseif (Rwt > t) && (Rwt > Tstructural) # Check if remaining wall thickness is above pressure tmin and structural tmin
print("Pass - Remaining Wall Thickness is Above Pressure Design Thickness And Above Structural Minimum Thickness")
end
"Pass - Remaining Wall Thickness is Above Pressure Design Thickness And Above Structural Minimum Thickness"
# Step 5 - Assess how much corrosion allowance has been lost / how much remains
# Determine how much CA is left
CA_lost = Rwt - tm
CA_remain = Rwt - t
# Check what % of corrosion allowance has been lost
if (CA_lost < 0) # If its negative value
CA_lost_perc = (CA_lost / c)*100
print("The % of corroson allowance lost = ",CA_lost_perc,"\nThe remaining corrosion allowance = ",CA_remain)
elseif (CA_lost >=0)
print("100% of the corrosion allowance is intact")
end
"The % of corroson allowance lost = -16.00"
"The remaining corrosion allowance = 0.04199999999999998"
# Estimate time to tmin based on spectrum of rates
CR_rates = [0.005,.01,.015,.02]
time_to_tmin = zero(CR_rates) # Initialize output
for i in 1:length(CR_rates)
time_to_tmin[i] = CA_remain / CR_rates[i]
end
Aggressive = CA_remain / 0.02
Aggressive = 1.08
time_to_tmin = DataFrame(time_to_tmin)
colnames = CR_rates
names!(time_to_tmin, Symbol.(colnames))
print(time_to_tmin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment