Jump to content

[0.20.2] Project Arcturus: Thrust Corrector, Remission and Range Safety


Recommended Posts

Important disclaimer: I'm not really a modder. I made these addons for myself, and I'm releasing them just to share them. I'm not good at providing support. If something doesn't work for you, I'm very sorry. I'll help if I can, but I can't promise to fix or improve anything. All the source code is available. Anybody's free to take it and do whatever they want with it. Go nuts.

Y'know how engines in KSP have different specific impulses at sea level and in vacuum? That's because some of the thrust of a real rocket engine comes from the difference in pressure between the exhaust and the ambient air. No ambient air means more pressure thrust, and a higher specific impulse.

A higher specific impulse means you get more thrust for the same propellant. Lower specific impulse means less thrust for the same propellant.

Except that's not how it works in KSP. In KSP, you always get the same thrust out of your engine at 100% throttle. It's just that at sea level, where your Isp is lower, your engine sucks down more propellant per second to achieve that thrust.

That's always bugged the heck out of me. I know, it's not a big deal, but it bugs me, it's bugged others, and at least one developer has suggested that it might be fairly considered a bug that deserves fixing.

Rather than wait around for a very low-priority fix to make it into a future release, I just decided (based on a suggestion from Wolfling) to fix it myself, with an addon.

Thrust Corrector is just a little plugin that dynamically changes the maximum rated thrust of every engine based on the current atmospheric conditions. That means the rate at which your engine consumes propellant at 100% thrust will be constant, but the maximum thrust the engine puts out will vary with altitude. In a vacuum, you'll get the rated maximum thrust, as defined in the config file. At sea level, you'll get the thrust you should get at your engine's maximum fuel flow, based on the sea-level Isp defined in the config file.

In the screen shot above, you can see a static test of the LV-T30 engine from the stock game. The T30 has a rated maximum thrust of 215 kilonewtons, and a vacuum specific impulse of 370 seconds. That means at 100% throttle, the engine will consume about 59.25 kilograms per second of propellant/oxidizer mix. Its sea-level Isp is 320 seconds, and 320 seconds times 59.25 kilograms per second times gâ‚€ gives you 185.95 kilonewtons of thrust. In the unmodded game, the T30 will still give you 215 kilonewtons of thrust on the launch pad; it'll just consume more than its maximum fuel pumping capacity to do it. But with my plugin installed, in static testing the T30 develops 186.4 kilonewtons of thrust on the launch pad at its maximum fuel-flow rate of 59.17 kilos per second of fuel mix. It performs slightly better on the pad than predicted because the pad is slightly above sea level. Cool, huh?

You might notice the discrepency between the predicted fuel mixture flow rate of 59.25 kilos per second and the rate reported by the game of 59.17 kilos per second. There's a simple explanation for that: The game is wrong. Specific impulse is defined as the thrust developed by an engine per unit of weight of reactant; that's why it's F / dm g₀; the factor of g₀ is there to convert units of reactant mass to units of reactant weight. The constant g₀, which defines the newton as a unit of force, is fixed at exactly 9.80665 m/s², which is based on but not equal to or dependent on the average acceleration of gravity on the surface of the Earth. To convert kilograms to newtons, the game should multiply by 9.80665 … but ModuleEngines multiplies by 9.82 instead. So all the numbers end up being slightly wrong. Which is actually kind of fun, because it the results you see in the game slightly different from predictions, just like always happens in real life.

The "rename vessel" functionality added in 0.18 (or whenever it was) is fantastic. No more having to hack the persistence file every time we want to launch the same saved ship twice as different missions! Only trouble is, "rename vessel" is something you have to do. You have to remember to hit the little button. And with it buried down in a right-click menu off an occasionally-hard-to-target command pod part, it's not really as convenient as it could be.

That's where Remission comes in. Remission is a tiny little addon that automatically prompts you to rename your ship every time you take it to the launch pad. Say goodbye to the annoyance of ending up with three "Comsat 1" missions because you forgot to rename them; say hello to the annoyance of being prompted every time you launch a rocket!

There've been a few range-safety and self-destruct addons released over the years, most notably TAC Self Destruct. They've all been really cool, but none worked exactly how I wanted. So I made my own.

When activated, this system detonates your spacecraft. Your whole spacecraft, piece by piece. When it's done, there's no debris left over; your whole vessel essentially evaporates.*

How do I install it? Start by downloading it. Install as usual, copying the ProjectArcturus folder to your GameData folder.

If you have Module Manager installed already, you're done, basically. All the stock probe cores will have a range safety device installed on them the next time you start the game. (Not including cores on vessels that are already in flight in your save file.)

If you don't have Module Manager, go download it, 'cause it's awesome … or else you can add the range safety device PartModule to whatever parts you like by hand. Pick a part somewhere in your GameData folder and edit its configuration file. Add the following lines to it somewhere between the opening "PART {" bit and the last "}":


MODULE
{
name = ArcturusRSD
}

Then just make sure whatever part you modified is on your ship.

How do I use it? Just hit the abort key. By default, that's the backspace/delete key on your keyboard; you can also activating it by hitting the on-screen button to the left of the altimeter. The range safety device(s) on your rocket add themselves to the abort action group automatically, so you never have to worry about sending a rocket to the launchpad with an unarmed self-destruct aboard. However, you do have to remember to remove any range safety devices from the abort action group if you don't want them to go off during an abort sequence. So there's that.

Which brings up an important thing to remember: You can kill your crew with this. The range-safety system doesn't care whether you have live Kerbals aboard your spacecraft. If you hit the abort switch, they will be incinerated. The system isn't installed on crewed parts by default, but if you're using the tried-and-true "use a probe core to make your spent stages controllable" trick, be aware that fiery, terrifying death is just one button-press away.

I wanna know more! Feel free to ask, or download the source code and have a peek under the hood.

* Note that this only applies to parts that are actually attached to your vessel when you activate the range-safety system. Anything that's disconnected, like spent stages you've already jettisoned, are technically separate vessels, and aren't detonated automatically when you use this system.

Edited by CaptainArbitrary
Link to comment
Share on other sites

Remission looks nice.

But I'm here for the exploder.

Time for 1 billion rocket explosions!

^This. Although I usually start my gravity turns like 200m AGL, when my rocket goes nuts and disassembles it always drops the parts all arround the launchpad, sometimes causing more damage. I really missed the range safety function, thanks!

Link to comment
Share on other sites

Does the thrust corrector work on modded engines as well? I'm all for realism but not if it involves me sorting through all of my engines =P

Yes, it does. In point of fact, it works on any part that's got a ModuleEngines module on it.

The way it works is this: At flight start, the plugin looks at every ModuleEngines module on the active vessel, and makes a note of the maxThrust parameter and the sea-level and vacuum Isps. Then it calculates, from the maxThrust and vacuum Isps, the maximum mass flow through the engine (dm = F / Isp g0). From then on, on every physics frame, it dynamically adjusts that engine's maxThrust parameter based on the static pressure of the atmosphere around the vessel.

So, unless I've overlooked something (which I almost certainly have!) it should "just work" on every engine on every vessel, stock, modded, whatever.

Link to comment
Share on other sites

Yes, it does. In point of fact, it works on any part that's got a ModuleEngines module on it.

The way it works is this: At flight start, the plugin looks at every ModuleEngines module on the active vessel, and makes a note of the maxThrust parameter and the sea-level and vacuum Isps. Then it calculates, from the maxThrust and vacuum Isps, the maximum mass flow through the engine (dm = F / Isp g0). From then on, on every physics frame, it dynamically adjusts that engine's maxThrust parameter based on the static pressure of the atmosphere around the vessel.

So, unless I've overlooked something (which I almost certainly have!) it should "just work" on every engine on every vessel, stock, modded, whatever.

