Build an Orbital Simulator in Julia
Write the math that keeps satellites in orbit—from scratch.
Last reviewed: March 2026Overview
Satellites do not just float randomly in space—their paths are governed by Newton's law of gravitation, a beautiful and precise equation that engineers have been using since the 1680s. In this project you will implement that equation in Julia, a modern scientific computing language that combines Python's readability with speeds close to compiled C. You will watch a simulated satellite trace perfect ellipses on your screen, driven by the same math NASA uses.
The key technique is numerical integration: breaking time into tiny steps and recalculating velocity and position at each one. Julia's DifferentialEquations.jl package wraps this process in a friendly interface so you can focus on the physics rather than the numerics. You will compare different orbit types—circular, elliptical, and highly elliptical—by changing just a few initial numbers.
Even if you have never programmed before, Julia is one of the most readable languages available. By the end of the project you will understand the two-body problem, know how to set up and solve an ODE, and have an animated orbit visualizer you built yourself—a genuinely impressive portfolio piece for a high school student.
What You'll Learn
- ✓ State Newton's law of gravitation and explain how it produces orbital motion.
- ✓ Translate a system of differential equations into Julia code using DifferentialEquations.jl.
- ✓ Distinguish between circular, elliptical, and hyperbolic orbits by their energy.
- ✓ Visualize time-series and 2D trajectory data using Plots.jl.
- ✓ Identify how changing initial velocity changes the shape of the resulting orbit.
Step-by-Step Guide
Install Julia and set up your environment
Download Julia from julialang.org and install it. Open the Julia REPL (the interactive prompt) and install needed packages by typing using Pkg; Pkg.add(["DifferentialEquations", "Plots"]). This may take a few minutes. Create a new file called orbit_sim.jl in a text editor or VS Code with the Julia extension installed.
Define the gravitational equations of motion
In your file, define Earth's gravitational parameter μ = 3.986e14 m³/s². Write a function gravity!(du, u, p, t) where u = [x, y, vx, vy] (position and velocity in 2D). Inside the function, compute the distance r = sqrt(x^2 + y^2), then set du[1]=vx, du[2]=vy, du[3] = -μ*x/r^3, du[4] = -μ*y/r^3. This is the two-body equation of motion.
Set initial conditions and solve the ODE
Define initial conditions for a circular orbit at 400 km altitude: r0 = 6371e3 + 400e3, v_circ = sqrt(μ/r0), and u0 = [r0, 0.0, 0.0, v_circ]. Set the time span to tspan = (0.0, 5400.0) (one ISS orbit period in seconds). Create and solve the ODE problem with prob = ODEProblem(gravity!, u0, tspan) and sol = solve(prob).
Plot the orbit and verify it is circular
Extract x and y positions: x_vals = [u[1] for u in sol.u] and similarly for y. Plot them with plot(x_vals, y_vals, aspect_ratio=:equal, label="Orbit"). Add a filled circle for Earth: scatter!([0],[0], markersize=30, label="Earth"). The orbit should close perfectly into a circle. If it spirals inward, check your units—a common mistake is mixing km and m.
Experiment with elliptical orbits
Change the initial y-velocity to 80% of circular speed: u0 = [r0, 0.0, 0.0, 0.8*v_circ]. Re-solve and re-plot. The orbit will now be an ellipse with Earth at one focus. Try 120% of circular speed for a larger ellipse. Measure the apogee and perigee distances from your plot and compare them to values computed from the vis-viva equation: v² = μ(2/r - 1/a).
Animate the satellite motion
Use Plots.jl's animation macros to create a short GIF of the satellite moving along its orbit. Write a loop using @animate that plots Earth and the full orbit path, then adds a dot at each successive position. Save with gif(anim, "orbit.gif", fps=30). Share the animation—it makes the physics viscerally real in a way static plots cannot.
Career Connection
See how this project connects to real aerospace careers.
Aerospace Engineer →
Astrodynamics engineers use ODE solvers daily to propagate orbits, plan maneuvers, and assess conjunction risk—this project is a direct preview of that work.
Space Operations →
Flight controllers must understand how gravity shapes satellite trajectories to interpret telemetry and plan orbit correction burns.
Astronaut →
Astronauts who understand orbital mechanics can assist with rendezvous procedures and contribute meaningfully to mission planning discussions.
Drone & UAV Ops →
The numerical integration techniques used here are identical to those inside drone autopilot state estimators that track position and velocity.
Go Further
- Add the J2 perturbation term (Earth's equatorial bulge) to your equations and observe the orbital plane slowly precessing.
- Implement a Hohmann transfer maneuver: apply two instantaneous delta-v burns to move from a low orbit to a high orbit.
- Extend to 3D by adding a z-axis and simulate an inclined orbit, then plot the ground track in latitude/longitude.
- Compare the Euler, RK4, and DifferentialEquations.jl solvers in terms of energy conservation error over many orbits.