import math import numpy as np import pylab import calc_prism as cp delta_z = 3.279 p_circ = {} p_circ["Q"] = 262.0 p_circ["d"] = 9.18 p_circ["y"] = 7.34 p_circ["g"] = 32.2 a = cp.area_circ(p_circ) b = cp.width_circ(p_circ) p_circ["v"] = p_circ["Q"] / a e = cp.e_circ(p_circ) f = cp.f_circ(p_circ) print a, b, e, f e2 = e - delta_z p_rect = {} p_rect["g"] = 32.3 p_rect["b"] = 6.56 p_rect["q"] = p_circ["Q"] / 6.56 yc2 = cp.yc_rect(p_rect) p_rect["y"] = yc2 ec2 = cp.e_rect(p_rect) print yc2, ec2 if e2 < ec2:
kn = 1.49 s = 0.001 tol = 1.0e+20 Y = np.arange(0.001, 1.0, 0.001) r = 1.0e+20 correct_y1 = -999 correct_f = -999 correct_re = -999 for y in Y: p_dict['y'] = y re = cp.re_circ(p_dict) f = find_f(re) lhs = (p_dict['Q'] * (f**0.5)) / ((8.0 * p_dict['g'] * s)**0.5) rhs = cp.area_circ(p_dict) * cp.r_circ(p_dict)**0.5 this_r = abs(lhs - rhs) if this_r < r: r = this_r correct_y1 = y correct_f = f correct_re = re print 'y,f,re', correct_y1, correct_f, correct_re p_dict['y'] = correct_y1 n = (kn * correct_f**0.5 * cp.r_circ(p_dict)**(1.0 / 6.0)) / ( (8.0 * p_dict['g'])**0.5) print 'n', n p_dict['d'] = 5.0 Y = np.arange(0.001, 5.0, 0.001)
import numpy as np import calc_prism as cp y = 10.0 v = 10.0 ys = np.arange(0.001,10.0,0.001) p_circ = {} p_circ['y'] = 7.34 p_circ['g'] = 32.2 p_circ['Q'] = 262. p_circ['d'] = 9.18 a_circ = cp.area_circ(p_circ) print a_circ b_circ = cp.width_circ(p_circ) print b_circ p_circ['v'] = 262.0/a_circ f_circ = cp.f_circ(p_circ) print f_circ
target_v = 2.0 kn = 1.49 tol = 1.0e+20 S = np.arange(0.001,0.005,0.0001) Q = np.arange(0.01,2.0,0.01) r = 1.0e+20 for s in S: r1 = 1.0e+20 for q in Q: p_dict['Q'] = q re = cp.re_circ(p_dict) f = find_f(re) lhs = (p_dict['Q'] * (f**0.5)) / ((8.0 * p_dict['g'] * s)**0.5) rhs = cp.area_circ(p_dict) * cp.r_circ(p_dict)**0.5 #print lhs,rhs,q this_r = abs(lhs-rhs) if this_r < r1: r1 = this_r correct_Q = q correct_f = f correct_re = re this_v = correct_Q / cp.area_circ(p_dict) #print s,correct_Q,this_v #break this_r = abs(this_v - target_v) if this_r < r: r = this_r correct_s = s
target_v = 2.0 kn = 1.49 tol = 1.0e+20 S = np.arange(0.001, 0.005, 0.0001) Q = np.arange(0.01, 2.0, 0.01) r = 1.0e+20 for s in S: r1 = 1.0e+20 for q in Q: p_dict['Q'] = q re = cp.re_circ(p_dict) f = find_f(re) lhs = (p_dict['Q'] * (f**0.5)) / ((8.0 * p_dict['g'] * s)**0.5) rhs = cp.area_circ(p_dict) * cp.r_circ(p_dict)**0.5 #print lhs,rhs,q this_r = abs(lhs - rhs) if this_r < r1: r1 = this_r correct_Q = q correct_f = f correct_re = re this_v = correct_Q / cp.area_circ(p_dict) #print s,correct_Q,this_v #break this_r = abs(this_v - target_v) if this_r < r: r = this_r correct_s = s
kn = 1.49 s = 0.001 tol = 1.0e+20 Y = np.arange(0.001,1.0,0.001) r = 1.0e+20 correct_y1 = -999 correct_f = -999 correct_re = -999 for y in Y: p_dict['y'] = y re = cp.re_circ(p_dict) f = find_f(re) lhs = (p_dict['Q'] * (f**0.5)) / ((8.0 * p_dict['g'] * s)**0.5) rhs = cp.area_circ(p_dict) * cp.r_circ(p_dict)**0.5 this_r = abs(lhs-rhs) if this_r < r: r = this_r correct_y1 = y correct_f = f correct_re = re print 'y,f,re',correct_y1,correct_f,correct_re p_dict['y'] = correct_y1 n = (kn * correct_f**0.5 * cp.r_circ(p_dict)**(1.0/6.0)) /((8.0 * p_dict['g'])**0.5) print 'n',n p_dict['d'] = 5.0 Y = np.arange(0.001,5.0,0.001) correct_y1 = -999
rhs = (n * p_dict['Q']) / (kn * (s**0.5)) tol = 1.0e+20 Y = np.arange(0.001, p_dict['d'], 0.001) r = 1.0e+20 correct_y1 = -999 correct_f = -999 correct_re = -999 for y in Y: p_dict['y'] = y #re = cp.re_circ(p_dict) #f = find_f(re) #lhs = (p_dict['Q'] * (f**0.5)) / ((8.0 * p_dict['g'] * s)**0.5) #rhs = cp.area_circ(p_dict) * cp.r_circ(p_dict)**0.5 lhs = (cp.area_circ(p_dict)**(5.0 / 3.0)) / (cp.p_circ(p_dict) **(2.0 / 3.0)) this_r = abs(lhs - rhs) if this_r < r: r = this_r correct_y1 = y print 'y,', correct_y1 p_dict['y'] = correct_y1 p_dict['v'] = p_dict['Q'] / cp.area_circ(p_dict) froude = cp.f_circ(p_dict) print 'v,fr', p_dict['v'], froude
kn = 1.49 s = 0.005 tol = 1.0e+20 Y = np.arange(0.001,1.0,0.001) r = 1.0e+20 correct_y1 = -999 correct_f = -999 correct_re = -999 for y in Y: p_dict['y'] = y re = cp.re_circ(p_dict) f = find_f(re) lhs = (p_dict['Q'] * (f**0.5)) / ((8.0 * p_dict['g'] * s)**0.5) rhs = cp.area_circ(p_dict) * cp.r_circ(p_dict)**0.5 this_r = abs(lhs-rhs) if this_r < r: r = this_r correct_y1 = y correct_f = f correct_re = re print 'y,f,re',correct_y1,correct_f,correct_re p_dict['y'] = correct_y1 p_dict['v'] = p_dict['Q'] / cp.area_circ(p_dict) froude = cp.f_circ(p_dict) print 'v,fr',p_dict['v'],froude
rhs = (n * p_dict['Q']) / (kn * (s**0.5)) tol = 1.0e+20 Y = np.arange(0.001,p_dict['d'],0.001) r = 1.0e+20 correct_y1 = -999 correct_f = -999 correct_re = -999 for y in Y: p_dict['y'] = y #re = cp.re_circ(p_dict) #f = find_f(re) #lhs = (p_dict['Q'] * (f**0.5)) / ((8.0 * p_dict['g'] * s)**0.5) #rhs = cp.area_circ(p_dict) * cp.r_circ(p_dict)**0.5 lhs = (cp.area_circ(p_dict)**(5.0/3.0)) / (cp.p_circ(p_dict)**(2.0/3.0)) this_r = abs(lhs-rhs) if this_r < r: r = this_r correct_y1 = y print 'y,',correct_y1 p_dict['y'] = correct_y1 p_dict['v'] = p_dict['Q'] / cp.area_circ(p_dict) froude = cp.f_circ(p_dict) print 'v,fr',p_dict['v'],froude
p_dict['g'] = 32.2 p_dict['d'] = 3.0 p_dict['Q'] = 15.0 kn = 1.49 s = 0.002 n = 0.015 rhs = (n * p_dict['Q']) / (kn * (s**0.5)) Y = np.arange(0.001,2.9,0.001) r = 1.0e+20 correct_y1 = -999 for y in Y: p_dict['y'] = y lhs = (cp.area_circ(p_dict)**(5.0/3.0)) / (cp.p_circ(p_dict)**(2.0/3.0)) this_r = abs(lhs-rhs) if this_r < r: r = this_r correct_y1 = y print 'y',correct_y1 p_dict['y'] = correct_y1 print 'f1',cp.f_circ(p_dict) p_dict['Y'] = Y yc1 = cp.yc_circ(p_dict) print 'yc1',yc1 p_dict['y'] = yc1 print 'fc1',cp.f_circ(p_dict) s = 0.02 rhs = (n * p_dict['Q']) / (kn * (s**0.5))