Exemplo n.º 1
0
k_loss = 0.0

Z = np.arange(80, 95, 0.01)
#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
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
        correct_y2 = y2
        min_tw_resid = abs(this_tw-tw)


print 'z,y1,y2',correct_z,correct_y1,correct_y2

if correct_y1 == Y1[0] or correct_y1 == Y1[-1]:
    print 'warning y1 not bracketing...'
Exemplo n.º 3
0

Z = np.arange(80, 95, 0.01)
# Z = np.array([64.5])
Y1 = np.arange(0, 5, 0.01)
min_tw_resid = 1.0e20
correct_z = -999
correct_y1 = -999
correct_f1 = -999
for z in Z:
    # --find y1
    min_z_resid = 1.0e20
    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
Exemplo n.º 4
0
import math
import numpy as np
import pylab

import calc_prism as cp     
 
#--tri params    
p_dict = {}   
p_dict['y'] = 1.12
p_dict['v'] = 60.0
p_dict['g'] = 32.2
p_dict['q'] = 60.0 * 1.12
f = cp.f_rect(p_dict)
m = cp.m_rect(p_dict)
print 'approach F: ',f
y = np.arange(0.001,100.0,0.001)
conj_depths = cp.find_depths(m,y,p_dict,cp.m_rect)
print conj_depths
#--find conjugates
#
#conj_c = cp.find_depths(m,y,p_dict,cp.m_tri)
#print conj_c
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
        correct_y2 = y2
        min_tw_resid = abs(this_tw - tw)

print 'z,y1,y2', correct_z, correct_y1, correct_y2

if correct_y1 == Y1[0] or correct_y1 == Y1[-1]:
    print 'warning y1 not bracketing...'
Exemplo n.º 6
0
Y = np.arange(0.01,3.5,0.01)
Q = np.arange(1.0,200.0,1.0)

r_f = 1.0e+20
correct_y = -999
correct_f = -999
correct_Q = -999
#tol_f = 0.01
#tol_h = 0.01
for y in Y:
    p_dict['y'] = y
    #print y
    r_h = 1.0e+20
    correct_Q_temp = ((H_res - y)*(2.0*p_dict['g']*(cp.area_rect(p_dict)**2)))**0.5     
    p_dict['Q'] = correct_Q_temp        
    f = cp.f_rect(p_dict)
    
    print y,f,correct_Q_temp,r_h
    if abs(f-1.0) < r_f:
        r_f = abs(f-1.0)
        correct_y = y
        correct_f = f
        correct_Q = correct_Q_temp    
    #this_r_f = abs(f - 1.0) 
    #break 
print r_h,r_f
print 'y,f,Q,r_f',correct_y,correct_f,correct_Q,r_f
p_dict['y'] = correct_y
p_dict['Q'] = correct_Q
numer = n**2 * p_dict['Q']**2
demon = kn**2 * cp.area_rect(p_dict)**2 * cp.r_rect(p_dict)**(4.0/3.0)