{
  "node": {
    "id": "block:bidirectional-grid",
    "type": "Block",
    "label": "Bidirectional grid / load interface",
    "properties": {
      "id": "bidirectional-grid",
      "name": "Bidirectional grid / load interface",
      "kind": "studio",
      "summary": "Average-power interface between a DC battery and a grid or load boundary.",
      "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.",
      "ports": [
        {
          "name": "p",
          "direction": "conserving",
          "unit": "V, A",
          "description": "Electrical terminal: potential and charge-conserving current."
        },
        {
          "name": "n",
          "direction": "conserving",
          "unit": "V, A",
          "description": "Electrical terminal: potential and charge-conserving current."
        },
        {
          "name": "command",
          "direction": "input",
          "unit": "W",
          "description": "Requested power; this does not bypass voltage, current, SOC or permission limits."
        },
        {
          "name": "soc",
          "direction": "input",
          "unit": "fraction",
          "description": "Typed signal input; its quantity must match the connected output."
        },
        {
          "name": "connected",
          "direction": "input",
          "unit": "dimensionless",
          "description": "Typed signal input; its quantity must match the connected output."
        },
        {
          "name": "bmsPermit",
          "direction": "input",
          "unit": "dimensionless",
          "description": "Typed signal input; its quantity must match the connected output."
        },
        {
          "name": "temperature",
          "direction": "input",
          "unit": "K",
          "description": "Typed signal input; its quantity must match the connected output."
        },
        {
          "name": "importPrice",
          "direction": "input",
          "unit": "currency/kWh",
          "description": "Typed signal input; its quantity must match the connected output."
        },
        {
          "name": "exportPrice",
          "direction": "input",
          "unit": "currency/kWh",
          "description": "Typed signal input; its quantity must match the connected output."
        },
        {
          "name": "dcPower",
          "direction": "output",
          "unit": "W",
          "description": "Observed result from the solved component or sampled controller."
        },
        {
          "name": "gridPower",
          "direction": "output",
          "unit": "W",
          "description": "Observed result from the solved component or sampled controller."
        },
        {
          "name": "loss",
          "direction": "output",
          "unit": "W",
          "description": "Observed result from the solved component or sampled controller."
        },
        {
          "name": "allowed",
          "direction": "output",
          "unit": "0 or 1",
          "description": "Observed result from the solved component or sampled controller."
        },
        {
          "name": "voltage",
          "direction": "output",
          "unit": "V",
          "description": "Observed result from the solved component or sampled controller."
        },
        {
          "name": "current",
          "direction": "output",
          "unit": "A",
          "description": "Observed result from the solved component or sampled controller."
        },
        {
          "name": "power",
          "direction": "output",
          "unit": "W",
          "description": "Observed result from the solved component or sampled controller."
        }
      ],
      "parameters": [
        {
          "key": "powerW",
          "label": "Power W",
          "unit": "W grid import (+), export (-)",
          "default": 0,
          "min": -1000000000,
          "max": 1000000000,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "importLimitW",
          "label": "Import Limit W",
          "unit": "W",
          "default": 7000,
          "min": 0,
          "max": 1000000000,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "exportLimitW",
          "label": "Export Limit W",
          "unit": "W",
          "default": 7000,
          "min": 0,
          "max": 1000000000,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "importCurrentA",
          "label": "Import Current A",
          "unit": "A",
          "default": 32,
          "min": 0,
          "max": 1000000,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "exportCurrentA",
          "label": "Export Current A",
          "unit": "A",
          "default": 32,
          "min": 0,
          "max": 1000000,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "importEfficiency",
          "label": "Import Efficiency",
          "unit": "fraction",
          "default": 0.95,
          "min": 0.01,
          "max": 1,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "exportEfficiency",
          "label": "Export Efficiency",
          "unit": "fraction",
          "default": 0.95,
          "min": 0.01,
          "max": 1,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "capacityAh",
          "label": "Capacity Ah",
          "unit": "Ah",
          "default": 100,
          "min": 1e-06,
          "max": 1000000000,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "reserveSoc",
          "label": "Reserve Soc",
          "unit": "fraction",
          "default": 0.2,
          "min": 0,
          "max": 1,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "targetSoc",
          "label": "Target Soc",
          "unit": "fraction",
          "default": 0.8,
          "min": 0,
          "max": 1,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "minimumVoltageV",
          "label": "Minimum Voltage V",
          "unit": "V",
          "default": 250,
          "min": 0.01,
          "max": 1000000,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "voltageLimitV",
          "label": "Voltage Limit V",
          "unit": "V",
          "default": 420,
          "min": 0.01,
          "max": 1000000,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "boundaryTimeS",
          "label": "Boundary Time S",
          "unit": "s",
          "default": 1,
          "min": 0.001,
          "max": 3600,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "minTemperatureK",
          "label": "Min Temperature K",
          "unit": "K",
          "default": 273.15,
          "min": 1,
          "max": 1000,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "maxTemperatureK",
          "label": "Max Temperature K",
          "unit": "K",
          "default": 318.15,
          "min": 1,
          "max": 1000,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "importPrice",
          "label": "Import Price",
          "unit": "currency/kWh",
          "default": 0.2,
          "min": 0,
          "max": 1000000,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        },
        {
          "key": "exportPrice",
          "label": "Export Price",
          "unit": "currency/kWh",
          "default": 0.1,
          "min": 0,
          "max": 1000000,
          "description": "Configured model parameter; the default is an initial editor value, not an operating recommendation."
        }
      ],
      "equations": [
        "P_grid_import = P_DC_charge / eta_import",
        "P_grid_export = -P_DC_discharge * eta_export",
        "P_loss = P_grid - P_DC"
      ],
      "example": {
        "title": "Model signed grid exchange",
        "text": "−5 kW requests export; +5 kW requests import. 5 kW exported at 95% efficiency needs about 5.26 kW battery power.",
        "url": "https://design.lemonergy.com/cosim.html?example=charging-v2g",
        "label": "Open the Studio example"
      },
      "limits": [
        "This excludes AC waveforms, synchronization, communications and certification.",
        "No islanding switches, smart-panel circuits or protection coordination are simulated."
      ],
      "evidence": [
        "js/charging-control.js",
        "js/charging-scenarios.js",
        "docs/CHARGING_BLOCKS_SPEC.md",
        "js/physical-network.js",
        "rust-core/src/charging_control.rs"
      ],
      "caseIds": [
        "v2g",
        "outage-support"
      ],
      "type": "bidirectional-grid",
      "implementationId": "bidirectional-grid",
      "url": "https://lemonergy.com/learn/glossary/blocks/bidirectional-grid/",
      "documentationUrl": "https://lemonergy.com/learn/glossary/blocks/bidirectional-grid/",
      "sourceFile": "block-library.json",
      "sourceRepository": "battery-design",
      "sourceRevision": "ef9802329b75bc15bb96885f8ed5d49425106696",
      "reviewed": "2026-10-27"
    }
  },
  "incoming": [
    {
      "id": "edge:usesBlock/outage-support/2",
      "type": "usesBlock",
      "source": "workflow:outage-support",
      "target": "block:bidirectional-grid",
      "properties": {
        "sourceFile": "wiki-blocks.json",
        "position": 2,
        "name": "Bidirectional grid / load interface",
        "type": "bidirectional-grid",
        "role": "Converts battery and grid/load power",
        "settings": [
          "importEfficiency / exportEfficiency",
          "importLimitW / exportLimitW",
          "Electrical ports p and n"
        ]
      }
    },
    {
      "id": "edge:usesBlock/v2g/1",
      "type": "usesBlock",
      "source": "workflow:v2g",
      "target": "block:bidirectional-grid",
      "properties": {
        "sourceFile": "wiki-blocks.json",
        "position": 1,
        "name": "Bidirectional grid / load interface",
        "type": "bidirectional-grid",
        "role": "Converts battery and grid/load power",
        "settings": [
          "importEfficiency / exportEfficiency",
          "importLimitW / exportLimitW",
          "Electrical ports p and n"
        ]
      }
    }
  ],
  "neighbors": [
    {
      "id": "workflow:outage-support",
      "type": "Workflow",
      "label": "Supply an outage load",
      "properties": {
        "id": "outage-support",
        "title": "Supply an outage load",
        "kind": "studio",
        "summary": "V2H illustrates outage-triggered dispatch and reserve.",
        "steps": [
          "Set outage time, load and reserve.",
          "Compare reserve with departure target."
        ],
        "example": "An ideal 10 kWh usable budget supplies 3 kW for 3.33 h before losses and limits.",
        "observe": "Reserve can hold while departure target is unmet.",
        "limits": "No islanding switches, smart-panel circuits or protection coordination are simulated.",
        "url": "https://design.lemonergy.com/cosim.html?example=charging-v2h",
        "label": "Open the Studio example",
        "evidence": [
          "js/charging-control.js",
          "js/charging-scenarios.js",
          "docs/CHARGING_BLOCKS_SPEC.md"
        ]
      }
    },
    {
      "id": "workflow:v2g",
      "type": "Workflow",
      "label": "Model signed grid exchange",
      "properties": {
        "id": "v2g",
        "title": "Model signed grid exchange",
        "kind": "studio",
        "summary": "Explicit battery and converter exchange average power.",
        "steps": [
          "Set export window and SOC reserve.",
          "Inspect power and energy."
        ],
        "example": "−5 kW requests export; +5 kW requests import. 5 kW exported at 95% efficiency needs about 5.26 kW battery power.",
        "observe": "Reserve and converter limits can reduce export.",
        "limits": "This excludes AC waveforms, synchronization, communications and certification.",
        "url": "https://design.lemonergy.com/cosim.html?example=charging-v2g",
        "label": "Open the Studio example",
        "evidence": [
          "js/charging-control.js",
          "js/charging-scenarios.js",
          "docs/CHARGING_BLOCKS_SPEC.md"
        ]
      }
    }
  ]
}
