Voltecx is in beta. The macOS build comes first; Windows and Linux packages are still being tested.Beta. macOS comes first; Windows and Linux are still in testing. What's new
Documentation

Battery (battery)

A rechargeable battery whose voltage follows its state of charge.

battery

Component reference · 繁體中文

Group: Sources · Kind: {"kind":"battery"}

When to use it

Use it for storage systems, battery chargers, electric vehicles and backup supplies. For a fixed voltage, use DC Voltage Source.

Pins

Pin Domain Meaning
p electrical Positive terminal
n electrical Negative terminal
soc signal State of charge, 0 to 1 (an output signal)

Common parameters

  • ah: Capacity (Default: 2.5)
  • soc0: State of charge at the start, 0 to 1 (Default: 0.8)
  • r0: Resistance that drops the voltage at once (Default: 50m)
  • ns: Cells in series; the voltage table is per cell (Default: 1)

Parameters

Key Unit Default Typical range Description
ah Ah 2.5 Capacity
soc0 — 0.8 State of charge at the start, 0 to 1
r0 Ω 50m Resistance that drops the voltage at once
r1 Ω 15m Resistance of the first RC branch
c1 F 2k Capacitance of the first RC branch
r2 Ω optional (off) Resistance of the second, slower RC branch
c2 F optional (off) Capacitance of the second RC branch
ns — 1 Cells in series; the voltage table is per cell
socs — 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 State of charge points of the voltage table
ocvs — 3.0 3.45 3.55 3.62 3.68 3.74 3.82 3.91 4.0 4.09 4.2 Rest voltage of one cell at each point
temp °C 25 Battery cell temperature
tref °C 25 Temperature the table and resistances belong to
dOcvDt V/K 0 Change of a cell's rest voltage with temperature
ea J/mol 0 Activation energy that raises the resistances in the cold
soh — 1 Capacity left after ageing, as a share of ah
rAge — 1 Growth of the resistances with ageing, 1 when new
thermal — optional (off) Thermal net of its cells; takes the heat of its resistances, and with ea set its temperature moves them

Parameter descriptions are in English in both languages.

Use for: Energy storage · Battery chargers · Electric vehicles · Backup supplies

Not for: Fixed supply voltage → dcVoltageSource · Supercapacitor storage → supercap

Formulas

Formula Equation Source
C-rate C-rate = i/ah IEC 61960-3:2017, clause 3
Run time from full t = 3600·ah/i Linden's Handbook of Batteries, 4th ed. (2011), Ch. 1
Terminal voltage under load V = ns·voc − i·r0 Linden's Handbook of Batteries, 4th ed. (2011), Ch. 2

Quick check

Inputs:

  • ah: Capacity = 2.5 Ah, ah
  • i: Discharge current = 5 A
  • r0: Series resistance = 50m Ω, r0
  • ns: Cells in series = 1 —, ns
  • voc: Cell open-circuit voltage = 4 V

Outputs:

  • crate: C-rate = i/ah —
  • trun: Run time from full = 3600*ah/i s
  • vt: Terminal voltage at once = ns*voc - i*r0 V

Model logic

  • The part stamps a controlled voltage ns·OCV(soc), then r0, then up to two parallel RC branches and an internal ammeter to p; the RC capacitors start at 0 V.
  • The state of charge integrates -i/(3600·ah·soh) from soc0 within 0 to 1; the cell OCV is a straight-line lookup in socs and ocvs, held at the ends.
  • The OCV follows the state of charge through control blocks, so it lags one step; r0, r1 and r2 belong to the whole pack and are not multiplied by ns.
  • Temperature and ageing scale the resistances and shift the OCV once per run; self-heating, self-discharge, hysteresis and rate-dependent capacity are not modelled.

Model

The battery is an open-circuit voltage, a series resistance r0 and up to two RC branches (r1 with c1, r2 with c2) in series. The open-circuit voltage is ns times the cell voltage, read from the table ocvs at the state of charge, with straight lines between the points of socs. The state of charge starts at soc0 and falls by i / (3600 * ah) per second, where i is the current out of p (the current of the part, named like the battery). It is the signal name:soc, held between 0 and 1, and a warning says when it was held while the current pushed on. The default table is an illustrative curve of the usual shape for one lithium-ion NMC cell, not measured data, and the default resistances and capacity are illustrative too. Temperature and ageing are set once for the run: at the cell temperature temp, every resistance is multiplied by exp(ea / R * (1 / T - 1 / Tref)) (the Arrhenius law, R = 8.314 J/(mol K), temperatures in kelvin) and by rAge, and every table voltage moves by dOcvDt * (temp - tref). Ageing also shrinks the capacity to soh * ah. The defaults (ea and dOcvDt 0, soh and rAge 1) leave a new cell at its table temperature. Self-heating and self-discharge are not modelled.

Common mistakes

  • The default table is for one cell. A pack needs ns set to the cells in series, or its voltage stays near 3.7 V.
  • ah is in ampere-hours, so a 100 ms run hardly moves the state of charge. Use a smaller ah to see the charge change in a short run.
  • A battery charged when full, or discharged when empty, keeps its voltage at the end of the table. Check the warning after the run.

Datasheet and sources

ah is the rated capacity, and r0 is the DC internal resistance. Take socs and ocvs from the open-circuit voltage curve of the cell, and r1, c1, r2, c2 from a pulse test: the slow recovery of the voltage after a current step. Take ea from the internal resistance measured at two or more temperatures (the slope of ln r against 1/T, times R), dOcvDt from the rest voltage at two temperatures (the entropic coefficient), and soh and rAge from the capacity and resistance of the aged cell against the new one.

Example

Open the example with the command file.openExample and the name demo:battery.


Generated by cargo xtask reference from the usage texts and parameter specs. Do not edit by hand.