post-kerbin-mining-corporation / SystemHeat

Adds an improved thermal mechanics experience to Kerbal Space Program.
16 stars 18 forks source link

Simulated heat transfers to live vessel #123

Closed drheat closed 1 week ago

drheat commented 2 weeks ago

In VAB I create a ship that has enough radiators and a nuclear generator, with radiators extended the heat loop is fine and balanced. Now I pack the radiators and save it, still in VAB.

Problem appears to be the heat loop simulation keeps going while in VAB even if the visualizer window is closed and it saves the ship with whatever temperature the reactor simulation reached at the time of the save. When that ship is deployed to be launched say through the Hangar mod, the reactor temperature isn't set to 0 but instead to whatever was saved in the VAB, resulting in an instant meltdown.

Notice the currentLoopTemperature in the saved vessel file:


    {
        name = ModuleSystemHeat
        isEnabled = True
        totalSystemTemperature = 750
        totalSystemFlux = 50
        currentLoopID = 0
        currentLoopTemperature = 115407.781
        nominalLoopTemperature = 750
        currentLoopFlux = 50
        stagingEnabled = True
        EVENTS
        {
        }
        ACTIONS
        {
        }
        UPGRADESAPPLIED
        {
        }
    }
ChrisAdderley commented 2 weeks ago

I can't reproduce this, you'll need to provide more info.

Here is what I tested

  1. Create a ship with a fission reactor, enough radiators and retract them: image
  2. Let the sim run a bit to get the temperature to very large numbers in the VAB
  3. Launch to pad and see what happens: image

Reading into your post, I would guess this is a specific interaction with the Hangar mod not correctly using the same pathways to launch as the way a vessel 'should' be launched (e.g. from VAB, SPH, etc). Can you confirm that in your case whether this replicates when you launch a vessel in the normal way? If so I will need logs, etc. If not, it's a specific issue with Hangar that will need to be looked into to support that mod's way of launching vessels.

drheat commented 2 weeks ago

Chris, thank you for looking into this! Vehicles work fine while on the launchpad from VAB and SPH, that was never an issue.

The issue I found is that super high temperature from simulation is written into the vessel file as the actual part temperature and that is not correct. The part temperature should be 0 in the file.

Any mod that uses vessel schematics to spawn things isn't going to be aware of the fact that temperature isn't something that should be set when spawning it in.

Where I'm coming from is that any mod be it SystemHeat or any other mod shouldn't write extra parameters in the vessel file that aren't needed when spawning in the vessel.

ChrisAdderley commented 2 weeks ago

Well, just an oversight related to how KSP stores persistence data. There isn't a real distinction between an in-flight variable and an VAB variable for vessels - they'll be written to the save file or the vssel file regardless.

I can clear this up which will fix this aspect of things, but I do need to look into how the vessel is spawned in Hangar. The reason is that there's other stuff in this mod that runs in an event that fires when a vessel is 'rolled out', which, among other things cleans up any simulation detritus and sets the initial conditions for a brand new vessel. Evidently Hangar doesn't fire that event when it launches a vessel, so those initial conditions may not be set which will need more handling.

drheat commented 2 weeks ago

Thank you! You're the best!

If you'd like I can also look if Extraplanetary Launchpads / SimpleConstruction is having any issues with SystemHeat as I have both in this playthrough.

ChrisAdderley commented 2 weeks ago

Would be appreciated.

ChrisAdderley commented 2 weeks ago

Also, I have pushed up a blind fix (as in, the value in the saved vessel data is zeroed, but not tested as I don't have Hangar installed) if you would like to grab the dll and test it.

drheat commented 2 weeks ago

I will do both tests tomorrow and let you know. Thank you! <3

drheat commented 2 weeks ago

Yes your fix worked as intended!

Here's the craft in VAB:

Printer_VAB

This is how the save file was showing the main reactor with the previous version of the mod:

MODULE
    {
        name = ModuleSystemHeat
        isEnabled = True
        totalSystemTemperature = 850
        totalSystemFlux = 1250
        currentLoopID = 0
        currentLoopTemperature = 1168237.25
        nominalLoopTemperature = 850
        currentLoopFlux = 1250
        stagingEnabled = True
        EVENTS
        {
        }
        ACTIONS
        {
        }
        UPGRADESAPPLIED
        {
        }
    }

And this is how it looks with your patched version:

MODULE
    {
        name = ModuleSystemHeat
        isEnabled = True
        totalSystemTemperature = 850
        totalSystemFlux = 1250
        currentLoopID = 0
        currentLoopTemperature = 2.70000005
        nominalLoopTemperature = 850
        currentLoopFlux = 1250
        stagingEnabled = True
        EVENTS
        {
        }
        ACTIONS
        {
        }
        UPGRADESAPPLIED
        {
        }
    }
ChrisAdderley commented 1 week ago

Released in 0.8.0