Skip to content

andrei-g99/rocket-sim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Index

  1. Introduction
  2. Physics
  3. Gallery

Introduction

Physics

Gravity Force

The simulator applies the standard newtonian gravity formulation. Assuming we are only interested in the force acting on the rocket, and that the center of the Earth is in the origin, the gravitational force is: $$\mathbf{F}_{g} = \frac{G m M_e }{|\mathbf{r}|^3}\mathbf{r}$$ Where:

  • G : gravity constant
  • m : mass of the rocket
  • M_e : mass of Earth
  • r : position vector of the Rocket w.r.t. the origin
# Gravitational force
F_g = (- p * G * M_e * m)/(np.linalg.norm(p)**3)

Drag force

The drag force is assumed to be a quadratic function of velocity, formulated as: $$\mathbf{F}_{d} = - \frac{1}{2} C_d \rho | \mathbf{v} |^2 \cdot \mathbf{\hat{v}}$$ Where:

  • v hat : normalized velocity vector
  • C_d : drag coefficient
  • rho : air density at current altitude
  • |v|: velocity magnitude

If the velocity is 0 the formula is skipped and drag force is also set to 0.

# Compute the drag force
abs_v = np.linalg.norm(v)
if abs_v != 0:
     normalized_vel = v / abs_v
     F_d = -normalized_vel * drag_force(np.linalg.norm(p), abs_v)
else:
     F_d = np.array([0, 0])

Thrust force

The thrust force is the direction of the rocket body orientation and depends on the fuel consumption rate and gas exhaust velocity.

# Compute the thrust force
if m_f > 0 and engine_active:
     F_t = np.array([np.sin(alpha), np.cos(alpha)]) * (r_f * v_e)
     F_t = rot_mat(gimbal_angle) @ F_t
else:
     F_t = np.array([0, 0])

Gallery

alt text

About

Rocket simulator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages