Jump to content

Who wants to test a plugin-powered Modular Engine and Fuel Tank system?


Recommended Posts

I'll release to spaceport once I have enough evidence that there aren't any hidden bugs, but in the meantime:

Ialdabaoth's Modular Fuel Tank system

source at: https://github.com/Ialdabaoth/modularFuelTanks

Released through GPL3.0 (http://www.gnu.org/licenses/gpl.html)

HOW IT WORKS:

1. First, you need a part configured with a ModuleFuelTanks. The simplest ModuleFuelTanks node you can have looks something like this:


MODULE
{
name = ModuleFuelTanks
volume = 400
TANK
{
name = LiquidFuel
}
TANK
{
name = Oxidizer
}
TANK
{
name = MonoPropellant
}
}

This tells my plugin that you have a fuel tank with a total volume of 400 Kerbos (note: one Kerbo = 6.25 Liters; talk to Squad), and you want the user to be able to fill that tank with any amount of MonoPropellant, Oxidizer and LiquidFuel, so long as the total volume of those 3 propellants adds up to less than 400.

If you want to get fancier, here is a more complicated MODULE:


MODULE
{
name = ModuleFuelTanks
volume = 400
basemass = 0.125
TANK
{
name = LiquidH2
loss_rate = 0.000015
efficiency = 0.975
mass = 0.000
}
TANK
{
name = LiquidOxygen
efficiency = 0.995
mass = 0.0003125
loss_rate = 0.0000025
}
TANK
{
name = LiquidFuel
efficiency = 1.0
mass = 0.0003125
}
TANK
{
name = Oxidizer
efficiency = 1.0
mass = 0.0003125
}
TANK
{
name = MonoPropellant
efficiency = 1.0
mass = 0.0005
}
}

This tells the module that this tank can hold LiquidFuel, Oxidizer, MonoPropellant, LiquidH2 and LiquidOxygen. It also tells the module how much additional mass or volume each type of tank consumes (beyond the mass and volume of the fuel itself), and that LiquidHydrogen is slightly leaky.

The values are:


name = LiquidOxygen // the RESOURCE name that this kind of tank holds
efficiency = 0.995 // the percentage of tank volume that can store fuel
mass = 0.0003125 // the additional dry mass added per volume of this tank
temperature = -183 // the temperature that fuel begins evaporating
loss_rate = 0.0000000002 // the rate at which fuel evaporates of the container.

Note that 'mass' and 'efficiency' is per volume of fuel, not per volume of tank+fuel. So

if you want a tank to store 360 units of LiquidOxygen, in the RESOURCES column say:


RESOURCE
{
name = LiquidOxygen
amount = 360
maxAmount = 360
}

Assuming the TANK configuration above, MaxAmount = 360 will create a tank that takes up (360 / .995) = 361.809 of the available volume, and which adds 360*.0003125 = 0.1125 tons to the dry mass of the tank, in addition to the mass of the LiquidOxygen itself. As long

as the tank's Part is at a temperature below -183 Celsius, no LiquidOxygen will leak out;

otherwise, LiquidOxygen will begin leaking out at a rate of (360*0.0000000001) = 0.000000036 units per second per degree Celcius that the part's temperature exceeds -183. At room temperature (25C), this works out to about 0.027 units per hour.

2. Once you have the module specified correctly in part.cfg, you can load up the tank in the editor. After attaching it to your ship, go to the Action Groups menu and click on the tank. There you will see various options - each fuel type will have a button to add a tank, or text boxes to adjust the tank volume and initial amount of that fuel, as well as a button to remove all tanks from this part. When you edit a If the system detects an engine attached, it will (usually) also give you a button to remove all tanks and then fill the entire volume with that engine's fuel, in the ratio that that engine consumes it.

When you edit a fuel tank, its load out is automatically copied to all identical symmetrical fuel tanks. If you want to have an asymmetrical load-out, attach each tank separately with symmetry off, then edit each tank individually.

3. You can also configure engines to use multiple fuel types, like so:


MODULE
{
name = ModuleEngineConfigs
configuration = LiquidFuel+Oxidizer (50 Thrust, 370 Isp)
modded = false
CONFIG
{
name = LiquidFuel+Oxidizer (50 Thrust, 370 Isp)
thrustVectorTransformName = thrustTransform
exhaustDamage = True
ignitionThreshold = 0.1
minThrust = 0
maxThrust = 50
heatProduction = 300
fxOffset = 0, 0, 0.21
PROPELLANT
{
name = LiquidFuel
ratio = 0.4
DrawGauge = True
}
PROPELLANT
{
name = Oxidizer
ratio = 0.6
}
atmosphereCurve
{
key = 0 370
key = 1 270
}

}

CONFIG
{
name = LiquidFuel+LiquidOxygen (55 Thrust, 390 Isp)
thrustVectorTransformName = thrustTransform
exhaustDamage = True
ignitionThreshold = 0.1
minThrust = 0
maxThrust = 55
heatProduction = 275
fxOffset = 0, 0, 0.21
PROPELLANT
{
name = LiquidFuel
ratio = 0.35
DrawGauge = True
}
PROPELLANT
{
name = LiquidOxygen
ratio = 0.65
}
atmosphereCurve
{
key = 0 390
key = 1 300
}

}

CONFIG
{
name = LiquidH2+LiquidOxygen (40 Thrust, 460 Isp)
thrustVectorTransformName = thrustTransform
exhaustDamage = True
ignitionThreshold = 0.1
minThrust = 0
maxThrust = 40
heatProduction = 250
fxOffset = 0, 0, 0.21
PROPELLANT
{
name = LiquidH2
ratio = 0.73
DrawGauge = True
}
PROPELLANT
{
name = LiquidOxygen
ratio = 0.27
}
atmosphereCurve
{
key = 0 460
key = 1 310
}

}
}

Each CONFIG node is effectively a ModuleEngines MODULE node that will overwrite the part's original ModuleEngines node when selected in the editor. Note that configuration=<name> MUST point to a CONFIG which matches the default ModuleEngines node.

[https://github.com/Ialdabaoth/ModuleManager/blob/master/ModuleManager.zip?raw=true]Download link from GitHub

This .ZIP contains the ModularFuelTanks plugin, the ModuleManager plugin, and ModuleManager .cfg files for each of the stock engines and fuel tanks in the game, as well as KW tanks and KSPX tanks, and courtesy ModuleManager .cfg files for Ferram Aerospace Research, RemoteTech, and IonCrossLSS. It also contains Resource definition .CFG files to give you a more "realistic" selection of fuels:

-LiquidFuel is now changed to have the density and performance stats of kerosene (RP-1)

-Oxidizer now has the density and performance stats of N2O4

-LiquidOxygen is added as an alternate oxidizer, which gives slightly better thrust and Isp at the cost of requiring cryogenic storage.

-LiquidH2 is added as an alternate fuel, which gives lower thrust but higher Isp, and which is required for the LV-N nuclear rocket.

Source code is here, if you're into that sort of thing.

Edited by ialdabaoth
Link to comment
Share on other sites

Hm... shouldn't the useable volume be less than the max amount of volume it can hold?

Change (line 239)

v += (float) fuel.maxAmount / fuel.efficiency;

to

v += (float) fuel.maxAmount * fuel.efficiency;

and the math should be fine and dandy. :)

Looks solid from my quick overview of the source, if I ever get time to I'll definitely test it. :D

Link to comment
Share on other sites

Hm... shouldn't the useable volume be less than the max amount of volume it can hold?

Change (line 239)

v += (float) fuel.maxAmount / fuel.efficiency;

to

v += (float) fuel.maxAmount * fuel.efficiency;

and the math should be fine and dandy. :)

