Jump to content

[SOLVED] KSP Thermodynamics 101


Recommended Posts

Hi all,

During the course of my modding adventures, I have found a need to create a custom heat shield module for use specifically to be integrated into other existing parts (such as command modules).

I have it functioning reasonably well though a bit of trial/error/process of deduction regarding how the stock shield seems to function.  However, I would like to improve its functionality to eliminate some of the quirks the stock mechanics have, such as the part skin temperature still hitting insane levels when the heat-shield is in-fact the part with the high temps (as such the entire parts starts to glow with the thermal-overheat-emissive).  (E.G the stock heat-shield does not start ablating much until ~1500k, at which point the overheat-glow is already triggered; unacceptable for an entire command pod to appear to be 'overheating' when the heat shield is in fact functioning properly and keeping things from exploding/overheating).

The main question I'm having is:  What does one unit of flux represent?  While interfacing with the API/methods, it has it listed as KiloWatts.  Okay, I know what a KW is (assuming 1 flux == 1 KW).  But it seems there is missing something from the equation.  One KW does not equal one degree for every part (logically anyhow, higher-mass parts should take more energy input to heat up).  Background:  I know little about thermodynamics, it is not anything that I have studied nor have any particular knowledge base regarding it.

If one 'thermal flux' unit = 1 KW of thermal energy -- It seems that I need to know how much one KW of energy will increase the temperature of a part, which I believe will be different based upon mass (and in real life, material composition/specific heat capacity).  Also, how does KSP treat the 'specific heat capacity' of different materials?  Is this simulated at all? (e.g. concrete, steel, and insulation foam all have different thermal absorption/storage properties for the same mass).


Thanks in advance for any answers and information, is much appreciated :)


Updated with proper information:

Thermal equations:

To change part temperature X degrees (instantly):

  • flux = X * part.thermalMass * (1 / TimeWarp.FixedDeltaTime)

degrees kelvin temp increase = (flux input / part.thermalMass) / ?? (there is a time factor involved that I have not figured out yet)

flux stored in a part = part temperature * part.thermalMass * ?? (there is a time factor involved that I have not figured out yet)

one degree kelvin increase requires (part.thermalMass) flux input for (?? time factor, ignoring part conduction/convection/radiation that happens during that time).

 

 

Edit/Update:

One thing I still have not been able to figure out -- how to disable the part glow effect? (not the aero-thermal effects, nor the debug-thermal glow effects, but the standard glow effect?)

I've got the heat shield functioning effectively; but the entire command pod starts to glow whenever skin temp > 800 (not sure of the threshold, first noticeable around there).  (and if I try to clamp the skin temp at ~600, the incoming flux to keep the temp there is insane; the simulated heat-shield ends up with ~10x the heat intake that it -should- have, due to improper simulation of the skin->ambient delta and how it attempts to equalize them)

Apparently this is the black-body radiation glow, as messing with the blackbody min temp in Physics.cfg will make it go away / change the start point.  Any known way to disable this feature for a specific part?

And a bit more investigation has revealed that this function is hardcoded somewhere within the part.Update() function(s), using what must be private methods and members (as there is nothing visible to interact with).

Is my only option to change the BlackBodyRadiationMin value?  And will this have any non-visual side effects?  (that glow is purely annoying to me, and I have no problem removing it entirely from my games, as long as it doesn't mess with anything else).

 

 

Edited by Shadowmage
Link to comment
Share on other sites

The thing you appear to be missing is part.thermalMass and part.skinThermalMass. Those two values are equivalent to the number of kilowatts required to increase the respective temperatures by one degree before any other effects are considered (eg. conduction to other parts)

Link to comment
Share on other sites

Sweet, I was wondering what those values were, because they certainly weren't representative of the parts physical mass :).

I'm guessing the 'thermal mass' is pretty much just (mass * specific heat for material) as a precomputed value?

Any idea how those values are calculated from the mass of a part?  (e.g. I am wanting to simulate a heatshield integrated onto the part, so I will need to know how much to adjust the parts base thermal mass by, and how much thermal mass the heat-shield should have).

Link to comment
Share on other sites

10 minutes ago, Shadowmage said:

I'm guessing the 'thermal mass' is pretty much just (mass * specific heat for material) as a precomputed value?

Correct.

From what I remember, thermal mass is calculated using (I can't remember how skinMass is calculated at this time)

thermalMass = (part.mass - <skinMass>) * part.thermalMassModifier

 

Edited by Crzyrndm
Link to comment
Share on other sites

23 minutes ago, Crzyrndm said:

The thing you appear to be missing is part.thermalMass and part.skinThermalMass. Those two values are equivalent to the number of kilowatts required to increase the respective temperatures by one degree before any other effects are considered (eg. conduction to other parts)

Very close :P

They are the number of kilojoules required to raise the temperature one degree. One kilowatt is one kilojoule per second. I screw them up too, sometimes ...  kW is power and kJ is energy. Or, think of kW as the rate at which energy is being moved. 

As for thermal mass, the default specific heat is 800 so it's part.mass * PhysicsGlobals.standardSpecificHeatCapacity * part.thermalMassModifier (use this if you want to change the part's thermal mass)

Skin also has its own thermal mass (as already mentioned) and is calculated in a similar fashion but uses part.skinThermalMassModifier

If you're dealing only in the configs then take a look at how I use skinThermalMassModifier in Deadly Reentry 

https://github.com/Starwaster/DeadlyReentry/blob/master/DeadlyReentry/SPP.cfg#L6-L9

(intention of those lines is to give space plane parts the skin thermal properties of space shuttle tiles. Very low thermal mass and skin-internal conduction, very high emissivity)

Edit: Yes, skin thermal mass is subtracted from base thermal mass; forgot about that, sorry

Edited by Starwaster
Link to comment
Share on other sites

3 minutes ago, Shadowmage said:

Very nice info :)

