Breaking ice with air cushion vehicle by python programming
Aim:- To find minimum pressure with the Newton raphson method using PYTHON programming.
Governing Equation:-
`p^3(1-beta^2)+(0.4hbeta^2-((sigmah^2)/r^2))p^2+((sigma^2h^4)/(3r^4)p)-((sigmah^2)/(3r^2))^3=0`
where p=pressure of cushion
h=icefield thickness
r=air cushion size
`sigma`=tensile strength of the ice
Objective:- The main objectives of this project are following
1)to find pressure value by the Newton Raphson Method
2)to find the optimal reduction factor and plot the corresponding graph
3)to tabulate the results of p for given values of h
Brief Theory:-
Air cushion vehicle:- It is and craft that can travel overland ice water and any other surfaces. It is generally known as hovercraft that glides over a surface upon an air cushion.
Air cushion:- This is nothing but a short description of fluid that uses compressed air.
Newton raphson method:- It is a method by which we can easily find a good approximation for the root of a function of real value f (x) = 0
Workflow:-
1) The first program is developed to determine the minimum pressure using the plot.
2)Pressure vs thickness plot is plotted
3)Tabulation of thickness and pressure is done
4)The second program is developed to find minimum pressure
5)Optimization of relaxation factor plot is plotted and tabulation is done.
Brief content of this project:- This project has been done by python Programming. The code has been attached below.
Program for determination of minimum pressure and plot:-
#Breaking ice with air cushion vehicle using python programming
import math
import matplotlib.pyplot as plt
import numpy as np
from tabulate import tabulate
#muller function
def f(p,h):
term_1 = pow(p,3)*((1-pow(beta,2)))
term_2 = ((0.4*h*pow(beta,2) - ((sigma*pow(h,2)/pow(r,2)))*pow(p,2)))
term_3 = ((pow(sigma,2)*pow(h,4)/(3*pow(r,4))))*p
term_4 = (pow((sigma*pow(h,2)/(3*pow(r,2))),3))
equation = term_1 + term_2 + term_3 - term_4
return equation
def fprime(p,h):
term_1 = 3*pow(p,2)*(1-pow(beta,2))
term_2 = 2*p*((0.4*h*pow(beta,2)) - (sigma*pow(h,2)/(pow(r,2))))
term_3 = ((pow(sigma,2)*pow(h,4)/(3*pow(r,4))))
equation_prime = term_1 + term_2 + term_3
return equation_prime
#taking inputs
beta = 0.5
r = 40
sigma = 150*144
height = [0.6,1.2,1.8,2.4,3.0,3.6,4.2]
"""
Where beta = width of ice (feet)
r = size of air cushion (feet)
sigma = tensile strength of ice (psi)
height = thickness of ice
"""
#Iteration
pguess = 40
alpha = 1
tolerance = 1e-4
i = 1
#appending of the pressure & iteration
pressure = []
iteration = []
for h in height:
while(abs(f(pguess,h))>tolerance):
pguess = pguess - alpha*(f(pguess,h)/fprime(pguess,h))
i = i + 1
pressure.append(pguess)
print(pressure)
print(i)
for i in range(0,7):
if i == 0:
print("height:pressure")
print(height[i],":",pressure[i])
#tabulation
headers = ["Thickness(h)","Pressure(p)"]
table = tuple(zip(height,pressure))
print(tabulate(table,headers,tablefmt = "orgtbl",numalign = "right"))
#Plotting of graph
plt.plot(height,pressure)
plt.title('Pressure vs Thickness')
plt.xlabel('Height(unit:feet)')
plt.ylabel('Pressure(unit:psi)')
plt.show()
Algorithm of the first program:-
1)Firstly input function has used for importing the math plotlib.py,num.py etc.
2)Muller function is derived
3)Necessary inputs are taken
4)The creation of pressure and iteration is done to store values as an empty array.
5)" for" loop is used for calling of each value
6)" while" loop is used for determination of the greater value
7)Using necessary formula N-R is done.
8)The table is created using the command and graph is plotted
Result:-
Plot:-
Program for finding minimum pressure ( relaxation factor(alpha) as 1 & h =0.6):-
#Finding of minimum pressure for breaking the ice by python programming
import math
import matplotlib.pyplot as plt
import numpy as np
from tabulate import tabulate
# muller's equation
def f(p,h):
term_1 = pow(p,3)*((1-pow(beta,2)))
term_2 = ((0.4*h*pow(beta,2) - ((sigma*pow(h,2)/pow(r,2)))*pow(p,2)))
term_3 = ((pow(sigma,2)*pow(h,4)/(3*pow(r,4))))*p
term_4 = (pow((sigma*pow(h,2)/(3*pow(r,2))),3))
equation = term_1 + term_2 + term_3 - term_4
return equation
def fprime(p,h):
term_1 = 3*pow(p,2)*(1-pow(beta,2))
term_2 = 2*p*((0.4*h*pow(beta,2)) - (sigma*pow(h,2)/(pow(r,2))))
term_3 = ((pow(sigma,2)*pow(h,4)/(3*pow(r,4))))
equation_prime = term_1 + term_2 + term_3
return equation_prime
#taking necessary inputs
beta = 0.5
r = 40
sigma = 150*144
height = [0.6]
"""
Where beta = width of ice (feet)
r = size of air cushion (feet)
sigma = tensile strength of ice (psi)
height = thickness of ice
"""
#Newton iteration
p_guess = 10
alpha = np.linspace(0.05,2,50)
tolerance = 1e-4
i = 1
h = 0.6
# pressure & iteration
pressure = []
iteration = []
for a in alpha:
pguess = 10
i = 1
while(abs(f(pguess,h))>tolerance):
pguess = pguess - a*(f(pguess,h)/fprime(pguess,h))
i = i + 1
pressure.append(pguess)
iteration.append(i)
x = min(iteration)
for i in range(0,100):
if i == 0:
print(alpha[i],x)
#Tabulation
header = ['alpha','iteration']
table = tuple(zip(pressure,iteration))
s = sorted(table)
print(tabulate(table,headers = header, tablefmt = 'pipe'))
#Plotting of graph
plt.plot(alpha,iteration)
plt.title('Optimization of Relaxation Factor')
plt.xlabel('Relaxation Factor')
plt.ylabel('No. of iteration')
plt.show()
Algorithm of the program:-
1) The module is imported, functions are defined
2)Necessary input is put
3)Newton iteration is performed
4)for loop is used and empty address is created to store values
5)The table is created and plotting is done result plot.
Result:-
Graph:-
Conclusion:- Through this whole project we have learned to use air cushion vehicles to break the ice by the Newton raphson method using a python program which is very useful for aircraft works, navy works, mechanical industry works and the python program developed to make the works for easier for less manpower.