<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Analysis of Sealing Potential of Liner Captured Between Aluminum Rings Via Shrink Fit.
First Objective
Step1:  ASME Pressure Vessel Code Equations
This code was developed for flat gaskets compressed between flanges. There are two equations, both give a value for the total bolt force needed to compress a gasket such that a seal is achieved at working pressure. Whichever equation gives a greater load for a specific design application is the one to be used. The following are the equations as they appear in Gaskets. Design, Selection, and Testing by Daniel E. Czernik
Step2:  Change in Liner Thickness Necessary to Achieve Seating Stress
The radial stress due to the compression of the liner follows Hooke's Law
Step3:  To know if this can be achieved, we must examine how much we can actually shrink the end cap, and whether or not that will allow enough clearance to fit the end cap into place before expansion. 
Maximum Thermal Contraction of End Cap
Thermal expansion/contraction can be thought of as a scaling of the position vectors of all the points in a body of uniform composition relative to its centroid. The thermal change in radius of the end cap is thus given by the following linear thermal expansion relationship
Step4:  Clearance for the End Cap
The above number does not account for some clearance to allow the end cap to slide into the liner. According to Engineer's Toolbox, a 3" diameter hole needs a minumum of 0.0025" of clearance to allow a shaft through with a free fit. This means that 0.00125" must be subtracted from the interference shrink fit to arrive at an achievable change in liner thickness due to shrink fitting. Thus
Step5:  The necessary change in liner thickness is less than the achievable change in liner thickness.  
Acording to the ASME pressure vessel code, the seal we need is achievable. However, the thermal contraction in the liner and the gap between aluminum rings that captures the liner, as well as the enormous change in yield strength and elastic modulus for PTFE when going to cryogenic temperatures may pose a problem. To be thorough, let's take a look at the liner stress under cryogenic conditions.
Pressure Exerted on Liner at Cryogenic Temperature
The liner will contract at cryogenic temperature, which will serve to reduce its stress due to the shrink fit, while the increase in elastic modulus at that temperature will increase its stress. This means that the liner will have a different stress state one once the tank is filled with LN2. The liner thickness at cryogenic temperature is
Step6:  Although the load on the PTFE at cryogenic temperature is greater, the yield strength of the PTFE is much greater at 19000 psi. The ratio of load to yield strength at ambient temperature is then much higher than the ratio at cryogenic temperature. We do have a value to use for seating stress of cryogenic PTFE, so we must either trust the ASME code for our extreme temperature conditions, or imperically test for the seating stress, which we do not have time to do before this project is terminated. 
Can We Use the Excess Space Allowed By the Thermal Contraction of the End Cap to Hold It In Place, and Dispense With the Bolts?
Right now the contact surface between the two aluminum parts is a cylidrical surface with a nominal diameter of 3 inches, and a height of 0.125 inches. Engineering Toolbox gives an aluminum-aluminum coefficient of friction of approximately 1.2 for clean, dry surfaces. This allows us to find the necessary pressure to secure the end cap in place using the shrink fit only and a factor of safety of 2.
$$A_{contact} = 2\pi rh$$
The normal force caused by the shrink fit is the product of the shrink fit contact pressure and contact area
<ASSISTANT_TASK:>
Python Code:
# Import packages here:
import math as m
import numpy as np
from IPython.display import Image
import matplotlib.pyplot as plt
# Properties of Materials (engineeringtoolbox.com, Cengel, Tian, DuPont, http://www.dtic.mil/dtic/tr/fulltext/u2/438718.pdf)
# Coefficient of Thermal Expansion
alphaAluminum = 0.0000131  # in/in/*F
alphaPTFE = 0.0000478  # in/in/*F (over the range in question)
# Elastic Moduli
EAluminum = 10000000  # psi
EAluminumCryo = 11000000  # psi
EPTFE = 40000  # psi
EPTFECryo = 500000  # psi
# Yield Strength
sigmaY_PTFE = 1300  # psi
sigmaY_PTFECryo = 19000  # psi
# Poisson's Ratio
nuAluminum = 0.33  # in/in
nuPTFE = 0.46  # in/in
# Temperature Change Between Ambient and LN2  
DeltaT = 389  # *F
# Geometry of Parts
# Main Ring Outer Radius
roMain = 2.0000  # in
# End Cap Inner Radius
riCap = 1.3750  # in
# Interfacial Radius
r = 1.5000  # in
# Liner Thickness
t = 0.125  # in
Explanation: Analysis of Sealing Potential of Liner Captured Between Aluminum Rings Via Shrink Fit.
First Objective:
Determine how much pressure will be placed on the liner at both room and cryogenic temperatures, based on the aluminum outer ring's inner diameter, an aluminum end cap's outer diameter, and the thickness of the PTFE liner. Compare this to the strength of the PTFE material at each of these temperatures.
Second Objective:
If the liner compression is at or exceeds the load necessary to seal the tank, determine the shrink fit pressure at the aluminum interface that can be achieved while maintaining this liner pressure.   
Assumptions:
Since little theory has been found governing the sealing potential of radially loaded gaskets in the shape of an annulus, we take the approach that we can break down the elements of the ASME pressure vessel code equations and apply them to our geometry.
The PTFE's strength is not sufficient to prevent the shrunken aluminum from returning to its original room temperature size, or deform either of the aluminum parts. In other words, the aluminum parts are rigid bodies moving relative to the PTFE as they expand or contract.
The interface of the aluminum parts is at the inner diameter of the outer aluminum ring, regardless of intereference thickness. ($R = D_{i,ring}/2$)
Stress concentrations in the liner that occur at the ends of the aluminum parts can be ignored.
The internal pressure of the vessel will have a negligible effect on the portion of the liner that is compressed between shrink-fitted aluminum parts.
End of explanation
m = 2.00
P = 45  # psi
yAmbient = 1200  # psi
sigmaPTFEAmbient1 = yAmbient
sigmaPTFEAmbient2 = m*P
sigmaPTFEAmbient = sigmaPTFEAmbient1
Explanation: ASME Pressure Vessel Code Equations
This code was developed for flat gaskets compressed between flanges. There are two equations, both give a value for the total bolt force needed to compress a gasket such that a seal is achieved at working pressure. Whichever equation gives a greater load for a specific design application is the one to be used. The following are the equations as they appear in Gaskets. Design, Selection, and Testing by Daniel E. Czernik:
$$W_{m_2} = \pi bGy$$ 
$$W_{m_1} = \frac{\pi}{4}G^2P + 2\pi bGmP$$
Where $W_{m_1}$ and $W_{m_2}$ are total bolt loads in pounds, $b$ is the effective gasket contact seating width in inches, $G$ is the mean diameter of the gasket contact face in inches, $y$ is the gasket contact surface unit seating load in pounds per square inch, $m$ is a dimensionless gasket factor, and $P$ is the maximum working internal pressure of the vessel.
For a typical round gasket, the effective gasket contact seating width is the difference between the outer and inner radii, or $r_o - r_i$. The mean diameter of such a gasket is simply the sum of the inner and outer radii, or $r_o + r_i$. When multiplied together, the product is the difference of the squares of the radii: $(r_o - r_i)(r_o + r_i) = (r_o^2 - r_i^2)$
This leads to the conslusion that $\pi bG = \pi (r_o^2 - r_i^2)$ is simply the area of one side of the gasket. This means that the $y$ is the only part of the first equation that we need for our analysis. We need at least enough pressure from the shrink fit to reach the seating load.
For the second equation, the first term is simply the prodcut of the internal working pressure and the cross sectional area normal to the central axis of the tank. In other words, this is the bolt load needed to prevent the ends from losing contact with the rest of the tank. Since we are loading the liner in the radial direction, we can also remove this term from our analysis of the liner as a gasket. The second term is similar to the first equation, but has a factor of two to account for both surfaces of the gasket that provide paths for escaping fluid, and $y$ is replaced with $mP$. Values for $m$ and $y$ appear to be imperically determined for different materials of varied thicknesses, and are found in tables provided by the ASME or material manufacturer. Dupont's PTFE Handbook lists PTFE as having a gasket factor, $m$, of 2.00 and a seating load, $y$, of 1200 psi for a 1/8" gasket. Because there will only be a fluid path on one side of the liner, we assume the factor of two can be removed. It should be noted that $y$ is for PTFE at ambient temperature, and is said to have the benefit of an operating temperature range from cryogenic to 450 &deg;C, but an estimate for a seating load at cryogenic temperature may need to be developed. 
Since the pressure vessel code equations are for bolt load (force), and not stress in the gasket directly, both sides of each can be divided by area. This simplifies the equations to suit our needs. This is similar to the simplified procedure found on page 111 of Gaskets by Czernik. The modified equations we will then apply to our gasket geometry are as follows:
$$\sigma_{PTFE, amb1} = y$$
$$\sigma_{PTFE, amb2} = mP$$
Since our operating pressure is only 45 psi, the first equation gives by far the greatest value.
Estimation of Minimum Seating Stress for PTFE at Cryogenic Temperature
I don't know what to do with this thing, or even if it is necessary. I may return to this another time
Czernik gives ranges of values for minimum seating stress for some common metals and flat gaskets (i.e. not corrugated) in Table 3.4. These values are:
Aluminum: 10000 - 200000 psi
Copper: 15000 - 45000 psi
Carbon Steel: 30000 - 70000 psi
Stainless Steel: 35000 - 95000 psi
These ranges account for variations in hardness or yield strength. Given some values found at Engineering Toolbox, we can find a value for what percent of yield strength these values are on average, and use that to determine a seating stress for PTFE at cryogenic temperature. The following is a list of nominal yield stresses from Engineering Toolbox:
Aluminum: 13778 psi
Copper: 10152 psi
Carbon Steel: 36258 psi
Stainless Steel: 72806 psi
End of explanation
deltaLinerAmbient = (sigmaPTFEAmbient/EPTFE)*t
print('The change in liner thickness due to compression must be', "%.4f" % deltaLinerAmbient, 'in, in order to achieve a proper seal.')
Explanation: Change in Liner Thickness Necessary to Achieve Seating Stress
The radial stress due to the compression of the liner follows Hooke's Law:
$$\sigma_{PTFE, amb} = \frac{\delta_{Liner, amb}}{t_{amb}}E_{PTFE, amb}$$
Where $t_{amb}$ is the liner thickness at ambient temperature before compression.
solving this equation for the change in liner thickness yields:
$$\delta_{Liner, amb} = \frac{\sigma_{PTFE, amb}}{E_{PTFE, amb}}t_{amb}$$
End of explanation
rCryo = r - r*alphaAluminum*DeltaT 
Deltar = r - rCryo
print('The maximum change in end cap radius equals: ', "%.4f" % DeltaR, 'in')
print('This means that the maximum theoretical interference for the shrink fit is ', "%.4f" % DeltaR, 'in')
Explanation: To know if this can be achieved, we must examine how much we can actually shrink the end cap, and whether or not that will allow enough clearance to fit the end cap into place before expansion. 
Maximum Thermal Contraction of End Cap
Thermal expansion/contraction can be thought of as a scaling of the position vectors of all the points in a body of uniform composition relative to its centroid. The thermal change in radius of the end cap is thus given by the following linear thermal expansion relationship:
$$r_{cyro} = r_{amb} - r_{amb}\alpha_{Al}\Delta T$$
The maximum change in radius is then simply the absolute value of the thermal change in radius from ambient to cryogenic temperature:
$$\Delta r = r_{amb}\alpha_{Al}\Delta T$$
End of explanation
deltaLinerAmbientMax = DeltaR - 0.00125
print('The achievable ambient temperature change in liner thickness due to shrink fitting is', "%.4f" % deltaLinerAmbientMax, 'in')
Explanation: Clearance for the End Cap
The above number does not account for some clearance to allow the end cap to slide into the liner. According to Engineer's Toolbox, a 3" diameter hole needs a minumum of 0.0025" of clearance to allow a shaft through with a free fit. This means that 0.00125" must be subtracted from the interference shrink fit to arrive at an achievable change in liner thickness due to shrink fitting. Thus:
$$\delta_{Liner, amb, max} = \Delta r - 0.00125"$$
End of explanation
tCryo = t - t*alphaPTFE*DeltaT
print ('The liner thickness at cryogenic temperature is', "%.4f" % tCryo,'in')
deltat = t*alphaPTFE*DeltaT
print ('The change in liner thickness due to thermal contraction is', "%.4f" % deltat, 'in')
tGap = t - deltaLinerAmbient
print ('The ambient temperature liner gap width is', "%.4f" % tGap, 'in')
deltaGap = tGap*alphaAluminum*DeltaT
print ('The change in gap width is', "%.4f" % deltaGap, 'in')
deltaLinerCryo = deltaLinerAmbient + deltaGap - deltat
print ('The total change in liner thickness at cryogenic temperature is', "%.4f" % deltaLinerCryo, 'in')
sigmaPTFECryo = (deltaLinerCryo/tCryo)*EPTFECryo
print('Thus, the maximum achievable pressure exerted on the PTFE at cryogenic temperature is', "%.2f" % sigmaPTFECryo, 'psi')
Explanation: The necessary change in liner thickness is less than the achievable change in liner thickness.  
Acording to the ASME pressure vessel code, the seal we need is achievable. However, the thermal contraction in the liner and the gap between aluminum rings that captures the liner, as well as the enormous change in yield strength and elastic modulus for PTFE when going to cryogenic temperatures may pose a problem. To be thorough, let's take a look at the liner stress under cryogenic conditions.
Pressure Exerted on Liner at Cryogenic Temperature
The liner will contract at cryogenic temperature, which will serve to reduce its stress due to the shrink fit, while the increase in elastic modulus at that temperature will increase its stress. This means that the liner will have a different stress state one once the tank is filled with LN2. The liner thickness at cryogenic temperature is:
$$t_{cryo} = t_{amb} - t_{amb}\alpha_{PTFE}\Delta T$$
The thermal contraction of the liner thickness is given by:
$$\delta_t = t_{amb}\alpha_{PTFE}\Delta T$$
The gap between aluminum rings will contract as well, leaving slightly less room for the liner at cryogenic temperature. The gap size at ambient temperature is specified to be the difference between the liner thickness and the change in liner thickness:
$$t_{gap} = t_{amb} - \delta_{Liner, amb}$$
The change in gap width is:
$$\delta_{gap} = t_{gap}\alpha_{Al}\Delta T$$
The change in liner thickness at cryogenic temperature is then given by:
$$\delta_{Liner, cryo} = \delta_{Liner, amb} + \delta_{gap} - \delta_t$$
The Liner's radial stress at cryogenic temperature is given by:
$$\sigma_{PTFE, cryo} = \frac{\delta_{Liner, cryo}}{t_{cryo}}E_{PTFE, cryo}$$
End of explanation
h = 0.125
mu = 1.2
deltaInterference = ((2*P*r**4)/(mu*h*EAluminum))*((roMain**2 - riCap**2)/((roMain**2 - r**2)*(r**2 - riCap**2)))
print('The intereference thickness needed to overcome the pressure force on the end caps is', "%.4f" % deltaInterference, 'in')
Explanation: Although the load on the PTFE at cryogenic temperature is greater, the yield strength of the PTFE is much greater at 19000 psi. The ratio of load to yield strength at ambient temperature is then much higher than the ratio at cryogenic temperature. We do have a value to use for seating stress of cryogenic PTFE, so we must either trust the ASME code for our extreme temperature conditions, or imperically test for the seating stress, which we do not have time to do before this project is terminated. 
Can We Use the Excess Space Allowed By the Thermal Contraction of the End Cap to Hold It In Place, and Dispense With the Bolts?
Right now the contact surface between the two aluminum parts is a cylidrical surface with a nominal diameter of 3 inches, and a height of 0.125 inches. Engineering Toolbox gives an aluminum-aluminum coefficient of friction of approximately 1.2 for clean, dry surfaces. This allows us to find the necessary pressure to secure the end cap in place using the shrink fit only and a factor of safety of 2.
$$A_{contact} = 2\pi rh$$
The normal force caused by the shrink fit is the product of the shrink fit contact pressure and contact area:
$$F_N = P_{shrink}A_{contact} = 2P_{shrink}\pi rh$$
The friction force is then the product of the normal force and the coefficient of friction:
$$F_friction = 2P_{shrink}\mu \pi rh$$
The force that the friction must overcome (with a factor of safety of 2) is 
$$F_{cap} = 2PA_{cap} = 2P\pi r^2$$
Equating these forces and solving for the shrink fit pressure gives:
$$P_{shrink} = \frac{Pr}{\mu h}$$
Shigley's Mechanical Engineering Design gives the shrink fit pressure as
$$P_{shrink} = \frac{E_{Aluminum}\delta_{interference}}{2r^3}[\frac{(r_o^2 - r^2)(r^2 - r_i^2)}{r_o^2 - r_i^2}]$$
Equating these and solving for the intereference thickness, $\delta_{interference}$, yields the following equation:
$$\delta_{interference} = \frac{2Pr^4}{\mu hE_{Aluminum}}[\frac{r_o^2 - r_i^2}{(r_o^2 - r^2)(r^2 - r_i^2)}]$$
End of explanation
<END_TASK>