You could model the power consuming "things" as constant resistance loads, all in parallel. A high resistance is a light load, and vice versa.
To find the total resistance of all parallel loads, use this equation:
R = 1/((1/R1) + (1/R2) + (1/R3) ...etc...)
If you have multiple batteries in parallel, you find the total resistance of all batteries using the same equation for the battery resistances.
The load resistance(s) is in series with the battery resistance(s), so next step is to simply add these two totals together. Rbatt + Rload.
Then use the equation
Power = Voltage*Voltage/Resistance to determine the performance of each load. The resistance here is the resistance of the individual load. Power equals performance.
As the battery voltage drops, you will see that the performance of each load will drop drastically. Also, when you have many loads connected, the battery resistance will be significant (it will cause the voltage to sag). With few loads, the battery resistance will have less of an impact.
If you want to model a Lithium battery, start out at 4.2 V when full. When the battery reaches 3 V; it's "flat", and the power should be cut. If you want to model a NiMH battery, start at 1.5V and cut at 0.8V or so. Or you could set these values anywhere you want.
The tweakable values here are
- full battery voltage
- empty battery voltage
- load resistance (can be different for each individual load)
- battery resistance (can be different for each type of battery)
- battery capacity (mAh, different for each type of battery)
If you want to stay somewhat realistic, you do not want to combine batteries with different max and min voltages in parallel.
However, if you implement the option to put batteries in series as well as parallel, you open up a whole new realm of possibilities: The output voltage is doubled, the battery resistance is doubled, the capacity in mAh stays the same.
To model how the battery gets depleted, you indeed need a charge state vs voltage curve. Find a real one on the Internet and build yourself a dictionary, or make an equation that approximates it, or something to that effect.
If you want to simplify this a lot, you can just say that the battery is at max voltage (e.g. 4.2V) when it's full (has all the mAhs), and at min voltage (e.g. 3V) when it's empty (has zero mAh left). At any charge state between 0 mAh and full mAh, you can interpolate between these two voltages to find the battery voltage at that charge state. This will give you a linear discharge curve, not perfect, but it will serve as a placeholder.
Let's say that the battery capacity is 1000 mAh == 1 Ah == 60 amps-minute == 3600 amps-second. Let's also say that the load is 1 Ohm and the internal resistance of the battery is 0.1 Ohm. We start with a full battery at 4.2 V.
Then the algorithm could go like this, with one second ticks:
- Find the current, the first tick it is
4.2V / 1.1 Ohm = 3.82A.
- The load is producing
3.82A * 3.82A * 1 Ohm = 14.5924W, so you know the performance.
3.82A * 3.82A * 0.1 Ohm = 1.45924W is lost as heat in the battery.
- The battery started out with 3600 amp-seconds, but now it only has
3600 - 3.82 = 3596.18 amp-seconds left.
- Now use your discharge curve to find the new battery voltage, let's say it's already dropped to 4.15V.
- Rinse and repeat.
You can now model the charge state, the battery voltage, and the appliance performance second by second.