Looks solid from my quick overview of the source, if I ever get time to I'll definitely test it. :D

No, the code is right as-is. Useable volume is what the player inputs, because that's what the player cares about. "Consumed volume" is equal to useable volume PLUS the inefficiency, which is equal to 1/efficiency.

As a user, you just enter "5500" in the LiquidH2 box, and it sets your LiquidH2 to 5500. If that takes up 6200 volume units, then 6200 volume units need to be subtracted from the tank - but as the user, you shouldn't have to do that math. You shouldn't have to say "if I want to store X units of this resource, how much should I ask for?" - you just pick your tank internal volume, and my system computes the rest.

Link to comment
Share on other sites


MODULE
{
name = ModuleFuelTanks
volume = 400


RESOURCE
{
name = LiquidOxygen
amount = 3600
maxAmount = 3600
}

Assuming the TANK configuration above, MaxAmount = 3600 will create a tank that takes up (3600 / .995) = 3618.09 of the available volume

I'm confused. You seem to be saying that you can put a fuel volume of 3600 units into a tank that is set to only store 400.

Link to comment
Share on other sites

I'm confused. You seem to be saying that you can put a fuel volume of 3600 units into a tank that is set to only store 400.

Heh, my bad... teach me to copy/paste from multiple files. The "3600" should read "360".

Link to comment
Share on other sites

There appears to be some confusion going on here, the volume amount isn't the volume of a resource but a volume of the entire fuel tank,the second line in the CFG determins how much resource the tank can hold as well as how much of the internal geometry the tank holding x amount of resource consumings, in effect giving us an upper cap on how much liquid/gas can go in a tank. Very Clever.

Link to comment
Share on other sites

No, the code is right as-is. Useable volume is what the player inputs, because that's what the player cares about. "Consumed volume" is equal to useable volume PLUS the inefficiency, which is equal to 1/efficiency.

As a user, you just enter "5500" in the LiquidH2 box, and it sets your LiquidH2 to 5500. If that takes up 6200 volume units, then 6200 volume units need to be subtracted from the tank - but as the user, you shouldn't have to do that math. You shouldn't have to say "if I want to store X units of this resource, how much should I ask for?" - you just pick your tank internal volume, and my system computes the rest.

Ah... that makes sense. It takes up more because it's less than 100% efficient with using storage space... Cool. :D

Link to comment
Share on other sites

I like this a lot. I would like to incorporate this into my next release of Hollow Structures & Hulls mod, which is still a ways out from being finished. I'll ping you again closer to when I'm finished for permission.

Great work either way!

Link to comment
Share on other sites

it would be nice to have some kind of "fill the rest of the tank with correct ratio of fuel/oxidizer" button. its annoying having to calculate the correct amount of fuel/oxidizer to fill the rest of the tank with after you add monopropellant. might i suggest adding xenon and electricity as well. also, how do you figure out the right volume of a tank? just add fuel and oxidizer together? what about basemass?

Link to comment
Share on other sites

If you want people to include it in their mods so its compatible it should be possible to far simpler config as very basic.

I can't speak for other modders but there's no way I'm going to be maintain the whole block with basemass and all for the whole 40-50 or so B9 tanks.

Something like this I could handle:


MODULE
{
name = ModuleFuelTanks
volume = 400
TANK
{
name = LiquidFuel
}
TANK
{
name = Oxidizer
}
TANK
{
name = MonoPropellant
}
}

Also, it needs to come with a premade preset for the right LFO mix, and that should be part of the base mod, you shouldn't have to specify it for every tank.

Link to comment
Share on other sites

it would be nice to have some kind of "fill the rest of the tank with correct ratio of fuel/oxidizer" button. its annoying having to calculate the correct amount of fuel/oxidizer to fill the rest of the tank with after you add monopropellant. might i suggest adding xenon and electricity as well. also, how do you figure out the right volume of a tank? just add fuel and oxidizer together? what about basemass?

Yeah, just add fuel and oxidizer together. Basemass is generally half the mass of the tank part, which seems to work out to 0.0003125 * volume.

Of course, some tanks break this - for example, my configs set the orange tanks as being a little heavier, in exchange for being more efficient at storing LOX and LH2.

Link to comment
Share on other sites

If you want people to include it in their mods so its compatible it should be possible to far simpler config as very basic.

I can't speak for other modders but there's no way I'm going to be maintain the whole block with basemass and all for the whole 40-50 or so B9 tanks.

Something like this I could handle:


MODULE
{
name = ModuleFuelTanks
volume = 400
TANK
{
name = LiquidFuel
}
TANK
{
name = Oxidizer
}
TANK
{
name = MonoPropellant
}
}

Also, it needs to come with a premade preset for the right LFO mix, and that should be part of the base mod, you shouldn't have to specify it for every tank.

Due to how some of the internals of KSP works, it's buggy if you don't specify a basemass. I can try to grab basemass from mass in the editor, but sometimes that glitches on the way to the launchpad - specifying it explicitly tends to fix that.

Other than basemass, though, you can totally do the rest of that - efficiency, mass, temperature, etc. all default so that if you want, you can just specify a propellant name.

Also, note that I am making plugin compatability much easier in future releases; this is my current project:

Module Manager

Link to comment
Share on other sites

If you want people to include it in their mods so its compatible it should be possible to far simpler config as very basic.

I can't speak for other modders but there's no way I'm going to be maintain the whole block with basemass and all for the whole 40-50 or so B9 tanks.

Something like this I could handle:


MODULE
{
name = ModuleFuelTanks
volume = 400
TANK
{
name = LiquidFuel
}
TANK
{
name = Oxidizer
}
TANK
{
name = MonoPropellant
}
}

Also, it needs to come with a premade preset for the right LFO mix, and that should be part of the base mod, you shouldn't have to specify it for every tank.

Funny enough, it DOES handle that "simplified" method - I'll edit the OP to note that.

Link to comment
Share on other sites

it would be nice to have some kind of "fill the rest of the tank with correct ratio of fuel/oxidizer" button. its annoying having to calculate the correct amount of fuel/oxidizer to fill the rest of the tank with after you add monopropellant. might i suggest adding xenon and electricity as well. also, how do you figure out the right volume of a tank? just add fuel and oxidizer together? what about basemass?

Done! The "Configure to {ratio} for {engine}" button is now a "Configure remaining volume to {ratio} for {engine}" button; if you want to configure the whole tank, click "remove all tanks" before clicking "configure to {ratio} for {engine}".

As for figuring out volume and basemass, volume is just fuel+oxidizer like you said. I tend to put basemass at 0.0003125 * volume, and then set the volume for LF and Ox at 0.0003125, because this adds up to the amount that KSP set for their tanks (which is 0.00625 * volume) while allowing H2 tanks to be a bit lighter.

Link to comment
Share on other sites

I'm having a huge problem with the LH2 and Nuclear engines... The mass of the dry tank is so low that the delta-V I get from a Tank of LH2 on a Nuclear engine is ridiculously low, while a standard engine provides three times the TWR and sometimes 10 times the delta-V. Which is very, very weird and unrealistic.

Link to comment
Share on other sites

I'm having a huge problem with the LH2 and Nuclear engines... The mass of the dry tank is so low that the delta-V I get from a Tank of LH2 on a Nuclear engine is ridiculously low, while a standard engine provides three times the TWR and sometimes 10 times the delta-V. Which is very, very weird and unrealistic.

You're right. I need to rebalance the NTR's.

Link to comment
Share on other sites

Okay, I'm not sure I've read this right, you said that you can configure an engine to use multiple fuel types. Does this mean that you can make a rocket that gets its oxidizer from the atmosphere and switches to LOX when atmosphere thins out too much?

Edited by Nobody_1707
It's is a contraction for it is, switched to the proper possessive.
Link to comment
Share on other sites

Okay, I'm not sure I've read this right, you said that you can configure an engine to use multiple fuel types. Does this mean that you can make a rocket that gets it's oxidizer from the atmosphere and switches to LOX when atmosphere thins out too much?

No, although that would be cooler.

I mean that in the VAB, you can click on an engine and set it to use different blends of fuel, each of which has a predefined Isp and Thrust rating.

Link to comment
Share on other sites

Minor bug note; the actiongroup tank config interface will list things the tank can contain, even if they're not defined in the /Resources/ folder. I haven't specifically tried but this would mean that a part made to be able to store Kethane, would show Kethane as an option even if the specific player doesn't have Kethane mod. On that note you should add a cfg flag to specify that a resource cannot be filled from launch like Kethane or IntakeAir, or assuming vanilla doesn't impliment a featureset like this, the resources they intend to add.

Link to comment
Share on other sites

Minor bug note; the actiongroup tank config interface will list things the tank can contain, even if they're not defined in the /Resources/ folder. I haven't specifically tried but this would mean that a part made to be able to store Kethane, would show Kethane as an option even if the specific player doesn't have Kethane mod. On that note you should add a cfg flag to specify that a resource cannot be filled from launch like Kethane or IntakeAir, or assuming vanilla doesn't impliment a featureset like this, the resources they intend to add.

That would all be amazing, but unfortunately there are limitations to 0.19's resource definition system (namely, I can't really extend it or even iterate through it).

I MAY be able to detect if a resource is undefined, and if so remove it; but note that even the main game isn't that fault-tolerant.

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