Jump to content

[WIP] [Plugin] Realistic RTGs


Gribbleshnibit8

Recommended Posts

Realistic RTGs

Download: Dropbox v0.2.0

Source: Github

License: GNU GPL v3.0

THIS MOD IS NO LONGER BEING DEVELOPED.

IF YOU LIKE THE IDEA, CHECK OUT:

JDiminishingRTG

I looked around for a while and didn't see this anywhere, so I decided I'd dive into KSP modding with something fairly simple (that turned out to be harder than expected*). So here's a simple Generator Module that creates a more real RTG. Decay rates are calculated in Kerbin days only, and the current setup of half-life have been converted from real-world values to Kerbin scale values for gameplay reasons based on this info.

The initial fuel and power output is balanced around the default RTG settings. So if you just drop one onto a ship and go it will have the same initial output. However, as the ship ages, the power output goes down (based on mission time). I don't really know how this works with ships on rails, that will need more testing

Warning: Loading this into existing ships that rely heavily on RTGs for power can cause issues if they are very old. Fuel decay is based on mission time, and could result in not enough power to run your ship.

Note: Needs Module Manager

Description:

A single new module called ModuleGeneratorRTG that creates Electric Charge at a decaying rate based on a half-life value.

Configuration:

Shown below with default values, this is the standard setup if you only include ModuleGeneratorRTG on you part.

  • FuelMass - The amount of radioactive material aboard in kilograms. This figures directly into the amount of power the part produces. Leaving it at default is suggested.
  • EnergyDensity - The amount of energy output per unit of FuelMass. Essentially the kilowatts per kilogram of radioactive material.
  • Halflife - Obviously the half-life of the substance. Calculated as the Earth half-life of a radioactive material multiplied by the Earth fraction of a Kerbin year, or 0.29. At one half-life the RTG will produce one half the power it did when installed.
  • Efficiency - To be the efficiency of the RTG at converting heat into electricity. It is still used, and can be tweaked to produce very large amounts of electricity with no change to other values.


MODULE
{
name = ModuleGeneratorRTG
FuelMass = 5
EnergyDensity = 0.45
Halflife = 8.352
Efficiency = 0.05
}

Planned/Desired Features:

  1. Selectable fuel
  2. Selectable thermocouple type
  3. Change fuel mass for more power output
  4. Load fuel types from resource files or allow it to be set in part module
  5. Add more RTG types (stirling RTGs, etc)
  6. More thermocouple types, also from resource files
  7. Dynamic weight based on fuel mass/type
  8. Costs depending on amount of fuel and the mass

Pictures may be of outdated settings.

Javascript is disabled. View full album
Edited by Gribbleshnibit8
Link to comment
Share on other sites

Looks neat.

