KSP-RO / RealFuels

Modular fuel tanks and engines, with real fuels and realistic performance.
55 stars 66 forks source link

Tank dry mass not properly calculated #343

Open RobertoBiundo opened 6 days ago

RobertoBiundo commented 6 days ago

I have tanken the liberty to check the dry mass calculation of tanks created with procedural tanks and have found that they are not properly calculated. As an example ill start with a WAC corporal "alike" tank (cilindrical)

The height of my tank is 4.8m and width 30.5cm (diameter). This gives in the game a volume of 263L and a dry mass of 102Kg. Ok, fair enough, we will use this as a point of reference.

Lets start checking this. The volume of a cilinder is: V = pi * r^2 * h And the area is A = ( 2 * pi * r^2 ) + ( 2 * pi * r * h ) For the provided parameters above this gives us 350.7L -> With a 75% ( V * 0.75 ) tank utilization this is indeed 263L And the area would be 47454 cm^2 -> 4.74 m^2. (This is the amount of material needed. 4.74m^2 of metal)

So far so good. Now lets create an optimized tank that hauls the same volume but with the minimal possible Area (thus reducing the dry mass both materials being equal).

This means we need to optimize for V and A We now V = pi * r^2 * h and A = ( 2 * pi * r^2 ) + ( 2 * pi * r * h )

form the first formula we get that h = V / ( pi * r^2 )

using this in the formula for area we get A = ( 2 * pi * r^2 ) + ( 2 * V / r )

So far so good. We want now to minimize this formula so we get the derivate of dA/dr dA/dr = ( 4 * pi * r^2 ) - ( 2 * V / r^2 )

Calculating where the derivate is 0 to get the min point ( 4 * pi * r^2 ) - ( 2 * V / r^2 ) = 0 we get r = cubic_sqrt( ( 2 * V ) / ( 4 * pi )

For the value of 350L ( to account for the 75% utilization ) we get that r should be 38.19cm ( diameter of 76.38cm ) and the height should be ( 76.38 cm ) <= AS EXPECTED

Now this also yeild an Area of 27491 cm^2 -> 2.74 m^2 (This is the amount of material needed. 2.74m^2 of metal)

TL;DR

NOW. We have crated a new tank that holds the same but with a lot less material. Granted, the aerodynamics are horrible, but it is lighter. Is it?........well....according to the game, no. both tanks have a dry mas of 102Kg. Actually any tank, on any configuration that you create that hauls 263L will have a dry mass of 102Kg no matter what. Quite unrealistic in my optinion. It would be amazing to not only minimize the formulas above but be able to include aerodynamics in the mix as well. This would allow you to get the best aerodynamic possible for the least weight possible.

The issue seems to plague all other tank types as well (i,e. cone type tanks suffer from the same). And this is a shame. Now, I know i'm being annoying as hell and that there are more pressing bugs. But in a game mode that has principia calculating the impact of all gravity forces on a ship is a shame that the ship itself has a weight that is wrongly calculated.

Would someone please fix this?, or point me in the right direction on the code so that I can fix it. I know nothing about the codebase and don't want to spend the rest of my month going over the whole thing. But I am a decent C# developer and if you point me to the correct part of the src ill pass on a PR your way.

Teykn commented 6 days ago

I think you might be confused? relating mass to volume results in density, with mass equal to density times volume. you optimized for surface area while keeping the volume the same. Mass isnt a function of surface area, so it makes sense the dry mass remains the same even after optimizing for surface area

RobertoBiundo commented 6 days ago

I think you might be confused? relating mass to volume results in density, with mass equal to density times volume. you optimized for surface area while keeping the volume the same. Mass isnt a function of surface area, so it makes sense the dry mass remains the same even after optimizing for surface area

Shouldn't the dry mass be the weight of the tank empty? So basically the weight of the material used to create the tank.

I think you are confusing here the volume the tank can hold (293L) Vs the volume of metal being used. The volume of metal would be The Area of the tank the thickness of the metal And the weight would be The Area of the tank the thickness of the metal * density of the metal

On both of my tank examples the thickness of the metal and the density remains the same on both examples. Therefore making them not important for the optimization and only the area is important a tank with less area would weight less. But that is not the case as showed above. A tank with more area weights the same as a tank with less area in the game at the moment provided that their tank volume is the same.

The weight seems to be calculated as a fraction of the volume of the tank itself and this is clearly wrong. Since in case 1 the tank would weight almost double than in case 2. Dry mass that is.

Nazfib commented 6 days ago

Thing is, the required thickness of tank skin changes when you make a tank larger. Larger diameter tanks need less thickness, smaller diameter tanks need more for the same structural strength.

In practice, this means that the weight of a (real-life) rocket tank is remarkably close to proportional to the volume, and not to the surface area.

RobertoBiundo commented 6 days ago

Great point @Nazfib. A larger tank would require more thickness. However do note that my tank is not that much larger and we would have doubled the thickess at this point (very aggressive). Even spaceX tanks are nearly a few mm thick.

Granted those use a different tech. Which brings more things to this. Ballon tanks for example should scale quite well but the scale the same as the steel ones. (Using the same volume to area principle).

And even if this is true then I would at least put limits to the tank thickness. Imagine in the current scenario a really really tall tank with the same volume. Have the same weight would mean that the thickness of the tank is then almost 0mm -impossible-. If anything this waaay taller tank would require thicker walls than my optimized chunky one.

But granted we would need to include a -structural integrity- ratio in the formula that could be based on tank height and width and have minimum tank thickness just as the aviation B9 parts have minimum metal thickness.

Capkirk123 commented 6 days ago

Yes, structural demands mean that tank mass is fairly proportional with volume, but there is absolutely a surface area effect as well.

I would like to add a surface area factor to procedural tanks, it would definitely he useful, but I unfortunately don't know much about the code itself.

Capkirk123 commented 6 days ago

Transferred to the correct repo. I believe the code in question is here

RobertoBiundo commented 6 days ago

Great. That was quick for not knowing the source code. I can work on this o and propose an improvement. Whish me luck. Time to dig into a physics rabbit hole