Jump to content

How to calculate Engine ISP from cfg file?


Recommended Posts

I'm looking at adding dV and TWR calculations into KerbalX.com so I need to be able to get engine ISP and part wet/dry mass from just the info found in part cfg files. I can gather data from part .cfg files, but I can't use any ingame functions.

So first question is, given the .cfg file for an engine, how do I work out it's ISP?

Also, is the mass given for parts in their .cfg files the wet mass? And then from that I'd need to subtract density*volume of each of its resources to get the dry mass? (in the case of fuel tanks)
Getting the density values for stock resources looks simple enough (from ResourcesGeneric.cfg), but I'm a bit confused about how mods with their own resources define them.

Thanks!

Link to comment
Share on other sites

When do you need the isp ? in flight just get it from engine.realIsp. Outside you need to do this :

float isp = engine.atmosphereCurve.Evaluate((float)engine.part.staticPressureAtm);
if (engine.useAtmCurveIsp)
	isp *= engine.atmCurveIsp.Evaluate((float)(engine.part.atmDensity / 1.225));
if (engine.useVelCurveIsp)
	isp *= engine.velCurveIsp.Evaluate((float)engine.part.machNumber);

And the mass in the cfg is the dry mass.

Edited by sarbian
Link to comment
Share on other sites

25 minutes ago, katateochi said:

I'm looking at adding dV and TWR calculations into KerbalX.com so I need to be able to get engine ISP and part wet/dry mass from just the info found in part cfg files. I can gather data from part .cfg files, but I can't use any ingame functions.

So first question is, given the .cfg file for an engine, how do I work out it's ISP?

 

It's in ModuleEngines or ModuleEnginesFX, in the atmosphereCurve field.  There is an entry that looks like

atmosphereCurve
{
  key = 0 331
  key = 1 291
}

The 'key' entries are part of a curve.  The first value in a row is atmospheric density, the second is ISP.  In the above example, the engine has an ISP of 291 at sea level ('1'), and a vacuum ISP of 331 ('0').  The maxThrust in the engine module is for vacuum.  To compute sea level thrust, multiply it by (sea level ISP / vacuum ISP).

 

Link to comment
Share on other sites

7 minutes ago, sarbian said:

When do you need the isp ? in flight just get it from engine.realIsp. Outside you need to do this :

I need it completely outside of the game as I'm trying to do this calc on a website where all I'll have is a craft file and some of the variables gathered from part cfg files. I was actually going to message you to see if you could help me with this! I essentially want to do the mechjeb equivalent of calculating dV and TWR for each stage for craft uploaded to KerbalX.com.  At the moment I'm just looking into which variables I need to gather from parts in order to make the calc possible.  And I'll be honest, the maths side of KSP, not my strong point! (and things like fuel lines concern me!)

 

10 minutes ago, MOARdV said:

It's in ModuleEngines or ModuleEnginesFX, in the atmosphereCurve field.  There is an entry that looks like

The 'key' entries are part of a curve.  The first value in a row is atmospheric density, the second is ISP.  In the above example, the engine has an ISP of 291 at sea level ('1'), and a vacuum ISP of 331 ('0').  The maxThrust in the engine module is for vacuum.  To compute sea level thrust, multiply it by (sea level ISP / vacuum ISP).

Oh cool, it's right there! That should make things simpler! Thanks!
So key = 0 is the vac and key = 1 is sea level, what about other key values like this from the 909 which has a key = 3 entry

atmosphereCurve
{
	key = 0 345
	key = 1 85
	key = 3 0.001
}

And this from the LV-T45 which has a key = 6

atmosphereCurve
{
	key = 0 320
	key = 1 270
	key = 6 0.001
}

What do those other keys mean? Can I essentially ignore them if all im interested in the end is getting dV for atmo and dV for vac?

Link to comment
Share on other sites

6 minutes ago, katateochi said:

what about other key values like this from the 909 which has a key = 3 entry

For planet with atmosphere with a higher density than 1 atmo at ground level.

Link to comment
Share on other sites

2 hours ago, katateochi said:

If you have parts that just have an atmosphereCurve with a single entry for key = 0 x, does that mean they have the same ISP in atmo?

I would guess "yes".  I have not looked at the details for the FloatCurve class and how it handles a degenerate "curve" with a single point.

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