KSP Interstellar Extended

KSP Interstellar Extended

1M Downloads

Molten salt reactor multiple issues

xDeerStalker opened this issue · 11 comments

commented

Changes in VAB to the molten salt reactor fuel type are not persistent in saved vehicles and because of that not when launching a new vehicle.

Reproduce: Build a new vehicle, add molten salt reactor, switch fuel type, save the vehicle and reload it.

So you basically cannot launch new molten salt reactors in UF4 mode since the latest release. Existing molten salt reactors are not affected.

Didn´t test if any other reactors are affected or if the fuel type is changable after launch by shutting down, swapping fuel and restarting the reactor.

Update: The bug only happens in career-mode. I currently have 2 of the 3 fuel types unlocked in my career savegame, maybe it´s related to that?

In sandbox, the bug doesn´t exist.
In career mode, the bug doesn´t exist when cheated to max tech.
In career mode, the bug exists in a new savegame with cheating science and buildungs when unlocking the molten salt reactor node with no upgrades.

further tests in the same savegame: (Upgrade 1 bought)

If you select uranium as fuel type, save and reload the vehicle, the fuel type is set to thorium.
however, if you now leave the VAB and come back, it´s set to uranium again.
If you now launch the vehicle after that procedure it´s configured for thorium on the launchpad even if the UI in VAB had shown uranium as fuel type.

Upgrade 2 bought:
same as upgrade 1
Now going deeper, uranium burnup is still missing. Found in reactorfuel config that it´s hidden behind nuclear fuel systems, but there is no indication for that inside the tech-tree. maybe add some upgrade icon thingy if possible?

Got it. The bug only happens if nuclear fuel systems is not yet researched and because of that uranium burnup is missing from the selectable fuel modes. Somehow, the reactor always defaults back to thorium if uranium burnup is not unlocked (it doesn´t matter if you actually want to use that mode).

I have the feeling that the bug may exist for other reactors as well where part of the selectable fuel modes are locked behind tech tree nodes.

TL;DR
Workaround: Unlock the node "nuclear fuel systems" in tech tree

commented

a TL;DR is below for fixing broken savegames

Update 2: existing molten salt reactors are affected by that bug. I guess all molten salt reactors in savegames where nuclear fuel systems was not already researched are now switched to thorium if the vessel was loaded while having the latest version of kspIE running. Maybe even in these games, UF4 MSRs are broken. I cannot confirm that having it researched will "fix" an old reactor when loading a vessel, so just don´t do that for now in your career saves. If you already did it or you have to do it in the near future in your career game, read below. If you didn't, don't do it until this is fixed.

Now we have a bit of a problem because this bug is persistent and on the same time, a lot of things changed codewise.

The bug has a much bigger impact than I initially thought, because it's not just a fuel type that can´t be loaded, but the whole fuel system references around the molten salt reactor have changed (probably?) without care about legacy supporting the old references.

So we have (at least) 2 things simultaniously:

  1. You cannot launch a new Vessel with fuel mode uranium (easy bug to fix i guess. probably just some inconsistency between ui and backend code) and you cannot use existing Uranium configured MSRs anymore because they get switched to Thorium the second you load the vessel. More on that below.

  2. Now the real trickery begins. The old UF4 Mode isn´t even the Uranium mode i`m talking about - it´s the "new" uranium burnup mode which is (invisibly) locked behind the nuclear fuel systems tech node. The Resource configuration also changed and now adds Uranium-233. But that's a minor issue because you don't need that in UF4 mode anyway.

However, the uranium burnup mode is not equal to the old UF4 Mode. Even if it was, that would be really bad because your default starter tech you had before is now locked behind a tech node that you may not have right now. You cannot "go back" to the old config by shutting it down and switching fuel modes because you don't have that fuel mode unlocked yet or even worse - your reactor is alone and 550 AE out in the void. if you have unlocked it and you have backup Generators that still work, you can maybe just switch the fuel type of the reactor (takes some days to cool down, so better get that fuel cells running. You did bring fuel cells to your century travel into the void, right?).

If you don't have the possibility to switch fuelmode in flight or not without letting your kerbals die, you have to edit your savegame(s) by hand (for now). There is a procedure in the TL;DR Section if you need to do that

Here, things start to get complicated and experimental. I tried to get into the code and fix the bug directly there by adding legacy support and an auto-conversion, but it's just too massive for me to understand and i don't even know where i should even start to look.

So i did the "easy" way - savegame editing by monkey patching it to the new version.

#################################################################################################
Consider this snippet from my current career save:

<<Segment 1>> OLD MOLTEN SALT REACTOR UF4 CONFIG
MODULE
{
name = InterstellarMoltenSaltReactor
isEnabled = True
electricPowerPriority = 3
powerPercentage = 10
forcedMinimumThrottle = 0
fuel_mode = 0
fuelmode_index = 0
fuel_mode_name = Uranium
fuel_mode_variant = FissionUF4

IsEnabled = True
IsStarted = True
....
MODULE
{
name = InterstellarFuelSwitch
isEnabled = True
selectedTankSetup = 0
configuredAmounts =
configuredFlowStates =
selectedTankSetupTxt = Lithium-6
configLoaded = True
initialTankSetup = ThermalPower;WasteHeat;Lithium6;UF4;Actinides;XenonGas;Tritium;Helium;ThF4
...

This is from an MSR with the old UF4 config that was not loaded during my testing.

#################################################################################################
Now here is a brand new Reactor from a sandbox game with the exakt same config in terms of "what it does":

<<Segment 2>> NEW MOLTEN SALT REACTOR UF4 CONFIG
MODULE
{
name = InterstellarMoltenSaltReactor
isEnabled = True
electricPowerPriority = 3
powerPercentage = 10
forcedMinimumThrottle = 0
fuel_mode = 1
fuelmode_index = 0
fuel_mode_name = Uranium Burnup
fuel_mode_variant = FissionUraniumBurnup

IsEnabled = True
IsStarted = True

MODULE
{
name = InterstellarFuelSwitch
isEnabled = True
selectedTankSetup = 0
configuredAmounts =
configuredFlowStates =
selectedTankSetupTxt = Lithium-6
configLoaded = True
initialTankSetup = ThermalPower;WasteHeat;Lithium6;UF4;Actinides;XenonGas;Tritium;Helium;Uranium-233;ThF4
....

As you can see, fuel_mode, fuel_mode_name and fuel_mode_variant changed as well as the initialTankSetup in the InterstellarFuelSwitch MODULE.

Let's fix this

#################################################################################################

TL;DR
I tested the following procedure for fixing broken reactors and it worked (for now):

**Edit: This fixes your reactors, but the system itself is still broken. Reactor works like a fresh one with "uranium burnup". But the fresh one doesn't work either, you don't get energy from it (but it's heating quite well, so i guess my kerbals will at least not freeze to death), see the attached image. btw, the exakt same radiator setup let's this run on 6% efficiency by VAB KSPIE helper in the current version and on 42% on the old version.

The image shows a "stable" fresh molten salt reactor stack of 2.5m size after 10 minutes at 100% override without any cooling (because electricity ran out) on the launchpad. Sorry for the german labels, i guess you can find out what it means in your language

Part temperature and heat sink temperature seem to be a bit too low for a nuclear reaction without active cooling
IMSR
**

BUT - This is experimental. It worked for me, but the process was more like "if i stick the screwdriver in the box over there, there will be sparks coming out over here". I didn't even look at the corresponding code.

Trust me, I'm an engineer.

Seriously, backup your save and hold the backup until the fix is live and working with your monkey patched savegame.

Now we can begin:

  1. if at all possible, research nuclear fuel systems asap. I guess in this instance where it´s about life or death of your kerbals ( ;-) ), cheating in career would be a valid solution by "borrowing" the 550 science points from the alt+f12 menu and paying them back later on by reducing your science for 550 points in the same menu.

  2. Save and leave the savegame. Going to main menu is enough, you don't need to reload any mods. The savegame always gets loaded fresh from the disk. Just remember that all earlier quicksaves where the bug already impacted reactors are not usable anymore without reintroducing the bug (while there is no fix out) or they must be changed too. Otherwise, your next autosave after reloading a quicksave will revert all the changes you do in the following steps.

  3. locate your main savegame under KSPInstallDirectory/saves/yourGamesName/persistent.sfs and open the file with notepad++ or your favorite texteditor. You did made that backup i talked about, right?

  4. search for "InterstellarMoltenSaltReactor". If you have active thorium reactors on purpose, scroll down roughly 500 lines check if there is a value is not 0 for the RESOURCE Node that holds TH4. If so, ignore that module and find the next "InterstellarMoltenSaltReactor" else go to 5.

  5. Scroll up this page and change the values from what you see (should look like <<Segment 1>> ) to the values in <<Segment 2>>. The InterstellarFuelSwitch MODULE is located directly below the InterstellarMoltenSaltReactor MODULE, easy to find. If the attributes are in a different order in your savegame, that should not make any difference.

  6. If you found your reactors broken (and that is probably the reason why you are on this page) consider restarting them right inside of the savegame in case there is no kerbal around to press the power switch. (IsEnabled and IsStarted should be True, idk what's the difference, maybe @sswelm can help here )

  7. If you reached the end of the file or in case of notepad++ coming back to the first reactor, save the file and after that alt+tab back into the game and load your savegame. It should be alright (for now)

commented

just tested again: The molten salt stack in uranium burnup mode is producing power, just idk 1/1000 th? of what it should produce. maybe a conversion error newly introduced? it's not producing enough to be self sufficient while powering the radiators, but it's enough to "significantly" slow down the time to blackout from 1s with the attached generator deactivated to 30 seconds when the thermal generator is active. The monkey patched stacks behave the same, so i guess that fix is working but it's not enough to make them usable again

commented

I did a lot more of testing with molten salt reactors in Sandbox and here are the results:

  • None of the fuel modes is working for producing electricity in combination with the thermal generator, not even thorium.
  • All of the fuel modes are producing heat and - by looking at the reactor control window - are working.
  • the thermal generator shows for all fuel modes a maximum electric Power of 0W.
  • Replacing the MSR with a pebble bed reactor in the otherwise exakt same setup works, it's has 25MW maximum electric power and produces. so it's definitly related to molten salt and probably not to all reactors
  • attaching a thermal nozle directly to the MSR results in a bug where it's not detachable anymore and the parts "merge" into one editing wise. ctrl+z and doing it again fixes this and it does not happen again
  • the same happens to other engines as well in combination with other parts, so it's probably not the MSR that's producing this issue
  • despite not producing power, the thermal generator shows an electric efficiency of 80% in the "normal" uranium mode of MSR. That is not possible by the laws of thermodynamics with T_high = 2000k and T_low = 500K
  • The thermal nozzle still works with the MSR so the heat is there, but the generator doesn't produce anything.. interesting
  • Replacing the thermal power generator with an upscaled thermal electric generator also produces no power

Conclusion:
Seems like a bug that only happens between the MSR and the Interstellar MJ Generator Module, since both thermal generators show 0 W maximum electric power in that MODULE, but not when attached to another reactor.

commented

@sswelm

I think i nailed it down to a change on FNPlugin/Powermanagement/FNGenerator.cs in commit 123f9dd

I still don't understand where all the values in this mod are coming from and how it all works together. I found this just interpreting the UI Strings and following the path of vars. Doing that, the marked change made me suspicious:
KSPIE_potential_bug

So, from the screenshot in comment 2, i know that the efficiency in this situation is not 0.0 and by looking at the file mentioned above, we see that the efficiency is saved inside overallEfficiencyStr which is just a toString() of percentOutputPower which by itself is just _totalEfficiency *100 . Long story short: _totalEfficiency is not 0. That's important. because it's directly correlated by a multiplication to the maximumElectricPower which is 0 in the screenshot in comment 2.

So the reason why molten salt reactors don't produce electric energy is because _maxChargedPowerForThermalGenerator MUST be 0. I know, by this point it's just the String of saying 0W, but i'm pretty sure this variable gets used somewhere else too where the power gets generated. But the issue is not in the follow-up code since that one works for pebble bed but not for molten salt.

I followed the code a bit more and found that _maxChargedPowerForThermalGenerator is correlated to rawChargedPower which itself is correlated to _attachedPowerSource.MaximumChargedPower while _attachedPowerSource is defined as an instance of the IFNPowerSource which inherits from IPowerSupply... long story short, it's implemented in the InterstellarReactor class. But it's just "added", not a hard dependency inside the interface that every Powersupply MUST implement.

Here is the Issue: because of that, InterstellarFissionMSRGC.cs doesn't have a MaximumChargedPower and inherits it from InterstellarReactor where it is initialized as 0.0 implicitly
Others might also not have it, but i didn't check.

Because of that all the other variables above are 0 up to the point where we would produce electric energy. So these reactors should also be broken if the theory is correct:

[KSPModule("Nuclear Salt Water Reactor")]
[KSPModule("Nuclear Thermal Reactor")]
[KSPModule("Fission Reactor")]

I don't know what would be the best approach to fix this but i hope this points you in the right direction.

Edit: maybe something like this could at least temporary fix the issue?

Func<double> calcMaximumElectricPower = () => {
    if(_totalEfficiency < 0) return 0;
    if(chargedParticleMode) return _totalEfficiency * _maxChargedPowerForChargedGenerator;
    else return _maxChargedPowerForThermalGenerator > 0 ? 
    _totalEfficiency * _maxChargedPowerForThermalGenerator : _totalEfficiency * _maxThermalPower; 
};
maximumElectricPower = calcMaximumElectricPower();

Assuming the bug is correctly identified and nothing else changed (besides the new fuel modes), this could/should work.
I'm not able to test it because i'm not able to get the project running in my visual studio instance to recompile the project.

commented

a simple Math.Max(_maxChargedPowerForThermalGenerator, _maxThermalPower) should do the trick, that way both the old and new situation will work

commented

Alright, I think I fixed the biggest issues in the latest release 1.26.23. I also added some automatic fuel switching in case a fuel mode was selected that was not available in the reactor

commented

I tested the version after the hotfix discussed here, but that alone didn't fix the reactor problem. I'll pull the new version, test again and give feedback

commented

Things I observed:

  • The problem with molten salt generators not beeing usable for producing electricity with the thermal power generator seems to be fixed. That applies for monkey patched savegame-reactors too.
  • Powerproduction changed significantly to the previous last working state ? Take a look on the second screenshot thermal power generator: cold bath and hot bath temps in combination with the efficiency seem to be way off - is this intended?
  • Minimum power throttle for molten salt reactor is set to 0, should be 25 (according to the forum thread i think?) and was on 10 2 releases before ( basically before the sciencelab patch went live )
  • These radiators shown here ( need to find out from which mod they are ) are calculated waaaay better in KSPIE-helper in the VAB then they are when launched. May be related to the efficiency-"problem", idk. They were overpowered before and they now feel nerfed, but the predicition inside the helper is off with the "real world" results.
  • The "Upgrade MK:1 4,50 MW" -Message is wrong, this is a MK3 reactor, so both upgrades are applied (as it is visible at the raw power output)
  • Edit: The efficiency issue only happens when the vessel is loaded. Unloaded reactor power via beam works fine with a correct(ish) efficiency. Tested with a MK1 MSR + , got 1,7 MW beamed power vs 250kW local generation while the vessel was loaded (another, not the one shown in the screenshots)

after_patch_vab

kspie_testrig_after_patch

Screenshots are from a career save

commented

Hi all, im playing kspie 1.26.25 but i played before a 26.23 patch.
Im try to share my findings with you.

  1. same problems with thermal generator when efficiency is very low and i think not matches with that thermal efficiency helper in VAB i have an idea that when thermal power generator efficiency calculated, the core temerature is taken from another reactor? is it posibble? that core temperature is taken from another type?

  2. same problem with uranium-233 tank after switch fuel mode.

BUT MORE - Liquid core engine (that similar as nerva but red one - unlocked just after nervas with isp 1600
use uranium-233 now and i dont know if its right same as before. but it uses burnup mode, but i think there are problems with another burnup could be here not 233 burnup, because this is on new molten salt.
Idea is that something bad with fuelmodes and resources where was changed definition of uranium 233 and it maybe causes switching or effeciency problems.

is it possible that uranium fuel modes switchable to burnup automaticaly switch every EnRu or normal uranium mode to uranium-233 mode? but i not tested deeply yet.

NOTE: i havent got unlocked that new fussionfission reactor yet in carreer mode. but normal molten salt and upgrade of fuel modes i have unlocked now.

I can perform some specific tests, if you need that. i little understand the code but little.
Hope that this information will be even little useful and efectivity and switch problem will be solved.

commented

It seems that thermal generator efficiency is only visual problem where decimal dot is moved one digit left. but if i force throttle generator gives right megajoules. exactly 10 times more than by its efficiency verified with win calculator :)
image

Issue with fuel modes - See what happens with candles fuel.
image

Last issue i found about molten salt reactor - i havent got print screen for it but recovery price especially for connection radius 0,625 m is about 66 k but price in VAB is under 10 k. I didnt land with bigger MSRs until now. i use it instead of batteries in landing capsule. so this bug saves me lot of money :) ill try again because im afraid of He3 created in reactor during flight but i think that it was few miligrams not for this amount of credits.

commented

There are figures with different fuel modes in Liquid Core Reactor engine.
No Actinides space
Invisible space for He4, Tritium and Xenon is visible only in reactor control window.
switching to burnup function and back in flight is normal.
Switching to thorium was in VAB.

2021-03-04 23_42_38-Window
2021-03-04 23_46_51-Window
2021-03-04 23_47_08-Window