Jump to content

NFT Fuel Tank Capcities and Ratios Discussion


Nertea

Recommended Posts

My suggested balancing scheme has been to make NFP tanks lighter and possibly slightly higher capacity than stock tanks, at the cost of heat resistance, drag, and structural integrity (they're designed for orbit, not launch vehicles).

I haven't found any means by which to increase drag. The maximum_drag & minimum_drag values no longer appear to do anything since 1.0. As for structural integrity, stock tanks have a crashTolerance of 6, which is already the lowest in the game. I suppose cryo tanks could be decreased to 4, but anything lower than that would probably just be annoying. Cryo tanks already have lower maxTemp (1200 vs 2000) and emissivity (0.2 vs 0.8). Basically, I agree it would be nice to differentiate cryo tanks from stock tanks on the basis you describe, but I'm not sure there is much room/ability to actually do so (other than heat characteristics, which has already been done), unless someone comes up with a way to artificially increase drag.

In regards to dry mass, Can the assumption be made that the different tank setups lose negligible volume to intertank space and gain negligible mass? I think these can be safe in the interest of not overcomplicating an already unnecessarily complicated problem.

That's exactly the assumption that my calculations make. Basically, I am proposing consistent dry mass per LH2 mass across configurations for a given tank, whether it's LH2-only or LH2/OX. This gets a bit confusing because the dry mass per LH2 mass is different from dry mass per OX mass, so the LH2/OX configuration needs to take both ratios into account in the correct proportion. Take a look at my previous posts for more info.

Edited by Fraz86
Link to comment
Share on other sites

Balancing vs volume is probably the best viable option here, as the NFP tanks are purposely lighter relative the stock equivalents by size.

That's what I was thinking. We can keep volume somewhat constant between the different setups. The current patch for stock tanks has the following volume calculations:

[TABLE=class: grid, width: 500]

[TR]

[TD][/TD]

[TD]Stock LF+OX[/TD]

[TD]LF or OX[/TD]

[TD]LH + OX[/TD]

[TD]LH Only[/TD]

[/TR]

[TR]

[TD]LF+OX as reference[/TD]

[TD]1[/TD]

[TD]1[/TD]

[TD]Not constant but it's about 1.4[/TD]

[TD]1.4[/TD]

[/TR]

[TR]

[TD]LH only as reference[/TD]

[TD]0.71[/TD]

[TD]0.71[/TD]

[TD]1[/TD]

[TD]1[/TD]

[/TR]

[/TABLE]

The NFP cryo tanks have the following volume capacities:

[TABLE=class: grid, width: 500]

[TR]

[TD]LH[/TD]

[TD]LH and OX[/TD]

[TD]OX Only[/TD]

[/TR]

[TR]

[TD]1[/TD]

[TD]

1.41

[/TD]

[TD]

3.7

[/TD]

[/TR]

[/TABLE]

You can notice the error there. Instead having mixed cryo tanks holding less fuel, they end up holding almost 3 times what they should have. That is caused by the way that the oxidizer fraction is calculated by the current fuel switch code. In short, it calculates the fraction of the tank that LH should take based on the current LH+OX burn ratio (10:1). Then, OX is added to the rest of the tank. What the script does not take in consideration is that LH is measured in liters while oxidizer is measured in fuel units. This magically fits 5.5 times as much oxidizer as it should have. My suggestion would be calculate the fraction of oxidizer that you need then fill the rest of the tank with liquid hydrogen, carrying out all calculations in fuel units and converting the LH to liters at the end.

That's exactly the assumption that my calculations make. Basically, I am proposing consistent dry mass per LH2 mass across configurations for a given tank, whether it's LH2-only or LH2/OX. This gets a bit confusing because the dry mass per LH2 mass is different from dry mass per OX mass, so the LH2/OX configuration needs to take both ratios into account in the correct proportion. Take a look at my previous posts for more info.

If we decide to have keep the volumes consistent between the different setups (I kinda like the 1:1.4:1.4 ratio that Nertea is using for the stock tanks), we definitely have to take a look at the tanks dry mass. The problem with the dry mass is very clear when you use atomic rockets converted to burn LH. The problem is that LH is 71 times less dense than LF. That results in the engines consuming 71 times the weight of fuel (my knowledge of rocketry is quite limited, but it has something to do with having to keep a constant exhaust velocity for a given ISP. This thread has more on the problem. It basically comes down to this formula: fuel rate in L/s = Thrust / ((density) * g * Isp). Nertea already took care of the atomic engines ISP in the extra patch in NFP, so this should be a huge problem). This plus the very low wet/dry tank weight ratio for LH only tanks makes atomic rockets basically unusable (thanks to the Rocket Equation).

To summarize the problem, first we should fix the volume problem with cryo tanks. Then, we can start balancing the dry weight of the tanks based on engine performance and what not.

Edited by pacbard
grammar
Link to comment
Share on other sites

Question, why does CryoEngines use a non Crygenic Oxidiser instead the real Crygenic Oxidiser: LqdOxygen? It would solve a lot of issues and make it consistent with other mods. Then you can simply use a 4:1 Ratio and it would make creating tanks a lot more simple and allow you to mix with RealFuels/Interstellar easier

Link to comment
Share on other sites

Question, why does CryoEngines use a non Crygenic Oxidiser instead the real Crygenic Oxidiser: LqdOxygen? It would solve a lot of issues and make it consistent with other mods. Then you can simply use a 4:1 Ratio and it would make creating tanks a lot more simple and allow you to mix with RealFuels/Interstellar easier

That's another problem and (per OP) it's one of the off-the-table issues. Nertea just wanted to add one resource (Liquid Hydrogen) and use the stock oxidizer. The cryo engines have been balanced to burn stock oxidizer (10:1, which is equivalent to a burn rate of 1.18:1 in fuel units or liters, and 1:7.05 by weight). As you know, the problem is that stock oxidizer is not liquid oxygen but probably something like Aerozine 45(does something like that even exist?) based on its density. I don't even know where we will end up if we go down this road. I am happy with the current cryo engines pack. It feels right with the other stock parts without going all crazy with realism.

For this reason, I suggested a burn ratio of 16:1 for cryo engines over at the cryo engine thread. That would take the burn rate by weight to about 1:4.41 and would balance the tanks a little better.

Edited by pacbard
Fixed ratio by weight
Link to comment
Share on other sites

About drag, I seem to recall a value in part .cfg called dragCoefficient (I may be misremembering so I need to go back in and verify). I believe that can be adjusted to simulate varying skin drag like you would have on something like the reactors or the ISRU refinery. This value could be slightly increased for the lighter weight tanks in question.

Like you said above, I'd rather not mess with the cryo engines pack too much. Thats in a good place. Your point is agreed with.

You have good math to deal with the inconsistencies, so I think thats sufficient progress for now. I wanna hear from Nertea and possibly implement your patch (I'm gonna dig into the .cfg and see about pasting it in for myself), and then, after the immediate glaring issues are patched, start addressing delta V balancing (which goes back to some of the issues I addressed in my megapost previous page about efficiency vs convenience).

Link to comment
Share on other sites

You have good math to deal with the inconsistencies, so I think thats sufficient progress for now. I wanna hear from Nertea and possibly implement your patch (I'm gonna dig into the .cfg and see about pasting it in for myself), and then, after the immediate glaring issues are patched, start addressing delta V balancing (which goes back to some of the issues I addressed in my megapost previous page about efficiency vs convenience).

As far as I can find using google/wikipedia, these are some dry/wet ratios for real world tanks: Apollo Stage II (stock LH+OX) 1:10, Shuttle External Tank (NFP LH+OX) 1:28, Titan II Stage I (A-50, which should be stock's LF+OX) 1:27. If we take stock 1:9 dry/wet ratio for tanks as benchmark, that gives us the following ratios: LF+OX 1:9, LH+OX - stock tanks 1:3, LH+OX - NFP tanks 1:9. Basically, stock tanks converted to LH+OX should have a dry/wet ratio of 1:3, cryo tanks should be able to have a similar ratio than stock LF+OX tanks. I don't know what to do with stock LH-only tanks and NFP OX-only tanks.

This is what we should change:

[TABLE=class: grid, width: 500]

[TR]

[TD=align: center]Tank Setup[/TD]

[TD=align: center]Current Dry/Wet Ratio[/TD]

[TD=align: center]Target Dry/Wet Ratio[/TD]

[TD=align: center]To do[/TD]

[/TR]

[TR]

[TD]Stock LH+OX[/TD]

[TD=align: center]1:6.07[/TD]

[TD=align: center]1:3[/TD]

[TD=align: center]Decrease fuel[/TD]

[/TR]

[TR]

[TD]Stock LH Only[/TD]

[TD=align: center]1:2.09[/TD]

[TD=align: center]1:3 (?)[/TD]

[TD=align: center]Increase fuel and decrease mass[/TD]

[/TR]

[TR]

[TD]NFP LH Only[/TD]

[TD=align: center]Variable between 1:2.5 and 1:3[/TD]

[TD=align: center]1:9 (?)[/TD]

[TD=align: center]Decrease weight[/TD]

[/TR]

[TR]

[TD]NFP LH+OX[/TD]

[TD=align: center]Variable between 1:12 and 1:15[/TD]

[TD=align: center]1:9[/TD]

[TD=align: center]Decrease fuel[/TD]

[/TR]

[TR]

[TD]NFP OX Only[/TD]

[TD=align: center]Variable between 1:14 and 1:18[/TD]

[TD=align: center]1:9[/TD]

[TD=align: center]Decrease fuel[/TD]

[/TR]

[/TABLE]

We can do this by tweaking the amount of fuel in each tank and at the same time changing the tank dry mass to get the target dry/wet ratio.

Edited by pacbard
Link to comment
Share on other sites

Pacbard,

Please review my prior posts regarding dry mass and LH2. The dry/wet ratio absolutely should not be equal when comparing stock LH+OX vs LH-only, or when comparing NFP LH vs LH+OX vs OX-only. If we use the "aggressive" numbers at the bottom of this post, plus make a couple corresponding changes to the cryo tank capacity numbers we end up with the following dry/wet ratios:

[TABLE=class: grid, width: 500]

[TR]

[TD=align: center]Tank Setup[/TD]

[TD=align: center]Current Dry/Wet Ratio[/TD]

[TD=align: center]Target Dry/Wet Ratio[/TD]

[/TR]

[TR]

[TD]Stock LH+OX[/TD]

[TD=align: center]1:6.07[/TD]

[TD=align: center]1:7[/TD]

[/TR]

[TR]

[TD]Stock LH Only[/TD]

[TD=align: center]1:2.09[/TD]

[TD=align: center]1:3.1[/TD]

[/TR]

[TR]

[TD]NFP LH Only[/TD]

[TD=align: center]Variable between 1:2.5 and 1:3[/TD]

[TD=align: center]1:3.7[/TD]

[/TR]

[TR]

[TD]NFP LH+OX[/TD]

[TD=align: center]Variable between 1:12 and 1:15[/TD]

[TD=align: center]1:8.1[/TD]

[/TR]

[TR]

[TD]NFP OX Only[/TD]

[TD=align: center]Variable between 1:14 and 1:18[/TD]

[TD=align: center]1:10.2[/TD]

[/TR]

[/TABLE]

Edited by Fraz86
Link to comment
Share on other sites

You know what? I was grilling some chicken for dinner and I had an epiphany. We want to keep the balance as close to stock feel as possible. Why? Because if I wanted to play with realistic weight and ratios and stuff I would be playing RSS+RO. Now, what does this mean for our little calculations? I present to you the "LOL so Kerbal" patch for Near Future Propulsion!


// Adds InterstellarFuelSwitch to LFO and LH2 tanks
// 5.5*total LFO


// LF/O tanks
@PART
[*]:HAS[@RESOURCE[LiquidFuel],@RESOURCE[Oxidizer],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels] {



%LF = #$RESOURCE[LiquidFuel]/maxAmount$
%OX = #$RESOURCE[Oxidizer]/maxAmount$

%totalCap = #$RESOURCE[LiquidFuel]/maxAmount$
@totalCap += #$RESOURCE[Oxidizer]/maxAmount$

%mixLH2 = #$totalCap$
@mixLH2 /= 1.1
%mixOX = #$totalCap$
@mixOX -= #$mixLH2$


%onlyLH2 = #$mixLH2$
@onlyLH2 *= 2

%tempVar = 0
%dryCost = 0

@dryCost = #$cost$

%LFCost = 0
%OXCost = 0
%LH2Cost = 0
%mixLH2Cost = 0
%mixLFCost = 0

// compute cost of stock tank fuel
@tempVar = #$RESOURCE[LiquidFuel]/maxAmount$
@tempVar *= 0.8
@mixLFCost += #$tempVar$

@tempVar = #$RESOURCE[Oxidizer]/maxAmount$
@tempVar *= 0.18
@mixLFCost += #$tempVar$

@dryCost -= #$mixLFCost$
@cost -= #$mixLFCost$

// Cost LF only
@tempVar = #$totalCap$
@tempVar *= 0.8
@LFCost += #$tempVar$

// Cost OX only
@tempVar = #$totalCap$
@tempVar *= 0.18
@OXCost += #$tempVar$

// Cost LH2 only
@tempVar = #$onlyLH2$
@tempVar *= 0.03675
@LH2Cost += #$tempVar$

// Cost mix
@tempVar = #$mixLH2$
@tempVar *= 0.03675
@mixLH2Cost += #$tempVar$

@tempVar = #$mixOX$
@tempVar *= 0.18
@mixLH2Cost += #$tempVar$

@tempVar = 0


// masses
%mixLH2mass = #$mass$
@mixLH2mass *= 0.9
%onlyLH2mass = #$mass$
@onlyLH2mass *= 0.85

MODULE {
name = InterstellarFuelSwitch


volumeMultiplier = 1
massMultiplier = 1

resourceGui = LF/OX;LH2/OX;LF;OX;LH2
resourceNames = LiquidFuel,Oxidizer;LqdHydrogen,Oxidizer;LiquidFuel;Oxidizer;LqdHydrogen


resourceAmounts = #$../LF$,$../OX$;$../mixLH2$,$../mixOX$;$../totalCap$;$../totalCap$;$../onlyLH2$


//tankCost = #$../mixLFCost$;$../mixLH2Cost$;$../LFCost$;$../OXCost$;$../LH2Cost$
displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


basePartMass = 0
tankMass = #$../mass$;$../mixLH2mass$;$../mass$;$../mass$;$../onlyLH2mass$
}

!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}

}






// Pure LH2 tanks
@PART
[*]:HAS[@RESOURCE[LqdHydrogen],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels] {

%LH2 = #$RESOURCE[LqdHydrogen]/maxAmount$


%mixLH2 = #$LH2$
@mixLH2 /= 2
%mixOX = #$mixLH2$
@mixOX *= 0.1


%OX = #$mixOX$
@OX *= 2


MODULE {
name = InterstellarFuelSwitch


volumeMultiplier = 1
massMultiplier = 1

resourceGui = LH2;LH2/OX;OX
resourceNames = LqdHydrogen;LqdHydrogen,Oxidizer;Oxidizer


resourceAmounts = #$../LH2$;$../mixLH2$,$../mixOX$;$../OX$


displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


basePartMass = 0
tankMass = #$../mass$;$../mass$;$../mass$
}

!RESOURCE[LqdHydrogen] {}
}


This is the basic assumption: the mixed LH+OX tank just works out to always have half of its volume in oxidizer (it's left to the reader to work out the formal proof. Hint: each unit of fuel is 5.5 liters and the burn ratio of a cryo engine is 1:10). The cryo engine pack has been balanced with this tank configuration in mind so let's not mess with it.

Then it just hit me, if half of the tank is oxidizer, the other half must be liquid hydrogen. If this is true, we can just double the amount of liquid hydrogen in a mixed tank to find out the amount of hydrogen in a LH only tank (we decided not to consider any volume lost to the intertank right?). If we work the problem backwards, we can just find the correct amounts for LH+OX and OX only for the NFP tanks.

This would fix the volume issue and balance the fuel issue (for example, two mixed tanks will give you the same amount of fuel as 1 tank of fuel and 1 tank of oxidizer, with the exception of LF and OX combos, because of the stock 4:5 burn ratio but this is really not an issue). Now we just have to fix the dry tank weight issue and we are golden!

As a side effect of this change, now all the cryo tanks underperform the stock tanks that have the same size. Is that how it was from the beginning? If not, we might just have to match the amount of liquid hydrogen for the cryo tanks to at least match their stock counterparts.

Edited by pacbard
Spoilered the code snippet
Link to comment
Share on other sites

Pacbard,

Please review my prior posts regarding dry mass and LH2. The dry/wet ratio absolutely should not be equal when comparing stock LH+OX vs LH-only, or when comparing NFP LH vs LH+OX vs OX-only. If we use the "aggressive" numbers at the bottom of this post, plus make a couple corresponding changes to the cryo tank numbers (decrease baseline dry mass by 40%, increase denominator of mixLH2 from 1.1 to 1.6, with corresponding decrease in mixOX) we end up with the following dry/wet ratios:

What do you think about this changes:


// Adds InterstellarFuelSwitch to LFO and LH2 tanks
// 5.5*total LFO


// LF/O tanks
@PART
[*]:HAS[@RESOURCE[LiquidFuel],@RESOURCE[Oxidizer],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels] {



%LF = #$RESOURCE[LiquidFuel]/maxAmount$
%OX = #$RESOURCE[Oxidizer]/maxAmount$

%totalCap = #$RESOURCE[LiquidFuel]/maxAmount$
@totalCap += #$RESOURCE[Oxidizer]/maxAmount$

%mixOX = #$totalCap$
@mixOX /= 2
%mixLH2 = #$mixOX$
@mixLH2 *= 10


%onlyLH2 = #$mixLH2$
@onlyLH2 *= 2

%tempVar = 0
%dryCost = 0

@dryCost = #$cost$

%LFCost = 0
%OXCost = 0
%LH2Cost = 0
%mixLH2Cost = 0
%mixLFCost = 0

// compute cost of stock tank fuel
@tempVar = #$RESOURCE[LiquidFuel]/maxAmount$
@tempVar *= 0.8
@mixLFCost += #$tempVar$

@tempVar = #$RESOURCE[Oxidizer]/maxAmount$
@tempVar *= 0.18
@mixLFCost += #$tempVar$

@dryCost -= #$mixLFCost$
@cost -= #$mixLFCost$

// Cost LF only
@tempVar = #$totalCap$
@tempVar *= 0.8
@LFCost += #$tempVar$

// Cost OX only
@tempVar = #$totalCap$
@tempVar *= 0.18
@OXCost += #$tempVar$

// Cost LH2 only
@tempVar = #$onlyLH2$
@tempVar *= 0.03675
@LH2Cost += #$tempVar$

// Cost mix
@tempVar = #$mixLH2$
@tempVar *= 0.03675
@mixLH2Cost += #$tempVar$

@tempVar = #$mixOX$
@tempVar *= 0.18
@mixLH2Cost += #$tempVar$

@tempVar = 0


// masses
%mixLH2mass = #$mass$
@mixLH2mass *= 0.9
%onlyLH2mass = #$mass$
@onlyLH2mass *= 0.85

MODULE {
name = InterstellarFuelSwitch


volumeMultiplier = 1
massMultiplier = 1

resourceGui = LF/OX;LH2/OX;LF;OX;LH2
resourceNames = LiquidFuel,Oxidizer;LqdHydrogen,Oxidizer;LiquidFuel;Oxidizer;LqdHydrogen


resourceAmounts = #$../LF$,$../OX$;$../mixLH2$,$../mixOX$;$../totalCap$;$../totalCap$;$../onlyLH2$


//tankCost = #$../mixLFCost$;$../mixLH2Cost$;$../LFCost$;$../OXCost$;$../LH2Cost$
displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


basePartMass = 0
tankMass = #$../mass$;$../mixLH2mass$;$../mass$;$../mass$;$../onlyLH2mass$
}

!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}

}






// Pure LH2 tanks
@PART
[*]:HAS[@RESOURCE[LqdHydrogen],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels] {

%LH2 = #$RESOURCE[LqdHydrogen]/maxAmount$


%mixLH2 = #$LH2$
@mixLH2 /= 2
%mixOX = #$mixLH2$
@mixOX *= 0.1


%OX = #$mixOX$
@OX *= 2


// masses
%LH2mass = #$LH2$
@LH2mass *= 0.000035425 //A Cryo tank is 3.20 times lighter than an equivalent stock tank
%mixLH2mass = #$LH2mass$
@mixLH2mass *= 1.1
%onlyOXmass = #$LH2mass$
@onlyOXmass *= 1.5


MODULE {
name = InterstellarFuelSwitch


volumeMultiplier = 1
massMultiplier = 1

resourceGui = LH2;LH2/OX;OX
resourceNames = LqdHydrogen;LqdHydrogen,Oxidizer;Oxidizer


resourceAmounts = #$../LH2$;$../mixLH2$,$../mixOX$;$../OX$


displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


basePartMass = 0
tankMass = #$../LH2mass$;$../mixLH2mass$,$../onlyOXmass$
}

!RESOURCE[LqdHydrogen] {}
}

I left the stock mass adjustments as they were in the original IFS patch. The additional LH in the stock tanks makes them too good already. The weight ratios are LF+OX 1:9, LH+OX 1:6.07, and LH 1:2.3.

For the cryo tanks, the weight is calculated based on the total LH volume (so, like stock tanks are 0.000625*volume, cryo tanks are 0.000035425*volume - once you take in consideration that LH is measured in liters, the weight for a NFP tank is about 3.20 times lighter than a stock tank.) Weight for a LH+OX tank is increased by 1.1 times and weight for an OX tank is increased by 1.5 times. Wet/dry ratios are LH 1:3, LH+OX 1:8.23, and OX only 1:10.

The only draw back about this scheme is that cryo tanks currently hold less LH as their stock counterparts of the same size. I think that it has to do with the balance that Nertea put in the original release of the mod (which was LH is 1.4 times the tank volume, and not 2 times the tank's volume as proposed by this patch). On the other hand, one cryo tank weighs the about same as stock tank double its size and holds about 1.5 times the amount of fuel. So, you still get more delta v for the same amount of fuel, so we could say that that balances out the cryo vs. stock tanks.

I haven't spent enough time trying various configurations between tanks and engines to see if all of this is still balanced with cryogenic and atomic engines. Let me know what you think about it.

Edited by pacbard
Link to comment
Share on other sites

That's another problem and (per OP) it's one of the off-the-table issues. Nertea just wanted to add one resource (Liquid Hydrogen) and use the stock oxidizer. The cryo engines have been balanced to burn stock oxidizer (10:1, which is equivalent to a burn rate of 1.18:1 in fuel units or liters, and 1:7.05 by weight). As you know, the problem is that stock oxidizer is not liquid oxygen but probably something like Aerozine 45(does something like that even exist?) based on its density. I don't even know where we will end up if we go down this road. I am happy with the current cryo engines pack. It feels right with the other stock parts without going all crazy with realism.

For this reason, I suggested a burn ratio of 16:1 for cryo engines over at the cryo engine thread. That would take the burn rate by weight to about 1:4.41 and would balance the tanks a little better.

I don't understand why LqdOxygen is of the table, its a real Oxidiser and MORE dense than stock Oxidiser, It compensates for LqdHydrogen low density. I though after CRP 0.4 the new LqdOxygen would be adapted by most mods, and I though the CryEngines mod used it. Now to my horror I found it still used the stock Oxydiser which leads to a lot of confusion and hand waving which isn't necessary. For KSPI I made the convention to use either use real resources, or Kerbal fantasy stock resources like LiquidFuel, but I do everything to avoid mixing them.

Link to comment
Share on other sites

As you know, the problem is that stock oxidizer is not liquid oxygen but probably something like Aerozine 45(does something like that even exist?) based on its density.

Did you mean nitrogen tetroxide rather than Aerozine?

Aerozine 50 is a fuel consisting of equal parts by weight of hydrazine (N2H4) and UDMH. It's commonly paired with (di)nitrogen tetroxide, N2O4, as an oxidizer. Both propellants are liquid at a useful range of temperatures and pressures, and the combination is hypergolic (ignites spontaneously). I'd think that "Aerozine 45", if it existed, would be a fuel (with a 45-55 mix of the two components) rather than an oxidizer.

Link to comment
Share on other sites

Did you mean nitrogen tetroxide rather than Aerozine?

Aerozine 50

is a fuel consisting of equal parts by weight of hydrazine (N2H4) and UDMH. It's commonly paired with (di)nitrogen tetroxide, N2O4, as an oxidizer. Both propellants are liquid at a useful range of temperatures and pressures, and the combination is hypergolic (ignites spontaneously). I'd think that "Aerozine 45", if it existed, would be a fuel (with a 45-55 mix of the two components) rather than an oxidizer.

Yeah. You are right. I should have said something like stock Liquid Fuel+Oxidizer is Aerozine 50. The bottom line is that stock oxidizer is not liquid oxygen but rather something like dinitrogen tetroxide as you said.

I don't understand why LqdOxygen is of the table, its a real Oxidiser and MORE dense than stock Oxidiser, It compensates for LqdHydrogen low density. I though after CRP 0.4 the new LqdOxygen would be adapted by most mods, and I though the CryEngines mod used it. Now to my horror I found it still used the stock Oxydiser which leads to a lot of confusion and hand waving which isn't necessary. For KSPI I made the convention to use either use real resources, or Kerbal fantasy stock resources like LiquidFuel, but I do everything to avoid mixing them.

That's a decision that only Nertea can make. But I want you to know that I totally agree with you about using Liquid Oxygen. It would make the conversions and balancing so much easier.

Edit:

For anyone interested in taking a look at cryo engines running liquid oxygen instead of stock oxidizer, this is a quick and dirty patch for it:


// Convert any engine that runs on LH to use Liquid Oxygen.
@PART
[*]:HAS[@MODULE[ModuleEngine*]:HAS[@PROPELLANT[LqdHydrogen],@PROPELLANT[Oxidizer]]]:LAST
{
@MODULE[ModuleEngine*]{


@PROPELLANT[LqdHydrogen] {
@ratio = 4 // Real fuels has 76.30830964721619
}


@PROPELLANT[Oxidizer] {
@name = LqdOxygen
@ratio = 1
}
}
}


// Adds InterstellarFuelSwitch to LFO and LH2 tanks
// 5.5*total LFO


// LF/O tanks
@PART
[*]:HAS[@RESOURCE[LiquidFuel],@RESOURCE[Oxidizer],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels] {

%LF = #$RESOURCE[LiquidFuel]/maxAmount$
%OX = #$RESOURCE[Oxidizer]/maxAmount$

%totalCap = #$RESOURCE[LiquidFuel]/maxAmount$
@totalCap += #$RESOURCE[Oxidizer]/maxAmount$


%onlyLH2 = #$totalCap$
@onlyLH2 *= 5.5
%onlyLOX = #$totalCap$
@onlyLOX *= 5.5


%mixLH2 = #$onlyLH2$
@mixLH2 *= 0.8
%mixLOX = #$onlyLOX$
@mixLOX *= 0.2

// masses
%mixLH2mass = #$mass$
@mixLH2mass *= 0.9
%onlyLH2mass = #$mass$
@onlyLH2mass *= 0.85

MODULE {
name = InterstellarFuelSwitch


volumeMultiplier = 1
massMultiplier = 1

resourceGui = LF/OX;LH2/OX;LF;OX;LH2
resourceNames = LiquidFuel,Oxidizer;LqdHydrogen,LqdOxygen;LiquidFuel;Oxidizer;LqdHydrogen;LqdOxygen


resourceAmounts = #$../LF$,$../OX$;$../mixLH2$,$../mixLOX$;$../totalCap$;$../totalCap$;$../onlyLH2$;$../onlyLOX$


displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


basePartMass = 0
tankMass = #$../mass$;$../mixLH2mass$;$../mass$;$../mass$;$../onlyLH2mass$;$../onlyLH2mass$
}

!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}

}


// Pure LH2 tanks
@PART
[*]:HAS[@RESOURCE[LqdHydrogen],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels] {

%LH2 = #$RESOURCE[LqdHydrogen]/maxAmount$
%LOX = #$RESOURCE[LqdHydrogen]/maxAmount$


%mixLH2 = #$LH2$
@mixLH2 *= 0.8
%mixLOX = #$LOX$
@mixLOX *= 0.2


MODULE {
name = InterstellarFuelSwitch


volumeMultiplier = 1
massMultiplier = 1

resourceGui = LH2;LH2/OX;OX
resourceNames = LqdHydrogen;LqdHydrogen,LqdOxygen;LqdOxygen


resourceAmounts = #$../LH2$;$../mixLH2$,$../mixLOX$;$../LOX$


displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


basePartMass = 0
tankMass = #$../mass$;$../mass$;$../mass$
}

!RESOURCE[LqdHydrogen] {}
}


Edited by pacbard
Added LqdOxygen patch
Link to comment
Share on other sites

This is the basic assumption: the mixed LH+OX tank just works out to always have half of its volume in oxidizer (it's left to the reader to work out the formal proof. Hint: each unit of fuel is 5.5 liters and the burn ratio of a cryo engine is 1:10).

These premises are from Nertea's OP:

  • LH2 is 1 liter per unit
  • OX is 5.5 liters per unit
  • Cryo engines burn 10 units of LH2 per 1 unit of OX

Therefore, LH2/OX tanks hold 10 liters of LH2 per 5.5 liters OX (~65%:35%).

Arguably, the 1.5x fudge factor could imply that LH2 has a "fudged" density of 0.667 liters per unit (i.e., 1.5 units per liter), in which case LH2/OX tanks hold 6.67 liters of LH2 per 5.5 liters OX (~55%:45%). In either case, OX should not occupy half of the tank.

That said, I do agree that taking a volume-based approach would be much more robust, and that we can better address the dry mass issue by putting it in terms of "X mass per unit OX capacity + Y mass per unit LH2 capacity." I've drawn up a config to implement these changes below. Take note of the fields with "EDIT HERE", as these will allow you to modify the important variables.

// LF/O tanks
@PART[*]:HAS[@RESOURCE[LiquidFuel],@RESOURCE[Oxidizer],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels]
{
%LF = #$RESOURCE[LiquidFuel]/maxAmount$
%OX = #$RESOURCE[Oxidizer]/maxAmount$

%totalCap = #$RESOURCE[LiquidFuel]/maxAmount$
@totalCap += #$RESOURCE[Oxidizer]/maxAmount$

%LH2FudgeFactor = 1.5 // <- EDIT HERE (effectively multiplies LH2 density by this number)
%mixOXProportion = 0.45 // <- EDIT HERE (proportion of tank volume containing OX; this value should be set approximately = 5.5 / [5.5 + [10 / LH2FudgeFactor]])
%massPerUnitLH2 = 0.000035 // <- EDIT HERE (dry mass per unit LH2 capacity)

%onlyLH2 = #$totalCap$
@onlyLH2 *= 5.5
@onlyLH2 *= #$LH2FudgeFactor$

%mixOX = #$totalCap$
@mixOX *= #$mixOXProportion$
%mixLH2 = #$mixOX$
@mixLH2 *= 10

%tempVar = 0
%dryCost = 0

@dryCost = #$cost$

%LFCost = 0
%OXCost = 0
%LH2Cost = 0
%mixLH2Cost = 0
%mixLFCost = 0

// compute cost of stock tank fuel
@tempVar = #$RESOURCE[LiquidFuel]/maxAmount$
@tempVar *= 0.8
@mixLFCost += #$tempVar$

@tempVar = #$RESOURCE[Oxidizer]/maxAmount$
@tempVar *= 0.18
@mixLFCost += #$tempVar$

@dryCost -= #$mixLFCost$
@cost -= #$mixLFCost$

// Cost LF only
@tempVar = #$totalCap$
@tempVar *= 0.8
@LFCost += #$tempVar$

// Cost OX only
@tempVar = #$totalCap$
@tempVar *= 0.18
@OXCost += #$tempVar$

// Cost LH2 only
@tempVar = #$onlyLH2$
@tempVar *= 0.03675
@LH2Cost += #$tempVar$

// Cost mix
@tempVar = #$mixLH2$
@tempVar *= 0.03675
@mixLH2Cost += #$tempVar$

@tempVar = #$mixOX$
@tempVar *= 0.18
@mixLH2Cost += #$tempVar$

// masses
%massOffset = #$mass$
@tempVar = #$totalCap$
@tempVar *= 0.000625 // standard dry mass per units of LF/OX
@massOffset -= #$tempVar$ // this value accounts for any non-standard fuel tank mass, which should remain constant across fuel configurations, e.g., extra mass for spaceplane tanks

%mixLH2mass = #$mixOX$
@mixLH2mass *= 0.000625

@tempVar = #$mixLH2$
@tempVar *= #$massPerUnitLH2$
@mixLH2mass += #$tempVar$
@mixLH2mass += #$massOffset$

%onlyLH2mass = #$onlyLH2$
@onlyLH2mass *= #$massPerUnitLH2$
@onlyLH2mass += #$massOffset$

@tempVar = 0

MODULE
{
name = InterstellarFuelSwitch

volumeMultiplier = 1
massMultiplier = 1

resourceGui = LF/OX;LH2/OX;LF;OX;LH2
resourceNames = LiquidFuel,Oxidizer;LqdHydrogen,Oxidizer;LiquidFuel;Oxidizer;LqdHydrogen

resourceAmounts = #$../LF$,$../OX$;$../mixLH2$,$../mixOX$;$../totalCap$;$../totalCap$;$../onlyLH2$

//tankCost = #$../mixLFCost$;$../mixLH2Cost$;$../LFCost$;$../OXCost$;$../LH2Cost$
displayCurrentTankCost = true

hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true

basePartMass = 0
tankMass = #$../mass$;$../mixLH2mass$;$../mass$;$../mass$;$../onlyLH2mass$
}

!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
}

// Pure LH2 tanks
@PART[*]:HAS[@RESOURCE[LqdHydrogen],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels]
{
%LH2 = #$RESOURCE[LqdHydrogen]/maxAmount$

%cryoFudgeFactor = 1.2 // <- EDIT HERE (this is a global increase in cryo tank volume to bring them in line with stock; ultimately, once desired volumes are decided on, the LH2 amount in the part config should be adjusted accordingly, rendering this variable unnecessary)
%LH2FudgeFactor = 1.5 // (this should match LH2FudgeFactor for stock tanks above)
%mixOXProportion = 0.45 // (this should match mixOXProportion for stock tanks above)

%massPerUnitLH2 = 0.000025 // <- EDIT HERE (dry mass per unit LH2 capacity; this should be < massPerUnitLH2 for stock tanks)
%massPerUnitOX = 0.0005 // <- EDIT HERE (dry mass per unit OX capacity; this should be < the standard stock value of 0.000625)

@LH2 *= #$cryoFudgeFactor$

%OX = #$LH2$
@OX /= #$LH2FudgeFactor$
@OX /= 5.5

%mixOX = #$OX$
@mixOX *= #$mixOXProportion$
%mixLH2 = #$mixOX$
@mixLH2 *= 10

// masses
%massOffset = #$mass$
%tempVar = #$LH2$
@tempVar *= 0.0000439766 // current standard mass per unit LH2 in part configs; needs to be adjusted if part configs are changed
@massOffset -= #$tempVar$ // this value accounts for any non-standard fuel tank mass, which should remain constant across fuel configurations, e.g., extra mass for spaceplane tanks

%onlyLH2mass = #$LH2$
@onlyLH2mass *= #$massPerUnitLH2$
@onlyLH2mass += #$massOffset$

%mixLH2mass = #$mixOX$
@mixLH2mass *= #$massPerUnitOX$

%tempVar = #$mixLH2$
@tempVar *= #$massPerUnitLH2$
@mixLH2mass += #$tempVar$
@mixLH2mass += #$massOffset$

%onlyOXmass = #$OX$
@onlyOXmass *= #$massPerUnitOX$
@onlyOXmass += #$massOffset$

@tempVar = 0

MODULE
{
name = InterstellarFuelSwitch

volumeMultiplier = 1
massMultiplier = 1

resourceGui = LH2;LH2/OX;OX
resourceNames = LqdHydrogen;LqdHydrogen,Oxidizer;Oxidizer

resourceAmounts = #$../LH2$;$../mixLH2$,$../mixOX$;$../OX$

displayCurrentTankCost = true

hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true

basePartMass = 0
tankMass = #$../onlyLH2mass$;$../mixLH2mass$;$../onlyOXmass$
}

!RESOURCE[LqdHydrogen] {}
}

The variables above give weight ratios of OX 1:9, LH+OX 1:6.9, and LH 1:3 for stock tanks, and OX 1:11, LH+OX 1:8.6, and LH 1:3.8 for cryo tanks.

EDIT:

Regarding LqdOxygen: I believe Nertea basically assumes that Oxidizer is LOX, which is completely reasonable. Oxidizer has a density of 0.90909 kg/L (i.e., 5 kg/u / 5.5 L/u), while CRP sets the density of LqdOxygen at 1.141 kg/L. The difference is fairly trivial. No reason to introduce a redundant resource.

EDIT 2:

Config updated

Edited by Fraz86
Link to comment
Share on other sites

What is the formal proof?

These premises are from Nertea's OP:

  • LH2 is 1 liter per unit
  • OX is 5.5 liters per unit
  • Cryo engines burn 10 units of LH2 per 1 unit of OX

Therefore, LH2/OX tanks hold 10 liters of LH2 per 5.5 liters OX (~65%:35%).

<snip>

But that was homework. :(

Anyhow, there is an error on how the original patch solves the problem. Basically, it does not take in consideration that oxidiser is measured in Fuel Units instead of liters. Currently, the calculations divide the tank volume in liters into 11 parts (from the 1:10 burn ratio). 10 parts are taken up by liquid hydrogen and the remaining 1 part is oxidizer. This would be ok when oxidizer is measured in liters, and not in fuel units. When you take the 1 part for oxidizer, you are magically fitting 5.5 times as much oxidizer per volume (remember that oxidizer is 5.5 liters per unit) in that 1/11 fraction of tank.

A formal proof would be the following:

Let's assume that a tank T has total capacity V, measured in Fuel Units (1 FL = 5.5 Liters). Let's then call VL the total volume of the tank in liters. By definition:

VL = 5.5 V

Tank T should hold VL liters of Liquid Hydrogen when converted to LH2.

To find out the mix fuel fraction, the IFS script currently performs the following operations:

VLH2 = VL /1.1

VOX = VL - VLH2

Substituting for VL and VLH2 in the equation for VOX gives us:

VOX = 5.5 V - (5.5 V)/1.1

= 5.5 V - 5 V

= 0.5 V

Which gives us that the total volume of oxidizer in a mixed LH+OX tank will always be 1/2 of the original tank.

Q.E.D.

The problem with the proof is that it assumes that VLH2 and VOX have the same units of measure when calculating the mix tank ratio. Cryo engines have been balanced with this basic assumption and Nertea seems not to be interested in changing it (and I understand it. Changing the LH2/OX ratios in the mixed tank will throw off the balance for cryo engines big time. All this conversation is really just for converted engines that use just use LH2 or balance NFT tanks in their mixed configuration, which we already agree that is way off).

If we assume that these calculations for the mix LH2+OX are intended, we take this the next logical step to assume that a tank filled with only with LH2 has double the amount of LH2 in a mix tank. After all, LH2 occupies 1/2 of a mixed tank, so why shouldn't be possible to fill a LH2 only tank with double that amount?

If we assume that the calculations are incorrect and we want to keep the volume in liters constant between the different tank setups, then we need to change the calculations to keep the same unit of measure during the calculations and then convert one of the two quantities to its unit of measure (in italics in the formulas).

The calculations in fuel units would be the following. Burn fraction between OX and LH2 is 1 FU:10L, which is equivalent to 1 FU:1.8181 FU. The tank has to be divided in 2.81 parts (1 part of oxidizer and 1.8181 parts of LH2). The rest of the volume is occupied by LH2, which is converted to liters.

VOX= V /(10/5.5+1) * 1

VLH2= V / (10/5.5 + 1) * 10 * 5.5

The same calculations can be done keeping all the volumes in liters. Burn fraction between OX and LH2 is 1 FU:10L, which is equivalent to 5.5L:10L, which simplified to a unit ratio equals 1L;1.8181L, giving us the same results as the ratio above. If you want to carry out the conversion in liters, you can use these equations:

VLH2 = VL / (5.5+10) * 10

VOX = VL / (5.5+10) * 5.5 / 5.5

Exercise: Calculate the correct volumetric fraction of LH2 and OX for a tank that has volume 800 Fuel Units.

[TABLE=width: 1000]

[TR]

[TD]All calculations in Fuel Units[/TD]

[TD]All calculations in Liters[/TD]

[/TR]

[TR]

[TD]VOX = 800 / (10/5.5 + 1) * 1

= 283.87 FU

VLH2 = 800 / (10/5.5 + 1) * 10/5.5

= 516.12 FU = 2838.7096 L

Which occupies a total of 283.87 FU + 516.12 FU = 799.9999 FU. (I know, rounding sucks).[/TD]

[TD]The thank holds 800*5.5 = 4400 L

VLH2 = 4400 / (5.5+10) * 10

= 2838.7096 L

VOX = 4400 / (5.5+10) * 5.5

= 1561.29 L = 283.87 FU

Which occupies a total volume of 2838.7096L +1561.29L = 4399.9999 L = 799.999 FU. (I know, rounding sucks).[/TD]

[/TR]

[/TABLE]

You can see from the numbers that the original calculation ends up fitting 1.4 times as much oxidizer in a mixed tank as it is supposed to do. (283.87 FU vs. 400 FU). I brought this up in the cryo engines thread and I think that Nertea added the 1.4 fudge factor to LH2 only tanks for that reason. From the patch notes:

Because KSP 1.03 is ages away, updating things nowish. Version 0.1.6 is up, except for CF, because approvals.

  • ....
  • Fixed fuel switch patch for stock tanks to give much more logical ratios
  • ....

Edit:

EDIT:

Regarding LqdOxygen: I believe Nertea basically assumes that Oxidizer is LOX, which is completely reasonable. Oxidizer has a density of 1 kg/L (per the premises put forth by Nertea), while CRP sets the density of LqdOxygen at 1.141 kg/L. The difference is fairly trivial. No reason to introduce a redundant resource.

Totally agree. I figured it out after I did the patch for LqdOxygen. The only difference is that it is easier to calculate the tank fractions if the fuel and oxidized use the same units. As I said before, I am happy burning stock oxidizer.

We just have to agree on the tank volume ratios and balance everything from there. My vote is for just keeping the bugged calculation for LH2+OX and double the amount of LH2 for a LH2-only tank. It keeps it easy even if we end up with tanks holding more than they should.

Edited by pacbard
Subscripts suck!
Link to comment
Share on other sites

Yeah. You are right. I should have said something like stock Liquid Fuel+Oxidizer is Aerozine 50. The bottom line is that stock oxidizer is not liquid oxygen but rather something like dinitrogen tetroxide as you said.

That's a decision that only Nertea can make. But I want you to know that I totally agree with you about using Liquid Oxygen. It would make the conversions and balancing so much easier.

Edit:

For anyone interested in taking a look at cryo engines running liquid oxygen instead of stock oxidizer, this is a quick and dirty patch for it:


// Convert any engine that runs on LH to use Liquid Oxygen.
@PART
[*]:HAS[@MODULE[ModuleEngine*]:HAS[@PROPELLANT[LqdHydrogen],@PROPELLANT[Oxidizer]]]:LAST
{
@MODULE[ModuleEngine*]{


@PROPELLANT[LqdHydrogen] {
@ratio = 4 // Real fuels has 76.30830964721619
}


@PROPELLANT[Oxidizer] {
@name = LqdOxygen
@ratio = 1
}
}
}


// Adds InterstellarFuelSwitch to LFO and LH2 tanks
// 5.5*total LFO


// LF/O tanks
@PART
[*]:HAS[@RESOURCE[LiquidFuel],@RESOURCE[Oxidizer],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels] {

%LF = #$RESOURCE[LiquidFuel]/maxAmount$
%OX = #$RESOURCE[Oxidizer]/maxAmount$

%totalCap = #$RESOURCE[LiquidFuel]/maxAmount$
@totalCap += #$RESOURCE[Oxidizer]/maxAmount$


%onlyLH2 = #$totalCap$
@onlyLH2 *= 5.5
%onlyLOX = #$totalCap$
@onlyLOX *= 5.5


%mixLH2 = #$onlyLH2$
@mixLH2 *= 0.8
%mixLOX = #$onlyLOX$
@mixLOX *= 0.2

// masses
%mixLH2mass = #$mass$
@mixLH2mass *= 0.9
%onlyLH2mass = #$mass$
@onlyLH2mass *= 0.85

MODULE {
name = InterstellarFuelSwitch


volumeMultiplier = 1
massMultiplier = 1

resourceGui = LF/OX;LH2/OX;LF;OX;LH2
resourceNames = LiquidFuel,Oxidizer;LqdHydrogen,LqdOxygen;LiquidFuel;Oxidizer;LqdHydrogen;LqdOxygen


resourceAmounts = #$../LF$,$../OX$;$../mixLH2$,$../mixLOX$;$../totalCap$;$../totalCap$;$../onlyLH2$;$../onlyLOX$


displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


basePartMass = 0
tankMass = #$../mass$;$../mixLH2mass$;$../mass$;$../mass$;$../onlyLH2mass$;$../onlyLH2mass$
}

!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}

}


// Pure LH2 tanks
@PART
[*]:HAS[@RESOURCE[LqdHydrogen],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels] {

%LH2 = #$RESOURCE[LqdHydrogen]/maxAmount$
%LOX = #$RESOURCE[LqdHydrogen]/maxAmount$


%mixLH2 = #$LH2$
@mixLH2 *= 0.8
%mixLOX = #$LOX$
@mixLOX *= 0.2


MODULE {
name = InterstellarFuelSwitch


volumeMultiplier = 1
massMultiplier = 1

resourceGui = LH2;LH2/OX;OX
resourceNames = LqdHydrogen;LqdHydrogen,LqdOxygen;LqdOxygen


resourceAmounts = #$../LH2$;$../mixLH2$,$../mixLOX$;$../LOX$


displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


basePartMass = 0
tankMass = #$../mass$;$../mass$;$../mass$
}

!RESOURCE[LqdHydrogen] {}
}


The volumeMultiplier and massMultiplier are obsolete, they are no longer in use, it's all done by code now. Btw, I suggest you turn this script into a mod and host it at Kerbalstuf, then I promise I will make a link to it.

Edited by FreeThinker
Link to comment
Share on other sites

Currently, the calculations divide the tank volume in liters into 11 parts (from the 1:10 burn ratio).

Those are not 11 equal parts, since 1 of them is actually 5.5 liters.

A formal proof would be the following:

Let's assume that a tank T has total capacity V, measured in Fuel Units (1 FL = 5.5 Liters). Let's then call VL the total volume of the tank in liters. By definition:

VL = 5.5 V

Tank T should hold VL liters of Liquid Hydrogen when converted to LH2.

To find out the mix fuel fraction, the IFS script currently performs the following operations:

VLH2 = VL /1.1

VOX = VL - VLH2

Substituting for VL and VLH2 in the equation for VOX gives us:

VOX = 5.5 V - (5.5 V)/1.1

= 5.5 V - 5 V

= 0.5 V

Which gives us that the total volume of oxidizer in a mixed LH+OX tank will always be 1/2 of the original tank.

Q.E.D.

Yes, I understand that the current method of calculating LH2/OX fills half the tank with OX. Unfortunately, this method is not accurate, because the denominator for calculating VLH2 should not be 1.1.

Burn fraction between OX and LH2 is 1 FU:10L, which is equivalent to 5.5L:10L

This is exactly what I pointed out in my previous post. Based on the basic constants presented by Nertea in the OP, the correct volume ratio is 5.5:10 (or 5.5:6.667 if the 1.5x fudge factor applies to LH2 density, which seems logical), not 1:1.

Changing the LH2/OX ratios in the mixed tank will throw off the balance for cryo engines big time.

I don't think this is necessarily true. If the 1.5x fudge factor is assumed to apply to LH2 density, we end up with a OX/LH2 volume ratio of 5.5:6.667, which is not a huge change from the current 1:1. This change can be balanced by decreasing dry masses for LH2-containing parts. Taking a consistent approach in terms of volume allows us to implement a much more consistent, logical, and robust fuel-switching algorithm.

Edited by Fraz86
Link to comment
Share on other sites

Agree to agree! WOW! I'm getting carried away. Fraz86, do you github? With all these code snippets flying around I don't know what we are talking about anymore.

If you want to use a script that keeps the volume constant across the different tank settings, you can use this:


// Adds InterstellarFuelSwitch to LFO and LH2 tanks
// 5.5*total LFO


// LF/O tanks
@PART
[*]:HAS[@RESOURCE[LiquidFuel],@RESOURCE[Oxidizer],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels] {



%LF = #$RESOURCE[LiquidFuel]/maxAmount$
%OX = #$RESOURCE[Oxidizer]/maxAmount$

%totalCap = #$RESOURCE[LiquidFuel]/maxAmount$
@totalCap += #$RESOURCE[Oxidizer]/maxAmount$

%onlyLH2 = #$totalCap$
@onlyLH2 *= 5.5 // CRP resources are measured in liters. 1 fuel unit = 5.5 L

%LH2toOX = 15.5 // 5.5 Liters of OX to 10 liters of LH2
@LH2toOX /= 5.5 // Convert fuel units (keeps the decimal numbers neat)
%mixOX = #$totalCap$ // Start with a tank full of OX
@mixOX /= #$LH2toOX$ // Find the correct percentage OX
%mixLH2 = #$totalCap$ // Use the total tank capacity
@mixLH2 -= #$mixOX$ // LH2 will fill the rest of the tank
@mixLH2 *= 5.5 // Convert LH2 to liters


// masses
%mixLH2mass = #$mass$
@mixLH2mass *= 0.9
%onlyLH2mass = #$mass$
@onlyLH2mass *= 0.85

MODULE {
name = InterstellarFuelSwitch

resourceGui = LF/OX;LH2/OX;LF;OX;LH2
resourceNames = LiquidFuel,Oxidizer;LqdHydrogen,Oxidizer;LiquidFuel;Oxidizer;LqdHydrogen


resourceAmounts = #$../LF$,$../OX$;$../mixLH2$,$../mixOX$;$../totalCap$;$../totalCap$;$../onlyLH2$


displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


basePartMass = 0
tankMass = #$../mass$;$../mixLH2mass$;$../mass$;$../mass$;$../onlyLH2mass$
}

!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}

}






// Pure LH2 tanks
@PART
[*]:HAS[@RESOURCE[LqdHydrogen],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels] {

%LH2 = #$RESOURCE[LqdHydrogen]/maxAmount$


%mixLH2 = #$LH2$


%LH2toOX = 15.5 // 5.5 Liters of OX to 10 liters of LH2
%mixLH2 = #$LH2$ // Start with a tank full of LH2
@mixLH2 /= #$LH2toOX$ // Find the correct percentage for LH2
@mixLH2 *= 10 // 10 parts of LH2
%mixOX = #$LH2$ // Start with a tank full of OX
@mixOX /= #$LH2toOX$ // Find the correct percentage OX (we are supposed to *5.5 parts / 5.5 liters)


%OX = #$LH2$
@OX /= 5.5 // Stock resources are measured in fuel units. 1 fuel unit = 5.5 L


// masses
%LH2mass = #$mass$
%mixLH2mass = #$LH2mass$
@mixLH2mass *= 1
%onlyOXmass = #$LH2mass$
@onlyOXmass *= 1


MODULE {
name = InterstellarFuelSwitch


resourceGui = LH2;LH2/OX;OX
resourceNames = LqdHydrogen;LqdHydrogen,Oxidizer;Oxidizer


resourceAmounts = #$../LH2$;$../mixLH2$,$../mixOX$;$../OX$


displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


basePartMass = 0
tankMass = #$../LH2mass$;$../mixLH2mass$,$../onlyOXmass$
}

!RESOURCE[LqdHydrogen] {}
}


Cryo engines lose about 20% of their delta v as a result of the new fuel amounts (I just tested 1 engine with 2 tank setups, so my sample factor is rather small). I think that we need to do some balancing of tank weights if we want to keep it consistent with the current numbers. Also, we could just reverse the factors when converting the LH2 tanks (for example, if we decide to have a *0.5 factors for stock LH2 tanks, we can have a /0.5 for NFT OX tanks).

BTW, if we decide to keep the volume constant across tank setups, I am against adding a fudge factor to buff up a specific tank setting. The problem is that KSP engine code does take in consideration the resource density when calculating the resource usage (that's one of the issues with NTR converted to LH2 and the reason why the NFP patch buffs ISPs). So, if we include a fudge factor, we will just increase the volume without increasing/decreasing the engine consumption - resulting in magic volume being added to the tank.

This is the other option that we have. We take the current calculations for mixed tanks as correct (I like to think that LH2 is pressurized so kebals can fit more liters in a tank - is it even possible?), then LH2 fills 1/2 of a tank and we can just double that to get the amount in a LH2-only tank. I balanced the tank weights so that they have the target wet/dry ratios that we discussed yesterday. The only draw back about this setup is that the NFP tanks are underperforming stock tanks of the same size in terms of volume.


// Adds InterstellarFuelSwitch to LFO and LH2 tanks
// 5.5*total LFO


// LF/O tanks
@PART
[*]:HAS[@RESOURCE[LiquidFuel],@RESOURCE[Oxidizer],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels] {



%LF = #$RESOURCE[LiquidFuel]/maxAmount$
%OX = #$RESOURCE[Oxidizer]/maxAmount$

%totalCap = #$RESOURCE[LiquidFuel]/maxAmount$
@totalCap += #$RESOURCE[Oxidizer]/maxAmount$

%mixOX = #$totalCap$
@mixOX /= 2
%mixLH2 = #$mixOX$
@mixLH2 *= 10


%onlyLH2 = #$mixLH2$
@onlyLH2 *= 2

%tempVar = 0
%dryCost = 0

// masses
%mixLH2mass = #$mass$
@mixLH2mass *= 0.9
%onlyLH2mass = #$mass$
@onlyLH2mass *= 0.85

MODULE {
name = InterstellarFuelSwitch

resourceGui = LF/OX;LH2/OX;LF;OX;LH2
resourceNames = LiquidFuel,Oxidizer;LqdHydrogen,Oxidizer;LiquidFuel;Oxidizer;LqdHydrogen


resourceAmounts = #$../LF$,$../OX$;$../mixLH2$,$../mixOX$;$../totalCap$;$../totalCap$;$../onlyLH2$


displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


basePartMass = 0
tankMass = #$../mass$;$../mixLH2mass$;$../mass$;$../mass$;$../onlyLH2mass$
}

!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}

}






// Pure LH2 tanks
@PART
[*]:HAS[@RESOURCE[LqdHydrogen],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels] {

%LH2 = #$RESOURCE[LqdHydrogen]/maxAmount$


%mixLH2 = #$LH2$
@mixLH2 /= 2
%mixOX = #$mixLH2$
@mixOX *= 0.1


%OX = #$mixOX$
@OX *= 2


// masses
%LH2mass = #$LH2$
@LH2mass *= 0.000035425 //A Cryo tank is 3.20 times lighter than an equivalent stock tank
%mixLH2mass = #$LH2mass$
@mixLH2mass *= 1.1
%onlyOXmass = #$LH2mass$
@onlyOXmass *= 1.5


MODULE {
name = InterstellarFuelSwitch

resourceGui = LH2;LH2/OX;OX
resourceNames = LqdHydrogen;LqdHydrogen,Oxidizer;Oxidizer


resourceAmounts = #$../LH2$;$../mixLH2$,$../mixOX$;$../OX$


displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


basePartMass = 0
tankMass = #$../LH2mass$;$../mixLH2mass$,$../onlyOXmass$
}

!RESOURCE[LqdHydrogen] {}
}


Both patches have been cleaned up of unused variables and outdated parameters.

Nertea, if you are still following this thread, what are your ideas about all this? We can be sitting here spinning our wheels all weekend long, but ultimately you are the one calling the shots.

Edited by pacbard
Link to comment
Share on other sites

Agree to agree! WOW! I'm getting carried away. Fraz86, do you github?

Yes I do!

With all these code snippets flying around I don't know what we are talking about anymore.

I agree, and at some point we should try to work from a common config. However, (no offense) I prefer the config that I developed, as I think it exposes the important variables in a user-friendly manner, stays close to Nertea's original vision, and it already implements a logical algorithm for calculating dry mass (i.e., based directly on the contents of the tank instead of arbitrary multipliers). Please, take a careful look the config:


@PART[*]:HAS[@RESOURCE[LiquidFuel],@RESOURCE[Oxidizer],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels]
{
%LF = #$RESOURCE[LiquidFuel]/maxAmount$
%OX = #$RESOURCE[Oxidizer]/maxAmount$

%totalCap = #$RESOURCE[LiquidFuel]/maxAmount$
@totalCap += #$RESOURCE[Oxidizer]/maxAmount$

%LH2FudgeFactor = 1.5 // <- EDIT HERE (effectively multiplies LH2 density by this number)
%mixOXProportion = 0.45 // <- EDIT HERE (proportion of tank volume containing OX; this value should be set approximately = 5.5 / [5.5 + [10 / LH2FudgeFactor]])
%massPerUnitLH2 = 0.000035 // <- EDIT HERE (dry mass per unit LH2 capacity)

%onlyLH2 = #$totalCap$
@onlyLH2 *= 5.5
@onlyLH2 *= #$LH2FudgeFactor$

%mixOX = #$totalCap$
@mixOX *= #$mixOXProportion$
%mixLH2 = #$mixOX$
@mixLH2 *= 10

%tempVar = 0
%dryCost = 0

@dryCost = #$cost$

%LFCost = 0
%OXCost = 0
%LH2Cost = 0
%mixLH2Cost = 0
%mixLFCost = 0

// compute cost of stock tank fuel
@tempVar = #$RESOURCE[LiquidFuel]/maxAmount$
@tempVar *= 0.8
@mixLFCost += #$tempVar$

@tempVar = #$RESOURCE[Oxidizer]/maxAmount$
@tempVar *= 0.18
@mixLFCost += #$tempVar$

@dryCost -= #$mixLFCost$
@cost -= #$mixLFCost$

// Cost LF only
@tempVar = #$totalCap$
@tempVar *= 0.8
@LFCost += #$tempVar$

// Cost OX only
@tempVar = #$totalCap$
@tempVar *= 0.18
@OXCost += #$tempVar$

// Cost LH2 only
@tempVar = #$onlyLH2$
@tempVar *= 0.03675
@LH2Cost += #$tempVar$

// Cost mix
@tempVar = #$mixLH2$
@tempVar *= 0.03675
@mixLH2Cost += #$tempVar$

@tempVar = #$mixOX$
@tempVar *= 0.18
@mixLH2Cost += #$tempVar$

// masses
%massOffset = #$mass$
@tempVar = #$totalCap$
@tempVar *= 0.000625 // standard dry mass per units of LF/OX
@massOffset -= #$tempVar$ // this value accounts for any non-standard fuel tank mass, which should remain constant across fuel configurations, e.g., extra mass for spaceplane tanks

%mixLH2mass = #$mixOX$
@mixLH2mass *= 0.000625

@tempVar = #$mixLH2$
@tempVar *= #$massPerUnitLH2$
@mixLH2mass += #$tempVar$
@mixLH2mass += #$massOffset$

%onlyLH2mass = #$onlyLH2$
@onlyLH2mass *= #$massPerUnitLH2$
@onlyLH2mass += #$massOffset$

@tempVar = 0

MODULE
{
name = InterstellarFuelSwitch

volumeMultiplier = 1
massMultiplier = 1

resourceGui = LF/OX;LH2/OX;LF;OX;LH2
resourceNames = LiquidFuel,Oxidizer;LqdHydrogen,Oxidizer;LiquidFuel;Oxidizer;LqdHydrogen

resourceAmounts = #$../LF$,$../OX$;$../mixLH2$,$../mixOX$;$../totalCap$;$../totalCap$;$../onlyLH2$

//tankCost = #$../mixLFCost$;$../mixLH2Cost$;$../LFCost$;$../OXCost$;$../LH2Cost$
displayCurrentTankCost = true

hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true

basePartMass = 0
tankMass = #$../mass$;$../mixLH2mass$;$../mass$;$../mass$;$../onlyLH2mass$
}

!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
}

// Pure LH2 tanks
@PART[*]:HAS[@RESOURCE[LqdHydrogen],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels]
{
%LH2 = #$RESOURCE[LqdHydrogen]/maxAmount$

%cryoFudgeFactor = 1.2 // <- EDIT HERE (this is a global increase in cryo tank volume to bring them in line with stock; ultimately, once desired volumes are decided on, the LH2 amount in the part config should be adjusted accordingly, rendering this variable unnecessary)
%LH2FudgeFactor = 1.5 // (this should match LH2FudgeFactor for stock tanks above)
%mixOXProportion = 0.45 // (this should match mixOXProportion for stock tanks above)

%massPerUnitLH2 = 0.000025 // <- EDIT HERE (dry mass per unit LH2 capacity; this should be < massPerUnitLH2 for stock tanks)
%massPerUnitOX = 0.0005 // <- EDIT HERE (dry mass per unit OX capacity; this should be < the standard stock value of 0.000625)

@LH2 *= #$cryoFudgeFactor$

%OX = #$LH2$
@OX /= #$LH2FudgeFactor$
@OX /= 5.5

%mixOX = #$OX$
@mixOX *= #$mixOXProportion$
%mixLH2 = #$mixOX$
@mixLH2 *= 10

// masses
%massOffset = #$mass$
%tempVar = #$LH2$
@tempVar *= 0.0000439766 // current standard mass per unit LH2 in part configs; needs to be adjusted if part configs are changed
@massOffset -= #$tempVar$ // this value accounts for any non-standard fuel tank mass, which should remain constant across fuel configurations, e.g., extra mass for spaceplane tanks

%onlyLH2mass = #$LH2$
@onlyLH2mass *= #$massPerUnitLH2$
@onlyLH2mass += #$massOffset$

%mixLH2mass = #$mixOX$
@mixLH2mass *= #$massPerUnitOX$

%tempVar = #$mixLH2$
@tempVar *= #$massPerUnitLH2$
@mixLH2mass += #$tempVar$
@mixLH2mass += #$massOffset$

%onlyOXmass = #$OX$
@onlyOXmass *= #$massPerUnitOX$
@onlyOXmass += #$massOffset$

@tempVar = 0

MODULE
{
name = InterstellarFuelSwitch

volumeMultiplier = 1
massMultiplier = 1

resourceGui = LH2;LH2/OX;OX
resourceNames = LqdHydrogen;LqdHydrogen,Oxidizer;Oxidizer

resourceAmounts = #$../LH2$;$../mixLH2$,$../mixOX$;$../OX$

displayCurrentTankCost = true

hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true

basePartMass = 0
tankMass = #$../onlyLH2mass$;$../mixLH2mass$;$../onlyOXmass$
}

!RESOURCE[LqdHydrogen] {}
}
// LF/O tanks

BTW, if we decide to keep the volume constant across tank setups, I am against adding a fudge factor to buff up a specific tank setting. The problem is that KSP engine code does take in consideration the resource density when calculating the resource usage (that's one of the issues with NTR converted to LH2 and the reason why the NFP patch buffs ISPs). So, if we include a fudge factor, we will just increase the volume without increasing/decreasing the engine consumption - resulting in magic volume being added to the tank.

My config already accounts for these considerations. The LH2FudgeFactor variable effectively sets 1 unit of LH2 to occupy LH2FudgeFactor-1 liters. Thus, it is magically increasing the density, not tank volume, as long as mixOXProportion is also adjusted appropriately. I believe it is important that we retain the ability to fudge the density of LH2, because otherwise it will require an "un-fun" volume, as Nertea already concluded (leading to his 1.5x fudge factor, which I have maintained in my config, but could be easily adjusted up or down).

The only draw back about this setup is that the NFP tanks are underperforming stock tanks of the same size in terms of volume.

This can be addressed simply by tweaking the variables that I have exposed in my config (see "EDIT HERE" comments) until we have achieved the desired balance.

Nertea, if you are still following this thread, what are your ideas about all this? We can be sitting here spinning our wheels all weekend long, but ultimately you are the one calling the shots.

I agree. We really need Nertea to provide further direction, as his opinion is the one that matters.

EDIT:

I updated the above config with new calculations that identify non-standard variations of fuel tank mass (e.g., extra mass for spaceplane tanks or service modules, or decreased mass for supersized LH2 tanks), and keep this mass offset constant across fuel configurations.

Also, here's an XL file that will allow you to play with the variables:

https://www.dropbox.com/s/cjs6ju2xwsl648p/Fuel%20switching.xlsx?dl=0

Edited by Fraz86
Link to comment
Share on other sites

I agree, and at some point we should try to work from a common config. However, (no offense) I prefer the config that I developed, as I think it exposes the important variables in a user-friendly manner, stays close to Nertea's original vision, and it already implements a logical algorithm for calculating dry mass (i.e., based directly on the contents of the tank instead of arbitrary multipliers).

No offense taken. It has been real fun digging into KSP's fuel logic and getting to know it better. I really like your idea of calculating the weight of the tank on the amount of fuel that it holds.

My config already accounts for these considerations. The LH2FudgeFactor variable effectively sets 1 unit of LH2 to occupy LH2FudgeFactor-1 liters, accomplishing basically the same thing as if you went into the CRP resource config and multiplied the density of LqdHydrogen by the specified number. Thus, it is magically increasing the density, not tank volume, as long as mixOXProportion is also adjusted appropriately. I believe it is important that we retain the ability to fudge the density of LH2, because otherwise it will require an "un-fun" volume, as Nertea already concluded (leading to his 1.5x fudge factor, which I have maintained in my config, but could be easily adjusted up or down).

I really don't want to rain on your parade, but your fudge factor is just multiplying the volume. KSP actually uses the density from the CRP file to calculate the fuel consumption per second. If you don't change the density of the fuel in the config file, the fuel consumption does not change (fun fact, if you increase the density of the fuel, fuel consumption will actually go down!). So if you put more fuel in a tank and you keep the consumption the same (because the actual fuel density stays the same), the result is to just increase the volume of the tank.

For example, the Volcano engine has an ISP of 410 sec and a thrust of 275 N. You can use the ISP formula to calculate the fuel rate in L/s (another fun fact! KSP uses L/s instead of fuel units per second with these calculations) using fuel rate = Thrust / (Average density of propellant * g * ISP) with the data for the volcano, you will get:

Fuel rate = 275 / ((1*0.005+10*0.00007085) * 9.81 * 410) = 11.97 fuel units of oxidizer and 119.7 fuel units of liquid hydrogen (which is close enough to what you get from the game - 11.981 ox/sec and 119.81 LH/sec - I think that the game uses a longer number for g). If you go and multiply the density of LqdHydrogen in the CRP file (I think I did the test with 1.5 times), you will get something like 11.27 L/sec of oxidizer and 112.7 L/sec for liquid hydrogen (again, for some reason KSP calls fuel units liters). Changing the density of the propellant has long reaching effects on the game. I think that this is the reason why Nertea does not want to touch the density of the propellant. It will throw off the balance of the whole pack (especially ISP and thrust).

I agree with you about trying to keep the game fun. My vote is for a fudge factor of 2 and an OX ratio of 0.50. This way, you can stack two LH+OX mixed tanks or one LH and one OX and get the same result. Easy, fun, intuitive, completely unscientific. In short, totally kerbal.

Link to comment
Share on other sites

I really don't want to rain on your parade, but your fudge factor is just multiplying the volume. KSP actually uses the density from the CRP file to calculate the fuel consumption per second. If you don't change the density of the fuel in the config file, the fuel consumption does not change (fun fact, if you increase the density of the fuel, fuel consumption will actually go down!). So if you put more fuel in a tank and you keep the consumption the same (because the actual fuel density stays the same), the result is to just increase the volume of the tank.

For example, the Volcano engine has an ISP of 410 sec and a thrust of 275 N. You can use the ISP formula to calculate the fuel rate in L/s (another fun fact! KSP uses L/s instead of fuel units per second with these calculations) using fuel rate = Thrust / (Average density of propellant * g * ISP) with the data for the volcano, you will get:

Fuel rate = 275 / ((1*0.005+10*0.00007085) * 9.81 * 410) = 11.97 fuel units of oxidizer and 119.7 fuel units of liquid hydrogen (which is close enough to what you get from the game - 11.981 ox/sec and 119.81 LH/sec - I think that the game uses a longer number for g). If you go and multiply the density of LqdHydrogen in the CRP file (I think I did the test with 1.5 times), you will get something like 11.27 L/sec of oxidizer and 112.7 L/sec for liquid hydrogen (again, for some reason KSP calls fuel units liters). Changing the density of the propellant has long reaching effects on the game. I think that this is the reason why Nertea does not want to touch the density of the propellant. It will throw off the balance of the whole pack (especially ISP and thrust).

You're right, I misspoke. What I'm doing with LH2FudgeFactor is not exactly the same as changing the density in the CRP resource config. As you said, changing the CRP config would alter the propellant mass ratio of LH2/OX engines. My config leaves the propellant mass ratio unchanged, while modifying the density of LH2 within fuel tanks.

This is analogous to Nertea's premise that Oxidizer has an "per liter density" of 0.90909 kg/L (i.e., 5 kg/u / 5.5 L/u), while it has a "per unit density" of 5 kg/unit. My config sets the "per liter density" of LH2 to [LH2FudgeFactor * 0.07085000] kg/L, while its "per unit density" remains 0.07085000 kg/unit. Tank volumes rely on "per liter density", while propellant mass ratios are determined based on "per unit density".

I agree with you about trying to keep the game fun. My vote is for a fudge factor of 2 and an OX ratio of 0.50. This way, you can stack two LH+OX mixed tanks or one LH and one OX and get the same result. Easy, fun, intuitive, completely unscientific. In short, totally kerbal.

If you'd like to try this out using my config, the LH2FudgeFactor should be set to 1.81818 (i.e., 10/5.5). The mixOXProportion should accordingly be set at 0.5. The cryoFudgeFactor should probably also be increased to around 1.5 due to balance against the increase in LH2 capacity of the stock tanks with such a high LH2FudgeFactor. These changes would likely result in cryo engines becoming over-powered, but perhaps it could be balanced out somehow. I'm not convinced this is the best option, but I think it's at least worth considering!

Edited by Fraz86
Link to comment
Share on other sites

I was away the weekend, will catch up tomorrow.

TL;DR: We found out that using the correct volumetric proportions to fill a tank makes no sense. Stock tanks don't make sense, so we cannot just convert them to liters and call it a day.

We calculated some wet/dry fractions that we think are balanced with real world rockets once you consider the stock world resize (it works out that the wet/dry fractions should be about 1/3 of real world ones). Check out the neat tables for more info.

Last, we are throwing around different configs for the tanks:

My idea is to keep the same tank setup for stock tanks converted to LH2, which always works out to have 1/2 of its volume in oxidizer. From there, we can just double the amount of LH2 in a mix tank to find out the volume for a LH2-only tank. I did some balancing for tank weights so the total delta v for cryo engines stays the about the same for stock tanks (the patch is 6% better in terms of dry/wet ratio, but once you consider payload the effects are negligible). NFT are 1/4 of the weight for LH2 and 1/2 of the weight for OX. This helps a lot with nuclear rockets (~50% boost in performance before payload).


// Adds InterstellarFuelSwitch to LFO and LH2 tanks
// 5.5*total LFO


// LF/O tanks
@PART
[*]:HAS[@RESOURCE[LiquidFuel],@RESOURCE[Oxidizer],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels] {

// Factors
%mixOXProportion = 0.5 // Percent of OX in a mix tank
%LH2tankDensity = 0.000043750 // 0.5 of the density of LH2
%OXtankDensity = 0.000625 // Same as stock

%mixLH2Proportion = 1
@mixLH2Proportion -= #$mixOXProportion$


%LF = #$RESOURCE[LiquidFuel]/maxAmount$
%OX = #$RESOURCE[Oxidizer]/maxAmount$

%totalCap = #$RESOURCE[LiquidFuel]/maxAmount$
@totalCap += #$RESOURCE[Oxidizer]/maxAmount$


%mixOX = #$totalCap$
@mixOX *= #$%mixOXProportion$
%mixLH2 = #$mixOX$
@mixLH2 *= 10


%onlyLH2 = #$mixLH2$
@onlyLH2 /= #$mixLH2Proportion$

// masses
// find mass modifier for special tanks
%massModifier = #$mass$
%tempVar = #$totalCap$
@tempVar *= 0.000625
@massModifier -= #$tempVar$


%onlyLH2mass = #$onlyLH2$
@onlyLH2mass *= #$LH2tankDensity$
@onlyLH2mass += #$massModifier$


%mixOXmass = #$mixOX$
@mixOXmass *= #$OXtankDensity$
%mixLH2mass = #$mixLH2$
@mixLH2mass *= #$LH2tankDensity$
@mixLH2mass += #$mixOXmass$
@mixLH2mass += #$massModifier$

MODULE {
name = InterstellarFuelSwitch

resourceGui = LF/OX;LH2/OX;LF;OX;LH2
resourceNames = LiquidFuel,Oxidizer;LqdHydrogen,Oxidizer;LiquidFuel;Oxidizer;LqdHydrogen


resourceAmounts = #$../LF$,$../OX$;$../mixLH2$,$../mixOX$;$../totalCap$;$../totalCap$;$../onlyLH2$


displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


basePartMass = 0
tankMass = #$../mass$;$../mixLH2mass$;$../mass$;$../mass$;$../onlyLH2mass$
}

!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}

}






// Pure LH2 tanks
@PART
[*]:HAS[@RESOURCE[LqdHydrogen],!MODULE[InterstellarFuelSwitch],!MODULE[ModuleEnginesFX],!MODULE[ModuleEngines],!MODULE[FSfuelSwitch]]:NEEDS[!modularFuelTanks]:NEEDS[!RealFuels] {

// Factors
%TankRescale = 1.35 // Volume rescale to match stock
%mixOXProportion = 0.5 // Percent of OX in a mix tank
%LH2tankDensity = 0.0000109375 // 0.25 of a stock tank
%OXtankDensity = 0.0003125 // 0.5 of a stock tank


%mixLH2Proportion = 1
@mixLH2Proportion -= #$mixOXProportion$


%LH2 = #$RESOURCE[LqdHydrogen]/maxAmount$
@LH2 *= #$TankRescale$


%mixLH2 = #$LH2$
@mixLH2 *= #$mixLH2Proportion$
%mixOX = #$mixLH2$
@mixOX /= 10


%OX = #$mixOX$
@OX /= #$mixOXProportion$


// masses
%LH2mass = #$LH2$
@LH2mass *= #$LH2tankDensity$

%onlyOXmass = #$OX$
@onlyOXmass *= #$OXtankDensity$

%mixOXmass = #$mixOX$
@mixOXmass *= #$OXtankDensity$
%mixLH2mass = #$mixLH2$
@mixLH2mass *= #$LH2tankDensity$
@mixLH2mass += #$mixOXmass$


MODULE {
name = InterstellarFuelSwitch

resourceGui = LH2;LH2/OX;OX
resourceNames = LqdHydrogen;LqdHydrogen,Oxidizer;Oxidizer


resourceAmounts = #$../LH2$;$../mixLH2$,$../mixOX$;$../OX$


displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


basePartMass = 0
tankMass = #$../LH2mass$;$../mixLH2mass$;$../onlyOXmass$
}

!RESOURCE[LqdHydrogen] {}
}


Fraz86 instead is trying to do something different. He is working on keeping a correct ratio between the oxidizer and LH2 in the tank setup. I think that he settled for 45% OX and 55% LH2. From there, he calculates the dry mass for the tanks. He also found out a way to keep the stock's additional weights the same while switching fuels (for example the weight increase for fuselage tanks) . You can find his patch here.

EDIT:

I updated the above config with new calculations that account for the extra mass of non-standard fuel tanks (e.g., spaceplane tanks or service modules), keeping the extra mass constant across configurations.

Also, here's an XL file that will allow you to play with the variables:

https://www.dropbox.com/s/cjs6ju2xwsl648p/Fuel%20switching.xlsx?dl=0

I love the additions! BTW, I finally went around reading your code. You did an awesome job with it. Take a look at the patch above. I basically ripped off some of your ideas and I think that I was able to find a way to get rid of the volume fudge factor for LH2. The idea is that when you pick the OX fraction, you are already settling on a density/pressure that LH2 will have in a mixed tank. From there, this is what I thought:

In a mixed tank, the LH2 will have some density/pressure because it is still occupying the same volume as the original tank. Now, we can just convert the OX fraction to LH2 using that same density/pressure that we used to convert 55% of the tank to LH2 for the LH2-only tank.

It works out like this:

OX_Liters = OX_volume * 2 * 10 (Double the volume of OX and use the special density/pressure factor that we used to find the LH2 liters in a mixed tank)

LH2_Liters = OX_Liters * fraction + LH2_Liters_mixed (Rescale the total liters of OX to 45% of the tank)

I'm not sure the reason why doublinging the volume of OX works. I think it has to do with finding how far away you are from 0.5 of a tank or something.

A numerical example for a FL-800 tank works out like this:

45%-55% mix -> 360 OX - 3600 LH2

100% LH2 -> (360 * 20 * 0.45) + 3600 = 6840 LH2 (Effective fudge factor of ~1.55)

Edit:

The *2 factor really does not make sense but it works out nicely. If we want to keep the LH2 density constant between tank setups we have to do something like this:

LH2_only = LH2_mix / (1 - OXProportion)

Beware that using that will make the LH2-only tanks very underpowered, at the expense of nuclear rockets. I would rather use a 50-50 composition and live with having a lot of LH2 in a LH2-only tank.

Edit 2: I updated my script with the new proportional calculations for LH2-only and OX-only tanks. Let me know what you guys think about is.

Edited by pacbard
Link to comment
Share on other sites

Those are not 11 equal parts, since 1 of them is actually 5.5 liters.

Where cones the logic come from that LF has a density of 5.5? My sources say it should be 5, not 5.5. Where does the extra 10% come from?

My proof: a 3200 Unit fueltank filled with LiquidFuel has a Liquid mass of 16 ton, now the same tank with (3200x5=) 160000L of Water has the same liquid mass of 16ton!! If the value was 5.5, the tank of water would have weighted 17.6 ton.

Edited by FreeThinker
Link to comment
Share on other sites

TL;DR: We found out that using the correct volumetric proportions to fill a tank makes no sense.

I don't think it's accurate to present this statement as a summary/consensus of the thread. My config is based on volumetric proportions, and I believe it works well and makes good sense. Yes, I fudge the LH2 density, as Nertea was already doing, but I don't think this ruins the concept of volume-based tank capacities.

I love the additions! BTW, I finally went around reading your code. You did an awesome job with it. Take a look at the patch above. I basically ripped off some of your ideas and I think that I was able to find a way to get rid of the volume fudge factor for LH2. The idea is that when you pick the OX fraction, you are already settling on a density/pressure that LH2 will have in a mixed tank.

It's true that LH2FudgeFactor and mixOXProportion are basically redundant variables, and it's possible to derive either one from the other (and I give instructions to do so in the comments of my config), so it's not strictly necessary to have them defined separately. The reason I define them separately is so the numbers can be rounded off (i.e., mixOXProportion of 0.45 instead of 0.4520548), in hopes that we can eventually arrive at nice round capacity numbers. For instance, this is possible with a LH2FudgeFactor of 1.5, a mixOXProportion of 0.45, and a cryoFudgeFactor of 1.1578947368421. If you plug those numbers into my XL file, you'll end up with aesthetically pleasing LH2 and OX amounts for all configurations.

Where cones the logic come from that LF has a density of 5.5? My sources say it should be 5, not 5.5. Where does the extra 10% come from?

My proof: a 3200 Unit fueltank filled with LiquidFuel has a Liquid mass of 16 ton, now the same tank with (3200x5=) 160000L of Water has the same liquid mass of 16ton!! If the value was 5.5, the tank of water would have weighted 17.6 ton.

It's 5.5 L/unit, which is actually less dense than 5 L/unit. This assumption comes from Nertea's OP, which states: "Here are some very basic constants that there is no room to change under this paradigm: Liquid Fuel is 0.005 t/u and is 5.5 litres per unit". As to how he arrived at this number, I'm not sure.

Edited by Fraz86
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...