Mark

How to model space travel with AI

How to design, develop and deploy complex simulations with the help of AI assistants.

Monday, May 1st, 2023



Are AI assistants just a fad, or can they truly help you build anything?

For the last few months, there's been a debate on whether these digital helpers are as powerful as they claim to be. Let’s explore just how much of a game-changer AI assistants can be, through the use-case of building a highly complex orbital simulator from scratch! Buckle up, because we're about to explore the cosmos through the lens of artificial intelligence.



If you're as passionate about spacecraft modeling as I am, you've probably heard of (or even used) popular space simulation programs like STK, GMAT, Kerbal Space Program, and the classic Orbiter Space Flight Simulator.

These simulation systems are usually very heavy as they integrate multi-body perturbations, atmospheric drag, etc.

So the code for these systems is complex, but could we build something like this with in 5 days? With some assistance form AI, yes.

This article is not meant to go into specifics of how such a system works. But as an analogy of how to build complex software with the help of AI.

Principles


The basis of being great at building software comes from the same principles, weather it is with the use of AI assistants or not. These principles, I believe, will just gain importance as we move into the future.

Build with Purpose

Focus on the end goal. Build a big vision. Make it actionable. Iterate.

Having a great vision is not something that comes up in one time, unless you’re lucky. It’s something you perfect over time.

Keep your work under a compass. AIs can help you build this by creating flowcharts, maps, or summaries. But iterate on them.

Build with Usability

Focus on the end usability. If your building something build with the problem you’re solving in mind.

Assistants can help in clearing up what are the main problems. But more important is to talk with the people you’re solving the problems in the first place.

Build with Knowledge

Know about what you’re building and, especially, who you’re building for.
If there are things you need to learn, learn them fast. AI Assistants can help with that. Just type:

“Write me a tutorial on: {insert topic}”

The steps:

  1. Envisioning the Product As a product developer with over a decade of experience, I know the importance of building a clear understanding of the product I want to create. In this case, I envisioned an orbital simulator capable of propagating spacecraft trajectories, detecting heating, drag, and reentry events, all while displaying complex visualizations in both 3D and 2D.

  2. Crafting the Simulator Pipeline The goal was to use scipy's solve_ivp and iterate on an initial state vector through time. With each iteration, I computed various orbital perturbations, so I needed the system to be as lean as possible.

  3. Physics Modelling I started by using astropy and poliastro's libraries but ended up rebuilding the equations on my side, which increased performance over 10x! Talk about efficiency!

  4. Visualization I hacked Plotly like crazy to offer the best 3D experience possible in a low-code app like Streamlit. This included modeling Earth with its accurate physical properties, ephemerides, and various charts to break down data into comprehensible slices.






5. Optimization By harnessing the power of Python's high-performance numba compiler, I managed to reduce processing times another 10x-50x – perfect for running on Streamlit's cloud systems.


You can see and download the code in it’s repository or try it out online here.


© João Montenegro, All rights reserved.

︎ HomeNext article ︎︎︎
More articles ︎︎︎