Search the Community
Showing results for tags 'thrustcurve'.
-
The curious case of the missing jet engine thrust.
CastleBravoTest posted a topic in KSP1 Discussion
This is my first post here. I was convinced by some friends to post the results of one of my investigations on this forum. It will be partly a question about things I have yet to fully discover, a bit of an explanation of how jet engines work. I will tell this investigation in chronological order explaining each step so if I have an error anywhere in my understanding feel free dear reader to point it out. I started this little investigation because of an unrelated efficiency calculation I wanted to do however it quickly spiraled into a bit of a rabit hole. I wanted to mathematically determine the most efficient jet engines for each flight regime but for this I needed a way to create a function for the thrust multiplier given the flight conditions(pressure and mach). To my understanding at the time the thrust was simply a function of two values those being the mach multiplier and the pressure multiplier. In other words: Thrust = mach_curve x pressure_curve Nice and simple right? The wiki shows these two curves as looking as follows for the whiplash: The data for these two curves are easy enough to find in the game files and look as follows (for the whiplash at least): velCurve { key = 0 1 0 0 key = 0.2 0.98 0 0 key = 0.72 1.716 2.433527 2.433527 key = 1.36 3.2 1.986082 1.986082 key = 2.15 4.9 1.452677 1.452677 key = 3 5.8 0.0005786046 0.0005786046 key = 4.5 3 -4.279616 -4.279616 key = 5.5 0 -0.02420209 0 } atmCurve { // definite 'kink' to the curve at high altitude, compared to flatter BJE curve key = 0 0 0 0 key = 0.045 0.166 4.304647 4.304647 key = 0.16 0.5 0.5779132 0.5779132 key = 0.5 0.6 0.4809403 0.4809403 key = 1 1 1.013946 0 } The way in which this is stored is not entirely obvious but through some googling i figured out it uses a technique called Cubic Hermite spline also known as Cubic Hermite interpolation [source for the curious reader: https://en.wikipedia.org/wiki/Cubic_Hermite_spline#:~:text=In numerical analysis%2C a cubic,of the corresponding domain interval.]. Each point (represented by a key) is defined by 4 properties which are the x, y coordinates and incoming and outgoing tangents in that order. To do this numerically in the program I was using(aka MATLAB) I had the option to either implement this interpolation from scratch or use one of the preexisting interpolation methods available to me. The functions that MATLAB had available were: spline() pchip() makima() I first decided on spline() and through that I aquired functions that produced the following curves: and: These curves look good but they differ slightly from the ones found in the wiki. This error could be through a number of reasons, it could be that i used the wrong interpolation function, it could be that the wiki is wrong or it could even be that both I and the wiki are wrong. I tried googling for which interpolation the devs used or which interpolation unity would use by default however very predictably this gave no results (Like many things in ksp odds are they implemented a custom interpolation method). Unable to find the answers I needed online i then proceeded to look at the functions themselves available to me. Each giving ever so slightly different behavior. If i am to show the difference in the interpolation method i am going to borrow an example from the online documentation for these functions:[image source: https://se.mathworks.com/help/matlab/ref/spline.html?searchHighlight=spline&s_tid=srchtitle_support_results_1_spline] As you can see from this image each interpolation method does it ever so slightly differently (though granted makima and spline are almost identical). The pchip() method seems most similar to the one used in the wiki however at this point I was through taking peoples word for it so i decided on a different course of action. To determine which of these methods I should use for my function I decided to conduct a little experiment. I slapped together a tiny test rig which would help me (with the aid of the autopilot mod) determine the properties of such a curve. The vehicle is seen below but there is not much to say about it: This vehicle flew on 100% throttle with infinite fuel turned on to limit the variables. The autopilot mod used was atmospheric autopilot [link: https://spacedock.info/mod/683/AtmosphereAutopilot]. This autopilot held 200m above sea level and flew only in the ocean east of the KSC. It held the speed asigned to it in mach and i confirmed the mach number both with the ingame aero data in the gui setting and through atmospheric autopilot. Then i sat down to record the data I needed. Here is a table (oh and since this whole journey started with efficiency I decided it could not hurt to record the fuel consumption as well). I did a little tweaking to the PID parameters mid flight to ensure zero steady state error and also a fast enough response. Here is the raw data: Raw experimental data Mach Thrust [kN] fuel drain [u/s] 1 292.2 1.372 1.2 297.6 1.487 2 350.2 1.785 2.2 357.2 1.821 2.4 363 1.852 2.6 368.4 1.878 2.8 371.8 1.89 3 375.6 1.915 3.1 375.4 1.914 3.2 374.8 1.910 3.3 374.2 1.908 3.4 372.8 1.901 3.5 371.1 1.89 3.6 368.8 1.88 3.7 365.8 1.865 3.8 362.1 1.846 3.9 357.6 1.823 4 352.0 1.795 I would have sampled higher but this is where my poor slapped together craft reached its maximum velocity and at any rate I had enough data to work with. I took extra readings in the top of that "hump" to check if it is flat or curved. Something else stood out about this though which became all the more apparent when this data was subsiquently graphed: There seems to be quite a bit of thrust missing from this. In other words we have a mystery multiplier at play somewhere in the code. It is less simple than the equation for thrust I stated near the beginning. That said from the smoothness of this curve especially around the mach 3 region i can at the very least conclude that the interpolation method in the wiki is wrong. To Investigate the thrust discrepency further I decided to plot the theoretical data divided by the experimental data and the result looks as follows: The results of this show that our mystery multiplier is nonlinear making life difficult. That said I have tracked down the identity of this multiplier. It can be found in a seemingly unrelated spot in the data for the engine. The parameters section for this engine is as follows: // Jet params atmChangeFlow = True useVelCurve = True useAtmCurve = True flowMultCap = 2.0 machLimit = 2.5 machHeatMult = 6.0 Can you spot it? well it may not necessarily be obvious at first glance but looking back on the raw data it is curious that the fuel flow never goes above the flowMultCap set by the game. That is because this is our culprit. The specific impulse is tied to both thrust and fuel flow rate. The equation for which looks like this: Isp = T * (dm/dt)-1 *g-1 where: T is "thrust" expressed in newtons, dm/dt is the mass flwo rate of the fuel into the engine expressed in kg/s g is the gravitational acceleration at the surface (9.81 m/s2) The equation for Isp Ties the two values together and since the thrust can't rise without an increase in fuel flow rate and the fuel flow rate can't rise due to the limiter the end result is a situatuation where the thrust is effectivly capped at low altitudes. Just to show this equation is accurate i am going to take a random set of values (say, @mach 3 ) and confirm the fuel flow rate from the thrust value and Isp: For the whiplash at this point Isp = 4000 T = 375.6 [kN] = 375600 [N] Rarranging the equation for the specific impulse gives: (dm/dt) = T * Isp-1 *g-1 substituting in the values gives: dm/dt = 375600 / (4000*9.81) => (dm/dt)theoretical = 9.572 [kg/s] To convert this to u/s we need to know the density which can be found on the wiki [https://wiki.kerbalspaceprogram.com/wiki/Liquid_fuel] to be 5kg/unit so: (dm/dt)theoretical = 9.572 [kg/s] / 5 [kg/u] => (dm/dt)theoretical = 1.9144 [u/s] this value is similar to the experimental value: (dm/dt)experimental = 1.9148 [u/s] The discrepency in the last digit can be ignored due to me doing this calculation with values with up to 4 significant figures and the limiting value (g) has 3 significant figures. Thus the experimental and theoretical values can be seen as equal and thus the equation works. When I went in and changed the flowMultCap to a much higher number then the whiplash behaved as expected reaching its full thrust multiplier so it iscertainly the culprit here. When looking at the KSP API [source: https://www.kerbalspaceprogram.com/ksp/api/class_module_engines.html] the description for this is: This quote does not provide any actual details of how this tapering off multiplier is implemented or how it works in detail. I did a little more digging around this but found no actual answers so this is where this investigation of mine ends for now. For anybody still reading this i thank you for your time. I also shall ask the question I mentioned at the beginning but never actually asked throughout the entire text. Does anybody how this flowMultCap curve is implemented? maybe you have decompiled the code somewhere and you have it handy and can share? maybe you instantly know from the shape of the functions i have presented? maybe you are a dev and have the actual code infront of you? no matter how any answers to this are appriciated and would also appriciate the feedback to any errors you have seen me make during this investigation. Thank you for reading.