ROCKET LAUNCHER
- 2 Devlogs
- 17 Total hours
BUILD , TEST , LAUNCH ... rockets
BUILD , TEST , LAUNCH ... rockets
wow this is going to be a massive devlog …. i was supposed to post one earlier this afternoon but its now nearly 12 am lol … anyways …. Wrote the Part class and the catalogue. Engines, tanks, nose cones,payloads. The numbers are loosely inspired by real hardware but I deliberately
did not use real names. Every engine carries sea level and vacuum thrust and
Isp, and Stage.thrust() interpolates between them on ambient pressure, so a
vacuum bell is genuinely useless at sea level and genuinely good up high.
Getting the delta-v map right took two goes. My first version computed each
stage’s mass ratio from that stage’s own mass only, which made the upper stages
look like they had thousands of m/s and the first stage almost nothing.
Obvious the moment you say it out loud, since stage one has to push everything
stacked above it as well. Added Rocket.mass_from(index) and used it for both
the start and end masses.
Second mistake in the same corner: I was using sea level Isp in Tsiolkovsky.
Everyone quotes vacuum delta-v, so my numbers did not match anything I could
compare against. Switched to stage.isp(0.0) and left a comment saying it
flatters the first stage, because it does.
The Isp of a stage with mixed engines was the fiddly bit. You cannot average
Isp directly, you have to add the mass flows and divide the total thrust by
them. Wrote it as a thrust weighted average in Stage.isp() and tested it with
two engines whose Isp differ by 100 s.
Spent the last two hours balancing the catalogue so the preset vehicles are not
ridiculous. My first heavy launcher lifted off at a thrust to weight of 3.7,
which flies like a dart and burns most of its propellant fighting drag in the
first 20 km. Real launchers sit somewhere around 1.2 to 1.7. Fixed by pairing
each engine with much larger tanks, which also brought first stage burn times
up to a believable 120 to 200 seconds instead of forty. …
Physics only, nothing on screen yet.
Started with the part I was least confident about, which is the atmosphere. I
wanted drag to actually matter instead of being a made up constant, so I looked
up the International Standard Atmosphere and typed the layer table in by hand:
base altitude, base temperature, base pressure, lapse rate, seven layers up to
84.8 km.
The barometric formula has two cases, one for layers where the temperature
changes with height and one for the isothermal layers where the lapse rate is
zero, and I lost about an hour to the first one. My pressures came out roughly
three times too low above 20 km. I had written the exponent as
-G0 * lapse / AIR_R instead of -G0 / (lapse * AIR_R). Staring at it did
nothing. What actually found it was printing my pressure at 0, 11, 20 and 32 km
next to the published numbers, at which point it was obvious the error grew
with altitude and therefore lived in the exponent.
The second problem was the top of the atmosphere. Above 84.8 km the tables run
out so I bolted on an exponential tail, and then noticed the vehicle was still
picking up a tiny bit of drag at 300 km, which slowly ate the orbit over a long
coast. Added a linear fade so density genuinely hits zero at
ATMOSPHERE_TOP = 140 km. Not physically correct, but the alternative is
modelling the thermosphere and I am not doing that for a game.
Last thing was the integrator. I wrote Euler first because it is four lines,
and wrote a test that drops a mass from 200 km with no thrust and no air and
checks that the specific orbital energy stays constant. It did not. It drifted
about half a percent per simulated minute, which sounds harmless until you
realise a long coast to apoapsis is fifteen minutes and the apoapsis walks
while you watch it. Rewrote derivatives() and pushed it through RK4, holding
thrust and mass fixed across the four evaluations. The mass changes by a few kg
over a 20 ms step so it makes no difference, and it keeps the state vector down
to four numbers instead of five. Energy now holds to about seven decimal
places.