Jump to content

more realistic electrical system ?


thyriel

Recommended Posts

I have not written any code myself for years now, but i've been thinking about this idea since a while now. How hard would it be splitting the "electricity" resource into "ampere" and "watts" ?

"Watt" would be what electricity is now and ampere would work like the waste resources in life support mods (=represents an electrical fuse). Whenever something is consuming watts, it increases the ampere being drawn from the electric system (and obviously lowers it when its turned off). If it's exceeding the limit bad things could happen, like loosing control until a kerbonaut repairs it (=replace the fuse) or so.

Calculations would be pretty easy too, asuming the system has a fixed voltage the amperes can be directly calculated.

What i'm unsure is how that system would work with certain part mods. I know there's quite a couple of them around that have incredible electricicity usage compared to stock parts, so probably it could end up with being unplayable with them or being dull easy with none of these parts.

I would welcome any kind of input, especially if there's maybe more "side effects" i haven't thought of yet that could make it much more complicated then it looks like now.

Link to comment
Share on other sites

This would be neat!

For simple math, let's say if I'm using 5 ElectricCharge/second, then I would produce 10 Amperes. Using 8 ElecticCharge/second would produce 16 Amperes.

My ship has a 20 Ampere max, so if I use more than 10 ElectricCharge/second, that would be 20 Amperes, and I lose my electrical system. Losing the electrical system could be done in several ways:

* Drain all ElectricCharge

* Simply prevent any ElectricCharge resource transfer

What would determine max Ampere capacity? A separate Fuse part, which could then be fixed by Engineers? A fuse module, added to all batteries, which again has a repair function? (I like that better, since it's no new parts)

You could then scale Amperes based on battery capacity.

("Batteries" would be anything that stores ElectricCharge, including command modules)

Should we just check Amepere usage against the highest Ampere-providing Fuse module?

Do we just add up total Amperes used, and total provided by Fuse modules, and do a simple comparison?

Should each part that draws Amperes check the closest Fuse module, and see if it will handle the load (way harder)

I'm thinking of just loading up a ship will a hundred of those little Z-100 batteries to handle a large Ampere load. Should that work, or should I have to put a heavier-Ampere module on my ship?

Somewhat related: Near Future electrical has capacitors that charge slowly (they convert ElectricCharge to StoredCharge), but then can discharge very rapidly (converting StoredCharge to ElectricCharge).

Edited by hab136
Link to comment
Share on other sites

That sounds a bit counterintuitive. Why have amperes be a value that increases as power is being consumed and then attach failure modes to filling the bar? At minimum you'd want to switch it upside down, making amperes a bar that decreases when power is in use, and attach failure modes to draining it all. This is how everything else in KSP works, meaning players expect it that way. If you want to limit maximum throughput, a better idea would be to limit what batteries and power producers can output, instead of simulating blowing fuses. Otherwise that would only make the power system more complex, but not in any way more realistic... Real spacecraft are designed to be able handle the necessary load, they don't just short out.

The thing is though: a really large part of what makes real electricity behave like it does is completely out of scope for KSP. Things like joule heating, self-capacitance, conductor resistance... none of these are really worth having. Even voltage will have to be handwaved. The electric subsystem isn't available for the player to construct. You cannot draw the wires yourself, affecting the distances and thereby the voltage drop; you cannot choose the wires either, which would affect the physical properties of each line; you don't have different output and input voltages of producers and consumers, and no transformers to unify them with. It's not really a question of adding parts either, you'd have to implement a whole new way of editing the internals of your craft.

Since you cannot simulate the physics involved, the best shot you have will be to instead create a system that superficially behaves roughly as if you were simulating the physics involved. I expect that the closest you're going to get is something like this:

Voltage

- Voltage is internally treated as a percentage of a maximum. You then arbitrarily designate a number to be displayed that looks good. For example, internal 100% could display 200V to the player if you think that looks good.

- Each consumer is given a voltage rating that must be present to feed it. It will be assumed that any system will have its own transformer to shift the voltage down or up for itself as appropriate; the required voltage rating simply represents what the spacecraft's power delivery system must provide, not what the consumer actually runs on (which is irrelevant). For example, the reaction wheels could demand that at least 25% of input voltage be present on the spacecraft (or 50V, if you happened to have set 100% as equaling 200V).

- A system that doesn't get its required minimum voltage shuts down instantly and does not work until it gets it back.

- For each battery, the voltage output is at 100% when the battery is full. As energy is consumed from the battery, the voltage slowly degrades. This is a curve that holds fairly steady over most of the range, and then starts dropping sharply on the last stretch. Something like: 100% voltage at 100% charge, 90% voltage at 50% charge, 80% voltage at 20% charge, 50% voltage at 10% charge and 0% voltage at 0% charge.

- Each power producer also has a voltage curve, but this time dependant on how close it is to its maximum current output (in amperes).

- The voltage of the spacecraft's power delivery system is the weighted average of that of all batteries and power producers that are currently delivering power, with a bias towards choosing high voltage sources first.

- Simplified example: if each battery can deliver 1 kW of power, and you have one that's at 100% voltage and one that's at 10% voltage, the spacecraft's power delivery system will be at 100% voltage when drawing up to 1 kW, at 70% voltage when drawing 1.5 kW, and at 55% voltage when drawing 2 kW. The weighted average ensures the smooth scaling.

Current

- Each battery and each power producer has a maximum number of amperes it can output at once. In conjunction with its voltage, this governs how much power it can output at most.

- Some battery types may be good at storing a lot, but can only output slowly. Others might output quickly but not store much.

- Power producers will scale their voltage curve according to how close they are currently running to their maximum output current.

Power

- Each consumer gets a minimum power requirement in addition to its minimum voltage requirement. Below this level of power, it shuts down and does nothing.

- Each consumer gets a maximum (optimal) power requirement as well. At this level, it works perfectly. As input power goes down, it runs slower or less effective.

- Each consumer requests its maximum power rating when on. If there are many consumers running, then they might request more than the spacecraft can offer in power output from producers and batteries combined, even if there is plenty of stored energy and/or fuel. In that case, each consumer would get less than 100%, causing them all to run slightly slower... or, perhaps if one system drops below its minimum and shuts off, the others will get more again.

- If the spacecraft produces more power from actual production sources (not batteries) than currently requested by consumers, the excess is used to charge the batteries if necessary.

Charge

- Two options for describing battery capacity: units of charge (ampere-hours etc) or units of energy (joules, kilowatt-hours etc).

- Units of charge are voltage-independent: a battery capable of outputting 1 ampere with a capacity of 10 mAh is able to output at maximum for 36 seconds, regardless of which voltage it is at. This means that this number alone makes no statement about the energy (and power) that can actually be delivered.

- Units of energy are voltage-dependent: initially the stored energy drops quickly, but as voltage (and power output with it) lowers, the stored energy will deplete more slowly as well. That means you cannot make any definite statements about how long you still have battery power left (in units of time).

Link to comment
Share on other sites

Wow didn't expected that long responses, thanks :) I'm going into details of your thoughts and questions tomorrow when i'm at my PC again.

Just a quick response to two of them:

Why have amperes be a value that increases as power is being consumed
That's how it works in real life. You have a given Voltage, things consume Watts and that produces an Ampere usage. If you hang too much on one fuse, it will break.
Real spacecraft are designed to be able handle the necessary load, they don't just short out.
That may be true today, but Apollo 13 had a hard time reactivating the capsule without exceeding the ampere limit - which was btw when i had that idea, while watching the movie).