It looks from the code (I can't access open .7z) like the fuel types are hard coded into the part? It might be preferable to use the resource definitions built into the game. It'll update mass and part cost when the amount of fuel gets tweaked. I think cost would be a nice motivator to use one fuel over another or to load as little fuel as feasible. I think the half-life defs would need to be either hard-coded or added to a config file.

* I found it very difficult to actually find any kind of information on KSP modding. I resorted to using other mods to figure out what I was doing and needed to do. Am I just not looking in the right places, or is there really a dearth of modding information, and if so why? Coming from modding Fallout, where there is dev provided wiki of all functions and features, and user maintained resources that go even further, this was a rather large barrier to my work. Obviously I made it around it, but I'm just curious if I didn't look in the right places

Looking at other mods is generally step one, and this is one of the big reasons the source code must be posted somewhere. All of the Unity specific stuff is documented (how well is a different question) on the Unity website. As a last resort, you can browse the assembly for public methods. I think there's eventually maybe sometime going to be official docs, but you have to remember that KSP is still alpha and things are changing fast enough. The KSP wiki has a little bit, but not much. Finally, sometimes the devs will make a post on some new feature.

For live help you can always try the #kspmodders IRC channel. Otherwise a search in the AddOn Development forum can be useful.

https://kiwiirc.com/client/irc.esper.net/?nick=ksp_guest|?#kspmodders

Edited by kujuman
Link to comment
Share on other sites

Would it be possible to release a version without the fuel loading, thermocouples, etc. Just the decay?

Once I get a little bit more done, I'll look into making a simple switch to disable all that. My main goal was to get it working first. Ideally the way I'd have that work is you just set a flag in the module def that tells it to use all default values and disable all tweaking. Obviously the big issue there is finding a good balance between the available half-life and the amount of EC generated. And of course, you're always welcome to just take the code and do whatever. Pretty sure I picked the correct license for that :)

Looks neat.

It looks from the code (I can't access open .7z) like the fuel types are hard coded into the part? It might be preferable to use the resource definitions built into the game. It'll update mass and part cost when the amount of fuel gets tweaked. I think cost would be a nice motivator to use one fuel over another or to load as little fuel as feasible. I think the half-life defs would need to be either hard-coded or added to a config file.

They are, because I didn't know how to load resource defs, and couldn't think of a mod that loaded them that I could look at. That is my eventual goal, so that new types of fuel can be easily added.

Looks neat.

Looking at other mods is generally step one, and this is one of the big reasons the source code must be posted somewhere. All of the Unity specific stuff is documented (how well is a different question) on the Unity website. As a last resort, you can browse the assembly for public methods. I think there's eventually maybe sometime going to be official docs, but you have to remember that KSP is still alpha and things are changing fast enough. The KSP wiki has a little bit, but not much. Finally, sometimes the devs will make a post on some new feature.

For live help you can always try the #kspmodders IRC channel. Otherwise a search in the AddOn Development forum can be useful.

https://kiwiirc.com/client/irc.esper.net/?nick=ksp_guest|?#kspmodders

Oh god IRC, that takes me back. I did run across taraniselsu's useful modding examples, which helped quite a bit. Honestly, the biggest issue I had was trying to figure out how to make it add electric charge! The coding was far easier than Fallout because I can use an IDE and intellisense and all that other wonderful modern stuff (I use Notepad++ to write all my Fallout stuff). Thanks for the tips, I'll definitely hit up IRC for some help.

Link to comment
Share on other sites

They are, because I didn't know how to load resource defs, and couldn't think of a mod that loaded them that I could look at. That is my eventual goal, so that new types of fuel can be easily added.

I'm not entirely sure what you mean by "load resource defs", so I'll just go over what I know.

A good primer is the official documentation in the third post here http://forum.kerbalspaceprogram.com/threads/92643-Official-PartModule-Documentation

The biggest difference is that RESOURCE_DEFINITION s now have more settings. I think the settings for solid fuel are a good start for fissile material. Default resources are in a file GameData/Squad/Resouces/ResourcesGeneric.cfg

Your custom resource can sit in a .cfg anywhere in the GameData folder (I think) so long as the resource definition block is there. Once you have a custom resource in a .cfg, the game will load it automatically.

Link to comment
Share on other sites

Maybe I can explain: RTGs have nuclear fuel (often Plutonium-238). This radioactive substance gives off heat, which is used to provide electricity. But radioactive materials have a half-life. That means that the power/heat output halves itself within a certain timespan. With Plutonium-238 that's 87.7 years. So if you start with a 238 loaded RTG it'll produce 100% power at year 0 and will degrade to 50% during 87.7 years (the mod might differ). This keeps halving within each subsequent period. The next 87 years it goes down to 25%, then 12.5%, 6.25%, etc. After a while the power output will be insufficient enough to power any of the onboard systems. This is what's important with faraway probes like Pioneer 10/11 and Voyager 1/2. They have a limited lifespan in which they can produce enough electricity to power the systems. In stock KSP it's not as important, but if Eeloo was as far away as the real Pluto it'd be six times farther away from Kerbol as it is now. Then RTG life would really mean a lot (since solar panels would be useless at that distance). It could already be very important with mods that add planets further out than Jool/Eeloo.

Link to comment
Share on other sites

Would it be possible to release a version without the fuel loading, thermocouples, etc. Just the decay?

While still trying to figure out how to get resources loaded (as per below) this would be fairly easily possible if I could figure out how to disable some of the right click fields.

Alternatively I've made a tentative "Simple" module that lets the key values be defined in the .cfg entry and then nothing edited in game.

I'm not entirely sure what you mean by "load resource defs", so I'll just go over what I know.

Very useful, thank you.

What I mean by loading is, I'd like to offer the user an option of multiple resource types (fissile fuels) to choose from. So I would need to load the appropriate resources into a list that can then be displayed in the part right-click menu. I'm not even sure if this is possible, as I can't think of any mods that do it this way. Ideally there would be a RESOURCE_DEFINITION that would contain all the parameters I need, that I would load into a list, gets names from, and display as options. Looking into that post and doing a bit of my own poking I think I might need a custom resource loader, if I want to have the energy density and half-life values available.

So things I need to figure out now:

  1. How to disable Events and Fields based on a variable in a .cfg
  2. How to load specific resources into a list that can be cycled through by clicking a button
  3. How to extend a resource def to allow me to add extra values (unless I can do this already)

Link to comment
Share on other sites

Awesome! I'm working on a electrical power mod and RTG half-lifes was a missing piece of the puzzle. Didn't want it to be complex, so that's why I asked for a simple version. Glad you're thinking about it. I have to say I'm amazed that no-one's made this mod sooner. RTGs are in stock and the generator module even has an efficiency rating. Why no-one fixed this before is anyone's guess.

Link to comment
Share on other sites

Yes and it never degrades. If you keep it totally realistic then it wouldn't be noticeable with real half-life, but if you divide the half-life by something like 10 (like the distances of the Kerbol System vs. the Solar System) then you'd have to plan ahead.

Link to comment
Share on other sites

What I did was divide by the difference in time between a Kerbin year and an Earth year based on the values here. So an Earth half-life gets multiplied by 0.29 to create the Kerbin half-life

28.7 * 0.29 = 8.325

This is subject to change, but seems to be good to me, though could probably actually be smaller. However, you have to remember too that at 8.325 years it will be producing half of the power it did to start with. The stock RTG produces 45Ec/m, so in 8.325 years would be producing just 22.5Ec/m which is quite a bit less. But due to the way it actually works out, you're slowly losing power over that entire lifespan. In 2 years it's producing only 33.75Ec/m, so you can see it actually fairly quickly becomes an issue.

This actually ties into why I elected to allow various fuel types, to allow for the selection of longer half-life materials at the expense of lower energy output. The longest I have gives over 100 years, but only 0.22Ec/s, which is pretty low (stock is 0.75Ec/s) but would allow your mission to last a long time on say, Eeloo.

The second factor, thermocouples, I kind of extrapolated based on some current technologies and a few theoretical ones that we have, but don't really use due to cost/difficulty in manufacture. The idea is to allow you to change the type to get more energy out of your fuel at the expense of increased cost.

Procedural cost and weight are things I need to figure out too. It'd be solved with Resource defs, but that's another issue to solve too...

Link to comment
Share on other sites

Updated to version 0.2.0.

Changes:


- Fixed resource output to not give an infinitely massive amount
- Removed the slider and options and made configuration via .cfg possible instead
- Added support for RLA_Stockalike
- Added support for the USI modules that I know use RTGs

Edited by Gribbleshnibit8
Link to comment
Share on other sites

  • 2 months later...
does this work on RTGs from other mods, like the one in near future electric?

It covers 6 you would have to add or write a cfg to add more but would be really no big deal to do.

EDIT- what it covers

@PART[rtg]
{
!MODULE [ModuleGenerator] { }
MODULE
{
name = ModuleGeneratorRTG
FuelMass = 5
EnergyDensity = 0.45
Halflife = 8.352
Efficiency = 0.05
}
}


// RLA_Stockalike ===================================================
@PART[RLA_mmrtg]
{
!MODULE [ModuleGenerator] { }
MODULE
{
name = ModuleGeneratorRTG
FuelMass = 1.667
EnergyDensity = 0.45
Halflife = 8.352
Efficiency = 0.05
}
}
@PART[RLA_ASRG]
{
!MODULE [ModuleGenerator] { }
MODULE
{
name = ModuleGeneratorRTG
FuelMass = 15
EnergyDensity = 0.45
Halflife = 8.352
Efficiency = 0.10
}
}
@PART[RLA_CSRG]
{
!MODULE [ModuleGenerator] { }
MODULE
{
name = ModuleGeneratorRTG
FuelMass = 10
EnergyDensity = 0.45
Halflife = 8.352
Efficiency = 0.05
}
}


// Umbra Space Industries ===========================================
@PART[USI_PodCapsule]
{
!MODULE [ModuleGenerator] { }
MODULE
{
name = ModuleGeneratorRTG
FuelMass = .333333
EnergyDensity = 0.45
Halflife = 8.352
Efficiency = 0.05
}
}
@PART[USI_PodCapsule]
{
!MODULE [ModuleGenerator] { }
MODULE
{
name = ModuleGeneratorRTG
FuelMass = 6.666666
EnergyDensity = 0.45
Halflife = 8.352
Efficiency = 0.05
}
}

EDIT- Covers Stock and some in Umbra Space Industries and RLA_Stockalike mod but if you wanted to add a mods RTG to this plugin find the name of the part and add

@PART[Part name here]
{
!MODULE [ModuleGenerator] { }
MODULE
{
name = ModuleGeneratorRTG
FuelMass = 5
EnergyDensity = 0.45
Halflife = 8.352
Efficiency = 0.05
}

If around the same size as stock or if you just want to use this one or change what ever.

Edited by Mecripp2
Link to comment
Share on other sites

  • 2 weeks later...
You beat me to it. I have felt that the efficiency should decay over time. Maybe for batteries too.

I actually had plans to do solar panels, just couldn't really find much info on their lifespan decay rates. Plus I have no clue how to go about determining if on surfaces, orbital locations etc to make it lose even efficiency when in atmospheres or decay more slowly when not in sunlight, etc.

I have made some with near future plugin but they have a core melt down lol needed to play with it more to see if, I could add the cooling Radiator to them.

EDIT- If you need help adding some let me know.

I'm sure that was at xXIndestructibleEVAXx, however, if you know of more mods that need RTGs I'll gladly add more configs for them.

Any input from anyone on balance of the current configs, plus any additional input is welcome. Maybe I should re-evaluate this and move to releases.

Link to comment
Share on other sites

  • 2 weeks later...

Holy ...., this is fantastic. I wanted to create something like this but seems it already exist, excelent!!!

Edit: I tried to compile the sollution but it appears I'm missing a file called ModuleGeneratorRTGSimple.cs

Edited by FreeThinker
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...