Woot, KSP launching hard mode engaged! I always thought that the engines worked strange, I just assumed that the pumps were able to provide enough fuel to get a higher thrust than the engine was designed for, and the throttle setting was computer controlled to control thrust output and not fuel flow.

Link to comment
Share on other sites

Woot, KSP launching hard mode engaged! I always thought that the engines worked strange, I just assumed that the pumps were able to provide enough fuel to get a higher thrust than the engine was designed for, and the throttle setting was computer controlled to control thrust output and not fuel flow.

In a way they are. This is why you'll hear them talking about the engine operating at "105% throttle" or something similar. This is because the "rated power level" is something established as a baseline operating power setting for the engines. For example, the SSME's had an RPL of 1670kN at sea level and 2090kN in vacuum. However, their "maximum power" setting was at 109% thrust, giving 1860kN of thrust at sea level and 2280kN in vacuum.

Engineers designed the SSME's to deliver that 100% power, however testing found they could exceed that and so performance data of up to 109% RPL was produced, but 104.5% was the maximum used in normal operations due to the rapidly increasing chance of part failure during operation above this power level.

For people used to car and airplane engines where the output of the engine is simply increased and a new model/variant number possibly assigned when developments or testing yields an increase in performance, with rocket engines, they just certify the engine for operation "above 100% RPL" and move on. :)

Link to comment
Share on other sites

Anyway to have this integrate with Mechjeb or engineer? TWR always are wrong... =/

Fair question, but I doubt it. Engines cannot, in the game, have different max thrusts at sea level and in vacuum. They have specific impulse curves, but no thrust curve; the rated thrust is just a number that isn't a function of anything. I imagine MechJeb and Engineer compute TWR by taking the rated thrust from the engine(s) in each stage and dividing it by the mass of that stage and all the stages above.

I guess I could try changing the plugin such that it runs in the editor and downrates the engine to its maximum sea-level thrust, so other plugins can get the right number out. But off the top of my head, I'm not sure what implications that'd have for save files and stuff. So while I might look at it in a little while, I can't promise I'll actually end up doing anything about it.

Link to comment
Share on other sites

Aye, just I use both mechjeb and engineer to get the deltav stats to build my rocket but if they are wrong when I obviously go to launch it makes this little hard =/

The ÃŽâ€v numbers are correct; ÃŽâ€v doesn't depend on thrust at all, but comes straight from Isp and your mass ratio via Tsiolkovsky's equation. Only the TWR number is wrong, because those plugins expect (quite reasonably) that the game is still making engines develop way too much thrust in atmosphere.

could perhaps the range safety feature be given as something to be set up in an action group?

It is. That's discussed in the top post, I think. It's bound to the abort action group by default; you can remove it from that group in the VAB if you want to.

Also, remember that the included Module Manager config file only puts a range-safety device on the stock probe cores. If your rocket only has a manned capsule on it, you won't get a range-safety device by default at all.

Link to comment
Share on other sites

The ÃŽâ€v numbers are correct; ÃŽâ€v doesn't depend on thrust at all, but comes straight from Isp and your mass ratio via Tsiolkovsky's equation. Only the TWR number is wrong, because those plugins expect (quite reasonably) that the game is still making engines develop way too much thrust in atmosphere.

While this is correct, the "experienced" ÃŽâ€v may change quite a bit with this plugin due to lower liftoff thrust and higher gravity loss.

Overall, great plugin. I'm adding the thrust corrector to my "hardcore mode" plugin list. :)

Link to comment
Share on other sites

Seeing as I am the person who suggested this, I suppose I should pop in and say that the thrust corrector is a great plugin.

By the way, it's a great plugin!

Also, as for the VAB TWR being off, would it be possible to add a button in the VAB to toggle engines between atmosphere/vacuum stats? That seems like the easiest way to deal with it.

Link to comment
Share on other sites