edit: The goal should somewhat be that you can't activate all 10 experiments at once (which real life rovers and probes can't do too) - and that it becomes tricky building small satellites, not like now that the little explorer probe has 4 comms, 3 mapping devices and half a dozend other stuff. And if you break that rover by activating everything, you need to send a technician (or perhaps another rover) to repair it.

Edited by thyriel
Link to comment
Share on other sites

Hmmm, okay. Brainstorming:

What would the amp limit be? That's a property you could give for example probe cores. Or you need to attach a small "fuse" part. But what keeps the user from always using the highest amperage fuse? IRL you want to make fuses as small as necessary to make sure it melts instead of the valuable equipment, but in this proposed system, the higher the fuse limit the more the player can do. If the fuse itself wasn't hardcoded into the command part, then you're going to need a reason for the player to choose a fuse other than the one with the highest possible tolerance.

Link to comment
Share on other sites

Wow didn't expected that long responses, thanks :) I'm going into details of your thoughts and questions tomorrow when i'm at my PC again.

Just a quick response to two of them:

That's how it works in real life. You have a given Voltage, things consume Watts and that produces an Ampere usage. If you hang too much on one fuse, it will break.

That may be true today, but Apollo 13 had a hard time reactivating the capsule without exceeding the ampere limit - which was btw when i had that idea, while watching the movie).

edit: The goal should somewhat be that you can't activate all 10 experiments at once (which real life rovers and probes can't do too) - and that it becomes tricky building small satellites, not like now that the little explorer probe has 4 comms, 3 mapping devices and half a dozend other stuff. And if you break that rover by activating everything, you need to send a technician (or perhaps another rover) to repair it.

