Hidráulica computacional

Estudiantes de Ingenieria Civil, que quieran platicar sobre su escuela, examenes y cursos.
Regulus
Usuario Principiante
Usuario Principiante
Mensajes: 1
Registrado: Mar Jun 28, 2022 2:27 pm
Colombia

import numpy as numpy
import matplotlib as mp
while True:
Pregunta=input("ELIGE LA OPCION\nProfundidades Alternas [1]\nProfundidad Critica [2] \n")
if Pregunta == str(1) or Pregunta == str(2): break
print("")
print("")
Pregunta=int(Pregunta)
print(" INGRESAR DATOS ")

if Pregunta == 1:
g=9.8
m = float(input("Ingrese la pendiente del Talud [m]: "))
b = float(input("Ingrese el Ancho de Fondo : "))
Q = float(input("Ingrese el Caudal del Canal [Q]: "))
E = float(input("Ingrese la Energia [E]: "))

C1 = 2 * m**2 * g
C2 = (4 * b * m * g) - (2 * m**2 * g * E)
C3 = (2 * b**2 * g) - (4 * b * g * m * E)
C4 = -2 * g * b**2 * E
C5 = 0
C6 = Q**2

print("")
print("RESULTADOS")

L5 = [C1,C2,C3,C4,C5,C6]

Raiz_ok = []
R = numpy.roots(L5)
for i in range(len(R)):
j = str(R)
aux_1 = j.find("+")
if aux_1 != -1:
j = str(R)
aux = j.find("+")
if aux == -1:
j_aux = j[3:-1]
aux = j_aux.find("-")
aux = aux + 3
k1 = float(j[1:aux])
k2 = float(j[aux+1:-2])
if k1 > 0 and k2 == 0:
Raiz_ok.append(R)
if aux_1 == -1:
j = str(R)
aux_2 = j.find("-")
if aux_2 == -1:
Raiz_ok.append(R)
print("")
if len(Raiz_ok)==0:
print("NO SE HALLARON RAICES POSIBLES PARA EL CANAL")
else:
print(f"Para una Energia de \033[1;31m{E}\033[0m las raices halladas son:\n\033[1;33mY subcritica\033[0m:{float(max(Raiz_ok))}\n\033[1;33mY supercritica\033[0m:{float(min(Raiz_ok))}")


if Pregunta == 2:
g=9.8
m = float(input("Indice del Talud? [m]: "))
b = float(input("Ancho de Fondo? : "))
Q = float(input("Caudal del Canal? [Q]: "))

C1 = m**3 * g
C2 = 3 * m**2 * b * g
C3 = 3 * b**2 *m *g
C4 = b**3 * g
C5 = 0
C6 = -2 * Q**2 * m
C7 = -(Q**2) * b

print("")
print("RESULTADOS")

L6 = [C1,C2,C3,C4,C5,C6,C7]

Raiz_ok = []
R = numpy.roots(L6)
for i in range(len(R)):
j = str(R)
aux = j.find("+")
if aux == -1:
j_aux = j[3:-1]
aux = j_aux.find("-")
aux = aux + 3
k1 = float(j[1:aux])
k2 = float(j[aux+1:-2])
if k1 > 0 and k2 == 0:
Raiz_ok.append(R)


for i in range(len(L6)):
print(f"Coeficiente \033[1;31m{i + 1}\033[0m: {L6}")
print("")
for i in range(len(R)):
print(f"Raiz \033[1;31m{i + 1}\033[0m: {R}")
if len(Raiz_ok)>=1:
y = min(Raiz_ok)
y_aux1 = str(y)
y_aux2 = y_aux1.find("+")
y = float(y_aux1[1:y_aux2])

# ----

Area = b*y + m * y**2
Velocidad = Q / Area
Cv = Velocidad**2 / (2*g)
E_min = Cv + y

print("")
print(f"Raiz util \033[1;33m[Profundidad critica]\033[0m: {y}")
print("")
print(f"\033[1;31mArea\033[0m: {Area}")
print(f"\033[1;31mVelocidad\033[0m: {Velocidad}")
print(f"\033[1;31mCv\033[0m: {Cv}")
print(f"\033[1;31mEnergia Minima para la profundidad critica\033[0m: {E_min}")
else:
print("NO SE HALLO RAIZ POSIBLE PARA EL CANAL")
Responder

Volver a “Estudiantes”

  • Información