# This code is public domain. # It is provided 'as is' without warranty of any form. # Andy Brice 15-Sep-2015. # http://www.successfulsoftware.net # # adjust these parameters # impulse= thrust * duration # a C class motor has an impulse of between 5 and 10 Ns mass = 0.15 #Kg thrust = 6 #Newtons duration = 1.6 #seconds step = 0.01 #seconds, smaller = more accurate t = 0.0 #Seconds h = 0.0 #Metres maxh = 0.0 #Metres v = 0.0 #Metres/second maxv = 0.0 #Metres/second g = 9.8 #Gravity Metres/second^2 while h >= 0.0: t = t + step force = -g * mass if t <= duration: force += thrust a = force / mass v += a * step h += v * step if ( h > maxh ): maxh = h if ( v > maxv ): maxv = v #print( "t=", t, " force=", force, " a=", a, " v=", v, " h=", h ) print ( "max height=", maxh, " flight time=", t )