RimWorld

RimWorld

Not enough ratings
Rimatomics PID Autothrottle
2
2
   
Award
Favorite
Favorited
Unfavorite
Mod, 1.3, 1.4
File Size
Posted
Updated
38.265 KB
2 Dec, 2021 @ 5:39am
12 Nov, 2022 @ 1:43am
3 Change Notes ( view )

Subscribe to download
Rimatomics PID Autothrottle

Description
Replaces the nuclear reactor autothrottle code in Dubs Rimatomics with a faster and more efficient one based on PID control.

Why make this mod?
Dubs Rimatomics offers an autothrottle feature for its nuclear reactors. However, this autothrottle has two drawbacks:
1) It will try to keep the overall power grid load somewhere between 0 and 5kW. Once this is achieved, it is done. This means, that your batteries will only charge slowly, and since Rimatomics uses energy weapons that take Wd directly from batteries (and take a lot of them at once) you may find yourself not having enough power when you need to defend yourself.
2) Once your batteries are full, it will still keep the grid a couple of thousand watts in the positive. Since batteries are at capacity already, the extra power is wasted. Most of you won't care about this considering the plentiful amount of power that comes with Rimatomics, but I don't like to waste anything.

What is PID control?
A control loop mechanism based on continuously checking a feedback value against a setpoint. It is usually used in more technical / industrial applications, typical example being temperature control. A detailed description can for example be read here: https://en.wikipedia.org/wiki/PID_controller
In this case, it adjusts the reactor's control rods in order to keep the power grid's battery charge at a certain percentage. If charge is below, power is increased, if it is above, it is decreased. The battery setpoint is currently 75% by default, you can increase it further in the mod settings (or decrease it) but do not set it to 100% - the system will not know to adjust downwards when power output is too high. I recommend to not go above 90%

How does it work?
The system will continuously check the battery charge percentage of the reactor control console's power grid against the setpoint. It calculates an 'error' value, which is just the difference between the setpoint and the actual value. The output value (control rod position) is calculated based on three parts:
1) Proportional: simply the error value multiplied by the proportional gain value. The larger the difference, the greater the adjustment.
2) Integral: every control loop iteration, the current error is added to the integrated error value. The longer an error persists one way, the greater (or smaller) the integrated error becomes. This value is then multiplied by the integral gain value and added to the result.
3) Derivative: a difference between the current iteration's error and the previous one is also calculated to determine the rate of change over time. This is multiplied by the derivative gain value and also added to the result. This just means that large changes in charge will reduce the response value to prevent overshoot. Derivative gain is not strictly needed for small reactors, but the large ones when fully fuelled have such large power outputs that they will change your battery charge very quickly and the D gain becomes necessary.

What to consider?
Technically, any particular system (in this case this would mostly depend on the reactor's power output) would require optimization of the PID gains. However, if you do not want to deal with this, I do not blame you - the mod comes with a set of default values that should work well enough with any reactor setup, although you might not get perfect battery charge times out of them.

Also please note that there is no "reset to default values" button in the mod settings yet either (this is planned, I just haven't figured it out yet). If you do change the values and forgot the default ones, they are P=2, I=0.00004, D=250. You can also go into your user folder where mod settings files are saved and delete it. That will restore the defaults next time you load the game.

Finally, this mod will only work correctly when you have your reactor power output (transformer), batteries and control console all on the same power grid. Sorry to all of you who use several transformers to feed separate power grids but I haven't found a way to sensibly handle those cases.

All credit for the Rimatomics mod of course goes to Dubwise.
29 Comments
polios3 14 Aug @ 12:12pm 
i temporarly uploaded this fix for you Belzebot until things in your life calm down.
https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=3548908112
polios3 9 Aug @ 9:36am 
all you have to do is cast some types. for example: you have "Text.Font = 1;" in your code, all you need to do is make something like this: Text.Font = (GameFont)1; , the Same with Text.Anchor, just Cast (TextAnchor). Yes.... i did it myself so i can now tell you :steamthumbsup:
belzebot  [author] 9 Aug @ 8:57am 
Hello everyone,

I'm aware of your feedback that this mod is currently not working with the latest versions.

Unfortunately I am extremely stressed with real life at the moment and do not have the time to spare to make an update.

I will look into it as soon as things calm down but can't say when that will be.
Xinjiang Uterus Collector 6 Aug @ 5:41pm 
It doesn't work currently, it breaks the reactor management interface. Would love to see an update if you have time. It's a really great idea
runbirdideal 12 Jul @ 8:34pm 
Hello.
I would like to ask you, are you planning to update the mod to 1.6?
I would be happy to know.
molo 11 Jul @ 5:46am 
I didn't grab an error log, sorry, but 1.6 isn't happy with this in my brief test. The entire reactor control panel is blacked out.
Mlie 18 Nov, 2024 @ 10:40am 
Since this mod has been reported working in 1.5 I added it to the No Version Warning-mod
https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=2599504692
belzebot  [author] 4 Jul, 2024 @ 11:05am 
Good to know!
MrClue 4 Jul, 2024 @ 6:57am 
Works perfectly with 1.5 !
Sally smithson 4 Jun, 2024 @ 12:01pm 
gotcha! Ill be giving it a test in my next run