How the replay works

Where is the Python?

There is none here, and nothing is installed. The relays you are stepping through are running in your browser, from the same machine files and the same PureScript simulation that run in Python beside pandapower in the demo. Only pandapower's power-flow answers were recorded, from the demo, and this page replays them.

1

Why a replay

The demo is a Python program: protection relays written in PureScript, compiled by Pythia to Python, running beside pandapower. A static website cannot run a Python process or a numerical library. We do not expect everyone who is curious to install and build the full project, so we made this.

It is not a canned demo, and it is not all running in your browser either. The Python side is canned: pandapower's answers were recorded. The PureScript side runs here for real: the analysis, the protection simulation and the relays themselves.

2

One source, two compilers

The same PureScript source is compiled twice: by Pythia (purepy) to Python, for the demo, and by purs, the standard compiler, to JavaScript, for this page. Both run the same protection simulation, Grid.Protection.protect, from the same two relay machine files.

The simulation never calls pandapower itself. It asks a solver: an interface in the source with a few operations, describe the network and solve its power flow among them. In the demo the solver is pandapower. In the replay it is a recording (Grid.Transcript.replaying) that answers each question with the answer pandapower gave when it was asked the same question.

The demo, in Python The replay, in your browser PureScript source analysis and relay simulation Pythia (purepy) to Python purs to JavaScript API compiled to Python The Relays compiled to JavaScript Relay machines Glassbox, 2 × JSON Conformance vectors 138, Node + Python pandapower power flow, N-1 sweep describe, solve, flows, sweep Recorded answers pandapower's, as JSON replayed recorded offline Native reference Python, no PureScript diffed with the API, to 1e-9 Replay check JavaScript = Python every recorded run, as text builds, loads, calls held equal by a check PureScript source analysis and relay simulation Pythia purs Relay machines Glassbox JSON API Python The Relays JavaScript pandapower power flow Recording of pandapower Reference plain Python Replay check byte for byte builds, loads, calls held equal by a check
Both programs: one PureScript source compiled to Python by Pythia, where it runs beside pandapower, and to JavaScript by purs for the replay, this page. Both load the same two Glassbox relay machines. The conformance vectors hold the machines' JavaScript and Python builds, at default settings. The replay answers from a recording of pandapower. A native Python reference checks the demo; the replay check holds the JavaScript to Python's answers.
3

What was recorded

check/record_stepper.py runs every run this page offers through the demo's own generated Python, against pandapower, and writes down every question the simulation asks and every answer it gets. The space is fixed in one place in the source (Grid.Stepper), which the recorder, the page and the check all read:

That is 2,624 runs, and they are what the choices above the replay offer. A question many runs ask, such as the intact network at a load factor, is kept once: 3,064 recorded answers in all, in one file per load factor, 9.2 MB as written or about 1.6 MB gzipped. The page loads only the file for the load factor it shows, so a first visit is about 140 KB gzipped, the page's code included.

4

What holds it to the demo

Python and JavaScript agreeing says the source means the same on both. It does not say the model is right; what the model is not is on the front page.

5

Asking for something not recorded

The choices above cover exactly what was recorded, but the page's address can ask for more: two lines out, say. The replay looks for the answer in its recording, does not find it, and says so in words: which power flow it needed, and that the demo can answer it.

The replay asked for lines 9 and 35 out at load factor 0.70: under the heading 'This state was not recorded' it says the run asks for a power flow with line 9, 35 out that was not recorded, and that the replay answers only from pandapower's recorded power flows.
The replay asked for lines 9 and 35 out together. The words are the page's own, built from the question the recording could not answer.
6

What the replay cannot do

Anything outside the recorded choices: a load factor of your own, two lines out, a relay setting of your own, the N-1 sweep over all 41 lines. Each needs pandapower, asked live, and that is the demo.

Grid Explorer, a Hylograph exhibit. The front page.