// Functions for calculating thrust values. @lazyglobal off. local G is 9.81. lock G to SHIP:BODY:MU / ((SHIP:BODY:RADIUS+SHIP:ALTITUDE)^2). // Returns the throttle value you should use to achieve the // target TWR. If TWR can't be achieved, returns 1.0. (full throttle) function ThrottleToTWR { parameter targetTWR is 1.5. local m is SHIP:MASS. return min((targetTWR*m*G)/SHIP:AVAILABLETHRUST, 1.0). } // Calculates the ship's current TWR. function TWR { local m is ship:mass. local t is THROTTLE * SHIP:AVAILABLETHRUST. return t/(m*G). } function BurnTime { parameter dV. local en is list(). list ENGINES in en. local f is en[0]:MAXTHRUST * 1000. // Engine Thrust (kg * m/s²) local m is SHIP:MASS * 1000. // Starting mass (kg) local e is CONSTANT():E. // Base of natural log local p is en[0]:ISP. // Engine ISP (s) return G * m * p * (1 - e^(-dV/(G*p))) / f. }