Next on my 'todo' list was to find a way to properly simulate non-ablative heat shielding and/or thermal-soak type methods of dealing with skin and re-entry heating.

 

That's what those lines which I referenced do; non ablative shielding but of the tile variety. They have very low thermal mass so they heat up very quickly. They also shed heat very quickly for the same reason. A few lines up is emissiveConstant which needs to be very high. (0.85-0.9)

It works best with shallow reentries. Steeper reentry will probably overcome it; if you want something that can survive steeper reentries then the thermal mass would need increasing.

 

Link to comment
Share on other sites

Skin thermal mass is always calculated first. It's

tmMult = PhysicsGlobals.StandardSpecificHeatCapacity * part.thermalMassModifier;
skin thermal mass = Max(0.1, Math.Min(0.001 * part.skinMassPerArea * part.skinThermalMassModifier * part.radiativeArea * tmMult, part.mass * tmMult * 0.5d));
 

Next, calculate part thermal mass:

part.thermalMass = Max(0.1, ((part.mass * PhysicsGlobals.StandardSpecificHeatCapacity * part.thermalMassModifier) + part.resourceThermalMass) - skinThermalMass)

 

Note that that means that skinMassPerArea is in kg/m^2, and it, like the modifiers, defaults to 1.

 

@Shadowmage you definitely only want to be dealing with fluxes, not temperatures. Also, while the glow is applied based on skin temperature, the game's code already *does* deal with a split between the exposed skin area (the blunt heatshieldy area) and the unexposed area (the rest of the capsule). The exposed area is tracked based on the cross-sectional area exposed to the wind (i.e. minus any occlusion) and has its own temperature and fraction of the total skin thermal mass, with the unexposed skin area having the remainder of the thermal mass and area. Once you leave atmosphere (or hit zero velocity, i.e. no wind to check cross section against) the skins are 'unified'.

Link to comment
Share on other sites

Thanks for the detailed info, should give me all I need to fix and finish the plugin (and anything else heat related I might want to play with :) ).

Some of what I was noticing was likely an artifact of my current heat shield code; with the information you guys have presented I'm pretty sure I can get it all sorted out now.

Link to comment
Share on other sites

One thing I still have not been able to figure out -- how to disable the part glow effect? (not the aero-thermal effects, nor the debug-thermal glow effects, but the standard glow effect?)

I've got the heat shield functioning effectively; but the entire command pod starts to glow whenever skin temp > 800 (not sure of the threshold, first noticeable around there).

 

Edit:  Apparently this is the black-body radiation glow, as messing with the blackbody min temp in Physics.cfg will make it go away / change the start point.  Any known way to disable this feature for a specific part?

Edited by Shadowmage
Link to comment
Share on other sites

Semi-solved/hacked around...

        public void LateUpdate()
        {
            if (HighLogic.LoadedSceneIsFlight)
            {
                mcu.Update(Color.black);
            }
        }

mcu being a MaterialColorUpdater that is initialized during OnStart.  Basically, the stock part-based code runs during the Update tick, and I come along during LateUpdate and force the glow back to 'black' (no glow).

Now to re-enable the glow when appropriate; should be simple now that I've figured out how to turn it off/overwrite it.

Yep, its a giant hack and potentially (slightly) detrimental to performance, but I could not locate any other way to do this for just a single part.

Link to comment
Share on other sites

8 hours ago, NathanKell said:

Yeah, I made the temp gauge edge highlighting tunable per part but not that, sorry.

No worries, it is perfectly understandable.  There is no reason for stock parts to need to alter that functionality.  I have found a reasonable workaround for my purposes.

Thanks again for the help with the math/info though, could not have done the rest of the module without it :)

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