The Space Elevator Simulator

or how far a small project can get you

A screenshot of the simulator, showing what an orbiting object would see. Climber in red, ribbon in grey, Africa in lots of colors.

TL;DR

After being found by my Mechanics teacher, I created a simulation of what a space elevator would be able to do. At the moment of writing, the simulator is at its fourth version, able to display what the orbiting body would see looking at the Earth from the orbit it is released on. Next version will allow adding engines to the payload and thus have any orbit, with the rough cost estimate of getting there.


Introduction

A long time ago, in 2014 (god, typing it out makes it actually sound old), I've started studying at Vanier College under the Computer Science and Math Pre-University program. This meant I got to do what I love - math and CS - and avoid what I didn't like - things like Biology, Organic Chemistry, and various boring science options.

In the first couple of classes I had, various teachers came up to our programming lectures and tell the students that if anyone wants a challenge, they could use a good coder. As I've already had experience in coding, I decided to "shop around" and see what could be interesting - and I did work on a small project involving fractals (fascinating subject!)

However, Stephen Cohen came across me somewhat accidentally. In the Mechanics class, we were studying elastic collisions, and as the math was rather simple, I quickly coded a small simulation for myself. You can see a similar simulation here. Since I thought myself so clever, I decided to show it to my physics teacher the following day, fully expecting it to be barely noticed and deserve a quick "Nice". Instead, I got much more.

Not only was Stephen impressed with the simulation, he immediately asked me to assist him. It turned out that Stephen has been working on the theory of a space elevator for years, since doing his MEng about that topic. And it was the exact moment he needed to have something coded.

An artist's rendition of a space elevator

What is the Space Elevator?

This was exactly my first question - perhaps only after "This is just a couple of lines, do you really think I can handle an actual research task?" As it turns out, the space elevator is an idea imagined by scientists and science-fiction writers alike, and it is exactly what it sounds like. Imagine we made a long enough ribbon, added a weight to its end and threw it into space, attaching the other end to the Earth. Then, simply add little machines climbing up the ribbon and you have an elevator to space.

Of course, a 3 sentence explanation is different from the scientific theory. Problems start creeping up fast: How do we make it long enough? Or sturdy enough? Or cheap enough to have investors be interested at all? Stephen's research deals with even more complex questions, such as how to counteract the harmonic oscillations a climber would impose on the ribbon (answer : more climbers, surprisingly).

But no matter these questions, what remains a fact at the moment is a distinct lack of a space elevator being built. The idea needs more interest not only from the investors but also from the general population, and particularly the future scientists. How best to outline the idea of a space elevator than give a portable, (hopefully) easy to use and intriguing model of what can be achieved?

A recreation of the first version. Honestly, it's probably accurate. I got better at aesthetics, I swear.

My work

So here I am, in a physics teacher's office, listening about the fancy math. Angles and Greek letters flying all over the place, I obviously get mixed up in them immediately. However, after a week of rereading and careful equation balancing, we were able to work out the equations guiding the process. The math is based on Orbital State Vectors, as we have both the position of the object at the moment the elevator doors open and the velocity it has as a result of Earth's sidereal rotation (that is, rotation around its own axis). In particular, we considered a 2D model, with everything happening in the equatorial plane, and thus we had just two variables : the height of launch and the time of launch.

We have a 2D model, we have two variables, and we have an equation that describes their motion around the Earth as a function of time - and thus, we can now try to visualize it. And even if this was the bulk of my job, it took me three entire iterations to build something that I could show not only from my computer to Stephen, but to a larger public as well. The first version was written using JavaFX/Swing, and I hope no one touches those things ever. Of course, the more important part for Stephen was the equations - but anyone familiar with programming will understand that mathematical equations translate really well into code. Only thing I really had to do with respect to the math was to write a Newton method solver for Kepler's equation, as it has no algebraic solution.

The second time, I used a library called Processing (and P5.js, its Javascript port, for the third version) to draw it better, faster, easier and have it finally available for a presentation. Switching to JavaScript also was an interesting task, as it does not have a nice class system. Or a type system. Or consistent behaviour. Of course, back then I was not aware of anything but vanilla JS, so I had to do it from scratch - but it worked out!

The game "Kerbal Space Program" (copyright Squad). The orbital equations I've learned got me to Duna, the game's equivalent of Mars!

Final words

By end of 2016, I was already in McGill, and so I've only gotten occasional updates from Stephen. So it was a massive surprise to learn that my simulator was presented at the International Space Elevator Conference, was shown to almost every person Stephen would discuss space elevators with, and even shown to Prof. Arun Misra, Stephen's MSc supervisor and McGill professor.

In 2019, I decided to surprise Stephen for Christmas and on my time off, wrote a completely revamped version 4 of the simulation. There were three main changes. First, I finally moved my code around to have distinct files: working in a single file was something I finally outgrew. Then, I modified my UI to use React + Bootstrap for the aesthetics and once again, separation of UI in logical blocks. But most importantly, I revamped our equation and brought into them the third dimension back. Even if it is not accessible directly, not only have the graphics moved to a 3D WebGL view, allowing for a globe view, but the orbits could now be 3-dimensional too!

I hope I'll find some time to work on version 5. It will finally not be a graphics upgrade but a feature one. I've encoded the equation to work directly from orbital state vectors. As such, I could at any point in time get a satellite's position and velocity vectors, add some velocity to simulate engines and voila - we now have orbits defined by more than just the elevator's doors opening.

If you made it down here, first of all, congratulations. I didn't expect to have so much to say. And second, I hope that your patience with my rant and your curiosity to go down this rabbit hole in the first place help you work on your own things. Even something you could code in an evening could shape your future for years ahead.

I've learned it the fun way.