TO FIND MINIMUM PRESSURE FOR BREAKING OF ICE WITH AIR CUSHION VEHICLE BY USING NEWTON-RAPHSON METHOD USING PYTHON PROGRAMMING
AIM
To write a code to solve for the minimum value of pressure using the newton Raphson method.
To find the optimal relaxation factor.
FORMULA USED
`p^3 (1-β^2 )+(0.4β^2-(σh^2)/r^2 ) p^2+(σ^2 h^4)/(3r^4 ) p-((σh^2)/(3r^2) )^3=0`
Where,
p= cushion pressure
h= thickness of ice
β = width of ice wedge
r = size of the air cushion
σ = tensile strength of the ice
GIVEN
β = 0.5
r = 40 feet
σ = 150 pounds per square inch
h = 0.6 feet
h = [0.6, 1.2, 1.8, 2.4, 3, 3.6, 4.2]
BODY OF CONTENT
Introduction
The Newton-Raphson method (also known as Newton's method) is a way to quickly find a good approximation for the root of a real-valued function f(x) = 0. It uses the idea that a continuous and differentiable function can be approximated by a straight-line tangent to it.
How it works
Suppose you need to find the root of a continuous, differentiable function f(x), and you know the root you are looking for is near the point x=x0. Then Newton's method tells us that a better approximation for the root is
`X1 = X0-(f(x0))/(f'(x0))`
This process may be repeated as many times as necessary to get the desired accuracy. In general, for any x-value xn, the next value is given by
`Xn+1 = Xn -(f(xn))/(f'(xn))`
Note: the term "near" is used loosely because it does not need a precise definition in this context. However, x0 should be closer to the root you need than to any other root (if the function has multiple roots).
Air-Cushion Vehicle
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.
STEPS OF PYTHON PROGRAM
A. Program to find the minimum value of pressure for different height
- Provide topic of the code which is under comment
- Calling of library which will used for plotting and calculating i.e. math, numpy and matplotlib.pyplot library.
- From line 12 to 20 program is written to define input for the function which is used to find the minimum pressure of breaking of ice for air cushion vehicle.
From line 21 to 30 program is written to form function to find the minimum pressure of breaking of ice for air cushion vehicle.
In line 21, defining of function is done for finding minimum pressure which takes input as p, h, beta, r, sigma.
where,
p= cushion pressure
h= thickness of ice
beta = width of ice wedge
r = size of the air cushion
sigma = tensile strength of the ice
From line 22 to 25, formulating of equation is done. After that combine equation is written in line no. 25 in variable a.
At last in line 30 value of a is return to the function.
- From line 34 to 41 program is written to form derivative function to find the minimum pressure of breaking of ice for air cushion vehicle.
In line 35, defining of derivative function is done for finding minimum pressure which takes input as p, h, beta, r, sigma.
where,
p= cushion pressure
h= thickness of ice
beta = width of ice wedge
r = size of the air cushion
sigma = tensile strength of the ice
From line 36 to 38, formulating of equation is done. After that combine equation is written in line no. 39 in variable a.
At last in line 41 value of b is return to the derivative of the function.
- From line 48 to 52, input for the program is provided which is used in the function.
In line 52, different values of h are given in feet which is used in function.
I have assumed the value for pressure as p_guess, provide the value of relaxation factor as alpha.
Tol is used to compare the result with tolerance.
From line 57 to 59 empty array is created for iteration, pressure1, pressure2.
- From line 62 to 78, defining of for loop is done to find the minimum pressure by the help of Newton Raphson method. This for loop used to calculate the pressure in psi unit.
In line 64, defining of iteration is done which starts from 1.
In line 67, while loop is used to calculate the minimum pressure which compare the absolute value of p guess with tolerance i.e. tol.
In line 70, newton Raphson equation is written to calculate the minimum pressure by doing several iterations of for loop and while loop.
In line 73, increment of iteration is done.
In line 76 and 78, append command is used to store the value of pressure and iteration in the empty array.
- From line 82 to 99, defining of for loop is done to find the minimum pressure by the help of Newton Raphson method. This for loop used to calculate the pressure in psft unit.
In line 85, defining of iteration is done which starts from 1.
In line 88, while loop is used to calculate the minimum pressure which compare the absolute value of p guess with tolerance i.e. tol.
In line 91, newton Raphson equation is written to calculate the minimum pressure by doing several iterations of for loop and while loop.
In line 94, increment of iteration is done.
In line 97 and 99, append command is used to store the value of pressure and iteration in the empty array.
- From line 103 to 107, code is written to make a plot of height Vs Pressure.
In line 103, plot command is used to plot the graph.
In line 104 and 105 label command is used to define the X and Y axis of the plot.
In line 106 title command is used to give the title of the plot.
In line 107 show command is used to show the plot.
- In line 111, print command is used to print the value of minimum value of pressure for minimum height.
- From line 113 to 117, comment is given to define the next code.
From line 118 to 127, code is written to form the table.
In line 118, print command is used to write the heading of the table.
In line 120, print command is used to write ‘_’ which divide the heading and data of the table.
In line 123, for loop is used to take each value of height, pressure(psi) and pressure(psft).
From line 124 to 126, H variable is used to take the value of height from h array, P1 variable is used to take the value of pressure(psi) from pressue1 array and P2 variable is used to take the value of pressure(psft) from pressue2 array by the help numpy command as np.
In line 127, print command is used to print the values of height, pressure(psi) and pressure(psft).
B. Program to find the optimal relaxation factor
- Provide topic of the code which is under comment
- Calling of library which will used for plotting and calculating i.e. math, numpy and matplotlib.pyplot library.
- From line 12 to 19 program is written to define input for the function which is used to find the minimum pressure of breaking of ice for air cushion vehicle.
From line 20 to 29 program is written to form function to find the minimum pressure of breaking of ice for air cushion vehicle.
In line 20, defining of function is done for finding minimum pressure which takes input as p, h, beta, r, sigma.
where,
p= cushion pressure
h= thickness of ice
beta = width of ice wedge
r = size of the air cushion
sigma = tensile strength of the ice
From line 21 to 27, formulating of equation is done. After that combine equation is written in line no. 27 in variable a.
At last in line 29 value of a is return to the function.
- From line 32 to 39 program is written to form derivative function to find the minimum pressure of breaking of ice for air cushion vehicle.
In line 33, defining of derivative function is done for finding minimum pressure which takes input as p, h, beta, r, sigma.
where,
p= cushion pressure
h= thickness of ice
beta = width of ice wedge
r = size of the air cushion
sigma = tensile strength of the ice
From line 34 to 36, formulating of equation is done. After that combine equation is written in line no. 37 in variable a.
At last in line 39 value of b is return to the derivative of the function.
- From line 42 to 49, input for the program is provided which is used in the function.
In line 52, different values of relaxation factor are given as alpha which is used in function. Here linspace command is used which divide the values in equal interval.
In line 54 and 55 empty array is created for iteration, pressure.
- From line 59 to 77, defining of for loop is done to find the minimum pressure as well as iteration for different values of relaxation factor by the help of Newton Raphson method.
In line 61, defining of iteration is done which starts from 1.
In line 62, defining of tol for tolerance is done.
In line 63, assuming the pressure is done as p guess.
In line 66, while loop is used to calculate the minimum pressure which compare the absolute value of p guess with tolerance i.e. tol.
In line 69, newton Raphson equation is written to calculate the minimum pressure by doing several iterations of for loop and while loop.
In line 72, increment of iteration is done.
In line 75 and 77, append command is used to store the value of pressure and iteration in the empty array.
- From line 81 to 85, code is written to make a plot of relaxation factor Vs Iteration.
In line 81, plot command is used to plot the graph.
In line 82 and 83 label command is used to define the X and Y axis of the plot.
In line 84 title command is used to give the title of the plot.
In line 85 show command is used to show the plot.
PYTHON PROGRAM
A. Program to find the minimum value of pressure for different height
"""
Newton raphson method to solve of Breaking Ice with Air cushion Vehicle
"""
#import of library
import matplotlib.pyplot as plt
import math
import numpy as np
"""
Forming of function f
where,
p= cushion pressure
h=thickness of ice
beta = width of ice wedge
r = size of the air cushion
sigma = tensile strength of the ice
"""
def f(p,h,beta,r,sigma):
term1= pow(p,3)*(1-pow(beta,2)) #these term1,2,3,4 are the part of the equation
term2= 0.4*pow(beta,2)-sigma*pow((h/r),2)
term3= p*pow(sigma,2)*pow((h/r),4)
term4= sigma*pow((h/r),2)/3
#By the help of term1, term2 , trm3, term4 we can make the equation for Breaking Ice with Air cushion Vehicle
a= term1 + pow(p,2)*term2 + (term3)/3 - pow(term4,3)
#return the value of a to the function
return a
#Forming of function of derivative of function f
def fprime(p,h,beta,r,sigma):
term_1= 3*pow(p,2)*(1-pow(beta,2)) #these term1,2,3,4 are the part of the equation
term_2= 2*p*(0.4*pow(beta,2)-(sigma*pow((h/r),2)))
term_3= pow(sigma,2)*pow((h/r),4)
b= term_1 + term_2 + (term_3)/3
#return the value of b to the function
return b
"""
input for the function
"""
beta = 0.5
r = 40
sigma_1 = 150 #tensile strength in pounds per square inch
sigma_2 = 150*144 #tensile strength in pounds per square feet
h = [0.6,1.2,1.8,2.4, 3.0, 3.6, 4.2] #Different values of heigth
p_guess1 = 50 #Assumption of pressure
alpha = 1 #relaxation factor
tol = 1e-6 #toleranace which is used to compare the result
iter = 1 #Iteration starts from 1
iteration= [] #Empty array of iteration
pressure1 = [] #pressure in pounds per square inch
pressure2 = [] #pressure in pounds per square feet
#For loop to find the value of min pressure in psi unit
for i in h:
iter = 1 #Iteration starts from 1
#While loop is used to compare it with the value of tolerance i.e. tol
while (abs(f(p_guess1,i,beta,r,sigma_1))>tol):
#p_guess1 is the guessing pressure
p_guess1 = p_guess1 - alpha*(f(p_guess1,i,beta,r,sigma_1)/fprime(p_guess1,i,beta,r,sigma_1))
#iteration increament
iter= iter+1
#storing the values of pressure(psi) in empty array of pressure1
pressure1.append(p_guess1)
#storing the values of iteration in empty array of iteration
iteration.append(iter-1)
#For loop to find the value of min pressure in psi unit
p_guess2 = 50 #p_guess2 is the guessing pressure
for i in h:
iter = 1 #Iteration starts from 1
#While loop is used to compare it with the value of tolerance i.e. tol
while (abs(f(p_guess2,i,beta,r,sigma_2))>tol):
#p_guess2 is the guessing pressure
p_guess2 = p_guess2 - alpha*(f(p_guess2,i,beta,r,sigma_2)/fprime(p_guess2,i,beta,r,sigma_2))
#iteration increament
iter= iter+1
#storing the values of pressure(psft) in empty array of pressure2
pressure2.append(p_guess2)
#storing the values of iteration in empty array of iteration
iteration.append(iter-1)
plt.plot(h,pressure2) #plotting of figure for height VS pressure
plt.xlabel('Height (ft)') #labelling of X axis
plt.ylabel('Pressure (psft)') #labelling of Y axis
plt.title('Height VS Pressure') #Defining title of the plot
plt.show() #command to show the plot
#printing the minimum value of pressure
print('Minimum value of pressure for h = 0.6ft is :',pressure2[0],'\n')
"""
Forming table for different pressure and height
"""
#printing the heading of the table
print("height | pressure(psi) | pressure(psft)")
#printing the "_" to divide the table heading and data
print("___________________________________________________________________________")
#for loop to print the table
for j in range(len(h)): #defing the limit of for loop
H= np.array(h[j]) #calling the values of height
P1 = np.array(pressure1[j]) #calling the values of pressure(psi)
P2 = np.array(pressure2[j]) #calling the values of pressure(psft)
print(' {:0.1f}\t{:30.7f}\t{:33.10f}'.format(H,P1,P2)) #printing the values of height and pressure to form table
B. Program to find the optimal relaxation factor
"""
Newton raphson method to find the optimal relxation factor
"""
#import of library
import matplotlib.pyplot as plt
import math
import numpy as np
"""
Forming of function f
where,
p= cushion pressure
h=thickness of ice
beta = width of ice wedge
r = size of the air cushion
sigma = tensile strength of the ice
"""
def f(p,h,beta,r,sigma):
term1= pow(p,3)*(1-pow(beta,2)) #these term1,2,3,4 are the part of the equation
term2= 0.4*pow(beta,2)-sigma*pow((h/r),2)
term3= p*pow(sigma,2)*pow((h/r),4)
term4= sigma*pow((h/r),2)/3
#By the help of term1, term2 , trm3, term4 we can make the equation for Breaking Ice with Air cushion Vehicle
a= term1 + pow(p,2)*term2 + (term3)/3 - pow(term4,3)
#return the value of a to the function
return a
#Forming of function of derivative of function f
def fprime(p,h,beta,r,sigma):
term_1= 3*pow(p,2)*(1-pow(beta,2)) #these term1,2,3,4 are the part of the equation
term_2= 2*p*(0.4*pow(beta,2)-sigma*pow((h/r),2))
term_3= pow(sigma,2)*pow((h/r),4)
b= term_1 + term_2 + (term_3)/3
#return the value of b to the function
return b
"""
performing newton iteration
"""
#input to the Function
beta = 0.5
r = 40
sigma = 150*144
h = 0.6
#alpha is the relaxation factor
alpha = np.linspace(0.1,1.9,50)
iteration= [] #Empty array of iteration
pressure = [] #pressure in pounds per square feet
#For loop to find the value of relaxation factor
for i in range(len(alpha)):
iter = 1 #Iteration starts from 1
tol = 1e-4 #toleranace which is used to compare the result
p_guess = 30 #Assumption of pressure
#While loop is used to compare it with the value of tolerance i.e. tol
while (abs(f(p_guess,h,beta,r,sigma))>tol):
#p_guess1 is the guessing pressure
p_guess = p_guess - alpha[i]*(f(p_guess,h,beta,r,sigma)/fprime(p_guess,h,beta,r,sigma))
#iteration increament
iter= iter+1
#storing the values of pressure(psft) in empty array of pressure2
pressure.append(p_guess)
#storing the values of iteration in empty array of iteration
iteration.append(iter-1)
plt.plot(alpha,iteration) #plotting of figure for relaxation factor VS iteration
plt.xlabel('Relaxation factor') #labelling of X axis
plt.ylabel('No. of iteration') #labelling of Y axis
plt.title('Finding the optimal relaxation factor') #Defining title of the plot
plt.show() #command to show the plot
RESULTS
- Plot of minimum value of pressure for different height
- Table of pressure for different height
- Optimal Relaxation factor for different iteration
CONCLUSION
- From the table we can say that for height ( thickness of ice field) 0.6 ft the minimum cushion pressure obtain is 4.14 psft.
- The plot for different values of thickness of ice field vs pressure is increasing continuously.
- In the plot of optimal relaxation factor, it is clear that for lower value of relaxation factor i.e. alpha the no. of iteration is high to obtain the minimum pressure by the help of Newton Raphson method.
As the value of alpha increase up to 1, the no. of iteration reduces.
No. of iteration is nearly same between the alpha 1 to 1.25.
As the values of alpha cross 1.25, the no. iteration requires to obtain the minimum cushion pressure is increasing. So, the optimum relaxation factor is in between 1 to 1.25 where the no. of iteration is minimum.
REFERENCES
- Video lecture of skill lync
- Wikipedia