Breaking Ice with Air cushion Vehicle - Find minimum pressure with Newton-Raphson method
Aim: To write a python script to solve for the minimum value of pressure using the newton raphson method.
where p denotes the cushion pressure, h the thickness of the ice field, r the size of the air cushion, σ the tensile strength of the ice and β is related to the width of the ice wedge.
Take β = 0.5, r = 40 feet and σ = 150 pounds per square inch (psi).
Objective:
- Use the newton raphson method to find out the value of pressure for h = 0.6 ft.
- Find the optimal relaxation factor for this problem with the help of a suitable plot.
- Tabulate the results of p for h = [0.6,1.2,1.8,2.4,3,3.6,4.2] assuming a suitable relaxation factor.
Theory:
A hovercraft, also known as an air-cushion vehicle or ACV, is an amphibious craft capable of travelling over land, water, mud, ice, and other surfaces.
Hovercraft use blowers to produce a large volume of air below the hull, or air cushion, that is slightly above atmospheric pressure. The pressure difference between the higher-pressure air below the hull and lower pressure ambient air above it produces lift, which causes the hull to float above the running surface. For stability reasons, the air is typically blown through slots or holes around the outside of a disk- or oval-shaped platform, giving most hovercraft a characteristic rounded-rectangle shape. Typically this cushion is contained within a flexible "skirt", which allows the vehicle to travel over small obstructions without damage.
Newton Raphson Method
The Newton–Raphson method, named after Isaac Newton and Joseph Raphson, is a root finding algorithm which produces successively better approximations to the roots (or zeroes) of a real-valued function. The most basic version starts with a single-variable function f defined for a real variable x, the function's derivative f ′, and an initial guess x0 for a root of f. If the function satisfies sufficient assumptions and the initial guess is close, then
`x_{1}=x_{0}-frac {f(x_{0})}{f'(x_{0})}`
is a better approximation of the root than x0. Geometrically, (x1, 0) is the intersection of the x-axis and the tangent of the graph of f at (x0, f (x0)): that is, the improved guess is the unique root of the linear approximation at the initial point. The process is repeated as
`x_{n+1}=x_{n}-frac {f(x_{n})}{f'(x_{n})}`
until a sufficiently precise value is reached.
Here is a picture to demonstrate how Newton-Raphson method works.
Code 1:
#Breaking Ice with Air cushion Vehicle - Find minimum pressure with Newton-Raphson method
#To find out the value of pressure h=0.6 feet
#To find Optimal relaxation factor for this problem with the help of suitable plot
import matplotlib.pyplot as plt
def f(p,h):
t1=pow(p,3)*(1-pow(b,2))
t2=((0.4*h*pow(b,2)-(s*pow(h,2))/pow(r,2)))*(pow(p,2))
t3=(pow(s,2)*pow(h,4)*p)/(3*pow(r,4))
t4=pow(((pow(h,2)*s)/(3*pow(r,2))),3)
return t1+t2+t3-t4
def fprime(p,h):
dt1=3*pow(p,2)*(1-pow(b,2))
dt2=((0.4*h*pow(b,2))-(s*pow(h,2))/pow(r,2))*pow(p,1)*2
dt3=(pow(s,2)*pow(h,4))/(3*pow(r,4))
return dt1+dt2+dt3
#Performing newton iterations to find the optimal relaxation factor for this problem with the help of a suitable plot
b=0.5 #width of the ice wedge
r=40 #size of the air cushion
s=150*144 #tensile strength of the ice (for converting psi to psf we meed to multiply by 144)
h=0.6 #thickness of the ice field
count=[]
alpha=[]
pressure=[]
a=0.05
tol=1e-4
i=1
miniter=1000
minalpha=2.5
#running the while loop only till relaxation factor =2
while(a<2):
alpha.append(a)
iter=1
p_guess=12
while (abs(f(p_guess,h))>tol):
p_guess=p_guess-a*(f(p_guess,h)/fprime(p_guess,h))
iter=iter+1
count.append(iter)
if(miniter>iter):
miniter=iter
minalpha=a
a=a+0.05
#output
print("Pressure=",p_guess)
print("No. of iterations :",miniter)
print("Optimal relaxation factor:",minalpha)
plt.plot(alpha,count)
plt.title("Optimal relaxation factor")
plt.xlabel("Relaxation factor(alpha)")
plt.ylabel("Number of iterations")
plt.show()
Explanation of code:
1.Importing matplotlib library.
2.The given data and constants are initialized and defined.
3.The given equation is assigned as a return value from function f and the differentiated equation is assigned as a return value from function fprime.
4.The Pressure for when height is 0.6 feet, No. of iterations and Optimal relaxation factor are obtained.
5.The graph for No. of iterations vs Relaxation Factor is displayed.
Result:
Plot:
Code 2:
#Performing newton iterations to tabulate the results for p for h=[0.6,1.2,1.8,2.4,3.0,3.6,4.2]
#assuming suitable relaxation factor
import matplotlib.pyplot as plt
#Given values
b=0.5 #width of the ice wedge
height=[0.6,1.2,1.8,2.4,3.0,3.6,4.2] #thickness of the ice field
s=150*144 #tensile strength of the ice
r=40 #size of the air cushion
alpha=1
tol=1e-4
pressure=[]
p_guess=30
iter=1
iterations=[]
def f(p,h):
t1=pow(p,3)*(1-pow(b,2))
t2=((0.4*h*pow(b,2)-(s*pow(h,2))/pow(r,2)))*(pow(p,2))
t3=(pow(s,2)*pow(h,4)*p)/(3*pow(r,4))
t4=pow(((pow(h,2)*s)/(3*pow(r,2))),3)
return t1+t2+t3-t4
def fprime(p,h):
dt1=3*pow(p,2)*(1-pow(b,2))
dt2=((0.4*h*pow(b,2))-(s*pow(h,2))/pow(r,2))*pow(p,1)*2
dt3=(pow(s,2)*pow(h,4))/(3*pow(r,4))
return dt1+dt2+dt3
#finding out value of p
for i in height:
while (abs(f(p_guess,i))>tol):
p_guess=p_guess-alpha*(f(p_guess,i)/fprime(p_guess,i))
iter=iter+1
iterations.append(iter)
iter=1
pressure.append(p_guess)
print("Height Pressure")
for i in range(0,7):
print(height[i]," ",pressure[i])
plt.plot(height,pressure)
plt.title('Pressure Vs Height')
plt.ylabel('Pressure (Pounds Per Square Feet)')
plt.xlabel('Height(Feet)')
plt.show()
Explanation of code:
1.Importing matplotlib library.
2.The given data and constants are initialized and defined.
3.The given equations is assigned as a return value from function f and the differentiated equation is assigned as a return value from function fprime.
4.The pressure for each value of height is found out applying given equation and are displayed.
5.The graph for Pressure vs Height is also displayed.
Result:
Plot:
Errors Obtained: Simple errors were obtained and were rectified easily.