diff --git a/execnode.ks b/execnode.ks index db3bed3..2cd7dea 100644 --- a/execnode.ks +++ b/execnode.ks @@ -25,16 +25,20 @@ print "dV = " + NEXTNODE:DELTAV:MAG. // Execute the burn, throttling down by half every time we're // consuming more than 25% of our dV in one update. -until NEXTNODE:DELTAV:MAG <= 0.25 or dVMin < NEXTNODE:DELTAV:MAG { +local droppedOnce is false. +until NEXTNODE:DELTAV:MAG <= 0.25 or (dVMin < NEXTNODE:DELTAV:MAG and droppedOnce) { // debug print "dVMin = " + dvMin. print "dV = " + NEXTNODE:DELTAV:MAG. - if NEXTNODE:DELTAV:MAG < dVMin { + if NEXTNODE:DELTAV:MAG > dVMin { + set droppedOnce to true. + } else { set dvMin to NEXTNODE:DELTAV:MAG. + set droppedOnce to false. } - wait 0.001. + wait 0.01. } unlock THROTTLE. diff --git a/lib/throttle.ks b/lib/throttle.ks index a60720e..b9e63a4 100644 --- a/lib/throttle.ks +++ b/lib/throttle.ks @@ -36,8 +36,11 @@ function BurnTime { // Docs suggest DeltaV:DURATION is not entirely reliable, however. // For now we're logging both values for comparison. local t is burnTimeCalc(dVs, m, Isp, f). + + // debug print "Computed stage burn time = " + t. print "KSC-estimated stage burn time = " + SHIP:StageDeltaV(s):DURATION. + // end debug local parts is list(). for part in parts { @@ -49,7 +52,12 @@ function BurnTime { return t + BurnTime(dV - SHIP:STAGEDELTAV(s):VACUUM, m, s - 1). } - return burnTimeCalc(dV, m, Isp, f). + // debug + local t is burnTimeCalc(dV, m, Isp, f). + print "Burn time in last utilized stage = " + t. + // end debug + + return t. } // Convenience function to wrap the actual calculation for burn time.