-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment4b.py
More file actions
33 lines (28 loc) · 1.05 KB
/
Assignment4b.py
File metadata and controls
33 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
Assignment 4(b) -Fixed-Point Iteration Method
Name: Isac Rajan
Roll No: 14ME130
Course: Applied Computational Methods in Mechanical Sciences
"""
import numpy as np
ho = 5 #Initial Guess of H
hn = 0.0 #New Value of H- Initalization
es = 0.05/100 #Prespecified Tolerance
ea = 0.0 #Relative Absolute error - Initialization
MAX_ITR = 500
f = open('Results4b.txt', 'w')
f.write("Results: FIXED-POINT ITERATION METHOD\n")
for i in range(1,MAX_ITR+1):
f.write("Iteration {}\n".format(i))
hn = ((0.0135*ho**2 + 0.27*ho + 1.35)/9.05097) ** 0.2 #Formulation
#hn = ((9.05097*ho**5 - 0.27*ho - 1.35)/0.0135) ** 0.5
#hn = (9.05097*ho**5 - 0.0135*ho**2 - 1.35)/0.27
ea = 100 * (hn-ho)/hn
ho = hn
f.write("\tRelative Aprrox Error(%) = {0:.6f}\n".format(abs(ea)))
if abs(ea) < es:
f.write("Solution is {:.5f}: Reached at Iteration = {}".format(hn,i))
break
f.write("\n\nSubtituting the solution in equation of Flow Rate:\n")
f.write("We get: Q = {}".format( ((0.0002**0.5) * (20 * hn) ** (5./3))/(0.03 * (20 + 2*hn) ** (2./3)) ))
f.close()