NEWTON RAPHSON METHOD

OBJECTIVE: To find minimum pressure using Newton-Raphson method

PROGRAMMING EXPLAINED:

  1. Two functions are defined. f and fprime. These function are defined to calculate next iteration value using NR method.
  2. To calculate pressure values for different thickness, for and while loop was used.In while loop absolute value of function, for given thickness was compared with tolerance 0.0001
  3. .
  4. Pressure and iterations values was appended when function value was less than tolerance.
  5. Imported PrettyTable and used for loop for adding values to table.
  6. For second part of challenge,linspace was used for gettting different values of relaxation factor. Thickness of ice was fixed to 0.6 units.
  7. Newton raphson method was used to calculate pressure.
  8. Here only iterations values was appended.
  9. relaxation factor was plotted against iterations values to find best realaxation factor.

 

 

 

#NEWTON RAPHSON METHOD
import math
import matplotlib.pyplot as plt
from prettytable import PrettyTable
import numpy as np

#INPUTS
r = 40
B = 0.5
sigma = 150*144
h = [0.6,1.2,1.8,2.4,3,3.6,4.2]
#Defining function to evaluate pressure
def f(p,h):
	t1 = pow(p,3)*(1-pow(B,2))
	t2 = (0.4*h*(B**2)-(sigma*(h**2))/(r**2))*(p**2)
	t3 = ((sigma**2)*(h**4)*p)/(3*(r**4))
	t4 = pow((sigma*(h**2))/(3*(r**2)),3)
	F = t1 + t2 + t3 -t4
	return F

#Differentiating first fumction for iteration in while loop
def fprime(p,h):
	t_1 = 3*pow(p,2)*(1-pow(B,2))
	t_2 = (0.4*h*(B**2)-(sigma*(h**2))/(r**2))*(2*p)
	t_3 = ((sigma**2)*(h**4))/(3*(r**4))
	Fp = t_1 + t_2 + t_3
	return Fp


P = []
it = []	
xp = 100
tol = 1e-4
alpha = 1
for a in h:
	i = 1

	while(abs(f(xp,a))>tol):
		xp = xp - (alpha*(f(xp,a)/fprime(xp,a)))

		i = i+1
	it.append(i)
	P.append(xp)



table = PrettyTable(['iteration','thickness','pressure'])
for x in range(0,7):
	table.add_row([it[x],h[x],P[x]])
print(table)

plt.plot(h,P)
plt.xlabel('thickness')
plt.ylabel('Pressure')
plt.show()
alpha__= np.linspace(0.1,1.9,500)
#print(alpha__)
h = 0.6
tol = 1e-4
iterations = []



for j in alpha__:
	i = 1    
	xp = 100
	   
	while(abs(f(xp,0.6))>tol):
		xp = xp - (j*(f(xp,0.6)/fprime(xp,0.6)))

		i = i+1
	iterations.append(i)
	

print(iterations)
print('the number of iterations ('+str(min(iterations))+') is least at: ')
for i in range(len(iterations)):

	if iterations [i]==min(iterations):
		print(alpha__[i])

plt.plot(alpha__,iterations)
plt.xlabel('aplha')
plt.ylabel('iterations')
plt.title('plot showing relaxation factor')

plt.show()





CONCLUSION:

Optimum relaxation factor was around 1.1 and we can see from results it takes less iterations to get the answer.

If we use relaxation factor less than 1, it will take more iterations to converge to answer.

 


Projects by LUV KUMAR

OBJECTIVE: To simulate the side crash analysis of the given neon model. STEPS: UNIT SYSTEM: During whole analysis, Kg KN mm ms was followed. INTERFACES: Deleted already defined interfaces and created Type 7 global interface. The properties for the Type 7 interface a Read more

FRONTAL CRASH ANALYSIS
LUV KUMAR · 2019-10-31 04:05:45

OBJECTIVE: To perform a frontal crash simulation using Radioss as a solver. STEPS: View components: In the NEON FRONT model there are 75 components. ASSIGNING MATERIAL ID, PROPERTY ID, AND CARD IMAGE: For rigid bodies, card image is none and prop id, mat id is uns Read more

OBJECTIVE: Studying Interfaces and boundary condition in Hypercrash, Hypermesh and meshing bumper assembly MESHING OF BUMPER ASSEMBLY: Topological error like faces not connected was removed using extend option under surface edit option. Auto mesh under 2D option wa Read more

OBJECTIVE: Through this challenge, we will study different material laws in Radioss and will select the best material law for the given scenario by simulating and plotting graph. STEPS CASE1: Changing the model name from FAILURE_JOHNSON_0000 to Law2_epsmax_failure.R Read more

OBJECTIVE: To compare the results with base simulation and improved shell elements properties by performing energy, mass error checks, plotting graph in HyperGraph and animating in HyperView. SIMULATION 1: With default Shell Properties. Imported Element_Formulati Read more

OBJECTIVE: To clean the geometry, extract mid surface, mesh the extracted surface and assign thickness to given models. LINK TO HYPERMESH FILES https://drive.google.com/file/d/1Op9RLc8y85U2qtlLyBNh5GYCglVHuNqN/view   PROCEDURE: Model was imported and to see Read more

OBJECTIVE: Surface mesh and volume mesh generation on given housing and arm bracket model. LINK TO HYPER MESH RADIOSS FILES: https://drive.google.com/file/d/1h0tOn4b9e9EDoVFqaGuKCjnWRgrHxUvL/view 3D MESHING: 3D Elements should be used when all dimensions are compara Read more

File Parsing in Python
LUV KUMAR · 2019-09-13 06:25:32

OBJECTIVE: To demonstate file parsing using Python. when we run the program, first thing appears is  to enter the filename,if we speicify correct name then we can see the rest output otherwise a message will show file not found. To store different properties li Read more

SciPy Curve Fitting
LUV KUMAR · 2019-09-12 14:32:22

OBJECTIVE: To curve fit given data using linear and cubic polynomial. For curve fitting, we imported curve_fit from scipy library. Defined two function, func and func1 which are used for fitting curve. Defined another function read_file to read temperature and cp v Read more


Loading...

The End