Newton-Raphson method
AIM:
1.To find the minimum pressure of the following function
2. Use the newton raphson method to find out the value of pressure for h = 0.6 ft.
3. Find the optimal relaxation factor for this problem with the help of a suitable plot.
4. 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.
NEWTON-RAPHSON METHOD:
Newton-Raphson method is a root-finding algorithm that uses the first few terms of the Taylor series of a function in the vicinity of a suspected root. Newton's method is sometimes also known as Newton's iteration, although in this work the latter term is reserved to the application of Newton's method for computing square roots.
CODE TO FIND THE MINIMUM PRESSURE FOR DIFFERENT THICKNESS:
import matplotlib.pyplot as plt
from prettytable import PrettyTable
import numpy as np
#function that needs to minimise
def f(p):
return pow(p,2)*(1-pow(beta,3)) + (0.4*h*pow(beta,2) - sigma*pow(h,2)/pow(r,2))*pow(p,2) + pow(sigma,2)*pow(h,4)/(3*pow(r,4))*p - pow(sigma*pow(h,2)/(3*pow(r,2)),3)
#derivation with respect to pressure p
def fprime(p):
return 3*pow(p,2)*(1-pow(beta,2)) + 2*p*(0.4*h*pow(beta,2) - sigma*pow(h,2)/pow(r,2)) + pow(sigma,2)*pow(h,4)/(3*pow(r,4))
#width of ice wedge
beta = 0.5
#thickness of ice field
h = [0.6,1.2,1.8,2.4,3,3.6,4.2]
#size of air cusion(feet)
r = 40
#stress
sigma = 150
#cushion pressure
p_guess = 0.3
#relaxation factor
alpha = 0.8
#pressure
P =[]
#tolerance
tol = 1e-4
iter = 1
#APPLYING NEWTON RAPHSON METHOD
for h in thickness:
while(abs(f(p_guess))>tol):
p_guess = p_guess - alpha*f(p_guess)/fprime(p_guess)
iter = iter + 1
P.append(p_guess)
print(iter)
for i in range(len(h)):
if i == 0:
print('Thickness pressure')
print(height[i] , ':' , P[i])
plt.plot(height,P)
plt.xlabel('height')
plt.ylabel('pressure')
plt.show()
EXPLANATION OF THE CODE :
1.First of all , a function is defiend for which minimum pressure needs to be calculated.
2.another function is created which is the derivative of the above function with respect to pressure.
3.Different variables are defiend such as thickness, beta, stress and others.
4.Tol variable is defiend to cope up with tolerance error.
5.Relaxation factor alpha is defiend which then changed according to the result
6. For loop and while loop is created by which the new minimum pressure can be calculated
for each value of thickness with some iterations
7. plot the the thickness vs pressure curve.
OUTPUT:
THICKNESS VS PRESSURE: