# Help with Engine FloatCurves

## Recommended Posts

Hi all,

I've recently learned that you can apply float curves to the engines within KSP in order to allow the thrust of the engine to vary as the propellant mass in connected fuel tanks varies.  The example I've been given is something like this:

key = 1 0.46
key = 0.754 0.46
key = 0 0.1

And what I've been told is:

Quote

Basically what it's saying here is that until 75.4% of fuel remains the booster will output at least 46% total thrust and then gradually taper off to 10% thrust as fuel approaches 0. Since this is a curve, (cubic Hermite splines﻿ are used, according to this reference) the thrust between 1 and 0.754 actually rises up to nearly 47% thrust and back down, passing through 46% as fuel reaches 75.4% then continuing to taper off.

However, when I go to replicate this curve in MATLAB (as a new part of the KSP Trajectory Optimization Tool I develop), I can't get the results to line up.  See this post:

Can someone provide some insight into what is going on internally with those engine floatcurves?  What's the underlying math (if anyone knows it)?  Are tangents at the data points being restricted to something somehow?

Thanks for the help!

EDIT: Turns out that after doing some research, the better question would be to ask what KSP does when those float curves are not defined with incoming and outgoing tangents, but instead are left blank/not included, as they are in my example above. Anyone know?

Edited by Arrowstar
##### Share on other sites

@Arrowstar KSP provides float curves for at least the following to affect thrust:

• Isp (in turn controlled by atmosphere pressure)
• Throttle
• Percentage of propellant remaining
• Velocity (mach) in atmosphere

KSP provides at least these other float curves to affect other aspects of engine behavior (likely unrelated to your query but may be interesting in your field)

• Isp affected by velocity in atmosphere
• Isp affected by throttle

The thing with tangents in KSP float curves is: By default a curve will tend towards parabolic and be very bendy when visualized. This is bad as when the curve has many points or its points are very close on one axis but far apart on the other, it can either go negative or far greater positive than you desire-- causing extreme buffing and nerfing of the engine as it crosses its performance envelope. If you set tangent values (at the very least, all 0's are sufficient in most cases) then the curve will be sharper or straighter as it goes through its points and will avoid the issues I've described.

Unity float curves may be a different kettle of fish to float curve calculators elsewhere. For the best experience I'd recommend you get the Unity IDE and this tool for it:

##### Share on other sites

@Arrowstar KSP provides float curves for at least the following to affect thrust:

• Isp (in turn controlled by atmosphere pressure)
• Throttle
• Percentage of propellant remaining
• Velocity (mach) in atmosphere

KSP provides at least these other float curves to affect other aspects of engine behavior (likely unrelated to your query but may be interesting in your field)

• Isp affected by velocity in atmosphere
• Isp affected by throttle

The thing with tangents in KSP float curves is: By default a curve will tend towards parabolic and be very bendy when visualized. This is bad as when the curve has many points or its points are very close on one axis but far apart on the other, it can either go negative or far greater positive than you desire-- causing extreme buffing and nerfing of the engine as it crosses its performance envelope. If you set tangent values (at the very least, all 0's are sufficient in most cases) then the curve will be sharper or straighter as it goes through its points and will avoid the issues I've described.

Unity float curves may be a different kettle of fish to float curve calculators elsewhere. For the best experience I'd recommend you get the Unity IDE and this tool for it:

Thanks for the suggestion!  That was very helpful.  Is there anywhere I can see what the allowable float curves effecting thrust and Isp are for engines?  That is, you've given me the six float curves descriptions, but how do you implement them in the part config files?  What are the keywords?

##### Share on other sites

On 1/8/2019 at 3:11 PM, Arrowstar said:

Is there anywhere I can see what the allowable float curves effecting thrust and Isp are for engines?

You can see just about everything available to engine configs on the ModuleEngines page on the KSP API website.

Here are the various engine curves, where they go in a part config, with accompanying activation keys and references for where to expect them in irl engines brought into KSP.

```PART
{
// basic stuff like title, manufacturer, mass, desc
MODULE
{
name = ModuleEnginesFX
// engine stuff
// propellant nodes

atmChangeFlow = True // allow atmosphere to change fuel flow and therefore, thrust

// Typical Isp curve for a rocket engine.
// Air-breathing engines tend to only have one key in this floatCurve.
// By default, thrust scales with Isp (with vacuum as the baseline).
// x is atm pressure, y is Isp
atmosphereCurve
{
key = 0 303 0 0
key = 1 258 0 0
}

// Use custom power curve for atmosphere pressure,
// Detach from fraction of vac Isp in atmosphereCurve{}.
// This behavior may be expected of hydrolox engines.
// x is atm pressure, y is thrust multiplier
useAtmCurve = True
atmCurve
{
key = 0 1 0 0
key = 1 0.4 0 0
}

// Use custom Isp curve for atmosphere pressure.
// The idea of this seems redundant next to atmosphereCurve{} but can be handy.
// It likely requires atmosphereCurve{} to have only one key.
// x is atm pressure, y is Isp multiplier
useAtmCurveIsp = True
atmCurveIsp
{
key = 0 1 0 0
key = 1 0.85 0 0
}

// Throttle affects Isp. Not used in stock but this example shows
// the Isp side of the true nature of afterburning turbofan engines.
// Makes you wonder why the Panther is multi-mode when irl it would not be.
// x is throttle state, y is Isp multiplier
useThrottleIspCurve = True
throttleIspCurve
{
key = 1 0.5 0 0
key = 0.9 1 0 0
}

// Scales the effectiveness of throttleIspCurve{} with atm pressure.
// I have not explored this so it's up to you to confirm if inclined to use this.
// This example assumes an engine whose Isp will scale with throttle
// while in vacuum but not in atmosphere.
// x = atm pressure, y = effect multiplier
throttleIspCurveAtmStrength
{
key = 0 1 0 0
key = 0.5 0 0 0
}

// Fraction of propellant remaining affects thrust.
// The stock solid rocket engines are missing this very badly.
// x is propellant available (0~1), y is thrust multiplier
useThrustCurve = True
thrustCurve
{
key = 0 0.2 0.0474578 0.0474578
key = 0.3695251 0.4
key = 0.8 1 -0.01682135 -0.01682135
key = 1 0.2 -12.33899 -4
}

// Velocity affects thrust. You will find this in all air-breathing engines.
// x is Mach, y is thrust multiplier
useVelCurve = True
velCurve
{
key = 0 0.85
key = 1 1
key = 2.5 4 0 0
key = 5 0
}

// Velocity affects Isp. This is an example of scramjet Isp falloff
// as it theoretically accelerates infinitely.
// x is Mach, y is Isp multiplier
useVelCurveIsp = True
velCurveIsp
{
key = 4 1 0 0
key = 7 0.6 -0.09088219 -0.09088219
key = 15 0.3 0 0
}
}
}```

## 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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×

• #### Community

• Release Notes

• #### Social Media

• Store
×
• Create New...