{
  "node": {
    "id": "block:battery-variable-energy-counter",
    "type": "Block",
    "label": "Energy counter with capacity input",
    "properties": {
      "id": "battery-variable-energy-counter",
      "name": "Energy counter with capacity input",
      "kind": "studio",
      "summary": "Integrates signed throughput. Changing capacity preserves fraction and reports revaluation separately.",
      "behavior": "Integrates signed discharge current or power over elapsed sample time. Charge efficiency applies during charging. The initial sample has zero elapsed time. Variable-capacity variants preserve the current fraction when capacity changes and report the resulting amount revaluation separately. Reset restores the initial fraction without integrating that event.",
      "ports": [
        {
          "name": "rate",
          "direction": "input",
          "unit": "W",
          "description": "Signed battery power; scalar.",
          "shape": [],
          "elementType": "real",
          "quantity": "power"
        },
        {
          "name": "reset",
          "direction": "input",
          "unit": "true / false",
          "description": "Reset; scalar.",
          "shape": [],
          "elementType": "bool",
          "quantity": "dimensionless"
        },
        {
          "name": "capacity",
          "direction": "input",
          "unit": "J",
          "description": "Energy capacity (J); scalar.",
          "shape": [],
          "elementType": "real",
          "quantity": "energy"
        },
        {
          "name": "fraction",
          "direction": "output",
          "unit": "1 (fraction)",
          "description": "State of energy; scalar.",
          "shape": [],
          "elementType": "real",
          "quantity": "fraction"
        },
        {
          "name": "throughput",
          "direction": "output",
          "unit": "J",
          "description": "Net throughput (J); scalar.",
          "shape": [],
          "elementType": "real",
          "quantity": "energy"
        },
        {
          "name": "revaluation",
          "direction": "output",
          "unit": "J",
          "description": "Capacity revaluation (J); scalar.",
          "shape": [],
          "elementType": "real",
          "quantity": "energy"
        },
        {
          "name": "boundary",
          "direction": "output",
          "unit": "J",
          "description": "Boundary amount (J); scalar.",
          "shape": [],
          "elementType": "real",
          "quantity": "energy"
        }
      ],
      "parameters": [
        {
          "key": "sampleTimeS",
          "label": "Sample interval (s)",
          "unit": "s",
          "default": 1,
          "description": "Positive sample interval. Initialization has zero elapsed time; subsequent accepted samples update memory."
        },
        {
          "key": "capacity",
          "label": "Energy capacity (J)",
          "unit": "J",
          "default": 7200,
          "description": "Energy capacity (J). This is an editable model input; the default belongs to the synthetic worked example."
        },
        {
          "key": "initialFraction",
          "label": "Initial SOE (0–1)",
          "unit": "0–1",
          "default": 0.8,
          "description": "Initial SOE (0–1). This is an editable model input; the default belongs to the synthetic worked example."
        },
        {
          "key": "chargeEfficiency",
          "label": "Charging efficiency (0–1)",
          "unit": "0–1",
          "default": 1,
          "description": "Charging efficiency (0–1). This is an editable model input; the default belongs to the synthetic worked example."
        }
      ],
      "equations": [
        "amount[k] = amount[k-1] - effectiveRate[k] * elapsedTime",
        "fraction = clamp(amount / capacity, 0, 1)",
        "charge capacity in coulombs = 3600 * capacityAh"
      ],
      "example": {
        "title": "Energy counter with capacity input worked example",
        "text": "Use the defaults below with Signed battery power = 2 W, Reset = 0 true / false, Energy capacity (J) = 7200 J. At 0 s, State of energy is 0.8 1 (fraction). Additional checks are listed below.",
        "url": "https://design.lemonergy.com/cosim.html?example=block-battery-variable-energy-counter",
        "label": "Open Studio example",
        "checks": [
          {
            "port": "fraction",
            "atS": 0,
            "value": 0.8,
            "tolerance": 1e-08,
            "label": "State of energy",
            "unit": "1 (fraction)"
          },
          {
            "port": "throughput",
            "atS": 0,
            "value": 0,
            "tolerance": 0,
            "label": "Net throughput (J)",
            "unit": "J"
          },
          {
            "port": "fraction",
            "atS": 1,
            "value": 0.7997222222222222,
            "tolerance": 1e-08,
            "label": "State of energy",
            "unit": "1 (fraction)"
          }
        ],
        "inputs": [
          {
            "port": "rate",
            "label": "Signed battery power",
            "value": 2,
            "unit": "W"
          },
          {
            "port": "reset",
            "label": "Reset",
            "value": 0,
            "unit": "true / false"
          },
          {
            "port": "capacity",
            "label": "Energy capacity (J)",
            "value": 7200,
            "unit": "J"
          }
        ]
      },
      "limits": [
        "Current or power bias accumulates. Fraction clipping is reported as a boundary amount; it does not make the connected plant respect that boundary. Energy variants need capacity in joules.",
        "The example verifies numerical behavior for synthetic parameters. Cell characterization and validation for an intended use are separate tasks."
      ],
      "availability": {
        "status": "released",
        "label": "Available in Lemonergy Studio",
        "detail": "The bundled example is available in the production release verified on 28 October 2026. The parameters and examples here are synthetic teaching fixtures, not a characterized cell or a validated operating limit."
      },
      "references": [
        "plett-modeling"
      ],
      "evidence": [
        "docs/glossary/native-block-verification.json"
      ],
      "sourceRepository": "Lemonergy Studio public contract",
      "sourceRevision": "verification-2026-10-27",
      "caseIds": [
        "native-battery-variable-energy-counter"
      ],
      "exampleTraces": [
        {
          "id": "battery-variable-energy-counter",
          "url": "https://lemonergy.com/learn/glossary/api/traces/battery-variable-energy-counter.json?v=621c07293f4b",
          "title": "Energy counter with capacity input recorded example",
          "exampleId": "block-battery-variable-energy-counter",
          "source": "Executed synthetic Lemonergy Studio example",
          "recordedOn": "2026-10-28",
          "points": 2,
          "channels": 4,
          "omittedChannels": 0,
          "interpolation": "step",
          "solver": {
            "method": "dormand-prince-45",
            "reason": "no-continuous-states"
          }
        }
      ],
      "type": "battery-variable-energy-counter",
      "implementationId": "battery-variable-energy-counter",
      "url": "https://lemonergy.com/learn/glossary/blocks/battery-variable-energy-counter/",
      "documentationUrl": "https://lemonergy.com/learn/glossary/blocks/battery-variable-energy-counter/",
      "sourceFile": "block-library.json",
      "reviewed": "2026-10-27",
      "releaseEvidence": {
        "environment": "production",
        "status": "verified",
        "revision": "e76cadfc203e15eb41f3478d8b1044a5b851953d",
        "verifiedOn": "2026-10-28",
        "exampleUrls": [
          "https://design.lemonergy.com/cosim.html?example=block-battery-variable-energy-counter"
        ]
      }
    }
  },
  "incoming": [
    {
      "id": "edge:usesBlock/native-battery-variable-energy-counter/0",
      "type": "usesBlock",
      "source": "workflow:native-battery-variable-energy-counter",
      "target": "block:battery-variable-energy-counter",
      "properties": {
        "sourceFile": "wiki-blocks.json",
        "position": 0,
        "name": "Energy counter with capacity input",
        "type": "battery-variable-energy-counter",
        "role": "Integrates signed discharge current or power over elapsed sample time. Charge efficiency applies during charging. The initial sample has zero elapsed time. Variable-capacity variants preserve the current fraction when capacity changes and report the resulting amount revaluation separately. Reset restores the initial fraction without integrating that event.",
        "settings": [
          "Use the parameter values in the block reference.",
          "Bundled example verified on the production release of 28 October 2026."
        ]
      }
    }
  ],
  "outgoing": [
    {
      "id": "edge:cites/block:battery-variable-energy-counter/reference:plett-modeling",
      "type": "cites",
      "source": "block:battery-variable-energy-counter",
      "target": "reference:plett-modeling",
      "properties": {
        "sourceFile": "block-library.json",
        "scope": "Scientific or mathematical background; implementation scope is stated by the block contract"
      }
    }
  ],
  "neighbors": [
    {
      "id": "workflow:native-battery-variable-energy-counter",
      "type": "Workflow",
      "label": "Energy counter with capacity input worked example",
      "properties": {
        "id": "native-battery-variable-energy-counter",
        "title": "Energy counter with capacity input worked example",
        "kind": "studio",
        "summary": "Integrates signed throughput. Changing capacity preserves fraction and reports revaluation separately.",
        "steps": [
          "Review the block inputs, units and model limits.",
          "Open the Studio example and run its bundled model.",
          "Compare the output channels with the numerical checks; change one input and run again."
        ],
        "example": "Use the defaults below with Signed battery power = 2 W, Reset = 0 true / false, Energy capacity (J) = 7200 J. At 0 s, State of energy is 0.8 1 (fraction). Additional checks are listed below.",
        "observe": "Inspect the outputs and numerical checks on the block reference page.",
        "limits": "Current or power bias accumulates. Fraction clipping is reported as a boundary amount; it does not make the connected plant respect that boundary. Energy variants need capacity in joules. The example verifies numerical behavior for synthetic parameters. Cell characterization and validation for an intended use are separate tasks.",
        "url": "https://design.lemonergy.com/cosim.html?example=block-battery-variable-energy-counter",
        "label": "Open Studio example",
        "evidence": [
          "docs/glossary/native-block-verification.json"
        ]
      }
    },
    {
      "id": "reference:plett-modeling",
      "type": "Reference",
      "label": "Extended Kalman filtering for battery management systems of LiPB-based HEV battery packs: Part 2. Modeling and identification",
      "properties": {
        "title": "Extended Kalman filtering for battery management systems of LiPB-based HEV battery packs: Part 2. Modeling and identification",
        "publisher": "Journal of Power Sources",
        "url": "https://doi.org/10.1016/j.jpowsour.2004.02.032",
        "type": "Research article",
        "scope": "Battery charge balance, open-circuit voltage, ohmic loss, polarization dynamics and model identification; parameters require cell-specific data.",
        "year": 2004,
        "authors": [
          "Gregory L. Plett"
        ],
        "accessed": "2026-10-27"
      }
    }
  ]
}
