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)
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