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
| Name | Direction | Unit | Meaning |
|---|---|---|---|
in0 | input | — | Input; real scalar. |
in1 | input | — | Replacement state; real vector [1]. |
in2 | input | — | Write enabled; bool scalar. |
out0 | output | — | Output; real scalar. |
out1 | output | — | State before update; real vector [1]. |
out2 | output | — | State after update; real vector [1]. |
out3 | output | — | Write accepted; bool scalar. |
Parameters
Defaults are initial model values. Select values for your own model and operating conditions.
| Parameter | Unit | Default | Meaning and limits |
|---|---|---|---|
Sample periodsampleTimeS | s | 1 | Positive period between accepted updates; outputs hold between updates. |
Initial held outputtables[0] | — | [0] | Output held before the first accepted update, with one value per output lane. |
Declared child operationnested | — | Discrete state space | The locally owned target operation. Its parameters, initial state, and typed ports are configured explicitly. |
State transition matrixnested.parameters.config.tables[0] | — | [0.5] | Matrix A in x_next = A x + B u. |
Input matrixnested.parameters.config.tables[1] | — | [1] | Matrix B in x_next = A x + B u. |
Output matrixnested.parameters.config.tables[2] | — | [2] | Matrix C in y = C x + D u. |
Direct input matrixnested.parameters.config.tables[3] | — | [3] | Matrix D in y = C x + D u. |
Initial statenested.parameters.config.tables[4] | — | [4] | Initial internal coordinates before an optional enabled replacement. |
Equations and rules
If write enabled: internal child state ← replacement stateObserve x_before; then y = C x_before + D uCommit 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 →| Output | Time (s) | Expected value | Unit | Absolute tolerance |
|---|---|---|---|---|
Outputout0 | 0 | 23 | — | 1e-08 |
State before updateout1 | 0 | [10] | — | 1e-08 |
State after updateout2 | 0 | [6] | — | 1e-08 |
Write acceptedout3 | 0 | 1 | — | 1e-08 |
Explore the recorded outputs
Scoped state writer recorded example
Scoped state writer / Output3 actual recorded samples. Lines are visual guides between samples. Synthetic example, not measured cell data.
Read the selected signal as a table
| Time (s) | Value |
|---|
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.
- 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.
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.
- 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)