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

Bidirectional grid / load interface interfaceInputs or arguments on the left, observed outputs on the right. Conserving terminals appear below the component. The tables give units and behavior.Bidirectional grid / load interfaceStudio blockcommandsocconnectedbmsPermittemperatureimportPriceexportPricedcPowergridPowerlossallowedvoltagecurrentpowerpn
Original Lemonergy interface view. Lines identify ports; they are not a completed simulation circuit.
Ports and observed outputs
NameDirectionUnitMeaning
pconservingV, AElectrical terminal: potential and charge-conserving current.
nconservingV, AElectrical terminal: potential and charge-conserving current.
commandinputWRequested power; this does not bypass voltage, current, SOC or permission limits.
socinputfractionTyped signal input; its quantity must match the connected output.
connectedinputdimensionlessTyped signal input; its quantity must match the connected output.
bmsPermitinputdimensionlessTyped signal input; its quantity must match the connected output.
temperatureinputKTyped signal input; its quantity must match the connected output.
importPriceinputcurrency/kWhTyped signal input; its quantity must match the connected output.
exportPriceinputcurrency/kWhTyped signal input; its quantity must match the connected output.
dcPoweroutputWObserved result from the solved component or sampled controller.
gridPoweroutputWObserved result from the solved component or sampled controller.
lossoutputWObserved result from the solved component or sampled controller.
allowedoutput0 or 1Observed result from the solved component or sampled controller.
voltageoutputVObserved result from the solved component or sampled controller.
currentoutputAObserved result from the solved component or sampled controller.
poweroutputWObserved result from the solved component or sampled controller.

Parameters

Defaults are initial model values. Select values for your own model and operating conditions.

Configuration fields
ParameterUnitDefaultMeaning and limits
Power W
powerW
W grid import (+), export (-)0Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum -1000000000; Maximum 1000000000
Import Limit W
importLimitW
W7000Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 0; Maximum 1000000000
Export Limit W
exportLimitW
W7000Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 0; Maximum 1000000000
Import Current A
importCurrentA
A32Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 0; Maximum 1000000
Export Current A
exportCurrentA
A32Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 0; Maximum 1000000
Import Efficiency
importEfficiency
fraction0.95Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 0.01; Maximum 1
Export Efficiency
exportEfficiency
fraction0.95Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 0.01; Maximum 1
Capacity Ah
capacityAh
Ah100Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 1e-06; Maximum 1000000000
Reserve Soc
reserveSoc
fraction0.2Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 0; Maximum 1
Target Soc
targetSoc
fraction0.8Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 0; Maximum 1
Minimum Voltage V
minimumVoltageV
V250Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 0.01; Maximum 1000000
Voltage Limit V
voltageLimitV
V420Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 0.01; Maximum 1000000
Boundary Time S
boundaryTimeS
s1Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 0.001; Maximum 3600
Min Temperature K
minTemperatureK
K273.15Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 1; Maximum 1000
Max Temperature K
maxTemperatureK
K318.15Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 1; Maximum 1000
Import Price
importPrice
currency/kWh0.2Configured model parameter; the default is an initial editor value, not an operating recommendation.
Minimum 0; Maximum 1000000
Export Price
exportPrice
currency/kWh0.1Configured 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_import
  • P_grid_export = -P_DC_discharge * eta_export
  • P_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.

  1. Bidirectional grid / load interface: Converts battery and grid/load power
    • importEfficiency / exportEfficiency
    • importLimitW / exportLimitW
    • Electrical ports p and n
Open the Studio example

Model signed grid exchange

Explicit battery and converter exchange average power.

  1. Bidirectional grid / load interface: Converts battery and grid/load power
    • importEfficiency / exportEfficiency
    • importLimitW / exportLimitW
    • Electrical ports p and n
Open the Studio example

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.js
  • js/charging-scenarios.js
  • docs/CHARGING_BLOCKS_SPEC.md
  • js/physical-network.js
  • rust-core/src/charging_control.rs

This implementation and its workflow uses (JSON) · Knowledge graph (JSON-LD)