MechJeb2

MechJeb2

4M Downloads

g0 in fuel flow simulation should be 9.82

tavert opened this issue ยท 2 comments

commented

It's only a 0.1% difference, but oddly KSP version 0.20.2 seems to use 9.82 m/s^2 for g0 in the specific impulse / flow rate calculation. I'll try to remember to check this again after 0.21 is released.

See an example here: http://i.imgur.com/76pTq6j.png

This is 1 mainsail at full throttle in vacuum, so thrust 1500 kN, Isp = 330 s, propellant flow rate mdot = 0.005 ton/unit * (41.66 fuel unit/s + 50.92 oxidizer unit/s) = 0.46288 t/s.

From the definition of specific impulse, g0 = F / (Isp * mdot) = 9.82 m/s^2. Conversely, if g0 were equal to 9.81 as you would expect (1 gee on Kerbin is still 9.81 m/s^2 based on mu/r^2), then the propellant flow rate would be 0.46335 t/s, or 41.70 fuel/s + 50.97 ox/s.

I believe the only place this should change is https://github.com/MuMech/MechJeb2/blob/master/MechJeb2/VesselState.cs#L540 since every other mention of 9.81 in the code is referring to gees acceleration.

Edit: fixed line number. Numbers look the same in 0.21, so no change on KSP's side.

commented

Merged

commented

I thought that the error might have been caused by a (rounding) error of the fuel flows. So I performed a test in which I captured the burning of the fuel from a Rockomax Jumbo-64 Fuel Tank by a LV-T30 Liquid Fuel Engine. It took 540.8 seconds. For this I looked at which frame the burn started and stopped and used that to determine the fraction of the in-game burn time (recorded at 30 frame per second).
In this case the formula for g0 would be:
g0 = F * t / (Isp * mf),
with:
F the thrust of the engine, which is equal to 215.0 kN
t the burn time, so 540.8 seconds
Isp the specific impulse, which is equal to 370 s
mf the mass of the fuel, which is equal to the total mass of the tank minus the dry mass, so 36 - 4 = 32 Mg

So g0 would indeed be equal to 9.8203 m/s^2

I also did a semi-error-analysis, in which I assumed that all the part values are exact (I do not expect that the developers would set the mass, thrust or Isp to a strange value with lots of digits behind the decimal point). So therefore the only source of error would be the measured time. Which is captured at 30 frame per second and since I subtract the final time from the initial time, the error in the burn time would be equal to two times half the stepsize, so Dt = 0.0333 seconds.
And therefore the error in g0 would only be:
Dg0 = g0 = F * Dt / (Isp * mf),
which yields: Dg0 = 0.0005 m/s^2

So the error in the game would not be in the flow rates, since the game showed 5.33 and 6.51 respectively, while the average flow rates are 2880/540.8=5.325 and 3520/540.8=6.509. So the error might be in the thrust, mass of the fuel or in the Isp.