CoCalc Public Filesassignments / פרוקייט גמר.ipynbOpen in with one click!
Authors: Dvir Hamdi, yoav yefet
Views : 60
In [ ]:
In [ ]:
In [2]:
def ternimal_vol(m,g,p,a,c):#הפונקציה מחזירהנ את המהירות המקסימלית שאובייקט יגיע אליה return ((2*m*h)/(p*a*c))**0.5
In [3]:
def Track_revaluation(m,s,vn,g,t): v_t = ternimal_vol(m,g,p,a,c) return v_t*math.tanh(v_t*t)
In [ ]:
In [ ]:
In [ ]:
In [4]:
def drag_force(Cd,A,P,V): #the sum of all forces which drag the rocket return (Cd*A*P*V**2)/2 #return the drag force #A - area #Cd - drag coefficient #P - density #V - flow veloctiy #https://he.wikipedia.org/wiki/%D7%92%D7%A8%D7%A8_(%D7%9B%D7%95%D7%97)
In [5]:
def Trust_force(m,v): #the power of the engine of the rocket return m*v #return the trusth force #m - the change of fule #v - the speed of the gass #https://he.wikipedia.org/wiki/%D7%93%D7%97%D7%A3_(%D7%9B%D7%95%D7%97)
In [ ]:
In [6]:
import math import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import matplotlib.animation as animation import random #b - angle of launch #mr - mass of the rocket without fuel #fuel_tank #m = mr + fuel_tank - total mass of the rocket #A = 0.6 - Area of rocket [M**2] #g = 9.8 - gravity coefficient [N/kg , M/s**2] #W = m*g - weight of rocket [N] #p = 1.184 - dencity of fluid [kg/M**3] #dm = 100 - mass of burned fuel per second[Kg] #vw = 0 - velocity of wind [m/s] #t = 0 - time [s] #c = 0.04 - drag coefficient [no units of measurement] #lvy = [0] - list of velocitys on y axis #lvx = [0] - list of velocitys on x axis #x = [0] - list of x [M] #y = [0] - list of Y [M] #m = mr + fuel_tank - total mass of rocket #lah = [] list of acc #TFall = 0 def degrees(x): return(x*math.pi/180) def av(b,W,m): Dy = drag_force(c,A,p,lvy[t] - vw) #(Cd,A,P,V) #drag force on x axis av = ((Trust_force(dm,770) - Dy)*math.sin(b) - W) /m #vertical acceleration [N/kg , M/s**2] return av def ah(b,m,c,p): Dx = drag_force(c,A,p,lvx[t] - vw) #(Cd,A,P,V) #drag force on y axis ah = ((Trust_force(dm,770) - Dx)*math.cos(b)) /m #horizonal acceleration [N/kg , M/s**2] return ah def rocket(b,mr,fuel_tank,A,g,p,dm,vw,t,c): g = 9.8 m = mr + fuel_tank W = m*g lvx = [0] lvy = [0] x = [0] y = [0] lah = [] TFall = 0 time = [0] for t in range(0,2000): time.append(t) if y[-1] < 0: y.pop() x.pop() time.pop() break if fuel_tank > 0: Dx = drag_force(c,A,p,lvx[t] - vw) #(Cd,A,P,V) #drag force on y axis Dy = drag_force(c,A,p,lvy[t] - vw) #(Cd,A,P,V) #drag force on x axis av = ((Trust_force(dm,500) - Dy)*math.sin(b) - W) /m #vertical acceleration [N/kg , M/s**2] ah = ((Trust_force(dm,500) - Dx)*math.cos(b)) /m #horizonal acceleration [N/kg , M/s**2] lah.append(ah) lvy.append(lvy[-1]+av) lvx.append(lvx[-1]+ah) fuel_tank -= dm #every second the fuel ank loses mass of burned fuel m = mr + fuel_tank x.append(x[-1]+lvx[t]) y.append(y[-1]+lvy[t]) else: x.append(x[-1]+lvx[-1]) y.append(y[-1]+lvy[-1]*TFall+0.5*-g*(TFall**2)) TFall+=1 return x,y rocket(degrees(45),100,1000,0.6,9.8,1.184,100,0,0,0.04)
([0, 0, 32.141217326661256, 99.62739502138223, 206.34644283335274, 357.1166395055535, 558.0682131101825, 817.2691917395098, 1145.8308874935458, 1560.0695419453027, 2086.4128989770816, 2775.6165723294325, 3464.8202456817835, 4154.023919034134, 4843.227592386485, 5532.431265738836, 6221.634939091187, 6910.838612443538, 7600.042285795889, 8289.24595914824, 8978.449632500591, 9667.653305852942, 10356.856979205293, 11046.060652557644, 11735.264325909995, 12424.467999262346, 13113.671672614697, 13802.875345967048, 14492.079019319399, 15181.28269267175, 15870.4863660241, 16559.69003937645, 17248.8937127288, 17938.09738608115, 18627.3010594335, 19316.50473278585, 20005.708406138197, 20694.912079490547, 21384.115752842896, 22073.319426195245, 22762.523099547594, 23451.726772899943, 24140.930446252292, 24830.13411960464, 25519.33779295699, 26208.54146630934, 26897.74513966169, 27586.948813014038, 28276.152486366387, 28965.356159718736, 29654.559833071085, 30343.763506423435, 31032.967179775784, 31722.170853128133, 32411.374526480482, 33100.57819983283, 33789.78187318518, 34478.98554653753, 35168.18921988988, 35857.39289324223, 36546.59656659458, 37235.800239946926, 37925.003913299275, 38614.207586651624, 39303.41126000397, 39992.61493335632, 40681.81860670867, 41371.02228006102, 42060.22595341337, 42749.42962676572, 43438.63330011807, 44127.83697347042, 44817.04064682277, 45506.244320175116, 46195.447993527465, 46884.651666879814, 47573.85534023216, 48263.05901358451, 48952.26268693686, 49641.46636028921, 50330.67003364156, 51019.87370699391, 51709.07738034626, 52398.28105369861, 53087.484727050956, 53776.688400403305, 54465.892073755655, 55155.095747108004, 55844.29942046035, 56533.5030938127, 57222.70676716505, 57911.9104405174, 58601.11411386975, 59290.3177872221, 59979.52146057445, 60668.7251339268, 61357.928807279146, 62047.132480631495, 62736.336153983844, 63425.53982733619, 64114.74350068854, 64803.94717404089, 65493.15084739324, 66182.35452074559, 66871.55819409795, 67560.7618674503, 68249.96554080266, 68939.16921415502, 69628.37288750737, 70317.57656085973, 71006.78023421208, 71695.98390756444, 72385.1875809168, 73074.39125426915, 73763.59492762151, 74452.79860097387, 75142.00227432622, 75831.20594767858, 76520.40962103094, 77209.61329438329, 77898.81696773565, 78588.020641088, 79277.22431444036, 79966.42798779272, 80655.63166114507, 81344.83533449743, 82034.03900784979, 82723.24268120214, 83412.4463545545, 84101.65002790686, 84790.85370125921, 85480.05737461157, 86169.26104796393, 86858.46472131628, 87547.66839466864, 88236.872068021, 88926.07574137335, 89615.27941472571, 90304.48308807806, 90993.68676143042, 91682.89043478278, 92372.09410813513, 93061.29778148749, 93750.50145483985, 94439.7051281922, 95128.90880154456, 95818.11247489692, 96507.31614824927, 97196.51982160163, 97885.72349495399, 98574.92716830634, 99264.1308416587, 99953.33451501105, 100642.53818836341, 101331.74186171577, 102020.94553506812, 102710.14920842048, 103399.35288177284, 104088.5565551252], [0, 0, 22.341217326661248, 69.25275916667898, 143.44566727176533, 248.2886213983865, 388.0814422034324, 568.5059440049371, 797.4270317166959, 1086.470243818149, 1454.6334168381477, 1454.6334168381477, 1933.9645154747218, 2882.8267127478703, 4291.420008657593, 6149.94440320389, 8448.59989638676, 11177.586488206207, 14327.104178662226, 17887.35296775482, 21848.532855483987, 26200.843841849728, 30934.485926852045, 36039.65911049094, 41506.5633927664, 47325.39877367844, 53486.36525322705, 59979.662831412235, 66795.49150823399, 73924.05128369232, 81355.54215778723, 89080.16413051872, 97088.11720188678, 105369.6013718914, 113914.8166405326, 122713.9630078104, 131757.24047372476, 141034.8490382757, 150536.98870146318, 160253.85946328726, 170175.66132374792, 180292.59428284515, 190594.85834057897, 201072.65349694932, 211716.17975195625, 222515.63710559977, 233461.22555787986, 244543.14510879654, 255751.59575834978, 267076.7775065396, 278508.890353366, 290038.13429882895, 301654.7093429285, 313348.81548566464, 325110.6527270374, 336930.42106704664, 348798.3205056925, 360704.5510429749, 372639.3126788939, 384592.8054134495, 396555.22924664157, 408516.78417847026, 420467.6702089355, 432398.0873380374, 444298.23556577583, 456158.3148921508, 467968.5253171624, 479719.0668408105, 491400.1394630953, 503001.9431840166, 514514.6780035745, 525928.5439217689, 537233.7409385999, 548420.4690540675, 559478.9282681717, 570399.3185809124, 581171.8399922898, 591786.6925023036, 602234.0761109542, 612504.1908182412, 622587.2366241649, 632473.413528725, 642152.9215319218, 651615.9606337552, 660852.7308342251, 669853.4321333315, 678608.2645310746, 687107.4280274542, 695341.1226224704, 703299.5483161232, 710972.9051084125, 718351.3929993385, 725425.2119889009, 732184.5620771, 738619.6432639357, 744720.6555494079, 750477.7989335167, 755881.2734162621, 760921.2789976441, 765588.0156776627, 769871.6834563178, 773762.4823336095, 777250.6123095377, 780326.2733841025, 782979.6655573039, 785200.9888291418, 786980.4431996164, 788308.2286687274, 789174.5452364752, 789569.5929028594, 789483.5716678803, 788906.6815315377, 787829.1224938317, 786241.0945547622, 784132.7977143294, 781494.4319725331, 778316.1973293734, 774588.2937848503, 770300.9213389638, 765444.2799917138, 760008.5697431004, 753983.9905931236, 747360.7425417833, 740129.0255890796, 732279.0397350125, 723800.9849795819, 714685.0613227879, 704921.4687646305, 694500.4073051097, 683412.0769442255, 671646.6776819777, 659194.4095183667, 646045.4724533921, 632190.0664870542, 617618.3916193529, 602320.6478502881, 586287.0351798598, 569507.7536080682, 551973.0031349132, 533672.9837603947, 514597.8954845128, 494737.9383072674, 474083.3122286586, 452624.21724868636, 430350.85336735076, 407253.4205846517, 383322.11890058924, 358547.14831516333, 332918.70882837404, 306427.0004402213, 279062.2231507051, 250814.57695982547, 221674.2618675824, 191631.4778739759, 160676.42497900603, 128799.3031826727, 95990.31248497595, 62239.652885915784, 27537.524385492172])
In [13]:
for k in range(0,90,10): x = [] #list of x values y = [] #list of y values x = rocket(degrees(k),100,1000,0.6,9.8,1.184,100,0,0,0.04)[0] y = rocket(degrees(k),100,1000,0.6,9.8,1.184,100,0,0,0.04)[1] plt.subplot(121) plt.plot(degrees(k),max(y),'g.') # in each point we took the highest point the rocket reached plt.xlabel('degrees(r)') plt.ylabel('y max [m]') plt.subplot(222) plt.plot(degrees(k),x[-1],'b.') plt.xlabel('degrees(r)') plt.ylabel('x [m]')
/ext/anaconda-2019.03/lib/python3.7/site-packages/ipykernel/__main__.py:6: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance. /ext/anaconda-2019.03/lib/python3.7/site-packages/ipykernel/__main__.py:10: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
Text(0, 0.5, 'x [m]')
In [14]:
k = 0.01 #the first value of c l = [] #list of max y values ks = [] # list of k values while k < 0.3: x = [] # list of x values ks.append(k) y = [] # list of x values x = rocket(degrees(45),100,1000,0.6,9.8,1.184,100,0,0,k)[0] y = rocket(degrees(45),100,1000,0.6,9.8,1.184,100,0,0,k)[1] l.append(max(y)) # we took the max value of y from every plt.subplot(222) plt.plot(k,x[-1],'b.') plt.xlabel('c') plt.ylabel('x [m]') k += 0.01 plt.subplot(121) plt.plot(ks,l,'g') plt.xlabel('c') plt.ylabel('y max [m]')
/ext/anaconda-2019.03/lib/python3.7/site-packages/ipykernel/__main__.py:11: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
Text(0, 0.5, 'y max [m]')
In [ ]: