Jump to content

[HOWTO] Airbreathing Engines in KSP 1.0


NathanKell

Recommended Posts

As promised, albeit delayed, here is a guide on how to make airbreathing engines in KSP 1.0+.

What's Changed

A number of things have changed for airbreathers in 1.0. First of all, velocityCurve is dead and gone. ModuleEngines (and ModuleEnginesFX, which now derives from ModuleEngines) don't support it. Second, the Isp bug relating to air has been fixed. Third, airbreathers now have fuel flow (and thus thrust) proportional to density and mach, and use two new curves, atmCurve and velCurve and three new boolean variables (atmChangeFlow, useAtmCurve, useVelCurve) to tune that. Fourth, four new number variables are supported for tuning performance, machLimit and machHeatMult, flameoutBar, and CLAMP. All this means that airbreathing engines can be simulated much more realistically in KSP 1.0, but making them takes a bit more work.

FloatCurves

It's worth noting that, if you didn't know, FloatCurves are a wrapper for AnimationCurves, which are Unity's way of implementing cubic bezier splines. FloatCurves can come in two forms: key = x y, and key = x y in out. The first mode makes Unity calculate the tangents itself, in the latter mode you specify the tangents. Please see here for more details on FloatCurves (though note that any reference to 'velocityCurve' is obsolete).

Parameter Overview

  • atmChangeFlow. The key thing to use, and that tells KSP your engine is an airbreather, is atmChangeFlow. If false, then atmospheric density has no bearing on thrust (i.e. you're no longer an airbreather). It defaults to false.
  • ignoreForIsp. Next, the PROPELLANT nodes have a new option. You'll see that for IntakeAir, stock airbreathers have `ignoreForIsp = True` set. That means that, properly, the mass of the air you're breathing in is ignored for Isp calculations. In .90 and earlier, KSP included that number, which meant that airbreathers (with a 1:15 ratio of fuel to air) had 16x the Isp they said they did. Always use `ignoreForIsp = True` when using IntakeAir or any other generated resource, unless no other resource has a density. You'll have to leave it out if you're making an electric propeller; in that case, Isp will describe the mass flow of the engine rather than the mass flow of the fuel used.
  • useAtmCurve and the atmCurve. If atmChangeFlow is specified but useAtmCurve is false, then flow will be linearly proportional to density (1x flow at sea level, declining as density declines). If true, then the curve is used, which relates density (in kg/m^3 divided by 1.225, so 1.0 at sea level) to the flow multiplier: the x (time) value of the curve is the atmospheric density/1.225, and the y (value) value of the curve is the flow multiplier. All stock airbreathers use the curve to better control thrust at altitude. If you're designing a jet engine you probably want a curve somewhere between the basic jet engine and the turboramjet; if you're designing a scramjet, you probably want the flow to start at 0 and then go up once you get to operating altitude, so something like key = 1 0, key = 0.5 0.1, key = 0.1 1.0, key = 0 0. If you're designing a propeller aircraft, you want the curve to be much flatter, only slightly better than linear in the 4+km region and tapering off to nothing by 12km.
  • useVelCurve and the velCurve. The velCurve relates mach number to flow multiplier, so the x (time) value is mach, and the y (value) value is flow multiplier. For high-bypass turbofans, you want a fairly linear decline from 1.0 at Mach 0 to 0 at Mach 1.05 or so. For turbojets and low-bypass turbofans, you want a roughly quadratic gain in flow past Mach 0.5, peaking somewhere around Mach 1.5 and going down to nothing by Mach 3. For afterburning jets, the peak should be Mach 2 to Mach 3, tapering off past Mach 4 or so, and for ramjets they won't have any flow until Mach 0.3 or so then climb slowly with the peak up past Mach 3, and the tapering off to nothing shouldn't be until Mach 5 (perhaps slightly past Mach 5, though Mach 5 is where ramjets usually die off). Special engines (like the combined-cycle RAPIER, which is a SABRE basically) may have slightly different parameters, and turboramjets (i.e. a turbojet + ramjet combo, like the stock TRJ) will perform like turbojets with afterburners under Mach 2, and then blending into ramjet behavior past Mach 2. Scramjets, well, there really isn't any unclassified data on them, but we know they don't work at all until past Mach 5, and really only work at high altitude, and if you're lucky they might give you some thrust in the Mach 5 - Mach 10 range. Propellers should have nearly the same curve as low-bypass turbofans do, starting at 1 and declinging rapidly, although they will still produce some thrust past Mach 1, just not very much (a multiplier of 0.1, tapering off to 0 by Mach 4, say). Note that their decline isn't very linear, and should fall somewhat slowly until Mach 0.6 or so, after which it falls rapidly until Mach 1.
  • machLimit and machHeatMult. These control the limit beyond which the engine starts producing extra heat; the extra heat produced is a multiplier to heatProduction, calculated as 1 + (mach - machLimit) * machHeatMult.
  • flameoutBar and CLAMP. These control how flameouts occurs. When the combined flow multiplier (product of atmCurve and velCurve) is below flameoutBar, the engine will flame out because "air combustion failed". The minimum flow multiplier will never go below CLAMP (to avoid a divide by zero error). You probably never need to touch CLAMP, but if you want a lower flameout bar than 7% (0.07) you can specify it.

Edited by NathanKell
added more on floatcurves
Link to comment
Share on other sites

Still don't understand how to use AtmCurve right.

Can you please help me with electric impeller config?

Was trying to use this:

atmCurve

{

key = 0 0 0 0

key = 0.3 0.18 0.6 0.6

key = 1 0.5 0.4 0.4

key = 5 1 0 0

}

velCurve

{

key = 0 1 0 0

key = 0.5 0.8 -0.9460317 -0.9460317

key = 0.8 0.3523809 -1.626984 -1.626984

key = 1 0 -1.761905 -1.761905

}

I want impeller to

1) have 100% thrust at Eve sea level, 40-50% thrust at Kerbin sea level and 20-30% thrust at Duna sea level. More thrust in denser atmosphere, less thrust in thin one.

2) be limited to 0.8 Mach, but able to reach it (at least at Kerbin).

P.S. "atmChangeFlow" parameter seems to check for oxygen. I was unable to start impeller on Duna and Eve with this on.

Edited by Dr. Jet
Link to comment
Share on other sites

That looks basically right, although that means that at roughly 6km on Kerbin (where density ~= 0.35, so /1.225 it ~=0.3) you'll also get a multiplier of 0.18.

atmChangeFlow has nothing to do with oxygen. However, you will need to create a ModuleResourceIntake that does not check for oxygen and creates a resource that your engine uses (intakeAir as collected by the stock intakes, well, the stock intakes check for oxygen).

Link to comment
Share on other sites

Nathan

Just wanted to say THANKS! I had been looking for a guide to understanding the new velocity curves a few days ago and happened across your post a day ago! I figured out a lot of what you wrote here on my own such as percentage of engine power at mach value. A lot of the other things you wrote here really helped me.

Regards,

Steve

Link to comment
Share on other sites

Yeah, no problem, except one. As you know this is something that becomes an issue with major changes, and that is what to do with the remaining now-false information. Some of the other engine snippets and threads contain it (not to mention everything else). I routinely come across new modders (I sometimes even get PMd) following outdated stuff because I still need to keep it linked, because no other thread contains the other relevant info. What do?

- - - Updated - - -

Actually it's the floatCurve thread that still mentions velocityCurve

Edited by Cpt. Kipard
Link to comment
Share on other sites

Taverius, who wrote the guide, hasn't been on since January.

- - - Updated - - -

Actually this particular instance might not be too problematic. So far I can't actually find anyone actively advising people to use the deprecated bits. Ignore me.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 months later...

atmChangeFlow. The key thing to use, and that tells KSP your engine is an airbreather, is atmChangeFlow. If false, then atmospheric density has no bearing on thrust (i.e. you're no longer an airbreather). It defaults to false.

Hey NathanKell, I would like to clarify this one bit.... If this false it ignores the atmcurve completely?

I wanted something a bit different... to have the fuel flow at maximum while thrust still decreases at higher altitudes, exemplifying an inefficient thin-air engine. Is it possible? And is it actually accurate or am I tripping?

Link to comment
Share on other sites

Hey NathanKell, I would like to clarify this one bit.... If this false it ignores the atmcurve completely?

I wanted something a bit different... to have the fuel flow at maximum while thrust still decreases at higher altitudes, exemplifying an inefficient thin-air engine. Is it possible? And is it actually accurate or am I tripping?

Be careful, you may be confusing atmosphereCurve, which defines Isp as a function of altitude, and atmCurve, which defines flow as a function of altitude. It is possible to do what you say, but it's not exactly accurate - if the pressure gets low enough the engine will flame out but until then, the only thing that matters for engine performance are the pressure ratios involved, and those stay the same. If anything, most jet engines will gain a bit of efficiency at higher altitudes because the temperature of the air is lower. Flow should change with altitude regardless though - the air is thinner meaning that the total mass flux entering the engine should scale with pressure.

Link to comment
Share on other sites

Be careful, you may be confusing atmosphereCurve, which defines Isp as a function of altitude, and atmCurve, which defines flow as a function of altitude. It is possible to do what you say, but it's not exactly accurate - if the pressure gets low enough the engine will flame out but until then, the only thing that matters for engine performance are the pressure ratios involved, and those stay the same. If anything, most jet engines will gain a bit of efficiency at higher altitudes because the temperature of the air is lower. Flow should change with altitude regardless though - the air is thinner meaning that the total mass flux entering the engine should scale with pressure.

I'm trying to adjust values for a propeller engine though. They will simply lose thrust to air density with altitude, so they require to either go faster or spin faster to bite on same chunks of air sort off. Needing more throttle making them less efficient to maintain same thrust levels at higher altitudes, even though with lesser air density also means fuel consumed and thus less engine power....

Anyway, there is a more pressing matter that's bugging me. This engine I'm tweaking has 16 maximum power and for the life of me I can't get it to output the actual maximum, it always sits around 10 even though its supposed to be optimal, for example at the runway.

Link to comment
Share on other sites

I'm trying to adjust values for a propeller engine though. They will simply lose thrust to air density with altitude, so they require to either go faster or spin faster to bite on same chunks of air sort off. Needing more throttle making them less efficient to maintain same thrust levels at higher altitudes, even though with lesser air density also means fuel consumed and thus less engine power....

But if you can do that at altitude than you can do that at sea level. It seems that what you want more is variation with throttle rather than atmosphere.

Anyway, there is a more pressing matter that's bugging me. This engine I'm tweaking has 16 maximum power and for the life of me I can't get it to output the actual maximum, it always sits around 10 even though its supposed to be optimal, for example at the runway.

Density is one possible factor - full flow is achieved at 1.225 kg/m^3, but it will vary with temperature, so in particular during the day the actual density is likely to be lower.

Link to comment
Share on other sites

In KSP 1.0.4 there's a new variable literally just for that. :)

multFlow

If true (by default) then atmCurve and velCurve multiply flow. If false, they multiply thrust.

Set it to false for propeller engines.

Wuuuuuttt? :wink::kiss:

Awesome, I'm guessing this will go right inside ModuleEngineFX right? Much thanks!

But if you can do that at altitude than you can do that at sea level. It seems that what you want more is variation with throttle rather than atmosphere.

Density is one possible factor - full flow is achieved at 1.225 kg/m^3, but it will vary with temperature, so in particular during the day the actual density is likely to be lower.

Ohhh dear god, didn't know KSP was actually accounting density for variable pressure and temperature... That is awesome, but complicated. :confused:

Anyway I'm quite annoyed at how I'm getting such low performance on this engine:


maxThrust = 20
atmosphereCurve
{
key = 0 9600 0 0
}
velCurve
{
key = 0 0.8
key = 0.4 1
key = 1.3 0
}
atmCurve
{
key = 0 0
//key = 0.8 1
key = 1 1
}

This is what I currently have. with 20 max thrust I'm getting at most 12N of thrust. And yes I've tried with the vel curveat maximum before stopped..

Having a 50~60% of max performance seems excessive due day time variation alone. The atm curve, 1 should equal the standard 1,225 kg/m³ doesn't it?

I'm imagining getting to the poles with could air and having a beast of an engine XD

And hints on how to fix this or should I just settle and increase max thrust?

Link to comment
Share on other sites

You're not specify tangents. That can lead to unintuitive behavior. See here for details:

http://forum.kerbalspaceprogram.com/threads/93332-INFO-KSP-floatCurves-and-you-the-magic-of-tangents

atmCurve is actually normalized (as atmosphereCurve is), so key = 1 1 means at 1.225kg/m^3 density the multiplier is 1.

Link to comment
Share on other sites

You're not specify tangents. That can lead to unintuitive behavior.

Yeah I know that's why I try to keep as simple as possible... the atmcurve is only two values so should work alright.

I'm assuming that when no tangent are specified the curve will just fit the best way doesn't it?

Just one other quicky question: the two values are tan-in tan-out right? that value being sen [0° ~90°] = 0 ~ 1 ?

Just read a bit more on that thread. unfortunately I can't get that editor to try out... Doesn't work on linux.

Edited by Gfurst
Link to comment
Share on other sites

Awwww yeahhhh!!!

Now were talking, very much thanks!

Actually I was figuring out it myself, it has nothing to do with sen but actually some magic with actually tangent to make some spline thing... I don't know... anyway:

Inside the game it self, the meta+f12 window shows a drag profile that you can edit... its far from anything intuitive but works if you place values to see how smooth the curve actually is.

velCurve
{
key = 0 0.8 2 2
key = 0.2 1 0 0
key = 0.9 0.2 -2 -2
key = 1.2 0 0 0
}

I polished my curve with this... I also figured that same tan-in/tan-out equals a smooth tangent line to both side of the curve on that point.

I still haven't figure out why my engine isn't going any near the maximum thrust yet. I'm suspecting it actually needs excess Air resource from 0.01 to 0.5, will test tomorrow.

Link to comment
Share on other sites

I have been thinking again... (I wonder why I even think in the first place)

the new multFlow value is really cool... It allows to change Engine Isp performance based on the resulting thrust of the other curves...

Interesting... but...

Come to think of it, internal combustion engines will have to lean the mixture injection less and less fuel as atmosphere density lowers. So that means it should actually be more economic.

On the other hand I think jet engines are the other way, because kerosene doesn't need a perfect mixture and air is being compressed either way. Am I tripping or what?

One thing is for sure though, the rockets are the one that should take advantage on the new variable... Meaning they would have constant fuel flow independent of thrust output.

Elaborate with me here please.

Link to comment
Share on other sites

  • 1 year later...

I'm doing a bit of necroing, but basically I'm pretty in the same problem in which it was @Gfurst , because I'm trying to make some propeller engines, and only NOW I found this thread about how to set their performances ( some help, if not too busy, from "sensei" @NathanKell or any Dev that could help me refine my toughts will be greatly apreciated because i was struggling until now :blush:):

basically, I know (on paper) that my engin has a given power at sea level (let's say 80%), then it ramps up to its 100% at 3000m, then it fades to the max altitude it can achieve (let's say 9000m), so basically (removing the tangent values, that I'll refine in a curve editor) I could have this as "atmCurve":

atmCurve
{
key = 1 0.8 xxx xxx // 80% at sea level 
key = 0.62859 1 xxx xxx // 100% at 3000m - I calculate the atmo density with samples in game made by the pressure science part :P
key = 0.21539 0.3 xxx xxx // basically having not enough air to push at 9000m
key = 0 0 xxx xxx // in space there is no air, then NO thrust
}

... then, to complete the setting, I should add:

atmChangeFlow = True // standard coding defining an airbreather
useVelCurve = True 
useAtmCurve = True
multiFlow = False // the needed change to vary the actual "thrust" (how many HP/kW should the engine have at a given altitude)

atmCurve
{
key = 1 0.8 xxx xxx // 80% at sea level 
key = 0.62859 1 xxx xxx // 100% at 3000m - I calculate the atmo density with samples in game made by the pressure science part :P
key = 0.21539 0.3 xxx xxx // basically having not enough air to push at 9000m
key = 0 0 xxx xxx // in space there is no air, then NO thrust
}

now... how should I use the "velCurve"???
My first thoughts are about a graph about its own "accelleration" up to the "max possible velocity" (... and if I understood correctly, in Mach numbers), until the propellers cannot push further anymore.
Starting with a low output from 0 (static), slowly going up (to recreate the propeller need to start to "bite" the air to accellerate, slower than a jet engine) up to the full potential of the blades (from take-off velocity onwards), untill, reached the designed "max speed", it starts to have those "issues" (I'm not an aircraft engineer, but I know that there are various fact that not let a propeller engine/its blades to accellerate past a given designed value) that stops it to gain more velocity...

Basically something like (again, just an example... I'll have to figure the exact values in various manners, othar than add the full values to smooth the curve later, changing those "xxx" I added with a proper curve configuration):

velCurve
{
key = 0 0.4 xxx xxx
key = 0.2 0.8 xxx xxx
key = 0.4 1 xxx xxx
key = 0.6 0.2 xxx xxx
key = 0.8 0.1 xxx xxx
}


... is it someway correct???

REFINING THE CONCEPT:

... I then found (still using the "fuel flow" mechanic before I'll add "mutliFlow = False") that sometime, from a levelled max speed, if my plane (a fighter) goes in a dive, the engine itself, past some velocities, could eventually "flame out" and turn itself "off", rather than keep spinning in "idle mode" (like when variable pitch blades goes "feathering"). How could I change/use "flameoutBar" (and/or eventually "CLAMP"...) as I'm not a genius and I do not have any practical example of them used in stock jet engine, to fine tuning the engine to have a very low thrust, but still being "turned on" (basically keeping the animation of the spinning, rather than the actual mechanics that "flame out" it, turning it off)?
What is the "basic-stock" value of "flameoutBar", to have that 7%? 0.07???

Up to now, guessing, I tweaked, lower and lower, the "ignitionThreshold" value in the ModuleEngine, to mitigate that behaviour, but probably I was messing with something not needed. What does this value do actually, in the synthax of a cfg? What is its "basic-stock" value?

Then... IntakeAir ratio: how much could be a someway correct value? Having as example some very different engine, in stock, from the BIG value in the larger turbofan like the J-90 Goliath, at 227, to the very small value of the turbo ram jet J-X4 Whiplash, at 8, what could be a balanced value for a "piston engine" (like those in WW2) or for a more modern turboprop (that uses the turbine concept geared to a propeller)? Should an hungry but powerful air cooled, radial engine (like the P&W R-2800 that powered F4U Corsair and P-47 Thunderbolt) have a higher or lower value than a V12, liquid cooled, less powerful but someway more efficient engine, like the Rolls-Royce Merlin (that powered the Spitfire, and in his american builod version, the P-51 Mustang) or that Daimler-Benz DB-601/605 (that powered the Messerschmitt Bf 109)???

After this wall of text, thanks to anyone that could eventually bother to answer, in advance ^_^

Edited by Araym
Link to comment
Share on other sites

  • 3 weeks later...

@Araym

First, what's '

multiFlow 

was that added in 1.2.x?

 

Second, the general gist of a prop engine is that atmCurve and velCurve represent the engine and atmCurveIsp and velCurveIsp represent the prop. So:

1. atmCurve should be linear if it is unsuper/turbo-charged. If it's supercharged, you'll have one peak per stage. If it's turbocharged, you'll be essentially flat-rated until you hit critical alt. Broadly speaking, atmCurve should track a BHP vs Altitude graph of the engine, with altitude converted into normalized density. Note that atmCurve (and atmCurveIsp) use normalized density (i.e. density in kg/m^3 divided by 1.225).

2. velCurve represents the effect of ram air, i.e. supercharged engines which take advantage of ram air can increase charge density above what the charger can normally grant, in static conditions, by 'ramming' the air in due to the velocity. So something like 1.0 at Mach 0, peaking about 1.2 or so at Mach 0.85, and then falling off sharply due to transonic weirdness.

3. atmCurveIsp should be linear. Thrust from a propeller is linearly proportional to air density.

4. velCurveIsp is where it gets interesting. A prop is a constant power device, so it will have its maximum thrust at 0 velocity and then taper off. However it's not at all linear because of the effect of pitch angle and tip speed. You want a generally downward sloping curve that tails off sharply once the tips start to go transonic (indeed might even go negative to represent the vastly increased drag).

 

Hope that helps!

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...