E55F
Skip to content

Repository files navigation

Lunar Transfer Orbital Simulation

A 2D Earth–Moon orbital flight simulation written in Python using numerical integration and event-driven mission phases.

This project simulates a multi-stage launch vehicle from liftoff, orbital insertion, translunar injection (TLI), and lunar transfer coast using custom physics, guidance, and mission sequencing systems.

Figure_5

Overview

This simulator was built to explore orbital mechanics, launch guidance, and translunar mission planning from the ground up without relying on external aerospace simulation engines.

The simulation includes:

  • Multi-stage launch vehicle dynamics
  • Earth and Moon gravity
  • Atmospheric drag
  • Open-loop ascent guidance
  • PEG-inspired orbital insertion guidance
  • Translunar Injection (TLI)
  • Dynamic launch window targeting
  • Event-driven mission phases
  • Numerical orbit propagation using SciPy

The project started as a launch/orbit sandbox and gradually evolved into a larger orbital mission framework.

Main Features

animation

Vehicle Simulation

  • Multi-stage rocket support
  • Wet/dry mass tracking
  • Stage separation
  • Variable thrust and ISP per stage
  • Mass flow simulation
STAGES = [
    {'name': 'Stage 1', 'm_wet': 2214e3, 'm_dry': 13e3, 'thrust': 33e6, 'isp': 250},
    {'name': 'Stage 2', 'm_wet': 470e3, 'm_dry': 43e3, 'thrust': 44e5, 'isp': 420},
    {'name': 'Stage 3', 'm_wet': 1205e2, 'm_dry': 152e2, 'thrust': 1e6, 'isp': 421},
]
mass ascent_1

Orbital Mechanics

  • Newtonian gravity
  • Two-body and Earth–Moon interactions
  • Elliptical Moon orbit
  • Orbital energy calculations
  • Apoapsis/periapsis estimation
Orbit luna_orbit

Atmospheric Model

  • Atmospheric density interpolation from real data
  • Aerodynamic drag calculations
  • Dynamic velocity losses during ascent
Figure_7

Guidance System

Ascent Guidance

The launch vehicle performs a gravity turn using configurable pitch shaping. With parameters for pitch start, ascent path, final booster angle and such.

Orbital Insertion

A PEG-inspired guidance mode attempts to circularize into Low Earth Orbit.

Translunar Injection (TLI)

The simulation computes launch timing windows and performs a continuous prograde burn until the transfer trajectory reaches lunar distance.

ascent_h_s_m

Development Notes

Early mission planning, transfer geometry calculations, and guidance experimentation were initially prototyped on whiteboard/paper before implementation.

Whiteboard2 Whiteboard1

Mission Sequencing

The mission is organized into flexible event-driven phases, which can be freely modified:

  • Liftoff
  • Ascent
  • Stage Separation
  • Orbital Insertion
  • Parking Orbit Coast
  • TLI Window Alignment
  • Translunar Injection Burn
  • Lunar Transfer Coast
mission_phases = [
    {'name': 'Liftoff', 'mode': 'burn', 'stage': 0, 'end': 'altitude', 'value': booster_pitch_start},
    {'name': 'Ascent', 'mode': 'burn', 'stage': 0, 'end': 'burnout', 'value': None},
    {'name': 'Stage 2', 'mode': 'burn', 'stage': 1, 'end': 'burnout', 'value': None},
    {'name': 'Stage 3 LEO', 'mode': 'burn', 'stage': 2, 'end': 'orbit', 'value': None},
    {'name': 'Coast', 'mode': 'coast', 'stage': 2, 'end': 'duration', 'value': 4000},
    {'name': 'LEO Coast', 'mode': 'coast', 'stage': 2, 'end': 'luna_in_place', 'value': None},
    {'name': 'LEO Coast Window', 'mode': 'coast', 'stage': 2, 'end': 'tli_window', 'value': None},
    {'name': 'TLI Burn', 'mode': 'burn', 'stage': 2, 'end': 'tli', 'value': None},
    {'name': 'TLI Coast', 'mode': 'coast', 'stage': 2, 'end': 'altitude', 'value': luna_per},
    {'name': 'Luna Orbit Coast', 'mode': 'coast', 'stage': 2, 'end': 'duration', 'value': 40000},
]

Physics Model

Main Equations used

The simulator numerically integrates motion using:
F = m * a

and Newtonian gravity:
F = G * ( m1 * m2 / r ^ 2 )

Orbital Velocity / Vis-Viva Equation
v = sqrt( mu * (2/r - 1/a))

Kepler’s Third Law:
T = 2pi * sqrt( a^3/mu )

Rocket Equation (Tsiolkovsky):
dv = Isp * g0 * ln( m0/mt )

The equations of motion are propagated using:
scipy.integrate.solve_ivp
LSODA adaptive solver

Technologies Used

  • Python
  • NumPy
  • SciPy
  • Matplotlib

Example Outputs

2D Earth–Moon Transfer

1

Altitude Profile

4 2

Speed Profile

5

Mass Profile

7 6

Guidance Angles

8 9

Project Structure

orbital_simulation/
├── main.py
├── earth_atmosphere_density.txt
└── README.md

Future versions will split the project into:

  • physics modules
  • guidance systems
  • targeting utilities
  • visualization tools
  • mission configuration files

Current Limitations

This project is still under active development and currently uses several approximations:

  • Simplified 2D orbital plane
  • No true patched-conic sphere-of-influence transitions
  • Simplified Moon transfer targeting
  • No full n-body propagation
  • Guidance algorithms are still experimental
  • Lunar orbit insertion is not yet implemented

Despite these simplifications, the simulation produces stable launch, orbit insertion, and translunar transfer behavior suitable for experimentation and visualization.

Future Improvements

Planned upgrades include:

  • Patched conics
  • Lunar sphere-of-influence transitions
  • Real lunar capture/orbit insertion
  • Improved PEG guidance
  • Orbital element utilities
  • Config system and GUI launcher
  • Better telemetry and plotting
  • Real-time visualization
  • 3D simulation support
  • Numerical optimization for transfer targeting

Running the Simulation

Install dependencies

pip install numpy scipy matplotlib

Run

python Main.py

Why I Built This

This project was created as a personal engineering and physics challenge to better understand:

  • orbital mechanics
  • launch dynamics
  • numerical integration
  • spacecraft guidance
  • mission sequencing
  • aerospace simulation architecture

Most of the systems were implemented manually from first principles rather than using existing aerospace frameworks.

References / Resources

About

Orbital Simulation - Takeoff to Lunar Transfer - Fully Plotted - Highly Flexible

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0