TECHNICALLY, you have a Voltage, and resistance, which specifies the Current draw (amps) Amps (Ampere) translates to Coulombs per second. Coulombs are a number of electrons. A certain number of electrons at a given eV have a certain potential (jouls) so, you can multiply Coulombs by voltage to get Joules. Joules over time is Wattage. So, we have "Power (Watts) = Voltage*Current (Amps).

Realistically, parts specify a MAX number of wattage (based off of voltage and current draw), hence why your power supply that says 90W (laptop) or 1000W (desktop) doesn't ACTUALLY use that much power at any given time. Note that Power (wattage) is a unit of energy per given time.

This is often why capacity of batteries are provided as A*hrs or mA*hrs. Along with the voltage, you can calculate the Power that the battery can provide, for a max time. eg. A 4Ahr battery at 12V, could provide 4A for 1 hour at 12V, or 1A for 4 hours at 12V (not necessarily, usually batteries have max current draws, so you couldn't get 4000A for 1/1000th of an hour.). This would equate to 48W for 1 hour, or 12W for 4. From those, you can get the Joules that could be provided.

Soooo... Realistically, parts that draw/generate electricity should use Watts as a resource draw indicator, and storage mediums (aka. batteries) should use Joules/KJoules or W*Hrs. There should be no mention of current (Amperes) unless you also plan on introducing voltage.

Disclaimer: I'm a Computer/Electrical engineer with a B.s. in Computer Engineering.

Edited by rbray89
Link to comment
Share on other sites

Well i have an idea to.

Until now we put a bunch of batteries and anything what needs electricity can use them.

Now if you wanna make it more realistic :

- solar panels usually requires charger unit , they can't just directly pump in batteries , they need a battery charger unit which limit the current/amps pushed in battery + decuple if the battery is 100% charged.

- also we can't just hook up 20 battery after your head's , they should be connected to a battery driver and the battery driver will output the charge for consumers.

So ingame :

- solar charger unit ( starts with a low end model , it will be limited to power so it will charge the battery slower )

- solar driver unit ( similar to the solar charger unit , but this one will redirect the remained power to the main power controller so the power will be used directly by consumers , if the solar charger unit can handle 4 charge/s and the solar panels output 6 charge/s , 4 charge will be pumped into batteries by the charger unit and 2 charges will be directed to the main power unit and can be consumed in real time by consumers but they cant be pumped into batterys )

- main power controller ( starts with low end model , limited to amp consumption if consumption is exceeded -> fuse pops ( nothing will be able to draw electricity) , and must be replaced by an Engineer Kerbal)

Link to comment
Share on other sites

Would it work to approach this as a resource transfer rate mod instead of a pure electrical systems mod? That way you could limit the discharge rate of an electrical component to f(max charge), you wouldn’t have a fuse that broke though you would just get complainants from parts saying there was insufficient electrical charge. However it would let you apply the same principle to any other resource so for example sticking a mainsail on the smallest fuel tank would prevent the mainsail from firing at max thrust because it simply could not drain the tank fast enough.

Link to comment
Share on other sites

How hard would it be splitting the "electricity" resource into "ampere" and "watts" ?

Unless voltage becomes relevant somehow (only would be if different equipment requiring different voltages would become a thing), it only needs to be Watt-hours (electric charge stored in batteries) and Watts (production and consumption of electric charge).

Haven't played it, but RO does this by having 1EC/s = 1kW.

It means that for instance a battery that holds "500" is a 500Watt-hour (0.5KWh) battery, and something that consumes 100 watts would run for 5 hours on that battery.

Link to comment
Share on other sites

Been thinking now half the day about all the input here, and i guess it would become extremely complicated in the end. (At least way too much complicated for my first mod). Much thanks to all for your input, at least it saved me a lot of time writing code and realizing afterwards all the problems you have mentioned :)

I think that's the *only* way to approach it. Problem is, you'll have to do a lot of plugin-ing (and extend the stock Part class) because resource transfer rates aren't supported stock, they're infinite by definition.

I think that could probably be simulated by just checking the actual drain rate when trying to activate something and refusing the activation if it's already too high. The ION drive would then need another check when thrust is changed.

But i guess that wouldn't force anyone to change current setups as ships tend anyway to have a lot stored electricity compared to what they drain. Only exception would be a small probe with ION drive i could think of, so it would more or less just limit the usability of the ION drive instead making electricity more interesting.

edit: is there actually any way of reading out all the individual parts and how much electricity they currently drain ? Just curious why i've never seen a mod displaying that information. (or did i just miss that mod ?)

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