Important disclaimer: I'm not really a modder. I made these addons for myself, and I'm releasing them just to share them. I'm not good at providing support. If something doesn't work for you, I'm very sorry. I'll help if I can, but I can't promise to fix or improve anything. All

OMG STOLEN. Thrust Corrector will be added to Modular Fuel System ASAP.

Link to comment
Share on other sites

While this is correct, the "experienced" ÃŽâ€v may change quite a bit with this plugin due to lower liftoff thrust and higher gravity loss.

Ah, that's a very valid point. The total ÃŽâ€v of the rocket doesn't depend on thrust, but how much of that ÃŽâ€v gets eaten by the Gravity Monster does. Thanks for pointing that out.

Overall, great plugin. I'm adding the thrust corrector to my "hardcore mode" plugin list. :)

Too kind. I'm glad you like it.

Seeing as I am the person who suggested this, I suppose I should pop in and say that the thrust corrector is a great plugin.

Again, thanks very much. I really appreciate the kind words, especially after the day I've had.

Also, as for the VAB TWR being off, would it be possible to add a button in the VAB to toggle engines between atmosphere/vacuum stats? That seems like the easiest way to deal with it.

It would in principle, I guess. In practice … I'm not sure exactly how that would work. The first problem with that approach that comes to mind is the GetInfo() issue. GetInfo() is the method called on PartModules to generate the VAB GUI. You know, the little window-like things that pop up when you mouse-over a part in the part catalog section, that tell you Isp and thrust and whatnot. If I'm correct  and I'm pretty sure I am, as I've done some fruitless screwing around with this  GetInfo() is only called once, at load time when the game database is being compiled. After that, the game just reports the data it already collected. So it can't be changed dynamically. If I'm correct about that.

Of course, it should still be possible to change the maxThrust parameter on a ModuleEngines-by-ModuleEngines basis dynamically, with as you say a button or something. If MechJeb, Engineer et al. work by dynamically polling the engines attached to the vessel and getting their maxThrusts, that would work … but only if that's true. I don't know that it is. I did experiment with having my addon run in the VAB as well as in flight, but I bailed on it when I found that my addon wasn't getting FixedUpdate() calls from Unity while in the VAB. I don't know if that's because I did everything right and that just doesn't happen or if it's because I screwed something up, but I stopped messing with it after just a few minutes of work.

Then there's having to add a GUI of some kind to the thing, and there's not a whole lot in the world I hate more than GUI programming.

So yeah … whine whine whine, the short answer is that sounds like it could be made to work, but I'd have to really force myself to do it. Not saying no, just … bleh.

OMG STOLEN. Thrust Corrector will be added to Modular Fuel System ASAP.

Freely given. If you wanna write a GUI and make the thing work in the VAB, I know at least a few people will be very happy.

I don't know if I've mentioned lately, by the way, just how dependent I've become on Modular Fuel System. It's completely changed the way I play the game. Even my capsules use the mod, so I can configure their consumables (hydrazine, Oâ‚‚ and the like) in the VAB. Thanks so much for it.

Link to comment
Share on other sites

Again, thanks very much. I really appreciate the kind words, especially after the day I've had.

One of those days?

So yeah … whine whine whine, the short answer is that sounds like it could be made to work, but I'd have to really force myself to do it. Not saying no, just … bleh.

Yep, one of those days.

It would in principle, I guess. In practice … I'm not sure exactly how that would work. The first problem with that approach that comes to mind is the GetInfo() issue. GetInfo() is the method called on PartModules to generate the VAB GUI. You know, the little window-like things that pop up when you mouse-over a part in the part catalog section, that tell you Isp and thrust and whatnot. If I'm correct  and I'm pretty sure I am, as I've done some fruitless screwing around with this  GetInfo() is only called once, at load time when the game database is being compiled. After that, the game just reports the data it already collected. So it can't be changed dynamically. If I'm correct about that.

Hmm...

What about dynamically adding a PartModule to every ModuleEngines that adds an additional GetInfo parameter (Thrust at see level)?

