Converter API¶
The simses.converter module is one class plus one Protocol: the Converter simulator and the ConverterLossModel protocol that loss curves satisfy. For the two-pass resolution, sign conventions, and the duck-typed storage contract, see the Converter concept page.
Converter¶
AC/DC converter that clamps to a rated power, applies a loss model, and forwards DC power to a downstream storage. Exposes the same step(power, dt) + state.power contract that it requires of its storage, so converters can chain.
simses.converter.converter.Converter
¶
AC/DC converter that wraps a downstream storage with a loss model.
Clamps the AC power setpoint to the rated max_power, converts it to
DC via the loss model, and forwards it to the storage. If the storage
cannot fulfil the requested DC power (by more than 1%), the converter
recomputes the actual AC power from the delivered DC power.
The storage is duck-typed: any object with a step(power_setpoint, dt)
method and a state.power attribute — typically a :class:Battery,
but also another :class:Converter (enabling converter chaining).
Attributes:
| Name | Type | Description |
|---|---|---|
max_power |
Rated maximum power of the converter in W. |
|
state |
Current converter state (power, setpoint, loss). |
|
model |
Loss model for AC/DC conversion. |
|
storage |
Downstream storage receiving the DC power setpoint. |
Source code in src/simses/converter/converter.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
__init__(loss_model, max_power, storage)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loss_model
|
ConverterLossModel
|
AC/DC loss model satisfying :class: |
required |
max_power
|
float
|
Rated maximum AC power of the converter in W (the
normalisation base for |
required |
storage
|
Any
|
Downstream storage exposing |
required |
Source code in src/simses/converter/converter.py
step(power_setpoint, dt)
¶
Apply an AC power setpoint over one timestep.
Two-pass resolution
- Clamp the AC setpoint to
[-max_power, max_power]. - Convert to DC via the loss model and delegate to
storage.step(power_dc, dt). - If the storage cannot fulfil the DC request (mismatch > 1%), recompute the actual AC power from the delivered DC power.
Side effects: updates self.state with the resulting
power_setpoint, power (AC side), and loss.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
power_setpoint
|
float
|
Requested AC power in W. Positive = charging, negative = discharging. |
required |
dt
|
float
|
Timestep in seconds. |
required |
Source code in src/simses/converter/converter.py
ac_to_dc(power_ac)
¶
Convert an AC power in W to the corresponding DC power in W.
Forward direction used in the normal simulation flow: the AC setpoint is converted to the DC power delivered to the storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
power_ac
|
float
|
AC power in W. Positive = charging, negative = discharging. |
required |
Returns:
| Type | Description |
|---|---|
float
|
DC power in W, same sign convention as |
Source code in src/simses/converter/converter.py
dc_to_ac(power_dc)
¶
Convert a DC power in W to the corresponding AC power in W.
Inverse of :meth:ac_to_dc. Used when the storage cannot fulfil
the requested DC power — the delivered DC power is back-converted
to find the AC power actually exchanged at the converter's AC
terminals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
power_dc
|
float
|
DC power in W. Positive = charging, negative = discharging. |
required |
Returns:
| Type | Description |
|---|---|
float
|
AC power in W, same sign convention as |
Source code in src/simses/converter/converter.py
Converter State¶
Mutable state written by each Converter.step() — AC setpoint, delivered AC power, and conversion loss.
simses.converter.converter.ConverterState
dataclass
¶
Mutable state of a :class:Converter.
Attributes:
| Name | Type | Description |
|---|---|---|
power_setpoint |
float
|
Requested AC power for the current timestep in W. |
power |
float
|
AC power actually delivered this timestep in W
(may differ from |
loss |
float
|
Conversion loss this timestep in W ( |
Source code in src/simses/converter/converter.py
Converter Loss Model Interface¶
Protocol that every loss model implements. Two methods operating on normalised power (p.u. of max_power); no inheritance required. See Choosing a Converter Model for the shipped implementations and Extending Converter Loss Models for writing your own.
simses.converter.converter.ConverterLossModel
¶
Bases: Protocol
Protocol for AC/DC converter loss models.
All power values are normalised to p.u. of max_power. Sign convention: positive = charging, negative = discharging.