an EPIC Light Sail Simulation
- 5 Devlogs
- 32 Total hours
an EPIC LightSail Simulation. I am using this simulation for a paper. It simulates the behavior of Light sail, with varying properties of the sail, laser, etc.
an EPIC LightSail Simulation. I am using this simulation for a paper. It simulates the behavior of Light sail, with varying properties of the sail, laser, etc.
WHATS UP LOVELY PEOPLE Another Nyx devlog it is!
You dont know what Nyx is? Its my light sail simulation for a paper im working on!
I did some code refining and yeah lots of boring stuff.
(Next devlog will be more detailed trust)
YO PEOPLE, i am BACK (ts so cringe. literally nobody cares). This devlog is about how almost lost my minds migrating my simulation’s rotation calculations into Quaternions, integrating RK4 and as always solving bugs, because Nyx is filled with bugs
(Oh, you dont know what Nyx is? well it is my passive beam riding light sail simulation, for a research paper im working on)
Ok so before this, Nyx used normal Euler angle rotations using thetaX and thetaY for orientation. At first it worked fine, but after longer simulations stuff started tweaking hard The sphere and paraboloid would randomly start flattening into weird pancake/disc things (which i lowkey think might be cuz matplotlib library hates me idk), rotations started looking cursed, and the orientation slowly became unstable over time. At first I thought matplotlib was just being goofy again, but nah, the actual orientation system itself was kinda cooked (most likely). The problem was that Euler angles are not really built for stable continuous 3D rotational dynamics. Rotations started interfering with each other and the geometry would slowly drift into nonphysical states during longer simulations.Basically Nyx had reached the point where the old orientation system just wasn’t enough anymore :(.
–
that’s it for me today, I hope YOU have a great day!
(BTW, i have no idea why the markdown on this devlog is so weird, i can not seem to fix it lowkey)
btw, if you havent seen my older devlogs, you are legally obligated to do so, and if not done, the police shall come for you
so, after my last devlog, added a new sail geometry, fixed A LOT OF BUGS and made the code efficient (not really) and improved the physics calculation, to a more complex force calculation engine (its not an engine, idk why i said that).
also, i realized paraboloids are pretty niffty as with some dingle dangle, we can have a circular sail without even making a new class!
Paraboloid geometry, cleaned up the radiation pressure code, quivers for visualization and better force equation.
the force equation is now
F = fmag * (2*cosTheta*normal - beamDih)
(this is embarrassing, but in my code, the beam direction variable is beamDih)
.obj file as a sail(The image below is when i broke the code. i accidentally wrote =+ instead of +=)
Nyx Devlog #2: The Curved Sail Arc
Status: Nyx V2 Complete
Mood: Sleep-deprived aerospace engineer
Bug Count: We don’t talk about the 90° bug.
So… what happened?
This dev cycle started with a simple goal:
“Let’s add some tilt to the sails.”
Several hours later, we somehow ended up with a computational beam-riding lightsail simulator.
Oops.
Gaussian Beams Are Cool
Nyx uses a Gaussian beam to model the laser intensity distribution.
def gaussian(r):
return I0 * np.exp(-2 * r2 / w02)
Basically:
The beam is strongest at the center.
The farther away you go, the weaker it gets.
Nature decided lasers should have exponential decay because apparently linear wasn’t dramatic enough.
Tilting the Sails
The sails can now rotate about the X and Y axes.
def rotateX(vector, angle):
x, y, z = vector
return np.array([
x,
y*np.cos(angle) - z*np.sin(angle),
y*np.sin(angle) + z*np.cos(angle)
])
def rotateY(vector, angle):
x, y, z = vector
return np.array([
x*np.cos(angle) + z*np.sin(angle),
y,
-x*np.sin(angle) + z*np.cos(angle)
])
This worked surprisingly well.
Unlike the visualization.
Introducing: The Hemisphere™
Rectangle sails were getting lonely.
So Nyx gained a new geometry:
class SphereLightSail():
(Yes, it’s technically a hemisphere. Naming things is hard.)
The hemisphere is discretized into tiny patches that each experience radiation pressure from the laser beam.
Science!
Radiation Pressure Time
Every tiny patch gets hit by photons.
The force magnitude is calculated using:
fmag = (2 * I / c) * (cosTheta**2) * dA
where:
I is beam intensity,
c is the speed of light,
cosTheta accounts for sail orientation,
dA is the patch area.
Translation:
Tiny packets of light aggressively boop the sail.
Torque Has Entered The Chat
Turns out forces acting away from the center like to cause problems.
tau = np.cross(position, F)
Nyx now computes total torque acting on the sail.
This means we can begin asking questions like:
Which geometries are stable?
instead of:
Why is Matplotlib gaslighting me?
Visualization!
Nyx can now visualize sail geometries using 3D plots.
scatter = ax.scatter(
self.xPoints,
self.yPoints,
self.zPoints,
c=self.intensities,
cmap=‘plasma’,
s=30
)
With a colorbar:
fig.colorbar(
scatter,
ax=ax,
label=‘Beam Intensity (W/m^2)’
)
And even a force vector:
ax.quiver(
0, 0, 0,
Force[0], Force[1], Force[2],
color=‘red’,
length=2,
normalize=True
)
It looks surprisingly professional.
Until you rotate it to 90°.
The Great 90° Incident
At one point, Nyx decided that rotating things by 90° was optional.
Several debugging sessions later:
“It’s probably fine.”
Nyx is now operating under the internationally recognized engineering principle of:
If the physics works, Future Me can fix the plotting (ik guys, ELITE mindset).
What Nyx V2 Can Do
Nyx V2
├── Gaussian beam model ✓
├── Rectangle sail geometry ✓
├── Hemisphere sail geometry ✓
├── Sail tilting ✓
├── Radiation pressure forces ✓
├── Torque calculations ✓
├── Intensity heatmaps ✓
└── Force vector visualization ✓
What’s Next?
We’re moving beyond random shapes.
Future geometries need to answer one question:
Could someone actually use this as a lightsail?
Possible candidates:
□ Paraboloids
□ Hyperboloids
□ Other beam-riding geometries from literature
Party hats are currently under review.
Final Thoughts
Nyx V2 was the phase where the project stopped feeling like a collection of scripts and started feeling like an actual research tool.
Also, I now know far more about Matplotlib’s quirks than any human
#Devlog 001 — The Beginning of Nyx (I call the light sails Nyx, because why not)
Started building the computational simulator for my project on passive beam-riding stability of interstellar lightsails.
What I implemented:
-A Gaussian laser beam model to simulate how beam intensity changes from the center outward.
-A rectangular lightsail simulator divided into tiny surface patches.
-Calculations for net force and net torque acting on the sail.
-Support for changing the sail’s position relative to the beam.
-Support for x-axis and y-axis tilts, allowing the sail to change orientation.
-Validation tests showing that centered sails produce near-zero torque and that results converge with increasing resolution.
-The beginnings of a 3D geometry engine, including a hemispherical lightsail generator using spherical coordinates.
-3D visualization of the hemispherical sail to verify that the geometry was generated correctly.
(Am currently working on the the force and torque calculation for the spherical sails)
(The test cases are for tilted says, the first one is not tilted at all and the last one is tilted 90 degrees)