Of course, it should still be possible to change the maxThrust parameter on a ModuleEngines-by-ModuleEngines basis dynamically, with as you say a button or something. If MechJeb, Engineer et al. work by dynamically polling the engines attached to the vessel and getting their maxThrusts, that would work … but only if that's true. I don't know that it is. I did experiment with having my addon run in the VAB as well as in flight, but I bailed on it when I found that my addon wasn't getting FixedUpdate() calls from Unity while in the VAB. I don't know if that's because I did everything right and that just doesn't happen or if it's because I screwed something up, but I stopped messing with it after just a few minutes of work.

FixedUpdate is for physics updates... (And for part modules, only when the part is enabled...) Try just Update. Also,

Then there's having to add a GUI of some kind to the thing, and there's not a whole lot in the world I hate more than GUI programming.

Could you just have a button to press to toggle, at least for a first try?

I don't know if I've mentioned lately, by the way, just how dependent I've become on Modular Fuel System. It's completely changed the way I play the game. Even my capsules use the mod, so I can configure their consumables (hydrazine, Oâ‚‚ and the like) in the VAB. Thanks so much for it.

Hmm... Ioncross?

Link to comment
Share on other sites

Sorry to derail the thread - I'm a big fan of this mod, I'm having some issues getting it to play nicely with the SABRE combined Jet / Rocket engines from the popular B9 Aerospace Pack. They're one engine with a toggle-able mode, so their parts files have the parameters for jets (atmospherecurve with velocitycurve) as well as the parameters for a rocket (another atmospherecurve contained within its own ModuleEngines). From tests with other rockets I've worked out how thrust is affected by this mod, and it seems pretty simple. I'll write it here, just in case I'm wrong someone can correct me: The Isp atmospheric to Isp vacuum ratio is the fraction that the base thrust is multiplied by, when you're at 1 atmosphere. I haven't done any tests to work out how it interpolates to get the value at intermediate pressures, but I don't think it's relevant to figuring this out.

Before getting to what seems to be going wrong, here are (what I think) are the relevant lines from the B9 engine's part file:

(These are from the jet mode)

maxThrust = 640

atmosphereCurve

{

// Atm.P. Isp iTan oTan

key = 0 1805 0 2.51E+07

key = 7.5E-06 1969 0 0

key = 0.0006 1658 0 0

key = 0.11 1853 0 0

key = 1 1600 -400 0

}

(these are from the rocket part)

maxThrust = 860

atmosphereCurve

{

key = 0 375

key = 1 330

}

So, here's the weird part. The Thrust Corrector mod works perfectly for the engine when it's in jet mode. On the runway, thrust is reduced to 88% (1600/1805) of its unmodded value. Switching to the rocket mode, I'd expect the rocket's thrust to drop to 88% as well (330/375). The problem is, the thrust actually goes to a shockingly-low 14% of its unmodded value on the runway. The only way I can think of to reproduce the measured thrust reduction is to use the %F multiplier from the jet engine when it's not moving (0.85), use the jet engine's base thrust instead of the rocket's base thrust (0.85*640/860), and then either the rocket Isp to jet Isp ratio for both components at sea level, or both components at vacuum (both ratios end up with a final thrust reduction of 13%). Obviously, something wacky is going on here, and it seems to be stemming from the fact that there are two ModuleEngines nested within one module that B9 uses to switch between engine modes. It just seems doubly strange to me because I would think that if the Thrust Corrector handles the jet engine correctly, then I'd expect it to either handle the rocket correctly or treat the rocket exactly the same as it does the jet. Instead it seems to be pulling just one Isp value from the rocket, and otherwise pulling a bunch of data from the jet.

Does anybody have any better ideas what might be going on, or what tests I could do to figure out what's going on? It's not the end of the world if I can't get these engines working, but they did look like they'd be fun for good-looking SSTOs. Thanks for reading, and extra thanks if you've got any ideas!

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