Project

Breaking Ice with Air cushion Vehicle - Finding minimum pressure with Newton-Raphson method using Python

  • problem statement:

For this challenge, writing 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).

1. Use the newton raphson method to find out the value of pressure for h = 0.6 ft.

2. Find the optimal relaxation factor for this problem with the help of a suitable plot.

3. 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

  • Aim:

Determining minimum pressure to break ice using an air cushion ice breaker - Newton Raphson method

  • OBJECTIVE:

To determine the minimum cushion pressure needed to break a given thickness of ice

using an air cushion vehicle through Newton-Raphson method using Python.

To find an optimum relaxation factor in the case of breaking an ice wedge of thickness equal to 0.6 feet using Newton Raphson Method

  • THEORY:

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. This method is based on linear approximation where it uses the idea that a continuous and differentiable function can be approximated by a straight line tangent to it.

Here is a picture to demosterate what Newton's method actudally does:


We draw a tangent line to the graph of f(x) at the point Both tangents are always intersected at the axis, except when they are in parallel (in such cases, root is not possible).

Equation to be solved:

To determine the minimum pressure Muller (“Ice Breaking with an Air Cushion Vehicle”) in Mathematical Modeling: Classroom Notes in Applied Mathematics, SIAM 1987) derived the equation

  • Target Equation:


p3(1−β)+(0.4β2−(σh2r2))p2+σ2h43r4p−(σh23r2)3=0p3(1-β)+(0.4β2-(σh2r2))p2+σ2h43r4p-(σh23r2)3=0

1st order derivative:

f'(p)=3p2(1−β2)+(0.4hβ2−σha2r2)2p+σ2h43r4f′(p)=3p2(1-β2)+(0.4hβ2-σha2r2)2p+σ2h43r4

Newton-Raphson is performed using:

Pguess=Pguess+α(f(Pguess)f'(Pguess))Pguess=Pguess+α(f(Pguess)f′(Pguess))

Here p = cushion pressure

h = thickness of the ice field

r = size of the air cushion

σ = tensile strength of the ice

β = related to the width of the ice wedge.

CASE 1 :- Code for calculating minimum pressure required to break ice wedges with different thickness and relaxation factor equal to 1
import matplotlib.pyplot as plt
import math
import numpy as np

# Defining the function
def function(p,h):
	term1 =pow(p,3)*(1-pow(beta,2))
	term2 =(0.4*h*pow(beta,2) - sigma*pow(h,2)/pow(r,2))*pow(p,2)
	term3 =pow(sigma,2)*pow(h,4)*p/(3*pow(r,4))
	term4 =pow((sigma*pow(h,2))/(3*pow(r,2)),3)
	term = term1+term2+term3-term4
	return term

# Defining the derivative of the function
def function_prime(p,h):
	term5=3*pow(p,2)*(1-pow(beta,2))
	term6=(0.4*h*pow(beta,2) - sigma*pow(h,2)/pow(r,2))*2*p
	term7=pow(sigma,2)*pow(h,4)/(3*pow(r,4))
	term_r = term5+term6+term7
	return term_r

#Input
r = 40 #size of air
beta = 0.5 #width of ice wedge
sigma = 150 #tensile strength
height = [0.6,1.2,1.8,2.4,3.0,3.6,4.2] #thickness of ice field
p_guess = 50 #cushion pressure to start iteration
alpha = 1 #relaxation factor
tol = 1e-4 #tolerance
pressure = []

iter = 1 #number of iteration
for h in height:
	while(abs(function(p_guess,h))>tol):
		p_guess = p_guess- alpha*(function(p_guess,h)/function_prime(p_guess,h))		
		iter = iter + 1	
	pressure.append(p_guess) #storing values of pressure in pressure array

for i in range(0,7):
	if i == 0:
		print(" : height : pressure")
	print(" | ", height[i]," | ", pressure[i])

print("Number of iterations = ",iter,)
plt.plot(height,pressure)
plt.title('Cushion presuure Vs thickness of ice field')
plt.xlabel('thickness of ice field')
plt.ylabel('Pressure')
plt.show()

code explanation

frist of All the required modules are imported using import comand, math for mathematical functions, matplolib for plotting, numpy for array processing
Functions(p, h) and function_prime(p, h) are defined which are further used for calculating the value of the non-linear function and its first derivative at diffferent values of pressure 'p' and ice wedge thickness 'h' and 'return' command is used in both the functions to return the required outputs when the functions are called further in the program.
Input parameters are assigned as beta = 0.5, r = 40 feet, sigma = 150 pounds per square inch (psi) and h = [0.6, 1.2, 1.8, 2.4, 3.0, 3.6, 4.2] feet.
We are now assuming p_guess = 50(first guess value of pressure, relaxation factor i.e alpha = 1, tolerance = 1e-4 and i = 1.
pressure is created as empty arrays for storing the values.

For calculating minimum value of pressure, using Newton Raphson Method, for different values of ice wedge thickness 'h' a 'for' loop with a counter variable 'height' is defined and used. Inside a for loop, a while loop is used to obtain the minimum value of pressure with the condition that loop will run till the absolute value of function 'f(p, h)' for p_guess and a(thickness for particular iteration of for loop) i.e 'abs(f(p_guess, a))' is greater than the tolerance value i.e 'tol'. Syntax used is 'while (absf(p_guess, a)) > tol):'. An absolute value of function is used because sometimes it is possible that Newton Raphson Method must not converge solutions and may take many iterations to reach the actual value of a root of the function. Therefore, we need to take modulus of the function, since, if in case value of function is slightly negative, the value after taking modulus will be greater than the tolerance value i.e 'tol'. Inside the while loop, the modified equation of Newton Raphson Method is defined and also the value of a variable 'iter' is defined as equal to 'iter + 1' so that it gets updated.

Also, the arrays 'pressure' gets appended for every iteration of the 'for' loop. Which help to storing values of pressure in pressure array

A graph of ice wedge thickness versus minimum cushion pressure is plotted with the help of command 'plt.plot' and passing the arrays 'cushion_pressure' and 'number_of_iterations' as an input arguments.

output of case 1 :

After seeing the above graph and table, it can be concluded that as the thickness of an ice wedge increases, the minimum cushion pressure required to break an ice wedge also increases in a non-linear fashion. This means minimum cushion pressure is directly proportional to the thickness of an ice wedge.
From case 1, it can be observed that by keeping the Relaxation factor at 1 throughout, the number of iterations is proportional to any of the depending factors like Pressue or the Thickness.
case 2:
For evaluating the optimium relaxation factor we are comparing the relaxation factor relative to the number of iterations for the corresponding relaxation factor.
import matplotlib.pyplot as plt
import math
import numpy as np

# Defining the function
def function(p,h):
	term1 =pow(p,3)*(1-pow(beta,2))
	term2 =(0.4*h*pow(beta,2) - sigma*pow(h,2)/pow(r,2))*pow(p,2)
	term3 =pow(sigma,2)*pow(h,4)*p/(3*pow(r,4))
	term4 =pow((sigma*pow(h,2))/(3*pow(r,2)),3)
	term = term1+term2+term3-term4
	return term

# Defining the derivative of the function
def function_prime(p,h):
	term5=3*pow(p,2)*(1-pow(beta,2))
	term6=(0.4*h*pow(beta,2) - sigma*pow(h,2)/pow(r,2))*2*p
	term7=pow(sigma,2)*pow(h,4)/(3*pow(r,4))
	term_r = term5+term6+term7
	return term_r
#Inputs
r = 40
beta = 0.5
sigma = 150
height = 0.6
p_guess = 50 
tol = 1e-4 
pressure = []

iter = 1
a1= []
itera= []
for a in range(1,200):
	a = a*0.01

	iter = 1
	p_guess = 50
	while (abs(function(p_guess,height)) > tol):
		p_guess = p_guess - a*(function(p_guess,height)/function_prime(p_guess,height))
		iter = iter + 1

	itera.append(iter)
	a1.append(a)
	print('relaxation factor=', p_guess)
	print('number of itration = ',iter)


plt.plot(a1,itera,color="green",linewidth=3)
plt.xlabel('relaxation factor',fontsize = 'large' , fontweight = 'bold')
plt.ylabel('No. of Iterations',fontsize = 'large' , fontweight = 'bold')
plt.title('relaxation factor vs No. of Iterations')
plt.savefig('alpha.png')
plt.show()
The above program is used for optimizing the relaxation factor used.
For evaluating the optimium relaxation factor we are comparing the relaxation factor relative to the number of iterations for the corresponding relaxation factor.

output of case 2 :

The above graph describes the relationship between the relaxation factor relative to its corresponding number of iterations.
The curve depicted in the graph is an exponentially decreasing curve. From the graph we can understand that the no. of iterations is very high for lower values of the relaxation factor,therefore it is acting as an under-relaxation entity
The minimum relaxation factor for the given equation is 0.01278 at 8 iterations.
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.