fixed burn time calculations for multi stage burns

This commit is contained in:
2026-04-19 21:52:07 -04:00
parent 9a4ae5e472
commit 7431ab7946
13 changed files with 221 additions and 155 deletions
+41 -17
View File
@@ -5,16 +5,23 @@ import("library/lib_orbits").
declare function Ascent{
parameter targetOrbit is 100.
parameter targetOrbit is 100000.
parameter vericalAscent is 1000.
parameter ascentProfile is 1.2.
parameter circ is 1.
parameter inc is 0.
print "Params (" + targetOrbit + ", " + vericalAscent + ", " + ascentProfile + ", " + circ + ", " + inc + ")".
print "Vertical Climb to " + vericalAscent.
set tgtPitch to 90.
set tgtPitch to 90.
set isDone to false.
lock throttle to 1.
lock steering to heading(90, tgtPitch, 270).
local head to 90 + inc.
lock steering to heading(head, tgtPitch, 270).
local lock asccent_prog to Map(apoapsis, 0, targetOrbit, 0.0, 1.0).
@@ -25,17 +32,21 @@ declare function Ascent{
local lock tgtPitch to (1 - ease) * 90.
when periapsis < targetOrbit then {
print "P: " + round(asccent_prog, 2) + " T:" + round(ease, 2) + " Pitch: " + round(tgtPitch, 2) + " " at(0, 2).
print "Ap: " + round(apoapsis, 2) + " Pe:" + round(periapsis, 2) + " Alt: " + round(altitude, 2) + " " at(0, 3).
print "P: " + round(asccent_prog, 2) + " T:" + round(ease, 2) + " Pitch: " + round(tgtPitch, 2) + " " at(0, 3).
print "Ap: " + round(apoapsis, 2) + " Pe:" + round(periapsis, 2) + " Alt: " + round(altitude, 2) + " " at(0, 4).
wait 0.1.
preserve.
if not isDone{
preserve.
}
}
//Auto Staging
when periapsis < targetOrbit then{
AutoStage().
wait 0.01.
preserve.
if not isDone{
preserve.
}
}
wait until apoapsis >= targetOrbit.
@@ -44,44 +55,57 @@ declare function Ascent{
lock tgtPitch to 0.
unlock steering.
if circ = 1 {
CircularizeBrute(targetOrbit, head).
}else if circ = 2{
Circularize(targetOrbit, head).
}
CircularizeBrute(targetOrbit).
set isDone to true.
unlock steering.
unlock throttle.
wait until throttle = 0.
}
local function Circularize{
parameter targetOrbit.
parameter head.
lock throttle to 0.
lock steering to heading(90, 0, 270).
lock steering to heading(head, 0, 270).
local warpTime is eta:apoapsis.
local burnDv is CalculateCircularizationDV().
local burnDv is CalculateCircularizationDV(targetOrbit, orbit:semimajoraxis).
local burnDuration is CalculateMultiStageBurnDuration(burnDv).
print "Warping to Circularization. " + round(burnDv) + "m/s. T: " + round(burnDuration, 2) + "s" at(0, 4).
set warpTime to warpTime - burnDuration.
local remDv is ship:deltav:current - burnDv.
print "Warping to Circularization. " + round(burnDv) + "m/s. T: " + round(burnDuration, 2) + "s" at(0, 5).
print "Final Dv expected: " + remDv + "m/s".
set warpTime to warpTime - burnDuration /2.
if warpTime > 0 {
wait until throttle = 0.
wait 0.01. //Wait for accelleration to stop
warpTo(time:seconds + warpTime).
set warpmode to "physics".
warpTo(time:seconds + warpTime - 3).
wait until eta:apoapsis >= burnDuration /2.
}
wait until eta:apoapsis <= burnDuration.
lock throttle to 1.
// wait burnDuration.
wait until periapsis >= targetOrbit.
lock throttle to 0.
wait 0.01.
}
local function CircularizeBrute{
parameter targetOrbit.
parameter head.
lock throttle to 1.
lock steering to heading(90, 0, 270).
lock steering to heading(head, 0, 270).
wait until periapsis >= targetOrbit.
lock throttle to 0.
}