



























Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!




























Anexo de códigos
1. Caída Libre a) import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D V= Z= Re= Cd= Drag= t = 0 h=0. Tmax = 25. dens_air = 1. dens_ball = 8000 Diameter = 0. Radius = Diameter/ Pi = 3. Nu = 0. g=9. test = 0 lt=[] lv=[] lz=[]
lRe=[] ltt=[] lvv=[] vv= hv= while (Tmax>t): if (Re<=1 and Re != 0): Cd = 24/Re elif (Re > 1 and Re <= 400): Cd = 24/pow(Re,0.646) elif (Re > 400 and Re <= 300000): Cd = 0. elif (Re > 300000 and Re <= 2000000): Cd = 0.000366pow(Re,0.4275) elif (Re > 2000000): Cd = 0. Z1 = hV V1= ((dens_air/(dens_ballRadius)) * ( (3/8)pow(V,2)Cd + Radiusg ) -g)h Z2 = h(V + 0.5V1) V2 = ((dens_air/(dens_ballRadius)) * ( (3/8)pow(V+0.5V1,2)Cd + Radiusg ) -g)h Z3 = h(V + 0.5V2) V3 = ((dens_air/(dens_ballRadius)) * ( (3/8)pow(V+0.5V2,2)Cd + Radiusg ) -g)h Z4 = h(V + V3)
ax.plot(lt, lz, label=" ", marker="",color="r") ax.set_xlabel('Tiempo') ax.set_ylabel('Posición') ax.grid(True) ax.legend(loc=2); plt.title('Posición vs. Tiempo') plt.show() fig, ax = plt.subplots() ax.plot(lt, lRe, label=" ", marker="",color="b") ax.set_xlabel('Tiempo') ax.set_ylabel('Num Reynolds') ax.grid(True) ax.legend(loc=2); plt.title('Número de Reynolds vs. Tiempo') plt.show() b) import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D V= Z=
Re= Cd= Drag= t = 0 h=0. Tmax = 25. dens_air = 1. dens_ball = 8000 Diameter =0.001 #0.001 #0.005 #0.02 #0. Radius = Diameter/ Pi = 3. Nu = 0. g=9. test = 0 lt=[] lv=[] lz=[] lRe=[] ltt=[] lvv=[] vv= hv= while (Tmax>t):
hv=vvt t=t+h lv.append(-V) lt.append(t) lz.append(-Z) lRe.append(Re) lvv.append(vv) ltt.append(hv) fig, ax = plt.subplots() ax.plot(lt, lv, label=" ", marker="",color="y") ax.set_xlabel('Tiempo') ax.set_ylabel('Velocidad ') ax.grid(True) ax.legend(loc=2); plt.title('Velocidad vs. Tiempo ') plt.show() fig, ax = plt.subplots() ax.plot(lt, lz, label=" ", marker="*",color="r") ax.set_xlabel('Tiempo') ax.set_ylabel('Posición') ax.grid(True)
ax.legend(loc=2); plt.title('Posición vs. Tiempo ') plt.show() fig, ax = plt.subplots() ax.plot(lt, lRe, label=" ", marker="*",color="b") ax.set_xlabel('Tiempo') ax.set_ylabel('Num Reynolds') ax.grid(True) ax.legend(loc=2); plt.title('Número de Reynolds vs. Tiempo ') plt.show() c) import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D V= Z= Re= Cd= Drag= t = 0
elif (Re > 400 and Re <= 300000): Cd = 0. elif (Re > 300000 and Re <= 2000000): Cd = 0.000366pow(Re,0.4275) elif (Re > 2000000): Cd = 0. Z1 = hV V1= ((dens_air/(dens_ballRadius)) * ( (3/8)pow(V,2)Cd + Radiusg ) -g)h Z2 = h(V + 0.5V1) V2 = ((dens_air/(dens_ballRadius)) * ( (3/8)pow(V+0.5V1,2)Cd + Radiusg ) -g)h Z3 = h(V + 0.5V2) V3 = ((dens_air/(dens_ballRadius)) * ( (3/8)pow(V+0.5V2,2)Cd + Radiusg ) -g)h Z4 = h(V + V3) V4 = ((dens_air/(dens_ballRadius)) * ( (3/8)pow(V+V3,2)Cd + Radiusg ) -g)h Z = Z + (Z1 + 2Z2 + 2Z3 + Z4)/ V = V + (V1 + 2V2 + 2V3 + V4)/ Re = -VDiameter/Nu vv= gt hv=vvt t=t+h lv.append(-V) lt.append(t)
lz.append(-Z) lRe.append(Re) lvv.append(vv) lzz.append(hv) fig, ax = plt.subplots() ax.plot(lt, lv, label="Velocidad en el aire", marker="",color="y") ax.plot(lt, lvv, label="Velocidad en el vacío", marker="",color="g") ax.set_xlabel('Tiempo') ax.set_ylabel('Velocidad ') ax.grid(True) ax.legend(loc=2); plt.title('Velocidad vs. Tiempo ') plt.show() fig, ax = plt.subplots() ax.plot(lt, lz, label="Distancia", marker="",color="r") ax.plot(lt, lzz, label="Distancia vacío", marker="",color="b") ax.set_xlabel('Tiempo') ax.set_ylabel('Posición') ax.grid(True) ax.legend(loc=2);
lz=[] lRe=[] ltt=[] lvv=[] vv= hv= while (Tmax>t): if (Re<=1 and Re != 0): Cd = 24/Re elif (Re > 1 and Re <= 400): Cd = 24/pow(Re,0.646) elif (Re > 400 and Re <= 300000): Cd = 0. elif (Re > 300000 and Re <= 2000000): Cd = 0.000366pow(Re,0.4275) elif (Re > 2000000): Cd = 0. Z1 = hV V1= ((dens_air/(dens_ballRadius)) * ( (3/8)pow(V,2)Cd + Radiusg ) -g)h Z2 = h(V + 0.5V1) V2 = ((dens_air/(dens_ballRadius)) * ( (3/8)pow(V+0.5V1,2)Cd + Radiusg ) -g)h Z3 = h(V + 0.5V2) V3 = ((dens_air/(dens_ballRadius)) * ( (3/8)pow(V+0.5V2,2)Cd + Radiusg ) -g)*h
Z4 = h(V + V3) V4 = ((dens_air/(dens_ballRadius)) * ( (3/8)pow(V+V3,2)Cd + Radiusg ) -g)h Z = Z + (Z1 + 2Z2 + 2Z3 + Z4)/ V = V + (V1 + 2V2 + 2V3 + V4)/ Re = -VDiameter/Nu t=t+h lv.append(V) lt.append(t) lz.append(Z) lRe.append(-Re) fig, ax = plt.subplots() ax.plot(lt, lv, label=" ", marker="",color="y") ax.set_xlabel('Tiempo') ax.set_ylabel('Velocidad') ax.grid(True) ax.legend(loc=2); plt.title('Velocidad vs. Tiempo (Pelota Ping-Pong Diametro= 0.036)') plt.show()
Pe = 2500; Pf = 1.22; l = 2; nu = 0.0000149; g = 9.81; A = (pi/4)(D.^2); vol = (pi/6)(D.^3); mf = Pfvol; me = Pevol; x0 = 30; w0 = 3; t = zeros(1, N); x = zeros(1, N); w = zeros(1, N); Re = zeros(1,N); Cd = zeros(1,N); x(1) = x0; w(1) = w0; Re(1) = 0; Cd(1) = 0.5; for i = 1:N
f1 = @(t,x,w) w; f2 = @(t,x,w) -(Pflabs(w)wACd(i)/(2me)) + ((gsin(x))/(mel))(mf-me); K1x = f1(t(i),x(i),w(i)); K1v = f2(t(i),x(i),w(i)); K2x = f1(t(i) + (h/2),x(i) + (hK1x/2),w(i) + (hK1v/2)); K2v = f2(t(i) + (h/2),x(i) + (hK1x/2),w(i) + (hK1v/2)); K3x = f1(t(i) + (h/2),x(i) + (hK2x/2),w(i) + (hK2v/2)); K3v = f2(t(i) + (h/2),x(i) + (hK2x/2),w(i) + (hK2v/2)); K4x = f1(t(i) + h,x(i) + hK3x,w(i) + hK3v); K4v = f2(t(i) + h,x(i) + hK3x,w(i) + hK3v); t(i+1) = a + ih; x(i+1) = x(i) + ((h/6)(K1x + 2K2x + 2K3x + K4x)); w(i+1) = w(i) + ((h/6)(K1v + 2K2v + 2K3v + K4v)); Re(i+1) = abs(w(i+1))D/nu; if (Re(i+1) > 0) && (Re(i+1) <= 1) Cd(i+1) = 24/Re(i+1); elseif (Re(i+1) > 1) && (Re(i+1) <= 400) Cd(i+1) = 24/((Re(i+1)).^0.646); elseif (Re(i+1) > 400) && (Re(i+1) <= 300000) Cd(i+1) = 0.5; elseif (Re(i+1) > 300000) && (Re(i+1) <= 2000000) Cd(i+1) = 0.000366((Re(i+1)).^0.4275);
K3v = f2(t(i) + (h/2),x1(i) + (hK2x/2),w1(i) + (hK2v/2)); K4x = f1(t(i) + h,x1(i) + hK3x,w1(i) + hK3v); K4v = f2(t(i) + h,x1(i) + hK3x,w1(i) + hK3v); x1(i+1) = x1(i) + ((h/6)(K1x + 2K2x + 2K3x + K4x)); w1(i+1) = w1(i) + ((h/6)(K1v + 2K2v + 2K3v + K4v)); Re1(i+1) = abs(w1(i+1))D/nu; if (Re1(i+1) > 0) && (Re1(i+1) <= 1) Cd1(i+1) = 24/Re1(i+1); elseif (Re1(i+1) > 1) && (Re1(i+1) <= 400) Cd1(i+1) = 24/((Re1(i+1)).^0.646); elseif (Re1(i+1) > 400) && (Re1(i+1) <= 300000) Cd1(i+1) = 0.5; elseif (Re1(i+1) > 300000) && (Re1(i+1) <= 2000000) Cd1(i+1) = 0.000366((Re1(i+1)).^0.4275); elseif (Re1(i+1) > 2000000) Cd1(i+1) = 0.18; end end clear f1 f Pf = 0; x2 = zeros(1, N); w2 = zeros(1, N);
Re2 = zeros(1,N); Cd2 = zeros(1,N); x2(1) = x0; w2(1) = w0; Re2(1) = 0; Cd2(1) = 0.5; for i = 1:N f1 = @(t,x2,w2) w2; f2 = @(t,x2,w2) -(Pflabs(w2)w2ACd2(i)/(2me)) + ((gsin(x2))/(mel))(mf-me); K1x = f1(t(i),x2(i),w2(i)); K1v = f2(t(i),x2(i),w2(i)); K2x = f1(t(i) + (h/2),x2(i) + (hK1x/2),w2(i) + (hK1v/2)); K2v = f2(t(i) + (h/2),x2(i) + (hK1x/2),w2(i) + (hK1v/2)); K3x = f1(t(i) + (h/2),x2(i) + (hK2x/2),w2(i) + (hK2v/2)); K3v = f2(t(i) + (h/2),x2(i) + (hK2x/2),w2(i) + (hK2v/2)); K4x = f1(t(i) + h,x2(i) + hK3x,w2(i) + hK3v); K4v = f2(t(i) + h,x2(i) + hK3x,w2(i) + hK3v); x2(i+1) = x2(i) + ((h/6)(K1x + 2K2x + 2K3x + K4x)); w2(i+1) = w2(i) + ((h/6)(K1v + 2K2v + 2K3v + K4v)); Re2(i+1) = abs(w2(i+1))D/nu;