Lemonergy · Studio block
Bidirectional grid / load interface
Average-power interface between a DC battery and a grid or load boundary.
- Implementation ID
bidirectional-grid- Reviewed
- 2026-10-27
Behavior
Import and export obey separate efficiency, power and current limits. Voltage and SOC barriers taper transfer at the configured envelopes. Import/export energy and net cost accumulate from actual transferred power.
Interface
| Name | Direction | Unit | Meaning |
|---|---|---|---|
p | conserving | V, A | Electrical terminal: potential and charge-conserving current. |
n | conserving | V, A | Electrical terminal: potential and charge-conserving current. |
command | input | W | Requested power; this does not bypass voltage, current, SOC or permission limits. |
soc | input | fraction | Typed signal input; its quantity must match the connected output. |
connected | input | dimensionless | Typed signal input; its quantity must match the connected output. |
bmsPermit | input | dimensionless | Typed signal input; its quantity must match the connected output. |
temperature | input | K | Typed signal input; its quantity must match the connected output. |
importPrice | input | currency/kWh | Typed signal input; its quantity must match the connected output. |
exportPrice | input | currency/kWh | Typed signal input; its quantity must match the connected output. |
dcPower | output | W | Observed result from the solved component or sampled controller. |
gridPower | output | W | Observed result from the solved component or sampled controller. |
loss | output | W | Observed result from the solved component or sampled controller. |
allowed | output | 0 or 1 | Observed result from the solved component or sampled controller. |
voltage | output | V | Observed result from the solved component or sampled controller. |
current | output | A | Observed result from the solved component or sampled controller. |
power | output | W | Observed result from the solved component or sampled controller. |
Parameters
Defaults are initial model values. Select values for your own model and operating conditions.
| Parameter | Unit | Default | Meaning and limits |
|---|---|---|---|
Power WpowerW | W grid import (+), export (-) | 0 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum -1000000000; Maximum 1000000000 |
Import Limit WimportLimitW | W | 7000 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 0; Maximum 1000000000 |
Export Limit WexportLimitW | W | 7000 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 0; Maximum 1000000000 |
Import Current AimportCurrentA | A | 32 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 0; Maximum 1000000 |
Export Current AexportCurrentA | A | 32 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 0; Maximum 1000000 |
Import EfficiencyimportEfficiency | fraction | 0.95 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 0.01; Maximum 1 |
Export EfficiencyexportEfficiency | fraction | 0.95 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 0.01; Maximum 1 |
Capacity AhcapacityAh | Ah | 100 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 1e-06; Maximum 1000000000 |
Reserve SocreserveSoc | fraction | 0.2 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 0; Maximum 1 |
Target SoctargetSoc | fraction | 0.8 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 0; Maximum 1 |
Minimum Voltage VminimumVoltageV | V | 250 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 0.01; Maximum 1000000 |
Voltage Limit VvoltageLimitV | V | 420 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 0.01; Maximum 1000000 |
Boundary Time SboundaryTimeS | s | 1 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 0.001; Maximum 3600 |
Min Temperature KminTemperatureK | K | 273.15 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 1; Maximum 1000 |
Max Temperature KmaxTemperatureK | K | 318.15 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 1; Maximum 1000 |
Import PriceimportPrice | currency/kWh | 0.2 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 0; Maximum 1000000 |
Export PriceexportPrice | currency/kWh | 0.1 | Configured model parameter; the default is an initial editor value, not an operating recommendation. Minimum 0; Maximum 1000000 |
Equations and rules
P_grid_import = P_DC_charge / eta_importP_grid_export = -P_DC_discharge * eta_exportP_loss = P_grid - P_DC
Worked example
Model signed grid exchange
−5 kW requests export; +5 kW requests import. 5 kW exported at 95% efficiency needs about 5.26 kW battery power.
Open the Studio example →Use in a workflow
Supply an outage load
V2H illustrates outage-triggered dispatch and reserve.
- Bidirectional grid / load interface: Converts battery and grid/load power
- importEfficiency / exportEfficiency
- importLimitW / exportLimitW
- Electrical ports p and n
Model signed grid exchange
Explicit battery and converter exchange average power.
- Bidirectional grid / load interface: Converts battery and grid/load power
- importEfficiency / exportEfficiency
- importLimitW / exportLimitW
- Electrical ports p and n
Connected concepts
Limits and interpretation
- This excludes AC waveforms, synchronization, communications and certification.
- No islanding switches, smart-panel circuits or protection coordination are simulated.
Implementation sources
This reference follows Lemonergy implementation sources. Scientific articles support the linked concepts separately.
Repository: battery-design · Revision: ef9802329b75bc15bb96885f8ed5d49425106696
js/charging-control.jsjs/charging-scenarios.jsdocs/CHARGING_BLOCKS_SPEC.mdjs/physical-network.jsrust-core/src/charging_control.rs
This implementation and its workflow uses (JSON) · Knowledge graph (JSON-LD)