Lemonergy · Studio block

Sample difference check

Checks absolute per-sample change against a strict maximum. The first comparison is skipped and reports zero change.

Implementation ID
native-check-gradient
Reviewed
2026-10-27

Behavior

difference[0] = 0; difference[k] = |value[k] − value[k−1]|. pass = (difference < configured maximum).

Interface

Sample difference check interfaceInputs or arguments on the left, observed outputs on the right. Conserving terminals appear below the component. The tables give units and behavior.Sample difference checkStudio blockin0out0out1
Original Lemonergy interface view. Lines identify ports; they are not a completed simulation circuit.
Ports and observed outputs
NameDirectionUnitMeaning
in0input1Value; real scalar.
out0output1Pass; bool scalar.
out1output1Absolute sample difference; real scalar.

Parameters

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

Configuration fields
ParameterUnitDefaultMeaning and limits
Sample period
sampleTimeS
s0.1Positive interval between sample instants. Values are held between samples.
Minimum 0
Maximum absolute sample difference
params[0]
10.3Configured value for Maximum absolute sample difference.

Equations and rules

  • difference[0] = 0; difference[k] = |value[k] − value[k−1]|
  • pass = (difference < configured maximum)

Worked example

Sample difference check — worked example

Value = 1. Pass at 0 s = 1; Absolute sample difference at 0 s = 0.

Open Studio example after release →
Numerical checks for the bundled synthetic example
OutputTime (s)Expected valueUnitAbsolute tolerance
Pass
out0
0111e-09
Absolute sample difference
out1
0011e-09

Explore the recorded outputs

Sample difference check recorded example

Sample difference check / Absolute sample difference
Sample difference check / Absolute sample difference against timeRecorded synthetic simulation values. Time in seconds; output in —.-0.50-0.250.2500.50.250.750.51—Time (s)
Sample difference check / Absolute sample difference: 0 — at 0 s

11 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

Sample difference check — worked example

Checks absolute per-sample change against a strict maximum. The first comparison is skipped and reports zero change.

  1. Sample difference check: difference[0] = 0; difference[k] = |value[k] − value[k−1]|. pass = (difference < configured maximum).
    • Use the block reference for settings and connections.
    • Implementation tested locally; public release pending.
Open Studio example after release

Connected concepts

Limits and interpretation

  • Checks change per sample, not change divided by elapsed time; the first comparison is skipped.

Reference basis

This software operation is defined by its public contract and worked example; no external research result is claimed.

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)