Esempio n. 1
0
            mins.append(idx)
    return mins


p_dict = {}
p_dict['g'] = 32.2
p_dict['q'] = 100.0
p_dict['y'] = 10.0
p_dict['v'] = 10.0
p_dict['b'] = 10.0

delta_z = 1.0

#p_dict['Y'] = np.arange(0.01,6.0,0.01)

e1 = cp.e_rect(p_dict)
yc1 = cp.yc_rect(p_dict)
ec1 = yc1 * 1.5

p_dict['b'] = 9.0

#--contraction mean new q
p_dict['q'] = (10.0 / 9.0) * (100.0)

Y2 = np.arange(0.001, 10.0, 0.0001)

#--subtract off the step height

#--calculate the residuals
rs = np.zeros_like(Y2)
mins = []
Esempio n. 2
0
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:
    print "choking downstream"
    new_e1 = ec2 + delta_z
    print new_e1
    ys = np.arange(0.0001, 9.17, 0.0001)
    new_alt_ys = cp.find_alternate_depths(new_e1, ys, p_circ, cp.e_circ)
    print new_alt_ys
Esempio n. 3
0
        #--calc this residual
        this_r = abs(this_val - target)
        rs[idx] = this_r
        
    #--loop over the residuals looking for minimums
    mins = []
    for idx in range(1,rs.shape[0]-1):
        if rs[idx] < rs[idx-1] and rs[idx] < rs[idx+1]:
            mins.append(idx)
    
    return z_array[mins]



z = np.arange(0.0001,2.0,0.0001)

target_e = 0.551 #from problem 1

p_rect = {}
p_rect['b'] = 1.0
p_rect['g'] = 9.81
p_rect['Q'] = 1.0
p_rect['q'] = p_rect['Q'] / p_rect['b']
p_rect['y_base'] = 0.5

delta_z = find_z(target_e,z,p_rect,e_rect_with_z)
print delta_z
p_rect['y'] = p_rect['y_base'] + delta_z

print cp.e_rect(p_rect)
#Z = np.array([64.5])
Y1 = np.arange(0, 5, 0.01)
min_tw_resid = 1.0e+20
correct_z = -999
correct_y1 = -999
correct_f1 = -999
for z in Z:
    #--find y1
    min_z_resid = 1.0e+20
    y1 = -999
    for this_y1 in Y1:
        p_rect['y'] = this_y1
        this_f1 = cp.f_rect(p_rect)

        h_loss = k_loss * (h_lake - z - this_y1)
        this_z = h_lake - cp.e_rect(p_rect) - h_loss
        #print this_z
        if abs(this_z - z) < min_z_resid:
            y1 = this_y1
            min_z_resid = abs(this_z - z)
            f1 = this_f1
    #print y1
    #--set y as the correct y1
    p_rect['y'] = y1
    f1 = cp.f_rect(p_rect)
    f1_sq = f1**2
    y2 = (y1 * 0.5) * ((1.0 + (8.0 * f1_sq))**0.5 - 1.0)
    this_tw = y2 + z
    #print this_tw
    if abs(this_tw - tw) < min_tw_resid:
        correct_z = z

Z = np.arange(0,100,0.1)
#Z = np.array([64.5])
Y1 = np.arange(0,10,0.01)
min_tw_resid = 1.0e+20
correct_z = -999
correct_y1 = -999
for z in Z:
    #--find y1
    min_z_resid = 1.0e+20
    y1 = -999
    for this_y1 in Y1:
        p_rect['y'] = this_y1
        h_loss = k_loss * (h_lake - z - this_y1)
        this_z = h_lake - cp.e_rect(p_rect) - h_loss
        #print this_z
        if abs(this_z-z) < min_z_resid:
            y1 = this_y1
            min_z_resid = abs(this_z-z)
    #print y1
    #--set y as the correct y1
    p_rect['y'] = y1
    f1 = cp.f_rect(p_rect)    
    f1_sq = f1**2
    y2 = (y1 * 0.5) * ((1.0 + (8.0*f1_sq))**0.5 - 1.0)
    this_tw = y2 + z
    #print this_tw
    if abs(this_tw-tw) < min_tw_resid:
        correct_z = z
        correct_y1 = y1
Esempio n. 6
0
    for idx in range(1,arr.shape[0]-1):
        if arr[idx] < arr[idx-1] and arr[idx] < arr[idx+1]:
            mins.append(idx)
    return mins


p_dict = {}
p_dict['g'] = 32.2
p_dict['q'] = 100.0
p_dict['y'] = 10.0
p_dict['v'] = 10.0
delta_z = 1.0

#p_dict['Y'] = np.arange(0.01,6.0,0.01)

e1 = cp.e_rect(p_dict)
yc1 = cp.yc_rect(p_dict)
ec1 = yc1*1.5
Y2 = np.arange(0.001,10.0,0.001)
E2 = np.zeros_like(Y2)
print e1,yc1,ec1

#--subtract off the step height
e2 = e1 - delta_z

#--calculate the residuals
rs = np.zeros_like(Y2)
mins = []
for idx in range(Y2.shape[0]):
    #--calc this_e
    p_dict['y'] = Y2[idx]
Esempio n. 7
0
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:
    print 'choking downstream'
    new_e1 = ec2 + delta_z
    print new_e1
    ys = np.arange(0.0001, 9.17, 0.0001)
    new_alt_ys = cp.find_alternate_depths(new_e1, ys, p_circ, cp.e_circ)
    print new_alt_ys
Esempio n. 8
0
#print p_trap['v']
f_trap = cp.f_trap(p_trap)
#print f_trap

e_trap = cp.e_trap(p_trap)
#print e_trap

p_rect = {}
p_rect['b'] = 1.5
p_rect['g'] = 9.81
p_rect['Q'] = 1.0

y = np.arange(0.0001,2.0,0.0001)

rect_depths = cp.find_depths(e_trap,y,p_rect,cp.e_rect)
#print rect_depths
p_rect['y'] = rect_depths[1]

p_rect['q'] = p_rect['Q'] / p_rect['b']

yc = cp.yc_rect(p_rect)
print yc

p_rect['y'] = yc
e_c_rect = cp.e_rect(p_rect)
print e_c_rect

q2c = ((2.0/3.0) * (e_c_rect))**(3.0/2.0) * (9.9)**0.581
print q2c

print p_rect['Q'] / q2c
Esempio n. 9
0
#print p_trap['v']
f_trap = cp.f_trap(p_trap)
#print f_trap

e_trap = cp.e_trap(p_trap)
#print e_trap

p_rect = {}
p_rect['b'] = 1.5
p_rect['g'] = 9.81
p_rect['Q'] = 1.0

y = np.arange(0.0001, 2.0, 0.0001)

rect_depths = cp.find_depths(e_trap, y, p_rect, cp.e_rect)
#print rect_depths
p_rect['y'] = rect_depths[1]

p_rect['q'] = p_rect['Q'] / p_rect['b']

yc = cp.yc_rect(p_rect)
print yc

p_rect['y'] = yc
e_c_rect = cp.e_rect(p_rect)
print e_c_rect

q2c = ((2.0 / 3.0) * (e_c_rect))**(3.0 / 2.0) * (9.9)**0.581
print q2c

print p_rect['Q'] / q2c