0
rocket = cylinder( pos=vector(0,0,0), color=color.red, size=vector(0.5,0.1,0.1),
                   velocity = vector(0,0,0), mass=100, fuel_mass=10.0,
                   make_trail = True, axis=vector(0,1,0) )

initial_mass = rocket.mass + rocket.fuel_mass
initial_fuel_mass = rocket.fuel_mass

graph(fast=True)
r_pos = gcurve(color=color.red)

exhaust_velocity = vector(0,-100,0)
mdot = 1.0 # Rate of mass loss per time.
dt = 0.001
t = 0
scene.camera.follow(rocket)

while (rocket.fuel_mass > 0):
    rate(500)
    dm = mdot*dt # Amount of mass lost in time dt.
    rocket.velocity = rocket.velocity + dm/(rocket.mass+rocket.fuel_mass)*(-exhaust_velocity)
    rocket.pos = rocket.pos + rocket.velocity*dt
    rocket.fuel_mass = rocket.fuel_mass - dm
    rocket.opacity = rocket.fuel_mass/initial_fuel_mass
    t = t + dt
    r_pos.plot(pos=(t,rocket.pos.y))

print(rocket.velocity.y,mag(exhaust_velocity)*log(initial_mass/rocket.mass))  

#-----CALCULATING RANGE, TIME OF FLIGHT, MAXIMUM HEIGHT, LANDING VELOCITY FOR DIFFERENT VALUES OF INITIAL VELOCITY RELATIVE TO TERMINAL VELOCITY------#
low=alpha-0.5
intermediate=alpha
high=alpha+0.5

for vfactor in [low,intermediate,high]:
  velocity=vfactor*vt*vector(cos(theta), sin(theta), 0)
  #constants for drag force
  B1=m*mag(g)/vt
  B2=m*mag(g)/(vt**2)
  #drag forces
  Fdrag1=-B1*velocity
  Fdrag2=-B2*(mag(velocity)**2)*norm(velocity)
  print('For vfactor =', vfactor, '\n')
  
  print('For motion without drag forces :')
  projectile_cal(vector(0,0,0))
  print('\nFor motion with linear drag force, FD1 = -beta1*v :')
  projectile_cal(Fdrag1)
  print('\nFor motion with quadratic drag force, FD2 = -beta2*(v^2)*norm(v) :')
  projectile_cal(Fdrag2)
  print('-'*80, '\n')

I have the simulation, but i don’t know how to display results/outputs. I don’t know how to connect the dots, if you know what i mean. Thank You.

Use characteristics similar to the Falcon 9 rocket for the following: Total Mass: 433,100 kg First Stage Propellant Mass: 321,600 kg Thrust: 7,607 kN Exhaust Velocity: 2,766 m/s

A) Calculations: i. Calculate how long it take for the rocket to burn through its fuel. ii. Calculate the final velocity of the rocket after all the fuel expended. B) GlowScript Simulation: i. Use GlowScript to simulate the motion of the rocket. Your simulation should calculate the following for each time step: position, velocity, acceleration, rocket mass. ii. Plot the position, velocity, acceleration, rocket mass as functions of time.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
John
  • 1
  • 1
  • As I understand, you are supposed to show several charts. Consider velocity. For each moment of time you will have some velocity value. So, you need to save all these values and then plot a graph. Try to use pandas dataframe to save and plot data. With pandas you can create several columns: time, position, velocity, acceleration and so on. – user12628549 Dec 16 '22 at 18:09

0 Answers0