Lemonergy · Studio block

Scoped state writer

Replaces a declared discrete state-space child state on an enabled write, then evaluates output and advances that state at the accepted sample.

Implementation ID
native-state-writer
Reviewed
2026-10-27

Behavior

Replaces a declared discrete state-space child state on an enabled write, then evaluates output and advances that state at the accepted sample. Trial evaluations read the held output without mutating state.

Interface

Scoped state writer interfaceInputs or arguments on the left, observed outputs on the right. Conserving terminals appear below the component. The tables give units and behavior.Scoped state writerStudio blockin0in1in2out0out1out2out3
Original Lemonergy interface view. Lines identify ports; they are not a completed simulation circuit.
Ports and observed outputs
NameDirectionUnitMeaning
in0input—Input; real scalar.
in1input—Replacement state; real vector [1].
in2input—Write enabled; bool scalar.
out0output—Output; real scalar.
out1output—State before update; real vector [1].
out2output—State after update; real vector [1].
out3output—Write accepted; bool scalar.

Parameters

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

Configuration fields
ParameterUnitDefaultMeaning and limits
Sample period
sampleTimeS
s1Positive period between accepted updates; outputs hold between updates.
Initial held output
tables[0]
—[0]Output held before the first accepted update, with one value per output lane.
Declared child operation
nested
—Discrete state spaceThe locally owned target operation. Its parameters, initial state, and typed ports are configured explicitly.
State transition matrix
nested.parameters.config.tables[0]
—[0.5]Matrix A in x_next = A x + B u.
Input matrix
nested.parameters.config.tables[1]
—[1]Matrix B in x_next = A x + B u.
Output matrix
nested.parameters.config.tables[2]
—[2]Matrix C in y = C x + D u.
Direct input matrix
nested.parameters.config.tables[3]
—[3]Matrix D in y = C x + D u.
Initial state
nested.parameters.config.tables[4]
—[4]Initial internal coordinates before an optional enabled replacement.

Equations and rules

  • If write enabled: internal child state ← replacement state
  • Observe x_before; then y = C x_before + D u
  • Commit x_after = A x_before + B u only after the full update succeeds

Worked example

Scoped state writer worked example

For A=0.5, B=1, C=2, D=3 and input 1, replacing the state with 10 before execution yields output 23 and next state 6.

Open Studio example after release →
Numerical checks for the bundled synthetic example
OutputTime (s)Expected valueUnitAbsolute tolerance
Output
out0
023—1e-08
State before update
out1
0[10]—1e-08
State after update
out2
0[6]—1e-08
Write accepted
out3
01—1e-08

Explore the recorded outputs

Scoped state writer recorded example

Scoped state writer / Output
Scoped state writer / Output against timeRecorded synthetic simulation values. Time in seconds; output in —.21.85022.4250.523123.5751.524.152—Time (s)
Scoped state writer / Output: 23 — at 0 s

3 actual recorded samples. Lines are visual guides between samples. Synthetic example, not measured cell data.

Download the recorded samples (JSON) · Open this Studio example after release

Use in a workflow

Scoped state writer worked example

Replaces a declared discrete state-space child state on an enabled write, then evaluates output and advances that state at the accepted sample.

  1. Scoped state writer: Replaces a declared discrete state-space child state on an enabled write, then evaluates output and advances that state at the accepted sample. Trial evaluations read the held output without mutating state.
    • Use the block reference for settings and connections.
    • Implementation tested locally; public release pending.
Open Studio example after release

Connected concepts

Limits and interpretation

  • One declared discrete linear state-space child, with 1–128 real state coordinates. No arbitrary external-block, continuous-state, or history-buffer writes.
  • Replacement is applied before output evaluation and state advancement. A failed or nonfinite update commits no partial state. Separate block instances own separate state.

Scientific and mathematical references

These sources explain the scientific and mathematical background. The behavior, interface and limits above define the Lemonergy implementation; a citation does not imply every model option in the source is implemented.

  1. Feedback Systems: System Modeling, Section 2.1, discrete-time systems

    Karl Johan Åström, Richard M. Murray · Princeton University Press; author-hosted chapter, California Institute of Technology

    Technical reference · Discrete state-space equations and the distinction between internal state and output. Scoped write ordering is a separate Lemonergy contract.

Implementation sources

This reference follows the public interface and locally verified numerical checks for an upcoming release.

Contract: Lemonergy Studio public contract · Verification record: verification-2026-10-27

  • docs/glossary/native-block-verification.json

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