Test Suite
test/runtests.jl loads tests by profile. Profile selection precedence:
- CLI argument (
julia --project=. test/runtests.jl <profile>) SPARLECTRA_TEST_PROFILE- default
fast
Pkg.test() uses the same runner and therefore the fast profile unless SPARLECTRA_TEST_PROFILE is set:
julia --project=. -e 'using Pkg; Pkg.test()'Test profiles
Every test group belongs to exactly one of eleven base profiles; extended is the union of the eight that are neither fast, install nor workshops, and all runs everything. The documentation build is a gate of its own (sh tools/run_gates.sh docs), not a profile: a change to Markdown or a docstring needs the docs build and nothing else. Through tools/run_gates.sh the docs build and the workshops profile run in a work tree of the commit, which holds the tracked files only: a page that reads a file that is in no repository fails there as it would on a fresh checkout. Both refuse to start on uncommitted changes of tracked files.
| Profile | Command | Scope | When to run |
|---|---|---|---|
fast (default) | julia --project=. test/runtests.jl fast | Results against an independent truth only: the MATPOWER file headers of the shipped synthetic cases, the ENTSO-E SmallGrid and MicroGrid against their SV, hand calculations, the PowSyBl fixtures and Sparlectra's own test nets against OpenLoadFlow; plus the docstring check and the API smoke. A result recorded from an earlier Sparlectra run is not a truth and does not belong here | Every pull request and every commit; CI runs this one |
pf | julia --project=. test/runtests.jl pf | Network model, terminal status, the rectangular Newton core and its linear solver, DC power flow, distributed slack, islands, external grid, auto mode, short circuit, parallel foundation, contingencies, scenarios, all controllers, the extended grid and contingency sets, the scenario engine, APSLF | After a change to the power-flow path, its controllers or the scenario engine |
se | julia --project=. test/runtests.jl se | State estimation, observability, topology validation, the measurement table | After a change to the estimator or the measurement model |
config | julia --project=. test/runtests.jl config | Configuration surface and validation, configuration documentation coverage, repository hygiene | After a change to a configuration key, a default or the documentation of one |
webui | julia --project=. test/runtests.jl webui | The local browser UI, with the state estimation page in a file of its own | Before every Web UI pull request; fast proves nothing about app/src/webui |
extd | julia --project=. test/runtests.jl extd | The service layer (run_sparlectra_api, the local PowerFlow service) and the shipped demo cases | After a change to the service layer or a demo case |
cgmes | julia --project=. test/runtests.jl cgmes | CGMES import and export with the checked-in deliveries, the series check and union of CGMES snapshots, the synthetic SSH series | After a change to the CGMES importer or exporter, a fixture or the shared network helpers they call |
formats | julia --project=. test/runtests.jl formats | The other case formats: MATPOWER parser and examples, SCF, SCF time series, DTF, PowSyBl, synthetic grids | After a change to a format reader or writer |
install | julia --project=. test/runtests.jl install | The installation path: a copy of the checkout without the application manifest, start_webui.jl --env-only twice, the first start sets up and compiles, the second does nothing; the develop step of the sysimage build replacing a checkout of another version; plus the tests that start child processes (the example suite runners, group example_infra) | Before a release; about a minute of cold compile, so not part of extended |
workshops | julia --project=. test/runtests.jl workshops | Every Literate workshop under docs/lit top to bottom in a fresh module, with the assert next to each printed number | After a change to a workshop or to an API a workshop uses; before the notebooks are regenerated |
legacy | julia --project=. test/runtests.jl legacy | Testsets that pin an earlier change (an issue, a bug, a bit-identity or off-path guarantee), cut from their area profile; each legacy group includes the file it was cut from for its helpers. Version 0.60.0 removed the ones that pinned removed paths (see the legacy section) | Before a release and on a change to a protected file; not on CI, not per commit |
extended | julia --project=. test/runtests.jl extended | pf, se, config, webui, extd, cgmes, formats and legacy in that order | Before a merge |
all | julia --project=. test/runtests.jl all | fast, extended, then install and workshops | Declaring a branch merge-ready, together with the docs build |
threads | sh tools/run_gates.sh threads (runs julia --threads=4 --project=. test/runtests.jl threads) | The parallel-vs-serial comparisons of every parallel site, five times in one process with four threads | Before every release, and after a change to a parallel site (short-circuit sweep, island power flow, scenario engine and N-1 batch, island-wise SE, QSTS, the CGMES SSH series union) |
The other profiles run single-threaded by default. There every parallel site takes its serial loop, so a parallel-vs-serial comparison checks the serial path against itself; its report line says SKIPPED, single-threaded process. The threads profile runs these comparisons threaded. It refuses to start with one thread and runs its groups five times in one process, because a single threaded run can pass by chance. Its groups (below) are runners that the area groups call as well, so they belong to no base profile.
tools/run_gates.sh <profile> --threads=N starts the test process of any profile with N threads (threads defaults to 4). sh tools/run_gates.sh extended --threads=4 is the threaded extended run: every comparison reports RAN with 4 threads, and the rest of the suite runs with the parallel sites on their threaded path. With --strands=2 the extended run starts two processes at once under the one gate lock, the profiles extended_a (cgmes, se, config, legacy) and extended_b (pf, webui, extd, formats), which together are exactly extended; each strand prints its own summary, a last line adds them up, and the gate fails when either strand fails.
sh tools/run_gates.sh set --threads=4 is the full gate set of one commit under one lock: three strands at once, set_a (cgmes, se, config), extended_b and set_c (fast, legacy), the last followed by the docs build and the workshops profile in a work tree of the commit; then the threads profile alone. The three strands together are exactly fast plus extended. The gate prints the output of every part, one line per part with its exit code and summary, and one line over the test parts; it fails when any part fails. install is not part of the set.
After every test profile, strand or part the gate prints run_gates: <profile> skipped/broken: <n>, the Broken count of its Test Summary (@test_skip counts as Broken), and at the end one line run_gates: profiles with skipped/broken tests: ... (or none). Without the FOR001/FOR002 files (in data/DTF or SPARLECTRA_DTF_DIR) the DTF validation tests skip with a note and add nothing to that count. With --release such a count fails the gate: it exits with 4 after all profiles ran, unless a profile failed, which keeps its own exit code. Release gate sets run with --release; the daily run records the line without it. The service layer and the Web UI are the SparlectraApp package under app/; the runner puts that directory on the load path and loads the package for every profile, so webui, the service part of extd and the application smoke test of fast (one power flow and one state estimation through the service API) run from the library checkout with the commands above.
Group membership (the table TEST_PROFILES in test/runtests.jl is the source; the runner refuses a group in two profiles or in none):
| Profile | Groups |
|---|---|
fast | docstrings, api_smoke, hand_calculations, matpower_header, entsoe_sv, openloadflow |
pf | core_model, terminal_status, powerflow_rectangular, factorized_linear_solver, 3wt_phase_taps, dc_powerflow, distributed_slack, island_diagnostics, external_grid, auto_powerflow, short_circuit, parallel_foundation, contingency, scenarios, controls, core_model_extended, contingency_extended, scenario_engine, apslf |
se | state_estimation, observability, topology_validation, measurement_table |
config | configuration, configuration_docs, repository_hygiene |
webui | webui, webui_extended, webui_state_estimation |
extd | programmatic_api, programmatic_api_extended, demo_cases |
cgmes | cgmes_importer, cgmes_export, cgmes_series, cgmes_ssh_series |
formats | matpower_metadata, scf, scf_series, matpower_examples, synthetic_grids, dtf_extended, powsybl_importer |
legacy | one group legacy_<file> per test file that lost testsets to it (list in the section on the legacy profile) |
install | install, example_infra |
workshops | workshops |
threads (not a base profile) | short_circuit_parallel, island_powerflow_parallel, contingency_parallel, state_estimation_parallel, multi_area_parallel, qsts_parallel, cgmes_ssh_series_parallel |
The fast profile
fast checks results against a truth that does not come from Sparlectra:
| Truth | Group | Files |
|---|---|---|
The solution the generator wrote into the header of the shipped MATPOWER cases (sp_case9, sp_case118, sp_case300, sp_case1354): Vmin, Vmax, slack and PV generation (gross, a bus with a load reports load plus export), losses, highest loading, Q-limit count | matpower_header | test/fast/ref_matpower_header.jl |
The SV profile of an ENTSO-E conformity set (SmallGrid, MicroGrid BE and NL, ReliCapGrid Galia; MicroGrid and Galia are read from the CGMES cache and report SKIPPED when missing) | entsoe_sv | test/fast/ref_entsoe_sv.jl |
| Hand calculations with the derivation in the test comment (DC 3-bus, generation of a slack or PV bus with a load, short circuit, and closed-form AC cases: a two-bus feeder, a phase shifter after the MATPOWER manual, a three-winding transformer in the star equivalent) | hand_calculations | test/fast/ref_hand_calculations.jl |
The OpenLoadFlow solution carried by the shipped PowSyBl bundles, and the OpenLoadFlow solutions of the test grids, the CIGRE HV net, sp_case14 and MATPOWER case14 and case118 in test/fixtures/openloadflow | openloadflow | test/fast/ref_openloadflow.jl |
| Docstring placement, and the service API smoke (one power flow and one state estimation) | docstrings, api_smoke | test/test_docstrings.jl, test/fast/ref_api_smoke.jl |
Results recorded from earlier Sparlectra runs (the demo-case fixtures, the N-1 CSV, byte fixtures) are memory, not truth, and stay out of fast. The files of a profile that leaves fast have to leave its include path as well: a profile that loads the same files and calls fewer testsets saves nothing, since the time is compilation. A test that pins an earlier change goes to legacy, a feature test to the profile of its area.
The legacy profile
legacy holds the testsets that pin an earlier change: an issue number, a bug, a bit-identity or off-path guarantee. They were cut from their area profile. Version 0.60.0 removed the ones listed below and rewrote the tap estimation testsets of legacy_state_estimation for the step-state model. A group legacy_<file> includes the file the testsets were cut from, for the helpers they use, and then test_legacy_<file>.jl next to it. A testset that was in doubt stayed in its area profile.
Run legacy before a release and on a change to a protected file (rectangular_network_solver.jl, entrypoint.jl, run_api.jl, control_framework.jl, configuration.jl, Sparlectra.jl). It is part of extended and all, and the CI does not run it.
A regression test for a new bug goes to the legacy group of its area. If the bug was a wrong result on a reference network, the reference test in fast is extended instead.
Version 0.60.0 removed the testsets that pinned removed paths, wording or an earlier run, and moved the groups that check current behaviour back to their area: the testsets of legacy_contingency to contingency (pf, the Web UI contingency service to programmatic_api_extended in extd), legacy_testgrid to core_model, legacy_auto_powerflow to auto_powerflow, legacy_observability to observability, legacy_topology_validation as the group topology_validation to se (the file keeps its name while the tap estimation work edits it), the rest of legacy_configuration_coverage to configuration, the busbar coupler testset of legacy_dc_powerflow to dc_powerflow, and the state estimation block of legacy_webui to the group webui_state_estimation in webui. Deleted with their groups: legacy_3wt_phase_taps, legacy_net_cache, legacy_piline_g, legacy_matpower_example, legacy_phase_tap_table, legacy_tap_changer_model, legacy_distributed_slack and pv_voltage_residuals.
| Group | Runner file | Cut from |
|---|---|---|
legacy_measurement_table | test/test_legacy_measurement_table.jl | test/test_measurement_table.jl |
legacy_state_estimation | test/test_legacy_state_estimation.jl | test/test_state_estimation.jl |
legacy_dtf_matpower_export_validation_example | test/extended/test_legacy_dtf_matpower_export_validation_example.jl | test/extended/test_dtf_matpower_export_validation_example.jl |
legacy_dtf_importer | test/extended/test_legacy_dtf_importer.jl | test/extended/test_dtf_importer.jl |
legacy_webui_extended | test/test_legacy_webui_extended.jl | test/test_webui_extended.jl |
legacy_webui | test/test_legacy_webui.jl | test/test_webui.jl |
legacy_voltage_dependent_control | test/test_legacy_voltage_dependent_control.jl | test/test_voltage_dependent_control.jl |
legacy_upfc_control | test/test_legacy_upfc_control.jl | test/test_upfc_control.jl |
legacy_tap_controller | test/test_legacy_tap_controller.jl | test/test_tap_controller.jl |
legacy_solver_interface | test/test_legacy_solver_interface.jl | test/test_solver_interface.jl |
legacy_series_reactance_control | test/test_legacy_series_reactance_control.jl | test/test_series_reactance_control.jl |
legacy_scf | test/test_legacy_scf.jl | test/test_scf.jl |
legacy_scenarios | test/test_legacy_scenarios.jl | test/test_scenarios.jl |
legacy_pv_voltage_residuals | test/test_legacy_pv_voltage_residuals.jl | test/test_pv_voltage_residuals.jl (deleted; the group includes test/testgrid.jl for its helpers) |
legacy_powsybl_importer | test/test_legacy_powsybl_importer.jl | test/test_powsybl_importer.jl |
legacy_matpower_metadata | test/test_legacy_matpower_metadata.jl | test/test_matpower_metadata.jl |
legacy_island_diagnostics | test/test_legacy_island_diagnostics.jl | test/test_island_diagnostics.jl |
legacy_hvdc_pair_control | test/test_legacy_hvdc_pair_control.jl | test/test_hvdc_pair_control.jl |
legacy_factorized_linear_solver | test/test_legacy_factorized_linear_solver.jl | test/test_factorized_linear_solver.jl |
legacy_external_grid | test/test_legacy_external_grid.jl | test/test_external_grid.jl |
legacy_demo_cases | test/test_legacy_demo_cases.jl | test/test_demo_cases.jl |
legacy_dc_powerflow | test/test_legacy_dc_powerflow.jl | test/test_dc_powerflow.jl |
legacy_cgmes_importer | test/test_legacy_cgmes_importer.jl | test/test_cgmes_importer.jl |
legacy_cgmes_export | test/test_legacy_cgmes_export.jl | test/test_cgmes_export.jl |
legacy_apslf | test/test_legacy_apslf.jl | test/test_apslf.jl |
legacy_api | test/test_legacy_api.jl | test/test_api.jl |
legacy_pv_voltage_residuals also checks the flat start of its phase-shifted PV net: with the slack at 50 degrees every bus starts at the slack angle, and with power_flow.start_mode.rotate_behind_pst the PV bus behind the 30 degree transformer starts at 20 degrees (0.60.0).
The tap estimation on step states (0.60.0) has testsets in two legacy groups. legacy_state_estimation (test/test_legacy_state_estimation.jl) holds the W2 link allocation, the island-wise partition, the PF-equivalence gate, the roundtrip and fixation tests, the release guards, the determinability guard and the run configuration as an argument (#381); the state_estimation row below marks them. legacy_webui: in "state estimation form settings are case scope (issue #377)" the checkbox "estimate taps" (state_estimation.tap_estimation.enabled) is checked on spcase14 and on feeder3hardpv_A by its default, and a saved false wins.
Which profile after which change
sh tools/run_gates.sh map <path>... (or map --since <ref>) prints the profiles a change has to run, in run order; it runs nothing. fast goes with every code change.
| Changed path | Profiles |
|---|---|
| a protected file (list above) | fast, pf, legacy |
src/stateestimation, src/numerics | fast, se |
src/adapters/cgmes | fast, cgmes, se |
src/adapters/scf, pgm, matpower | fast, formats, extd |
src/adapters/dtf, powsybl, src/import | fast, formats |
src/config | fast, config |
app/src/api | fast, extd |
app/src/webui | fast, webui |
any other file in src | fast, pf |
| a test file | the profile of its group; legacy as well when a test_legacy_ file was cut from it |
docs/lit | workshops, docs |
tools, Project.toml, .github | install |
docs/src, Markdown | docs |
| a release | every profile, legacy, install, workshops, docs |
Runner switches and output
SPARLECTRA_TEST_SKIP_GROUPS(comma-separated group names) drops named groups from any profile and prints every skipped group at the start of the run. It exists for the app build workload (tools/app_workload_runtime.jl); do not use it to get a green development or CI run.SPARLECTRA_TEST_SHOW_WARNINGS=1lets@warnrecords from Sparlectra modules reach the console. By default the runner drops them: the tests exercise deprecated configuration values, version-less YAML files, non-case keys handed towrite_case_configand advisory topology prechecks on purpose. Errors, log records from other packages, and@test_logsassertions are not affected.SPARLECTRA_TEST_VERBOSE=1or--verbose(julia --project=. test/runtests.jl fast --verbose) shows the full test output; the profile selection is unchanged.SPARLECTRA_TEST_GC_BETWEEN_GROUPS=1requests a GC cycle after each completed group.SPARLECTRA_TIMING_TESTS=1enables the runtime-scaling legs (seescenario_enginebelow).SPARLECTRA_SYSIMAGE_TRACE_TESTS=1makes the sysimage workload trace the fast profile instead of its curated list of interactive paths (see Sysimage), for a comparison only.tools/run_gates.shstarts Julia with--startup-file=no: a personalstartup.jlthat loads Revise invalidates hundreds of method instances of the system image, which the run then infers again. Use the same flag when runningtest/runtests.jlby hand on such a machine.
Default output is compact: the selected profile, one line for the include phase (parsing and compiling the testset bodies), one [i/n] marker per group (n is the number of groups in the profile), and Julia's final test summary. Each group's line says PASS, or FAIL with the number of failed and errored tests of the group, and carries wall time, compile and recompile time, allocations and GC time, so a slow group can be told apart from a group that merely compiled a lot. Import diagnostics, auto-profile tables, Q-limit tables and the rectangular/Q-limit diagnostic blocks are suppressed (they remain available through solver verbose > 0). Two things surface immediately: captured lines containing SKIPPED or RAN and the report lines of the parallel-vs-serial comparisons (parallel comparison <name>: RAN with 4 threads or SKIPPED) are re-printed under the group's line, so an availability-gated testset never skips invisibly and every run says which comparisons ran threaded; and Test Failed at / Error During Test at blocks are replayed to stderr under the group line.
Test framework: fast
include fast: 12.345 s (...)
[1/6] docstrings ... PASS 1.234 s (...)
[2/6] api_smoke ... PASS ...
...
[6/6] openloadflow ... PASS ...Reference timings
Measured warm on the development machine (16 cores, Julia 1.13, package images built with the full precompile workload, each profile in its own process, the second run with the compile cache of both packages in place, also for the child processes some tests start; the first run after a source change does not count): fast 28 to 31 s, pf 151 s, se 49 s, config 23 s, cgmes 47 s, formats 125 s, extd 65 s, webui 150 s, legacy 223 s (one thread, test time without the Julia start), install about 75 s. The acceptance limit for fast is 60 s, separate from the measured range. A profile that grows by more than ten percent against these numbers needs a cause before the change is committed; the numbers are updated here on purpose, never silently. A run right after a source change can show more, because the sysimage dry-run test starts a child process with its own compile cache.
The image matters as much as the code: on the default image (precompile workload off, the install default) every profile compiles the solver paths itself and takes roughly 1.8 times these numbers (webui test group 185 s instead of 69 s, measured on one commit). tools/run_gates.sh therefore rebuilds both images with SPARLECTRA_PRECOMPILE_WORKLOAD=full when the loaded image was not built with it (the mode is baked into the image as PRECOMPILE_WORKLOAD_MODE; an image without the constant counts as unknown and is rebuilt), announces the rebuild with its duration, and a comparison against the reference is only valid on such a run. Measured this way the extended profiles add up to about 14 minutes. The gate loads the library from the root environment and from app/ (the docs build also from docs/); when their manifests resolve a shared package at different versions, the library gets one compile cache per environment and every source change builds it more than once. tools/run_gates.sh warns about that drift; updating both manifests to the same versions removes it. CI runs the fast profile on the default image, so the install path (no workload, every path compiled on first use) keeps a gate of its own.
Per-group seconds are dominated by Julia compilation, and which group pays depends on run order: the first group that touches a code path compiles it for everyone after. Judge a "group got slower" observation against warm times, never against a single group's cold seconds. Two conventions keep the compile share down and are expected of new tests and new service code:
- Every
@testset "..." begin ... endbody is wrapped asbegin (function () ... end)() end. Julia infers one function body at a time, and the cost grows faster than the length. A testset body that contains areturnof its own scope, aconst, a type definition,using/importor@evalcannot be wrapped and stays as it is. - A long function that takes loosely typed arguments (a callback, a
nothing-or-value setting, anAbstractDict) is compiled once per distinct argument type combination. The API entry, the state-estimation service and the configuration context take a thin keyword wrapper that puts those values behind one concrete carrier struct (or a@nospecialize); the options struct_ApiRunOptionsinapp/src/api/run_api.jlis the pattern.
Fast versus extended ownership
"Extended" here means the profiles that are not fast (pf, se, config, webui, extd, cgmes, formats, legacy).
| Area | fast | Extended |
|---|---|---|
| Power flow | AC solution of the four shipped MATPOWER cases against their header (Vmin, Vmax, slack and PV generation, losses, highest loading), DC reference values, the closed-form hand cases | Solver options, Q-limit handling, islands, controllers, scenarios, contingencies (pf); the pins of earlier changes (legacy) |
| CGMES and formats | SmallGrid and MicroGrid against their SV profile, the PowSyBl bundles against OpenLoadFlow | Importer and exporter behavior (cgmes, formats) |
| State estimation | A noise-free table on the SmallGrid reproduces the SV state | Estimator, observability, measurement table (se) |
| Service layer | One power flow and one state estimation through run_sparlectra_api | The service in full, the demo cases (extd) |
| Web UI | nothing | webui: fast proves nothing about app/src/webui |
| Documentation/hygiene | The parser-based docstring check (docstrings): every docstring sits directly on the definition it documents, in every tracked file below src/, app/src/, ext/, test/ and examples/ | Configuration documentation consistency and normalized tracked-path/content repository hygiene scans, plus the reference-page coverage assertion (config) |
Case files and fixtures
Large MATPOWER and DTF cases are not part of the repository. Tests look for them in the directory resolved by Sparlectra.large_cases_dir():
SPARLECTRA_LARGE_CASES_DIR, if set (override for CI and special setups)- otherwise the Web UI user case directory (
~/.local/state/sparlectra/webui/data/mpoweron Linux,%LOCALAPPDATA%\Sparlectra\WebUI\data\mpoweron Windows)
Test groups that need a large case check availability and report SKIPPED when the file is absent; the fast profile does not depend on any large case. Tests only read from this directory; generated files go to mktempdir. data/mpower/ in the repository holds fixtures only, and the gate check fails on untracked files there. The assertion count depends on that directory, so a measurement has to say which count it was taken with; the SKIPPED lines say which run happened.
New tests use the shipped demo cases (data/scf/sp_case5, sp_case6tap, sp_case14, sp_case60, sp_case188, see Shipped Demo Cases) and the synthetic MATPOWER cases under data/mpower (sp_case9, sp_case118, sp_case300, sp_case1354); load_fixture_net serves them. A download belongs only in tests of the download and cache machinery itself; a fresh installation downloads nothing. What still gates on the case cache says so with a SKIPPED line: the SCF round-trip legs on real MATPOWER files (numeric bus names, unlimited ratings, a neutral tap outside its band), the case9/case14 DC oracle tables, the case118 byte gate, the case300 screening anchor, and the DTF deliveries.
No test downloads a CGMES delivery. Some tests read the ENTSO-E conformity packages and the ReliCapGrid models from the local CGMES cache (data/CGMES or SPARLECTRA_CGMES_CACHE) and print SKIPPED when a package is missing. These are third-party data and are not checked in. CGMES coverage runs on deliveries exported by Sparlectra itself: tools/gen_cgmes_fixtures.jl imports spcase14 (OLTC voltage controller), spcase118 (54 machines with asymmetric Q limits and synchronous condensers) and spcasePST (phase-shifting transformer, bus link), names every element uniquely after the source case, solves them with the Q limits the EQ file declares and writes EQ, TP, SSH and SV under `data/cgmesdemo/<case>/with a fixed header stamp, so a regeneration is byte identical; the SV profile is the solution of the delivery itself. Not covered, because the exporter cannot produce it: node-breaker topology, boundary sets and X-node equivalents (apart from the hand-written two-operator CGMspcase6igm` for the bus areas), DifferenceModel files, CGMES 3.0, HVDC converters, machine short-circuit attributes, and the quirks of real deliveries.
Large measurement networks are picked by what a test judges. The pegase cases (case1354pegase, case13659pegase) are OPF instances whose base states carry overloads and non-converging outages by construction; they are the oracle for convergence, import conventions (rad, shift sign -1.0), start ladders, Q-limit switching and runtime/memory scaling, and nothing else. Anything that presupposes an operated grid (screening quality, N-1 loading margins, voltage bands, scenario evaluation) is judged on RealGrid (ENTSO-E CGMES, local cache, via the CGMES adapter) and case300 as the small local MATPOWER case.
Group reference: model, solver, estimator and format groups
| Group | Files | Main checks |
|---|---|---|
docstrings | test/test_docstrings.jl | Every docstring sits directly on its definition (Julia 1.13 drops the text on a blank or comment line in between, and code in between takes the docstring itself): parses every tracked .jl file below src/, app/src/, ext/, test/ and examples/ and reports a bare string at block level and a docstring whose signature line names another binding than the one it is attached to; probes of the check itself for the attached, blank-line, comment-line and helper-between layouts. Replaces the line-based scan of repository_hygiene. |
api_smoke | test/fast/ref_api_smoke.jl | One power flow and one state estimation through run_sparlectra_api and start_powerflow_run on spcase5, the Q-V verdict in metadata and run.log (also the non-physical end point of the Zeng/Chiang file under classic simultaneous switching, buses 2, 3 and 6), the measurements.csv artifact under `excelde(a measurement table that reads back withreadMeasurementTable!, its verdict file in the run's format with one line per row) and the verdict on the shipped bad-data set (the scaled row, found by comparing with the clean set, is the one eliminated). Moved fromtest_api.jl` |
hand_calculations | test/fast/ref_hand_calculations.jl | DC power flow of a 3-bus net by hand, generation of a slack and a PV bus that carry a load, short circuit of an external grid and the IEC 60909-0 cases by hand, a two-bus feeder in closed form, a phase shifter after the MATPOWER manual (P_f = V_f V_t / x sin(theta_f - theta_t - phi)), a three-winding transformer in the star equivalent. The derivation stands in each test |
matpower_header | test/fast/ref_matpower_header.jl | sp_case9 against the DC solution in its header; sp_case9, sp_case118, sp_case300, sp_case1354 against the AC numbers in their headers: Vmin, Vmax, Q-limit count (not for sp_case1354: the header says 36, the solve ends with 35 at the same voltages), slack and PV generation (gross), losses, highest branch loading |
entsoe_sv | test/fast/ref_entsoe_sv.jl | ENTSO-E SmallGrid (tracked fixture), MicroGrid BE and NL and ReliCapGrid Galia (CGMES cache, SKIPPED line when absent) solved and compared with their SV profile: voltages, angles, flows, machine-bus generation; on Galia the reactance curve of the linear phase shifter GA-TR2_1 (its notice, and the SV state within 1.5e-5 pu, 2.6e-5 pu without the curve); the SmallGrid state estimation with a noise-free table |
openloadflow | test/fast/ref_openloadflow.jl | The five PowSyBl bundles solved with the OpenLoadFlow settings and compared with the OLF voltages, angles and generator outputs (not the generator outputs of four_substations), the line flows of ieee14, and the Y-bus of ieee14 against MATPOWER case14 read from the shipped OLF input case14.m (max-norm 1e-9). The test grids createTest3BusNet (also with its 15 Mvar limit binding), createTest5BusNet and createCIGRE and the shipped sp_case14 (flat start, controllers off), built as the other tests build them, and MATPOWER case14 and case118 read from their fixture file (flat start, reactive limits enforced, they bind in case118 and OpenLoadFlow runs with its limits there) and compared with the OpenLoadFlow solution in test/fixtures/openloadflow: voltages to 1e-6 pu, angles to 1e-4 deg, generation per bus and both ends of every branch flow to 1e-3 MW and Mvar. Each fixture holds the MATPOWER file the net was exported to; the CSV header names the tool, its parameters and the sha256 of that file, and the test checks the hash. For case14 and case118 that file is the export Sparlectra wrote of the original MATPOWER case, so the test does not cover the import of the original file. The PowSyBl micro_grid_be at the tolerance of the Web UI configuration (1e-5): the adapter options from the configuration give remote regulation with a deadband of 1e-4 pu, the remote control converges to its target within the deadband, and the voltages agree with OpenLoadFlow to 1e-4 pu |
core_model | test/testgrid.jl | The active-set voltage-side release (the shipped Zeng/Chiang case reaches the physical solution with at least one PQ->PV release and a clean Q-V check, the classic one-at-a-time mode ending on a physical point as well (no bound on the voltage difference between the modes: switching variants need not coincide), while with a margin of 1.0 the stability check, whose voltage tolerance is that margin, names no bus and the Q-V check with its fixed tolerances names buses 2, 3 and 6; the feeder machine clamped below its setpoint stays clamped; the shipped case118 keeps its clamped set and iteration count with and without the rule; the unit test on active_set_q_limits! covers both sides, the margin, the Q band fallback without voltages, a narrow-band machine of the guard (released on the wrong side only on a converged iterate, then held by the one-retry lock and the group release; held on the right side, inside the margin and without voltages) and the lock_pq threshold in percent of the Q band (below and above it, a zero band switching on any overshoot, a band with one infinite limit not switching inside the hysteresis) and the group release of twice-clamped buses on a converged iterate (a member that violates again stays clamped as group_hit, the others return as group_revert and are released again without it on the next converged iterate, no release before convergence, at most QLIMIT_GROUP_RELEASE_MAX_ROUNDS failed rounds, hit counts unchanged); the final Q-limit check with its two thresholds: every class on synthetic injections, the bounded warning, the strict 0/0 regression, the configuration default and validation, the same verdict for the three enforcement modes on spcase14, and the classic run's within-hysteresis row at bus 6 of the Zeng case; the Q-limit stability check, conditions (6)/(7) of Zhao et al., of each Zeng run: no violation under the active set with buses 3 and 6 under the one-retry lock, none under classic one-at-a-time (bus 6 PV 0.68 MVAr over its Qmax, inside the hysteresis, on its limit and inside its band), buses 2, 3 and 6 (Qmax above the setpoint) under classic simultaneous with every significant Q-V finding among its failures, not checked without Q-limit handling, each warning captured); core net construction and validation, small inline MATPOWER import helpers, file-based MATPOWER projected-start normalization, the ratio-profile start candidate (exact on a two-bus tap, absent without factors, behind a requested DC start, breadth-first factors, built only for a flat start with the projection on, configuration default reaching the solver), the flat start behind phase shifters (`powerflow.startmode.rotatebehindpst, default off and checked so: a 3-bus net with a 30 and a 90 degree shifter starts the bus behind it at 0 with the switch off and at minus the shift with it on, and with it on converges to the high root of the hand-calculated load equation, 0.95319 pu, with the iteration count and the angle of the solve at shift 0, through the keyword and through the configuration key onrunsparlectra; the same from the stored start of the hand-built net (1 pu and 0 degrees, no stored angle), while a stored start with an angle is kept; at a slack angle of 10 degrees every bus starts at 10 degrees and the bus behind the shifter at 10 minus the shift, and the solution is the one at slack angle 0 turned by 10 degrees; in a mesh (a 30 degree shifter parallel to two lines, a 20 degree shifter behind) the far end of the parallel shifter keeps 0 and the bus behind the second shifter gets -20, the shift of the path with the fewest shifters, not -50 over the path with the fewest branches; a three-winding star point starts turned by the shift of its stiffest winding with the switch on and at its ratio without it; the model-only MATPOWER export writes the default flat start, and the re-read case with an unsolved PV bus behind a 90 degree shifter, solved with the switch on, gives the flat-start solution; with the switch off the flat start at 30 degrees ends on the low root (voltagecollapse, erg 0) and the warning (@testlogs) and the result summary line namepowerflow.startmode.rotatebehindpst = true, while the run with the switch on logs no hint, a flat start replaced by the DC start projection does not count as a start without angles (the test reads the vector Newton starts from), and a net without shifter on the low root from a stored start without angles gets no hint either; with a slack angle of 10 degrees the export writes every bus at 10 degrees, and the reader with the switch on still starts the bus behind a 90 degree shifter at -80 degrees and reaches the high root; the run-level flat start checks every start angle against the slack angle, 0.99 degrees on the PowSyBl micro_grid_be bundle, whose one phase shifter lies in a mesh, so its start with the switch on equals the start without it), PV/PQ lock-ID resolution, the per-bus Q band (a unit without voltage regulation enters both ends with its fixed Q, with or without limits of its own, a unit with a Q(U) characteristic with its Q at the held voltage instead of its scheduled Q and its limits; a regulating unit without limits opens the band whatever the order of the units), Q-limit enforcement-mode parsing and classical base-failure/no-reenable dispatch checks, rectangular nonfinite mismatch and status-row diagnostic preservation, Jacobian condition-number estimator checks (exact diagonal case, Hager bound, near-singular flagging, input rejection), the KCL link allocation on a ring of three links (minimum-norm split; a reactor at a member draws its Mvar out of the balance, 0.60.0), link handling (afterrunpf!the slack bus of a link cluster carries the slack balance of the hand-merged net, every other member keeps its own load and generation, two linked PV machines share the merged Q at the same position in their Q bands and, at a setpoint they cannot hold, clamp at the sum of both bands at the voltage of the merged bus, and the total bus power equals the merged net), shunts (a shunt set byupdatePQShunt!equals the constructor path: per-unit G/B and the same power flow;showwrites its whole text to its own stream), reporting/output checks, and summary-file output regression (the generation of a slack and a PV bus that carry a load is checked infast, grouphandcalculations). Large sparse Ybus checks and large MATPOWER matrix-body scanner coverage are extended-only. Since 0.50.0testpilineg.jlcovers the physical line input: anaddACLine!line in ohm and siemens has the same Y-bus as the line given in per unit,addACLinePerKm!the same as its totals (withtanδand withgusperkm), b from the capacitance withouttanδis not zero, 60 Hz on the net (net.nominalfrequencyhz, a new net takesmodel.nominalfrequencyhz) gives 6/5 times b with r and x unchanged, a frequency that is not positive is refused, and the SCF writer states the frequency of the net, and the keywords of the per-unit form before 0.50.0 are refused with a message that names the replacement. Since 0.20.0testpilineg.jlalso covers the per-terminal shunt split: an explicit split on a line and a transformer stamps each arm on its own end (the from arm through the ratio squared), the flow helpers use the arm of the end they leave, the two setters keep the totals as the sums, a partial keyword set is refused, and no code path outsidebranch.jlwrites a branch total alone (grep oversrc). The wrong-branch check also judges the angle across the reference bus's own branches: on the shippedspcasePST(reference machine behind its own transformer) the operating root stays quiet, the same state rotated by 164 degrees is flaggedreferencebranchangleexceededahead ofbusangleexceeded, and the configured bound reaches the check throughrun_sparlectra. The DC candidate of the start projection: with the net's DC model its angles equal those ofrundcpf!(phase-shift injections included) and are not capped, so a candidate beyond the configured 60 degrees reports no clipped bus and no clip limit, while theimag(Ybus)` fallback is capped at 60 degrees and counts the bus. |
terminal_status | test/test_terminal_status.jl | Per-terminal branch status (one-sided open branches): the dangling-node reference anchor (a :open_to/:open_from reduction matches a solve with an explicit zero-injection auxiliary bus to 1e-10, for a line and for a transformer with off-nominal ratio and phase shift), bitwise equivalence of both-flags-open with status = 0 in the Y-bus, solver toggles between runs (sparsity-pattern invalidation), isolation of the open-side bus in the island report, the MATPOWER export substitution (BRSTATUS 0 plus exact `Yinbus shunt,openterminal=marker, voltage-identical reimport), the result surface (open@tomarker,Open terminalsheader count,terminalstate`/open-end voltage report columns), and the state-estimation guard rejecting flow measurements on partially open branches |
powerflow_rectangular | test/test_solver_interface.jl | Rectangular power-flow API behavior, sparse-only solver path, AC-island detection/reference validation/independent solving including aggregate all-island convergence status and iteration accounting, the reference priority on the shipped two-island case data/scf/two_islands_prio.scf.json (the stated priority wins, without priorities the strongest unit instead of the smallest PV bus, the island-wise solve, the byte-identical SCF round trip of the optional field, a negative priority rejected), Q-limit and typed configuration entry checks, the Q-limit stability check on two cases: a bus of lock_pv_to_pq_buses held at its Qmax above the setpoint gives exactly one violation named with its lock and the warning, the same case without the lock none; spcase60 with a 4.0 .. 5.5 MVAr band at Birkkamp110 and Westtal110 gives none under the active set with and without the guard (no lock named: the narrow-band clamp of the guard is releasable) and under classic simultaneous, where Q comes from the solved voltages (5.500 MVAr) and the result report shows the same value; the Q of a PV bus with a shunt is the same whether the shunt sits in the Y-bus or enters as a voltage-dependent injection; in auto mode on a net without Q limits the check follows the auto gate and reports the run as not checked; a regulated machine on a bus joined to the slack bus by a closed link is out of the check with one island and with two; a bus with a Q(U) generator next to its regulating machine takes Q from the solved voltages in the terms of its band: clamped at Qmax below the setpoint it passes, free as PV with the band narrowed on the solved state it fails, the Q-limit guard's start voltage of the buses it runs as PQ (a locked bus satisfies its own bus equation at the start; spcase1354 with every PV machine given a zero Q band and a 1.06 pu setpoint converges with the guard on), the reason of a run at max_iter (the rule on synthetic histories; case14_zeng with switching held back to a converged iterate gives iteration_limit at max_iter 3 and type_identification_divergence at 5, with the pre-switch mismatch kept beside the one after the switch and the last iterate in the stability report; with the default switching start numerical_divergence and the PQ->PV releases in the Q-limit log; the classic modes iteration_limit at max_iter 3; spcase60 with a -1.0 .. 0.5 MVAr band at Birkkamp110 and Westtal110 `numericaldivergenceunder the active set with and without the guard, classic simultaneous and classic one-at-a-time (without the guard the run is repeated withmaxiterat the end of a window of three falling iterations after the last switch, far above the first mismatch: same history, stillnumericaldivergence), the reason kept under the control frame and the Q-limit log on the linked net; withpowerflow.dc.fallbackthe run is not checked, the net holds the DC state), current-iteration start rejection diagnostics on a tiny synthetic case, including accepted and rejected framework control-status composition (a failed solve keeps the solver's reason), ordered local MATPOWER batch execution, the thinrunacpflowalias, legacy-keyword rejection, the forwarding of every solver option of the positionalrunpf!with a non-default value to the keywordrunpfrectangular!` on the plain, merged and island-wise path (a child process replaces the keyword method with a probe), the optional merit-function Armijo line search (value/scaling, acceptance/fallback/active-set-skip reasons, config validation, merit.enabled=false regression, and a converging flatstart/Q-limit-switching functional case), the optional scaled-Newton trust-region step control (config validation, acceptance/collapse unit coverage, trustregion.enabled=false regression, a converging functional case with log/diagnostics assertions, and radius-collapse non-convergence reporting), and wrong-branch detection output visibility across ACPFlowReport metadata, the AC island diagnostics CSV, and the console summary line, including the highest-voltage-level scope regression (a dip below the top level never triggers; the same dip on the top level does), and the AC rescue ladder / DC fallback (power_flow.rescue recovers a poisoned start and records the winning strategy, power_flow.dc.fallback leaves a DC state with the AC status honestly non-converged, defaults leave both mechanisms off) |
factorized_linear_solver | test/test_factorized_linear_solver.jl | umfpackreuse linear-solver selection and factorization-reuse behavior for the rectangular power-flow Jacobian path; `powerflow.computebackendwithout the CUDA extension (agpurequest runs on UMFPACK bit-identical to the CPU run with the reason in the status,autowithout a measurement stays on the CPU,gpufallbacktocpu = falseis an error; RAN or SKIPPED); the state estimator's normal-equation solve (reuse per pattern,stateestimation.linearsolverwith the UMFPACK default and theklufallback warning when the KLU extension is missing, the KLU run reported as RAN or SKIPPED;stateestimation.symmetricgainmirroring the upper triangle of an inexactly symmetric gain matrix onto the Cholesky route); power mode's sparse LU (powerflow.powermodelu:auto,kluandumfpackgive the same solution to 1e-12,autodecides by KLU's symbolic flop estimate on the first solve and keeps the decision after a branch outage, on a copy of the net and per island,resetpowermode!decides again, UMFPACK without the KLU extension and theklufallback warning; the KLU part reported as RAN or SKIPPED); the fixed Jacobian pattern (powerflow.jacobianfixedpattern: the builder gives one pattern for PV and all-PQ types with the values of the structural build and replays in place across a type flip; withtrueone analysis per solve with the same types and state within 1e-8 on the three-bus Q-limit net; on sp_case300 with and without distributed slack the defaultautowith the threshold lowered to 300 buses gives one analysis across the switches, andautobelow the default threshold the analysis count, state and mismatch history offalsebit for bit; the tests that count analyses on switches setfalseexplicitly; no effect, reasonnocontextand the verbose line withlinearsolver = umfpack`; in power mode one UMFPACK analysis over two solves, KLU as many analyses as without the switch and no fallback) |
3wt_phase_taps | test/test_3wt_phase_taps.jl | create3WTWindings!'s phase_tap_side/phase_taps keywords: existing-behaviour snapshot, single-winding attachment, ratio+phase coexisting on one winding, and validation errors |
configuration | test/test_configuration_coverage.jl, test/test_runner_helpers.jl | Configuration-key coverage (the dishonest-Newton keys, power_flow.jacobian_fixed_pattern and power_flow.jacobian_fixed_pattern_min_buses: one default in template, struct, loader and solver profile, auto, true, false as Bool, string or Symbol, bad values refused by the loader and by the Web UI override check, also for power_flow.jacobian_reuse, power_flow.power_mode and the two reuse limits), safe refresh checks including current-iteration start defaults, forwarding checks, start-voltage value-domain validation (including state_estimation.bad_data.substitute_sigma_factor below 1 refused with the key named, state_estimation.observability.on_unobservable defaulting to abort, observable_islands and scheduled arriving and other values refused, restore_sigma_rel (default 0.30) and restore_vm_sigma_nominal_pu (default 0.05) arriving and refused when not positive, power_flow.plausibility.vmin_warn from a file and as an override, 0 accepted and negative refused, and cgmes_import.start_values and cgmes_import.placeholder_guards parsing: defaults flat/warn_skip, sv/strict accepted, invalid values rejected with the key name), and test-runner output-mode helper checks Since 0.20.0 also the loader's tolerance for stored files: an unknown or removed key in a configuration file (removed diagnostics switches, powsybl_import.python_exe, a second YAML nesting of a key) loads with a warning naming the key and is dropped, the warning captured by the test, while an unknown key in a programmatic override still raises. The QSTS run keys qsts.mode, qsts.base_step and qsts.snapshot_controls are case scope: the general file reaches a case without a case file, a case file beats the general file, an override beats the case file, and values outside the domain are refused on the override path and in the typed parser. The start strategy keys and the wrong-branch bounds are case scope the same way; the source report of effective_config.yaml lists every wrong-branch bound and names the case configuration file as the source of one it sets. The network-parameter stamp also sets the system frequency (model.nominal_frequency_hz reaches net.nominal_frequency_hz on the MATPOWER, SCF and DTF paths) and leaves a frequency the case file stated alone; the form default of the frequency select is pinned to the configuration default. state_estimation.zero_injection_sigma_mva (0.60.0): default ZERO_INJECTION_SIGMA, 0, a negative value and Inf refused with the key named in a file and as a Web UI override, the form default of its field equal to the configuration default. state_estimation.sigma_by_voltage_level: a block-style table keyed by the nominal voltage arrives row by row sorted by level, an empty mapping is no table, a key that is no positive number (bad_vn_kv), two keys of one voltage and a key written twice in a file (duplicate_vn_kv), a zero sigma, a negative rel_pct, a row without an absolute sigma (no_sigma, also with only rel_pct) and an unknown column, vn_kv included, each fail with the key, the row key and the reason word, the key the writers use reads back to the same kV, a file with the levels 380, 110, 10.5 and 0.4 reads back each level and a quoted key ("10.5":, '380':) reads as the bare one, read from a file also with the file name and the line of the column or row (configuration file and case configuration file), a flow mapping (row value or whole table) fails with flow_style and a - list line stops the YAML reader with the block-form hint; the same parser guards a GUI override and the key is case scope. state_estimation.tap_estimation.impedance_correction (0.60.0): default auto, a bare YAML off arrives as off, on (bare, quoted or as a GUI override) and true are refused with the key named, a scalar in place of the tap_estimation block is refused naming the block. From the former legacy group: the Q-limit enforcement keys and the one-default rule of template, struct and loader, value domains of overrides and files, Web UI keys in both directions, and the configuration refresh. Also from there: the Q-limit hysteresis, final bound, cooldown and re-enable band of the run configuration reach the net in run_sparlectra; on the Zeng case the default leaves bus 6 above its Qmax (stability warning captured), hysteresis_pu: 0 clamps it to PQ at Qmax without a warning. state_estimation.start_mode.rotate_behind_pst: default false, a file value and a Web UI override arrive, a scalar for the block and a non-Bool override are refused with the key named, and the form default mirrors the configuration default. state_estimation.last_value: defaults off, 60 minutes and factor 3; a factor below 1, an age of 0 and a scalar for the block are refused with the key named; the BadDataConfig keyword constructor refuses a substitute factor below 1 like the file loader. power_flow.qlimits.guard.violation_threshold_pct (percent of the bus Q band): .inf, inf, -1, a list, a mapping, true and null in a file and NaN in the constructor are refused with an ArgumentError naming the key, the text "2.5" reads as 2.5. |
matpower_metadata | test/test_matpower_metadata.jl | MATPOWER parser metadata fields, legacy bus sorting of bus_name, opt-in bus-name import, the missing-bus_name warning once per case (a repeated import of the same case gives no warning, a different case warns again), branch-kind override, the line/transformer rule without a kind (0.60.0: a hand-built file with TAP 1 and SHIFT 0 on one voltage level read as a line, TAP 1 between 110 and 20 kV as a transformer with ratio 1, TAP 1 with a shift and TAP 0.98 as transformers, both readers alike, an explicit kind winning, the Y-bus equal to the one of the rows with plain MATPOWER semantics to 1e-12), branch metadata retention, FOR001 contingency mapping, default/opt-in mpc.dcline behavior including PF/loss/Q/V/Q-limit mapping and voltage-control safeguards, writeMatpowerCasefile write_solution column count/VM-VA/marker behavior and Pmax/Pmin 9999/-9999 for a unit without an active-power limit, three-winding star points through a model-only round trip (addBus! names the node after busName, the star points auxiliary by their AuxBus type, flat-start value and mpc.sparlectra.aux_buses in the file, auxiliary role kept by the direct import, the SCF converter and an SCF round trip, a file without the list and with Aux_ bus names still read as auxiliary, the re-read nets converging from the file voltages and from a flat start), the generator setpoints as Vg and as the PV and slack bus Vm of an unsolved createCIGRE() net with a reimport that solves to the same voltages, the mpc.sparlectra.tap_changer_model roundtrip marker preventing double tap-impedance correction, the mpc.sparlectra.links busbar-coupler extension (parse, link contraction in the power flow, export roundtrip, malformed-block rejection), the mpc.sparlectra.tap_changers nameplate extension (neutral-vs-live mapping onto the branch tap fields, ratio-less phase shifters, the Delta-u additional-voltage stepper with its live position and roundtrip, a ratio changer plus a Delta-u changer on one branch (0.60.0: the import against the hand value, both positions through the MATPOWER and SCF writers and back, the generator flows against a hand-set truth, psi 180 refused, a stated SCF alpha_deg 0 kept and a missing key read as 90, psi kept by setTapEstimation! with enabled = false and mode = :ratio, a psi set to 0 by hand refused by both writers off Delta-u step 0 and warned about by the MATPOWER writer at step 0, a 1.25 % ratio step at both band ends through the MATPOWER round trip), exclusive phase grids, generated-flow consistency, export roundtrip, rejection matrix incl. a 13-column block and a neutral ratio of 0; the ratio and shift in effect in TAP/SHIFT (#513): the Y-bus of the written rows with plain MATPOWER semantics equal to createYBUS to 1e-12 for a PST off neutral, the Delta-u PST and sp_case14, Wehrden written as TAP = 1.0 with the neutral 1.025 and position 4 in the block, the re-import through both readers with the same tap fields and a bitwise equal Y-bus and the power flow to 1e-12, a file in the format of 0.50.0 read with the old rule to the same net and a bitwise equal power flow, and an edited TAP kept at the tap position with a warning), net.name staying the case name (not a bus's original name) when mpc.bus_name metadata is present, and the generator costs (mpc.gencost) of the shipped sp_case9 through MATPOWER export, SCF and the converter path (identical matrix), no block for a case without costs, the block left out with a warning when a unit has no cost row, P rows only when some Q rows are missing, an unassignable block dropped on import with a warning, and GenCost rejecting invalid rows One reference per synchronous area (#465): every type-3 bus of its own island stays a reference, a second one in the same island becomes PV with a warning. A NaN current step in mpc.sparlectra.tap_changers puts both changers on the neutral position 0 (TAP and SHIFT of the branch rows), marks them (ratio_step_assumed, phase_step_assumed) and names each in one info line, on the direct import and through the adapter. writeMatpowerCasefile of that net logs exactly one warning per transformer naming the assumed ratio or phase step, and the reimport reads the written steps as transferred with the same live tap ratio and shift. A voltage tap controller that moves the assumed ratio changer takes its mark off, and the export then warns about the phase changer only. |
programmatic_api | test/test_api.jl | Focused GUI-ready power-flow API coverage for serialization and transport helpers, path and validation safety (including run-index acceptance of symlinked output roots, skipped on Windows), one successful small API run, one pre-solver failure, one numerical/island failure, Solver-time and Total-time contracts, critical DC-line default and strict-rejection smokes, one small independent-island regression, and the net-parameter stamp guard (each importer stamps the configured switching parameters exactly once: MATPOWER and SCF on shipped cases, CGMES on the checked-in spcasePST delivery under `data/cgmesdemo, DTF whendata/DTF/FOR001.DATis present with a spoken skip otherwise). Exhaustive CSV/export matrices, full artifact inventories, persistent restart/history/delete lifecycle matrices, repeated performance-log modes, complete island artifact-content matrices, and the fixed-reference self-check contract (verbatim-start summary inselfcheck.log, per-busselfcheckresiduals.csv`, the spcase14 residual property plus the cache-gated historical case14 anchor) are extended-only in programmatic_api_extended. |
programmatic_api_extended | test/test_api_extended.jl | Extended coverage of run_sparlectra_api and the local PowerFlow service: case resolution, Q-limit metadata and the q_limit.log artifact, the artifact list with kinds and MIME types, the one CSV format for every artifact of a run and its auto default (portable, German and US locale; the suite itself runs under LC_ALL=C.UTF-8, so auto writes the technical format there), the diagnose self-check report, run deletion safety, the start keys a flat start switches off shown in effective_config.yaml with their configured value, also for a run that fails in the solve after the import. Since 0.20.0 also the tap-changer model precedence artifact: an SCF case with a typed phase model run through run_sparlectra_api writes tap_models.log (kind tap_model_log, named in run.log), the same network without the model writes none. The <case>_calc_<date>.m export of sp_case9 carries its mpc.gencost block unchanged. The Web UI contingency service (artifacts and metadata, reference take-over count, invalid kind rejected, a per-case weight file applied and warned) moved here from the legacy contingency group. power_flow.qlimits.classic_max_passes as an override on the Zeng case: one classic one-at-a-time pass stops at the limit, not converged, with bus 3 failing the Q-limit stability check (the metadata names it, run.log carries the warning); two passes converge without a violation, bus 6 ends PV inside the hysteresis over its Qmax. An abort that reaches the state estimation service on spcase188 (token set when the service imports the case, first abort point in the observability check) leaves the service as PowerFlowAborted, not as a failed run with `invalidmeasurements. When the rewrite ofeffective_config.yaml` after a failed solve fails as well (the file replaced by a directory), the warning is logged and the run returns its own error. |
state_estimation | test/test_state_estimation.jl | WLS state-estimation behavior (baseline convergence and voltage accuracy, the resolution keyword of generateMeasurementsFromPF rounding U in kV and P in MW within half a step with the sigma unchanged, measurement add helpers, passive-bus zero-injection handling, zero injection as equality constraint against weighted rows on spcase14/60 with an elimination that never removes a constraint and a two-island net (0.60.0: SEResult.conditioning names the gain matrix under on and the KKT matrix under constraint, both Jacobi-scaled, the KKT matrix is not worse conditioned than the gain matrix with rows at 1e-3 MW, one multiplier entry per passive bus with the fused coupler bus of spcase60 once as link_aggregate, none under on; on spcase14 weighted rows at 1e-5 MW, added under `stateestimation.zeroinjectionsigmamva, give the state ofconstraintto 1e-6 pu (at 1e-7 MW the gain matrix is singular to working precision), the balance ofconstraintat every passive bus from the Ybus is below 1e-9 pu, and a wrong constraint at a load bus carries the largest multiplier), PMU angle measurements, with the angle reference of 0.60.0 on the 3-bus net with the slack at -5 deg and on MicroGrid BE from the CGMES cache (report lineSE angle reference MicroGrid BE: RANorSKIPPED): result voltages, write-back and warm start in the model reference with the slack at its stored angle, the warm start from the converged state in one iteration, alpha the time base offset (0 or 5 deg) instead of the slack angle, J at the noise level underpmurefoffset = off), theImagMeascurrent-magnitude rules (prediction roundtrip, 3 sigma value gate, shunt-bay variant, observability invariance), bad-data localization stage 1 (wiiexposure, sequential elimination with trace/stop reasons, ZIB protection and the protection byMeasurement.origin: a derived shunt row and a:pseudorestorerow with the largest residual stay in, a:pseudorow and a measured row with a SHDERIV id do not, origin kept throughseprepare, the link-cluster aggregate and the island remap, optional K-matrix report), the range check of the voltage measurements (0.60.0, in the same testset) on the shipped sp_case14: 0 kV with an imported state of 1.02 pu, a non-finite value and 1.6 pu at energized buses are replaced (substitute value and source, sigma times 3, a warning per row fromrunsediagnosticsandrunse!, counter 3, ranking fieldrangecheck = :rangechecksubstituted, never eliminated, converged), 0 kV at a bus behind its open branch takes the bus row, its injection and the flow of the open branch out of the estimation (deenergized, info line, converged; an island without a source is not energized), and in the SE service on sp_case5 with 0 kV at Lindhof_110 the run.log line, the metadata counters, the verdict reasonrangechecksubstitutedand the se_deltas.csv row (raw reading as measured, estimate and t_est from the substitute and its widened sigma), shunt estimation (case A recovery with freeze guards, write-back gate, voltage sensitivity; case B back-calculation with sign and sigma propagation), the phase-3 link rules (SE on the contracted net with member sync, LINKAGG aggregation and partial-cluster exclusion, a passive bus with couplers only that the branch-only marking types isolated, between two fed busbars and parallel to one: it gets its voltage and zero-injection rows, the cluster stays one island with no partial-cluster exclusion, dof 14 and 18 by row count, and the link flows into it add up to 0 on noisy data, within 1e-8 underconstraintand within the ZI sigma underon; link measurements as WLS rows (0.60.0: the study case, a single coupler with a capacitor on one side and its P meter 100 MW off the balance flow at sigma 2 MW, is the top normalized residual, localizable, eliminated first, and after the elimination the P and Q link flows equal the KCL at the fed bus from the power flow to 1e-6; a consistent row adds one dof and fits; a coupler ring with P meters on all three links reading the balance split plus 5 MW gives one circulation state and flows equal to the meters, the reported condition number equals the exact dense 1-norm condition of the Jacobi-scaled gain matrix (the unscaled one is more than 1e4 times larger), a 30 MW error on one link is the top residual, is eliminated first, and the other two keep the circulation, and after a later power flow the flows are the bitwise KCL split of the new state again (source = :kcl); the same ring in a two-island net, measured at another operating point than the last power flow of the net: the island path recomputes branch flows and shunt powers on the estimate, so the link flows after the estimate equal the meters; a P meter only on a coupler hanging off the ring (in no loop) gets no circulation state, adds exactly one dof and the flow after the estimate is the balance flow; a cluster shunt withupdateshunts, model B halved after the measurements: the estimate finds the true B, and the link Q flow and its residual follow it), bitwise KCL regression of the W2 allocation plus measured ring split (inlegacystateestimation), a single link whose flow the balance fixes keeps it against a gross link measurement and the residual shows the error,seviewclassification), the phase-4 hardening (robust R stages with solve/diagnosis separation incl. the generalized knees k1/k2 with bitwise 3/6 equivalence and continuity at t = k1, the rows that elimination protects left at stage 0 understaged(a zero-injection row and a derived shunt row with a real sigma at t = 200 on the row-level stage, and on the 3-bus net a zero-injection row with sigma 0.5 MW at a bus injecting about 30 MW absent fromrobustRows), the replacement suppression judged on the converged state with statistics on original sigmas, the k_eliminate exposure, Wilson-Hilferty band test with:high/:lowreasons, diagnostics state unification, the topology precheck on sp_case14 with the readings of its most loaded branch at zero: named as closed without flow under the stored state, skipped with a summary note at a flat start), the phase-5 chain (runpffromse!start modes with slack pickup, untouched model loads, and the measurement/model-discrepancy case separating:sestatefrom:sesnapshot), island-wise SE (inlegacystateestimation: two-island partition with per-island references and band verdicts, unmeasured-island skip, closed-link island fusion, merged chain registration), the transformer tap estimation on the step state s of each tap changer (0.60.0): the PF-equivalence gate at 1e-10 (inlegacystateestimation) of the unstamped overlay at the start position for the changer kinds a to f on nameplate, typed and stored data, plus the live-tap KCL consistency regression;Tap changer data: s -> t(s)(step factor, slope and start position against the importers' own functions, a degree-form phase changer ofcase14zengp306activeSetAdeclared and released, only declared changers released: the constructor's default ratio grid and the transformers of the shipped plainspcase118.mgive no release andsetTapEstimation!refuses them, case6495rte from the large-case directory imported as in the SE service has 9019 branches, 1603 transformers and 0 released tap changers (printsRAN, orSKIPPEDwhen the case is not cached), one nameplate row releases exactly that transformer, and the one branch with the complex t(s) against the explicit chain of ideal transformer, ratio section, auxiliary bus and phase section for the kinds a to f, alpha 0/30/60/90 and two pairs: the 2x2 terminal admittance after the Kron reduction of the auxiliary bus to 1e-10 relative over the band at four neutral shifts, one power flow per case with terminal voltages and flows to 1e-9 pu; the typed asymmetrical model with an x curve underimpedancecorrectionwritten back at every step of its band underautoandoff: x of the curve under both, r with the resolver factor underautoand r of the run underoff, sourcetableunder both);Tap estimation per changer type(kinds a to f with exact measurements on both ends: from the neutral step back to the true step to 1e-6 with J below 1e-9, impedance correctionautoandoffwith the source per row (per-step data follow the step under both and nametable, the typed analytic correction namesanalyticunderautoandnominalunderoff), and the analytic case underoffagainst a truth with the step impedance: J above 0, the right step; the typed transformer read from an SCF file differs in r and x betweenautoandoffafter the write-back to its step, and a stored CGMES set with an x curve and the analytic flag gives the same r and x under both, r unscaled);Tap estimation Jacobian column(the tap column of H against a central difference over s at an off-step position, kinds b and e; then the derivative matrix: kinds a to f, alpha 0/30/60/90, changer on the from and the to side, both band ends, the middle and a table point,impedancecorrectionautoandoff(offon the changer without its impedance data), P, Q and |I| at both ends and |U| at both terminals: the textbook derivatives of the two-port for the ratio and pure phase changers against a Richardson central difference of the exact prediction to 1e-10, and the tap column minus its forward difference error 0.5 h g'' against that difference, one-sided to the right at the table point, to 1e-6 in every cell);Tap estimation T2 line(4.715 deg on the line of the additional voltage, not 5.84 deg on the circle);Tap estimation MicroGrid BE` (BE-TR21 from its SV step 16 back to a truth at step 2 on the absolute band 1 to 25, every stored set equal to its branch at the import steps; four regulators two steps up with the noise of seed 240 without Va (the default keeps the machine transformers among them out, at least one row machine_transformer; the sequential fixation run lets them in with include_machine_transformers): the rounding at once raises J far above the 95 % quantile, the run warns, sets the flag and fixes the steps one at a time onto the truth with J equal to a run at the true taps; gated on the CGMES cache, RAN or SKIPPED is printed); roundtrips recovering injected mechanical steps (in legacy_state_estimation, like the release guards and the determinability guard that follow) with the fixation run on the nearest physical step (ratio, declared degree changer, fraction plus Delta-u pair) incl. the off-grid half-step case and the :offgrid_tap_residual note (both warn about the J rise above the 95 % quantile and set the flag); the release guards (machine-transformer detection, a bridge transformer without a far-side voltage: kept out by the start test (:radial_no_voltage_pin) and with an 8 MW load and exact rows estimated again by the recheck at the estimate on the truth step 2 but with sigma_s of several steps, so kept at the transferred step 0 with :weak_at_estimate (the notice gives the estimate 2 and sigma_s), without load and with noisy rows not estimated (the notice carries the voltage hint: measured minus estimated |V| at the terminal with a Vm row), the joint estimate of the recheck does not converge and the run is bitwise equal to no release, partial :both column re-packing with bitwise stamp restore); the determinability guard, since 0.60.0 the rank test on the scaled central-difference Jacobian at the start point with the structural rules naming the cause (:no_angle_anchor with :conditional on the ratio partner, :symmetric_start at an exact symmetric start (also for a symmetrical changer on a bridge without a far-side voltage: a pure angle changer gets no bridge cause and the notice of a pure angle regulator), a phase table started at a vertex of its ratio estimated since the rank test (its column carries the slope to the right of the start) with :sign_from_start and the vertex notice, a Va row on the far side plus an Ia row at the terminal: from a flat start the zero current keeps the Ia row out of the start test (:symmetric_start there) and the recheck at the estimate estimates the step again on the truth, with sigma_s of several steps at the default sigmas, so it is not taken over (weak_at_estimate, transferred step 0, the notice gives the estimate), from a warm start it anchors the edge at once and the step comes back exactly, :relative_only for parallel members, :relative_to_frozen for phase regulators only relative to a frozen one (not fixed, continuous in the fit; on the shipped spcase60 without Va br72 at -0.5 with J zero after the fixation; a typed winding parallel to a `:modelmismatchtable changer, where the diagnostics residuals give the run J; in both the diagnostics Jacobian carries the columns of these regulators, the sum ofwiiis the dof of the run, and on sp_case60wiiand the normalized residual of the active flow of br71 and br72 equal the response of the run to a 10 sigma error on that row), the elimination whose control solve converges only in the fallback without tap estimation (shipped sp_case5, a 5 % Delta-u changer at psi 60 on a bridge without Va, a gross Vm error at its far bus and a second Vm meter 0.07 pu high there: the base run converges released, the elimination of that meter is reverted with stopnotconverged),:notobservablefor a zero column (also for the Delta-u changer at psi 90 on the bridge without the rows of its branch and its buses: no:signfromstartnote and no note text in its notice) and for a column below its FD noise bound on every row (one row above its bound next to a noise-only row keeps it released), while a regulator seen only by a row with a huge sigma is estimated without the weak-column notice (the hint reads the unweighted Jacobian; on a hand matrix it follows the size of the Vm column, not a weight), the constellation of a study case (a passive bus on a link-like line with zero-injection rows of weight 5e5 against weight 1, far from the ratio changer: estimated exactly, no notice; this test fails on the former column rule), and a ratio plus phase pair with one row weighted 1e3 above the others comes back,:notseparable,:modelmismatchthrough the service mass release with a notice; a Delta-u changer at psi 90 started at step 2 with the truth at the turning point 0 of |t|, exact and with noise: converged, and since the recheck at the estimate (0.60.0) withdrawn to the transferred step 2,notobservableatestimateat the vertex 0 (exact, seed 5),mirrorstepfitsat a fixed step 4 (tight sigmas, seed 6, notice with the mirror step -4), and over twelve noise seeds every run converged on the side of its start and withdrawn, a run that ends above the band end with exactly one out-of-band warning naming the mirror step and every other run with none; the same changer from step 2 with the truth 3 is withdrawn withmirrorstepfits. Until the recheck these runs were fixed at 0, 4 and 3 with the vertex notice); the two-island aggregation with per-island rows, summed fixation J/dof, and bitwise cross-island isolation, switched off without a mergedtapFixationand every rowdisabled`, and an island without tap states that does not converge (maxiter 3) starting no fallback and keeping the fixed estimate of the other island; the whole-net fallback on the model of run 1 (trafo 7 off by -20 steps, update_taps, maxiter 4: both fallback log lines, trafo 3 back on its transferred ratio, every row `fallbacknotconvergedwithstepmodel0, voltages and J equal to the run with tap estimation switched off); released taps in the parallel island test (rows and write-back equal to the serial run, five repeats); the completion coverage:updateTapswrite-back with bitwise protection and the flows and losses of the net computed on the written-back taps (equal to the truth power flow, also on the parent net of the two-island fixture), the PMU current-phasor synergy shrinking the phase-regulator spread, bad data next to a released trafo (elimination names the row, tap stays within half a step, diagnostics on the tap-unified net), the machine-trafo back-calculationcalcMachineTrafoTapFromSEincl. mutual exclusion, the keysstateestimation.tapestimation.excludeandincludemachinetransformers(a released machine transformer calculated byrunse!withupdatenet, not calculated without it, on a single-island and on a two-island net, estimated withincludemachinetransformers, and left at the step the run solved with by the end-step stamp of the SE service bad-data rounds (tapstampendsteps!, model at step 0, truth at 2); an excluded transformer by name and by mRID kept at its step and not calculated, a user exclusion winning over the machine rule, the warning for an entry without a transformer, and the GSU whose generator sits behind a closed coupler (a closed link joins the GSU terminal to the machine bus): a machine transformer by the closed-link cluster on both paths,runse!andvalidatemeasurements(notestimatedwithoutupdatenet,calculatedat the truth step with it,notestimatedwith reasonqnotmeasuredingroup, the transferred step and the info line naming the bus when the machine bus has no Q row (with a branch marked as without a transferred step the notice of this row and of the calculated row begins with "step not transferred, middle position assumed"),calculatedat the truth step with notepfromschedulewhen it has no P row,estimatedat the truth step on both paths withincludemachinetransformers, stillestimatedat the truth step with it when the machine node has no voltage row (the rank test sees the step through the losses)), and excluded by mRID on both paths), and theseviewrelease listing with one entry per regulator), the tap fallback on non-convergence,Tap step from the control target(the gate net with a radial ratio changer: with the far-side Vm row estimated exactly withsigmasbetween 0 and 1 and 0 sigma from its step; with the far side seen only by the from-end flows not estimated,radialnovoltagepin, and with a voltage controller whose target is the true voltagestepfromtargetgives the true step after a run withupdatenet`: the transferred step at the truth without a notice, three steps off with the notice, also with a phase controller on the same transformer ahead of the voltage controller, no controller an empty column), the measurement generator (critical thinning to a target count, the thinned set observable in the verdict of the SE run on spcase60 and above the dense search caps on spcase1354, where the AC rank alone once let a magnitude deficit of 3 through, and the relative sigmas of generateMeasurementsFromPF: per row max(f |value|, floor), Va absolute, a dominating floor on every row), the run configuration as an argument (in `legacystateestimation), and the DTF case through the SE service on the shipped demo deck (with the format named and without it the same objective; a.DATfile that is no deck fails with its name and the reason).Measurement generator tap deviation on the changer set(0.60.0): on the CGMES delivery of the import's tap changer set test the generator moves the stored changer of each drawn transformer, and the mass release fixes the phase and ratio regulators two steps off their model steps with J after the fixation below 1e-9, underimpedancecorrectionautoandoff: the x curve of B-C is per-step data and follows the step under both, so the two sets are equal, the rows name the sourcetablefor B-C andnominalfor the phase table without r and x, and on the imported delivery the reactance of B-C is the same under both at every step of its band; the taps block lists only transformers with a changer, a deviation off the points of a phase table is refused, and a delivery without changers gets no deviation and a note.State estimation tap fallback(0.60.0): on sp_case5 with the bridge changer that does not converge released,tapestimation.enabled = falsegives no tap state (notapFixation, the dof of the run without a release), the rownotestimated/disabledand no write-back underupdatetaps; the fallback logs both lines, setsfallbackusedwith reason and 40 iterations of run 1, marks the rowfallbacknotconverged, and equals the switched-off run bitwise;fallback = falsereturns the non-converged run; the same bridge changer with truth and start at step -8 and exact measurements ends at the mirror estimate -12 across the turning point of its |t| at step -10 and is rounded to the band end -10: the row isoutofrange, its notice names the band and the mirror step -8, andrunse!logs one warning with the same text; a ratio changer of 1.25 % on br5 whose model band -10 to 10 is too small for the truth, start 0, exact measurements: truth 11 with the row sigmas times 5 lies 0.39sigmasbeyond the band end and is fixed to the end step 10 with statusestimated, truth 13 with the default sigmas lies 5.9sigmasbeyond it and gets statusoutofrangeat the transferred step 0, not fixed, with the J rise flagged; both notices give the distance insigmas, both runs log the out-of-band warning; at -10 the step column has no rank, so the recheck at the estimate (0.60.0) withdraws the changer (notobservableatestimate) and the transferred step -8, the truth, stays with J below 1e-8 (until the recheck it stayed fixed at -10 with statusestimated). The recheck on the same bridge br5: a Delta-u changer at psi 90 (1 % per step), truth 3, start 2, exact measurements without angle rows, is withdrawn withmirrorstepfits(J at the mirror step -3 at rounding level as at 3, the notice names both J) and keeps step 2; a ratio changer plus that psi 90 changer, truth (2, 3), start (0, 0) from a flat start with a Va row at the far bus and an Ia row at the from end: the start test keeps the phase changer out (no current at the start, the Ia row does not count), the recheck at the converged state finds it determinable and estimates it again with the ratio changer; with row sigmas of 0.05 times the defaults (a well determined re-estimate,sigmasbelow 0.5 steps) both are taken over on the truth with J below 1e-8 and noconditionalnote left, with 5 % and with 1 % per phase step (the first round, the ratio changer alone, rounds far from its continuous value with these rows, and the one warning that the simultaneous fixation raised J is asserted); with the default sigmas at 1 % the phase re-estimate (step 3,sigmas4.16) is not taken over (weakatestimate, transferred step 0) and the ratio changer keeps its first estimate (step 2) with theconditionalnote, the phase row shows its re-estimate 3 andsigmas4.16, andratioestandangleestdegof both rows are the composite at the ratio estimate and the transferred phase step; the psi 90 changer alone from step 0 with the tight rows is kept out by the start test, the run has no tap state, and the recheck on that converged run estimates and fixes it at the truth 3 withsigmasbelow 0.5; the same changer from step 1 with the default sigmas has no angle anchor at the flat start (:signfromstart) and is estimated in the first round, at the converged state the Ia row anchors the edge, so no mirror check runs and it stays fixed at 3, although the run with the net at the mirror step -3 gives J below 9. A weak re-estimate is not taken over: the gate net with a 10 kV bus behind a bridge transformer (ratio changer, truth step 2, start 0, 8 MW load) and noisy rows (seed 11) without the voltage of the cut-off bus; the recheck estimates it again at 6.33 withsigmas6.76 steps, the changer keeps its transferred step 0 withweakatestimate, the notice and one info line name the estimate andsigmas(before the bound it was fixed at 6); the row keeps the estimate insestandsigmas, and the state, from a new solve with the transferred step, equals the run with the changer not released (voltages within the solve tolerance 1e-6, J within 1e-9 relative). The bad-data rounds of the SE service (sebaddatarounds!`) on spcase14 with a 5 % Delta-u changer at psi 60 on branch 16 (truth step -6) and the Vm row of its 20 kV bus 0.1 pu low: round 1 falls back, its diagnostics on the transferred step eliminate the gross row, round 2 estimates step -6 (both run.log lines). In the service on warmupcasePST: cap 1 fails with both reasons in the status and both lines in run.log, with fallback = false without them; switched off, every changer row of `setapestimates.csv(the machine transformer included) isnotestimated/disabled; on sp_case188 at a warm cap of 2 the fallback writes both lines, the status line, the reason per row and the line above the result table; theworsefit` rejection of the staged start falls back the same way (spcase14 with a ratio changer at the off-grid model position 4.4 and exact measurements: the fixed step fits worse than the model position, run.log line 1 run 1 rejected (worse_fit, ...), rows fallback_worse_fit, the rejected note on the diagnostics, the summary and the Web UI tap section; J bitwise, dof, iterations and se_state.csv equal the run with tap estimation switched off), and with fallback = false the fixed estimate is the result. Bad data on the end steps (0.60.0): on spcase14 with the ratio changer of branch 16 two steps off in the truth and -2 kV on its 20 kV voltage, round 1 eliminates that row on the fixed steps of the result run (run.log line), round 2 estimates branch 16 two steps off again, `sebaddataroundsis 2, and J, dof and steps equal the service run with that row marked invalid. Since 0.20.0 also the tap-fallback consistency on the CGMES MiniGrid: with the fixture setcgmesminigridtapfallbackthe released-tap attempt fails and the repeat without tap estimation converges,run.logcarries both fallback lines, every changer row has reasonfallbacknotconverged,sediagnostics.mdopens with the same J, dof and iterations asrun.log, and the set's eliminations are confirmed (all five of the default budgetmaxeliminations = 5), while its staged start keeps the estimate of the two released legs; with the fixture setcgmesminigridtaprejected(two strongly coupled legs) the rounding at once raises J far above the 95 % quantile, the steps fixed one at a time give a consistent pair (one step below the truth, J equal within 0.01) and the staged estimate is kept with the fixation flags in the metadata (before the sequential fixation it was rejected asworsefit); with the fixture setcgmesminigrideliminationrevertedthe cold release falls back, its machine transformer B_2WT_21_11_2 (no Q row at HG1) staysnotestimatedwithqnotmeasuredingroupand its run.log line, and the repeat from the start values of run 1 confirms all eliminations of the budget, five since the default became 5 (until 0.60.0 the repeat started from the converged frozen-tap state, where the third control solve did not converge and was reverted), and the staged start keeps its estimate (both undertest/fixtures/measurements/, gated on the conformity package in the local cache, never downloaded; RAN or SKIPPED is printed).Tap estimation ladder (stages 1, 2, 4)` (0.60.0, the verification ladder of the tap estimation): cases are the 3-bus net S-F-T with one changer per kind (a, b at alpha 30 and 60, c, d, e, f) and the pairs a + d and a + b60, spcase14 with the step data of its case file (ratio and phase changers of br16 and br17 alone and as pairs), spcasePST, warmupcasePST and MicroGrid BE (gated on the CGMES cache, RAN or SKIPPED is printed), truth +2 and -3 steps off the model steps on the imported cases and 3 to 6 steps on the 3-bus net, Va where a changer needs an angle anchor. Stage 1: on every case the tap column of H minus its forward difference error against the Richardson central difference of the exact prediction, at the start steps, below 1e-6 for every row. Stage 2: exact measurements, every released changer estimated, its fixed step the true step (sest within 1e-6) and J after the fixation below 1e-8. Stage 4: measurement sets in which one changer drops out: no measurement at the transformer and its terminals (spcase14 br16, spcasePST and warmupcasePST br8, MicroGrid br9), no angle anchor (the two 3-bus pairs and the phase changer of spcase14 br16 without Va; a phase changer on a bridge has no angle anchor, the radial counterpart of the mesh without P flow; spcase14 has no mesh through a transformer and the 3-bus net no mesh at all, so this is their second variant): that changer not_estimated with a rank reason, its transferred step and a notice, the other changers estimated at the true step or with the note :conditional (the ratio changer of the 3-bus pair a + b60 without Va, whose notice names the frozen phase position), the run converged; the estimated partner on the transformer of the dropped changer (the two 3-bus pairs and the ratio changer of spcase14 br16 without Va, three rows counted) has a notice naming the partner's reason and transferred step. A partner of a withdrawn changer (0.60.0): on the 3-bus net a ratio changer and a quadrature changer with a reactance curve, truth (2, 4), start (0, 4), no Va, noisy rows (seed 4), the recheck withdraws the quadrature changer (`mirrorstepfits, transferred step 4) and the ratio changer is estimated again with it at 4: fixed at the true step 2 (the joint estimate gave -2), itssestandsigmasequal to the run that releases it alone, and the state equal to the net at (2, 4) without a release; a ratio changer estimated 5sigmasbeyond its band (status = outofrange, transferred step 0) next to the symmetrical changer d: d is estimated again with the ratio changer at 0 (equal to the run that releases d alone), fixed at its true step 3, its notice names the partner, and the state equals the net at (0, 3) without a release. A mesh without P flow (no P flow row on the mesh of br8 of sp_casePST, warmup_casePST and MicroGrid BE; Q flows, |I|, Vm and the injections stay): no changer drops out, every changer isestimatedat the true step. Set C (no P flow, no |I| and no P injection in that mesh; the P row of bus 9 drops as a partial link-cluster sum): the precheck finding:meshwithoutpmeasurement` names exactly the mesh branches on spcasePST, warmupcasePST and MicroGrid BE, and none on the full set; on the two PST cases it is on the result of runse! too, and the changer row of br8 (in the mesh) carries the mesh notice with status estimated and reason none while br7 (outside) does not; with the P injection at bus 2 kept there is no finding, no row carries the mesh notice and both changers end at the true step (regression case); set C on the truth net with nothing released is the documented second solution: from the truth state J below 1e-20, from the flat start converged at J 15.42 (within 0.05, dof 33) with the angle differences on br1 and br3 of opposite sign to the truth. A missing shipped case file of the ladder fails the test. Tap estimation ladder, noisy measurements (stage 3): the same cases with the sigmas of measurementStdDevs(), 100 draws with fixed seeds (MersenneTwister seeds 1 to 100, so the counts are the same on every run), and every run converged. Per released changer, counted over the draws that estimated it (at least one; the other draws and their reasons, the fallback of runse! among them, are printed, not asserted): the estimate within two `sigmasof the true step in at least 89 % of these draws (89 of 100; a correct estimator falls below with about 0.2 % probability per changer), and the rounding hits of the true step not below the 0.1 % quantile of Binomial(n, p), n the estimated draws and p the mean of 2Φ(0.5/sigmas) - 1 over them. Changed after the first result (0.60.0): before, only the rounding hits were asserted, at least 95 of 100, and the two-sigma count was printed, not asserted. The fixed 95 is replaced because a normal estimate rounds onto its step in 95 % of the draws only forsigmasbelow 0.255 steps; the two-sigma count is asserted at 89, not 95, because a correct covariance puts 95 of 100 draws within two sigma only with about 70 % probability. Each changer prints one line with its counts. Replaced with the rank test (0.60.0): the weighted weak-column cases (a row at sigma 1e9 with the notice and the log line, a row at sigma 1e3 next to a Vm row at sigma 1e-7, a weight ratio of 1e20) and the hand-matrix table over the row weight, which pinned the weighted hint; the study-case constellation and the unweighted hand-matrix table replace them. The tests of the former r1/r2 cascade (its PF-equivalence gate in three release modes, the cascade roundtrips at alpha 90 and 30 on the constructor degree grid, the r1/r2 column layout of a partial:bothrelease, r1/r2 values in the topology regression oftopologyvalidation) were replaced by the tap estimation tests above when the cascade was removed in 0.60.0. The asserts of the formeroffrule (per-step data held at the start impedance: the table cases ofTap estimation per changer typeunderoffagainst the start impedance and with a J rise against the step impedance, the two generator sets that differed by the x curve) and the machine transformer calculated with Q from the generator schedule were replaced by the asserts above in 0.60.0. A nameplate changer without a transferred step (tapcurrentstep = NaN) starts at the neutral position, its row notice begins with "step not transferred, middle position assumed" (row fieldstepassumed), the estimate reaches the true step, the write-back clears the mark, the restore of the saved branch (copytapposition!`) brings it back, and the fallback result keeps the text in front of its notice; no other changer case carries the notice. Start ladder (0.60.0) on spcase14 with its shipped set: at a cap of 3 the flat start fails and the second try from the stored case voltages converges (SEResult.start = :stored_after_flat), bit for bit equal to the run with flatstart = false; no second try with start_ladder = false, after a converged flat start, or on a net without stored voltages; a set abort token stops the rank test of the tap columns (PowerFlowAborted). In the tap fallback block on spcase188 at a cap of 2 from the flat start: with the ladder off the staged start fails and no released run starts (fallback reason `stagednotconverged, run fails naming the staged start); with the ladder the staged start converges from the case voltages and the fallback run converges on its second try (sestart,setapstagedstartfrom`, the run.log lines). |
observability | test/test_observability.jl | The observability side of state estimation on nets built once per run (3-bus, spcase14, the link net closed/open/with shunt): global and local observability metrics on full, reduced and sparse sets incl. `measurementjacobian(labeled H: row/column counts against the global check, flow rows named by oriented branch, bus rows by bus, every row touches a state, rank agrees withevaluateglobalobservability), a numerical deficit never overruled by a full structural matching (thinned sp_case14 draws), the rank verdict independent of measurement scale andranktolfactorforwarded, null-space dark states (the column-restricted local check is necessary but not sufficient, the 7-bus spanning-tree set names exactly the dropped bus), the matrix-only helpers (rank, matching, redundancy, local column selection, error paths), the two-stage FD-aware rank tolerance on the linked net (closed link observable, open link as measured island partition, explicittolwins, island-internal angle pair fails the local check), and the Takahashi diagnostics (dense/sparse path equivalence on three case classes, FD exact-zero sparsity, guard fallback with warning, K pinning the dense path, LDLt second attempt, bit-identical FD column coloring, full and row-restricted, on the shipped cases with a P and a Q row on their coupler and on sp_case1354) with criticality from diag(Omega) (no budget, a 600-row identity has every row critical, the per-row rank tests stay ascriticalitymethod = rank` with their budget skip, and both methods agree on spcase5 with a flow row removed) The rank read from the LDLt pivots agrees with the decomposition (#399) on every case, spcase1354 included; on spcase1354 the full injection set is observable in the P-theta and Q-V models and not weakly observable at the stored state (largest flow standard deviation of the covariance near 9.8 MW), the patterns without buses 700 to 702, 100 to 105 and 50 to 60 have P-theta deficits 2, 5 and 10 (missing injections minus one), Q-V deficit 0 and AC deficits 0, 0 and 5, with the flows outside the region measured (evidence E2) the deficits are 0, 0 and 1 and equal the AC deficits, and without 50 to 60 the boundary iteration gives the observable islands 1352, 1 and 1 and the region {30, 52}; with eleven unmeasured buses (above the dense threshold) the null-space iteration on the gain matrix gives the AC deficit of five the SVD counts (the sparse QR alone two) without a warning, and the islands, region and deficits equal those of the dense path. Observable islands (identify_observable_islands, the observable_islands field, from the decoupled P-theta model with the boundary iteration after Monticelli and Wu) and the deficits of the P-theta and Q-V models on the shipped IEEE 14-bus topology (case14zengp306activeSetA), spcase60, spcase118, spcase300 and twoislandsprio: the split at branch 7-8 derived by hand and its zero-injection counter-check, a larger gap with angle and magnitude deficits, a boundary injection that ties three free groups and is dropped (four observable islands), a bus with P only (magnitude dark, angle not), a bus seen through one Q flow (full deficit 1, not 2), boundary and link rows on two small nets (Q rows carry no P-theta row and are never dropped, a P link-flow row enters through its row model and is dropped; with an open line in front the placement names the unobservable branches like `identifyobservableislands`), an observable set with every old field unchanged and rank and dark columns equal to a dense SVD recomputation, the orthonormal null basis of the gain-matrix iteration and its deficit on Kahan's matrix, the SVD and sparse paths giving the same rank, deficits, observable islands with labels, region, removed rows, dark buses and weak report on the case14 and spcase60 gaps and on fixed removal patterns of spcase118 and spcase300 (thinned sets and ten-bus regions), and three network islands (one with the observable islands 1.1 and 1.2, one observable, one not measured) with the deficit from the first alone; estimated one by one (on_unobservable = observable_islands) the result rows are 1.1, 2 and 3, bus 2 removed with its dark magnitude and 3 not measured. The SE service on that case file: abort rejects it with se_not_observable and the island counts, observable_islands estimates two units, a set of P rows only is rejected with se_not_observable, and on the observable two-island set weak_check_after_estimation = false leaves the weak class undetermined. runse! on the case14 split under observable_islands: both observable islands estimated, island 1.1 with relative angles from bus 1, the flow on 7-8 and the total losses NaN, each island equal to runse! on its cut-out subnet and, with noise-free rows, to the power flow; without the Vm rows of island 1.1 its 13 buses are removed as dark magnitudes (voltages and flows NaN) and bus 8 is island 1.1, with the magnitude of bus 7 seen only through its boundary injection it fails the rank check (Q-V deficit 1); abort takes the network-island path as before, an observable set gives the same result bit for bit under both values, and the weak class at the estimate is clean per island. A dark magnitude at bus 7 (derived by hand) cuts the one observable island into 1.1 and 1.2, bus 7 removed with its reason. A weak branch at the estimate (the P injection at bus 8 with 50 MW as the only row of the flow on 7-8) is a gap under observable_islands: buses 7 and 8 leave with reason :weak, the rest is estimated again and is clean; abort only reports it (branch 7-8, buses 7 and 8); a cut estimate that does not converge (a 1000 MW error on the flow of branch 9) keeps the converged estimate before the cut with its weak report. The SE state file of an estimate per observable island reads back with the unestimated buses and branches named (branch 7-8 between two islands, the 13 dark buses and every branch), one warning, and runpf_from_se! refuses it like the in-memory estimate; a full estimate reads back without a warning. Restoration with scheduled values (restore_observability, on_unobservable = scheduled): the case14 split closes under zero_injection = on with the zero injection of the passive bus 7 (P = 0, the zero-injection sigma, a zero-injection row), under off with the P schedule at bus 8 (0 MW, sigma the 1 MW floor) and bus 7 reported as a passive bus that would close it; the weak class at the stored state is clean (verdict :observable), runse! estimates the whole net, the row is :pseudo_restore and survives the elimination of a 50-sigma flow error; a redundant P candidate at bus 2 is skipped; without a P schedule at bus 8 nothing is taken and the run equals observable_islands; U by the four rules (stored SV value, unit set point, median of the measured Vm of the level, nominal voltage with 0.05 pu), each derived by hand on case14 under zero_injection = off; on twoislandsprio no candidate leaves its network island. Measurement placement (suggest_measurement_placement) on case14 with Vm rows only: injection takes exactly the deficit of 13 steps (bus 8 first), flow at least 13, pmu 14 under pmu_ref_offset = auto (the first PMU fixes only the offset) and 13 under off, each set observable by evaluate_global_observability with the suggested rows; max_steps and the configured placement_max_steps stop early with stop_reason = max_steps; no_critical on an observable set with every row critical ends with no critical row; on twoislandsprio no step leaves network island 1, and pmu stops on the magnitude gap; with a magnitude gap alone pmu takes no step. On spcase1354 without buses 700 to 702 the P schedules at 700 and 701 close the deficit 2 and the set stays weakly observable after restoring (seven branches above 20 MW at the stored state); without 100 to 105 the zero injections of the passive buses 100 and 104 come first and with the schedules at 101 to 103 close all five (observable), under `zeroinjection = offthey are only reported and four schedules close four of five. The weak class from the covariance of the estimate (concept U4) on sp_case118 (Vm, P and Q at every bus, no flows) at the stored state: observable with the default sigmas, weakly observable with P and Q at 30 MW; every branch-flow and magnitude standard deviation equals a dense inv(G) reference built frommeasurementjacobian, on the dense and the sparse path, with no entry outside the pattern of the Takahashi selected inverse, and the affected buses are the ends of the branches above the bound; the singular fallback (weakdirections) equals an SVD reference, its buses a proper subset of those of the former tolerance rule; on case14 with the zero injection at bus 7 weighted (on) and as a constraint (constraint) every standard deviation equals the dense inv(G) and KKT reference, the two modes agree and without the zero-injection rows the flows at bus 7 are looser; not determined on a net that stores the flat profile; the bounds ofstateestimation.observabilityparse, are refused when not positive, and a tight bound reaches the check;runse!carries the class at the estimate in every run (weakcheckafterestimation, default on, basis:estimatedstate, equal to the standalone call on the estimated net) andnothingwith the key off. Two network islands where one carries a bus on a closed link only (the last bus): the generated cluster rows read the device injection, and the merged verdict keeps the LINKAGG rows as index 0 at the length ofcriticalitywii` (1.1.0: BoundsError in the generator and in the merge). spcase14 with the magnitude of bus 14 dark: a second runse! from a net with NaN voltages of the first converges, the SE service with the staged tap start estimates one observable island, and a NaN in the Jacobian is named by _sigma_max instead of a LAPACK error, also by numeric_rank_pivots with an explicit tolerance. The nearly critical list of the SE run log leaves a LINKAGG aggregate (index 0) out instead of naming it #0. A set whose every row lies in a de-energized network island is refused with an error that names the voltage range check, not the current rows. |
topology_validation | test/test_legacy_topology_validation.jl | Topology validation (all advisory): the stage-1 precheck matrix (each finding kind fires exactly its synthetic case, a clean set fires none) incl. the false-positive guards (lightly loaded branch expected near zero and flat start state without expectation, spcase14 shipped set clean, open link disagreeing freely, partially measured node skipped, shunt buses balanced with the measured voltage), the advisory contract (findings present AND the estimation still runs), the stage-2 fingerprint (model-closed/actually-open transformer: elimination exhausts, band :high, the finding names the right station; a curable 10-sigma error never classifies as topology), the stage-3 hypothesis test (:auto candidates at the elimination budget 3 the test states, the default 5 no longer exhausts the elimination on this net, the true toggle ranked first and supported, honest ambiguity on the small net, the input bitwise untouched, the island case), and the singular-normal-equations regression (dense LS fallback with a raised `svdmax_n`, parallel released taps converging on a least-squares split instead of crashing) |
measurement_table | test/test_measurement_table.jl | Since 0.50.0 every shipped measurement set (data/scf, data/mpower/warmup_casePST, the MiniGrid fixtures under test/fixtures/measurements) is a measurement table; the groups that read one directly (scf, observability, factorized_linear_solver, topology_validation, legacy_state_estimation, api_smoke) load it with readMeasurementTable!. The measurement table on the ENTSO-E SmallGrid (test/fixtures/cgmes_smallgrid, NodeBreaker BaseCase): the reader's format rules (each rule breaks one row, rows are kept with their problem, a foreign header is refused, quoting of a comma and a quote survives the writer, a line break in a cell or comment is refused before anything is written, a missing or other version line is refused by name, the CSV v1 marker is no table version, the fixture reads and writes back byte for byte), the import report of the synthetic fixture smallgrid_synthetic.table.csv (two snapshots, the inactive row and the three handmade faults counted, every injection row ending in a bus sum, a member with only an invalid value making its sum inactive, a member without a row making it partial, an invalid row next to a valid one of the same member reported as invalid_unused, two U rows at one bus kept as redundancy and the same key twice counted as duplicate), U from an Analog on a terminal becoming a VmMeas at an energized node (also on a switch terminal) and not_modelled at a de-energized one, a noise-free table reproducing the SV voltages (sign and unit conventions) (the bad-data elimination of the four marked rows of the first snapshot is in legacy_measurement_table); a branch open at one end in a CGMES case (the CGMES index and the SV generator leave out the flows of both ends and name the reason, a row on such a terminal is reported as not_modelled, the estimate on the rest converges); name keys keep their exact form (_B9 and B9 are two buses; B7 and B7 read as one key and the row is reported as ambiguous; in the mRID index _tn1 finds tn1); the name addressing on the shipped sp_case14 (nameMeasurementKeys: bus names, <branch name>:from/:to with the names of the file, the branch number where two branches share a name (on a copy with one name on the parallel lines), prosumer names qualified with the bus where they repeat; the CSV generator's set rewritten with names imports to the same measurements, an unknown name and an mRID are reported as unknown_key, the SE service estimates the table on the SCF case); the generator from a solved power flow on sp_case14 (generateMeasurementTableFromPF: noise 0 reproduces the power-flow voltages to 1e-6 pu with and without the injection rows, coverage draws the share of buses and branch ends by the seed, equal seeds give equal rows, gross errors marked by source, a zero sigma floor or relative U sigma refused by both generators; a sigma whose weight overflows is lifted to the floor, which follows state_estimation.zero_injection_sigma_mva below ZERO_INJECTION_SIGMA (1e-7 stays) and never rises above it (30 keeps 1e-3), and the zero_injection_sigma keyword of importMeasurementTable wins over the active value); pseudo rows for unobserved injections (generatePseudoMeasurementTable: on sp_case14 the cut injection rows of the load buses come back as exactly those members with the setpoints and the noise-free state is reproduced, the bus sums that use a pseudo row get origin :pseudo (also a sum that mixes a measured and a pseudo row) and keep it through the noise re-draw and the table writer, a sigma that is not positive is refused; on the SmallGrid fixture the fully observed second set gets no rows, the first set P and Q for every member, cut load buses exactly their members, and the filled set imports without problems and estimates consistently); repeated generated names at one bus (two generators and two loads with the same name: each gets <name>@<bus>#<k>, all stay members of the bus sum, noise 0 with injection rows reproduces the state, a member without a row gives partial_injection); two shunts at one bus (the power flow stamps both, the table sums them into one ShuntQMeas, the estimator predicts the sum, noise 0 reproduces the state, the measurement generator writes one ShuntQMeas per bus); bus balances, angles and the shunt bay current (every type of the CSV generator, with Va, Ia and branch currents, written as table rows on node and terminal keys arrives with its value, the bay current of a single shunt becomes a bus ImagMeas, Ia at an injection is unsupported, the noise-free set reproduces the solved state; at a bus with two shunts I is unsupported; a balance row with the source token zero_injection keeps its sigma and gets the ZI_PINJ_bus_<k> id; a bus link end is a link flow target: P at the to end imports as a link measurement with the opposite sign, Q at the from end keeps it, I is unsupported, the set written back carries both rows at the from end, an open link is not_modelled, and the closed breaker of the spcasePST delivery resolves to its link at both terminals); U in kV giving back the pu value bit for bit (400 random pu values and sigmas on the `spcase14buses, some needing more than 17 digits, written, read and written again byte for byte, imported to exactly the pu values; a short cell divided as its Float64; a value cell that is no number refused by the writer); the converter from the measurement CSV v1 (convertMeasurementsV1on a noisyspcase14set with voltages, angles, bus balances, flows, currents, current angles, zero-injection rows at sigma 0.05 and an inactive row: the negative currents the noise drew and a duplicate row are listed with their lines in the result and the table, the comment ids oftruthvalueandcriticalrowsfollow the rows, the import gives the v1 measurements bit for bit in their order with the announced ids, and J, state, dof and the eliminations of the bad-data pass are the same; the first SmallGrid set written as v1 with mRID bus references converts without a problem and gives the same estimate and eliminations; a link flow is listed asnotmodelled);readMeasurementTable!applying the first set or the one with a given timestamp and refusing an unknown timestamp; the Web UI generator writing the table (onspcase14and the SmallGrid with currents, current angles, gross errors and zero-injection constraints: the version line, truth and zero-injection rows in the file, the rows it cannot carry listed, the table import giving every written row of the set bit for bit, and the SE service running the table and refusing the same set written as CSV v1 withconvertMeasurementsV1named); the SE service refusing a table whilestateestimation.measurementtableis off (key named in the message) and, switched on, estimating the first set and writingmeasurementimport.txt, themeasurements.csvartifact of that run (the zero-injection rows with their source token, read back with the mRID index to the input set bit for bit in value and sigma, a second run on it with the same J, the verdict file joined by line number), and a redundantUrow on a busbar section of a measured node giving no duplicate finding (seduplicaterows) for the run. Withstateestimation.topologyvoltagekandtopologykclkat 0.01 the same run writes one row per topology pre-check finding tosetopology.csvand the result page links it; a run without findings writes no such file. The last valid value for a missing one (stateestimation.lastvalue) onspcase14with three timestamps: a branchPmissing at the second is filled from the first (value of the first, sigma times 3, origin:lastvalue, the line of the original), aUwithout a sigma cell that isvalid=falseand a branchPwith only a pseudo row are filled the same way, the gap of the firstPat the third timestamp (75 minutes after its reading) stays, aQmissing at the third comes from the second; the import report names the oldest timestamp, the filled rows carrylastvalue;<timestamp>and read back with origin:lastvalue; switched off, every set equals the import of its timestamp alone bit for bit, and a single timestamp gets nothing when on; a set without a timestamp skips the fill-in with one warning; a zero-injection row is never the original of a last value, and the rows a filled value replaces are countedlastvaluereplaced; a gross reading filled into the second set is eliminated byrunsediagnostics. In the SE service on the SmallGrid table (aUof the second set left out, 60 minutes after the first)run.lognames the filled values and the oldest timestamp, and a row of the estimated set markedlastvaluekeeps its source inmeasurements.csvand has originlastvalueinmeasurementsverdict.csv. Onspcase5a set without a timestamp behind one with a timestamp is picked by the request value(no timestamp), and the placement run records the set it worked on (semeasurementtimestamp) for its repeat. Measurement sigma by voltage level, checked on hand rows against hand values onspcase14(110 kV and 20 kV): with a row for both levels a measurement without its own sigma carries the sigma of its level (U in pu of the bus, P and Q at the bus of the branch end, both ends of the 110/20 kV transformer, a bus sum of one member), and the row with its own sigma keeps it; a bus sum is the root sum of its members (four injections at one 110 kV bus); with only the 110 kV row the 20 kV measurements take the default, and on the generated table the summary counts them so, the configured 380 kV level is reported as not in the case, and the summary gives the pu sigmas; the hand calculationpmw = 2,relpct = 1(3 MW at 300 MW, 2 MW at 100 MW); without a matching level (empty table, or 999 kV only) the sigmas, J, the state and the residuals are bitwise those without the key, onspcase14and on the first SmallGrid set with every second sigma cell emptied (there the key is set in the active configuration and compared with a run without it); the generator writes the level sigma (one row per level by hand), draws the same noise scaled by it, and reproduces the state at noise 0 to 1e-6 pu with and without the table; the pseudo rows carry the level sigma (a 20 kV and a 110 kV load); at a 380/110 kV transformer ofspcase188the 110 kV end takes the 110 kV row and the 380 kV end the 380 kV row; the SV generator on the SmallGrid writes the level sigma at the configured level and its own sigma elsewhere; the Web UI measurement generator onspcase14with the table in the case configuration writes the level sigma on the P, I and U rows at 110 kV with the same noise draw scaled to it (one row of each type by hand, the number of such rows against the generator's count), and leaves the other rows and the zero-injection constraints as without the key (a 110 kV Q row, a 20 kV row and a constraint). The SE service run on the SmallGrid table reports the measurements per level with the origin of their sigma in the metadata (sesigmabyvoltagelevel),run.logandsediagnostics.md, and names a configured level the case does not have. On a copy of thespcase5table with a second set without timestamp, the SE and placement services select either set bysetimestamp((no timestamp)names the set without one),readMeasurementTable!selects with the same helper and lists the sets with the same labels, a placement on the measurements of the case file refuses a timestamp like the SE service, and a set whose every row is inactive makes the observability check throwSENoActiveMeasurementsErrorand the SE service reportinvalid_measurements`. |
multi_area | test/test_multi_area.jl | Multi-area estimation (1.2.0). The partition of spcase118 against the area column of the MATPOWER file (tie branches exactly the closed branches between areas, border buses their ends, one owner per row, a flow row at the to end owned by the area of that end), the area list file (header, comment, three separators, a bus named twice refused) also through `stateestimation.multiarea.partition`; a closed link group cut by the list goes to the area of its representative and the estimate equals the power flow. On spcase118: noise-free rows give the power flow state within 10 tol per state (independent truth); the sum of the area models equals the Schur complement of the integrated gain matrix onto the border variables (relative 1e-6); noisy rows give the estimate, J and dof of runse! within 10 tol, also with PMU angles in one area (offset 7 degrees); PMU rows in two areas and an area without rows are refused; three gross errors (one on a tie branch) are eliminated in the order and with the normalized residuals of runse_diagnostics. Nine released ratio changers on spcase118: the eight inside an area are fixed at their true steps (-3 to +3), as by runse!, the one on a tie branch is not estimated (`:tiebranch, one row), the voltages equal the integrated estimate with the same exclusion, and the release per area matches the integrated decision for all nine (a differing row is flagged). The shipped sp_case10_areas: partition, tie lines and border buses from the file, the coupled busbar in area 2, the changer released by the file and fixed at its true step +2 by both estimates, same state, J and dof. The CGMES delivery sp_case6_igm: two areas and their names from the operator models, the X nodes and the Sued tie ends as border buses, the estimate in two areas equal to the integrated one. The SE service withmultiarea.mode = twolevelwrites the three area tables, the run.log line and the metadata, names a refusal (zeroinjection = constraint) and keeps the run; the result page gets the Areas section. The area runs on worker threads equal the serial run (5 repeats,multiarea_parallelin thethreads` profile). |
auto_powerflow | test/test_auto_powerflow.jl | Automatic power-flow mode: read-only feature extraction on four case classes, ordered-rule strategy selection with step-control exclusion, the escalation ladder (cap, skip reasons, L4 locks, L5 evidence gate, seed-only L6), DC-fallback labeling, precedence, decision-log artifact and metadata mirror, hint-generator ids, the startup latency hint, and the auto-profile precedence level (explicit non-default user keys survive every recommendation, applied and skipped pairs reported, resolveconfig carries the level and explicit overrides beat it). Through the service: every open escalation stage on warmupcasePST keeps a consistent autodamp/merit pair, and the DC fallback is labeled honestly and off by default. |
scf | test/test_scf.jl | Sparlectra Case Format writer: the one result-CSV writer (write_result_csv under technical and excelde, the SE state CSV round trip in excelde (version 2 header with estimated and observable_island), the AC island report and every CSV of an excelde power-flow run carrying the semicolon); deterministic ids with byte-identical repeat and rebuild exports, the PGM component subset, SI unit conversion against hand-computed references (line ohm/farad on the to-side base, live k/theta, appliance W/var), the namespaced block (roles, the three-winding `legdirectionread from the legs, tap changers with the Delta-u controller, names, config, opt-in start state), measurement-to-sensor pairing with complete row accounting, the FACTS base-impedance guard, the round-trip identity (byte-identical re-export, identical Y-bus, measurements, power-flow iterations and voltages, identical state-estimation objective and state; every measurement kind on sp_case14 including the shunt-bay rows; measurement rows of SCF 1.2 and later with the table semantics: one row per measurement in vector order, table types, shunt bay as a row with its value, current sensors in A, a U value that needs 18 digits written and read back bit for bit, a long literal kept as text only at value and sigma of the rows (elsewhere a Float64, written back without error, also110.000000000000000000in a hand-edited U row throughreadscfjson/writescfjson), the zero-injection flag written in the row and read back (a row with the ZI id shape but no flag stays ordinary), row validation (flag on a U row, type at the location, undefined node, a sensor at another location, unknown key), a sensor without a row read after the rows, a strayshuntbayrowsblock refused, and a revision 1.0 file with rows per sensor,shuntbayrowsand the old current scale read to the same measurements; a link flow row named in the export warning instead of being dropped), the permanent v1 fixture, reader validation (unknown keys, unsupported components, dangling references, duplicate ids, batch datasets, malformed JSON),DynamicDataand the revision 1.3 blockextra.<machine>.dynamics(defaults, the unit type following the inertia, aDynamicDataErrornaming the field for every rule; on sp_case14 a machine with every field, one with a subset and one without written and read bit for bit with a byte-identical re-export, no block without data, the round-trip comparison reporting a lost block, the case as a 1.2 file read to the same network, a broken block refused with the key named), the tap changer sets of the state estimation in theestimationkey oftapchangermodels(a stored set of every kind with tables, reactance curves, the additive grid and the impedance flag, an empty set, typed windings off their neutral steps (a ratio model, a reactance curve, the impedance correction) with and without a set: byte-identical re-export, the release of a phase and a ratio changer carried by the file, the live ratio, shift and impedance and every field kept; without stored sets no key, no set and the same Y-bus; a broken key, kind or missing field and an origin other than cgmes or powsybl refused with the entry named, a typed asymmetrical changer in the conventiondirectregulatingvectorunderimpedancecorrectionread with exactly one warning naming its entry and the reciprocal file read without a warning, a derived set on a branch refused by the writer; the CGMES deliveries of the importer test with their sets through the file and the first export a fixed point of the writer, and the tap estimation on a re-read delivery with the voltages and tap rows of the original), the controller round trip through the declarative schema (the rankpriorityand the control rangetapmin/tapmax` of a tap controller written only when set; on spcase6tap a ratio and a phase controller on one transformer next to a third one, a repeated apply that adds none, the write and read, and the outer loop settling inside the deadbands), the study definitions with their load-time validation, the study runs themselves (an N-1 case list and exclusions taken from the file, a rejected multi-outage case, a short-circuit run on the file's own sources with its case, c-factor and explicit bus sweep, and the missing-source path), the round trip of the MATPOWER quirks on a small hand-built .m net (numeric bus names, an unlimited rating, a neutral ratio outside the default band with its warning, a bus shunt under both shunt models, one bus in a second area: byte identity, the bus areas, component names, bus order, Y-bus, every field by reflection, the solve from the start state), the own-name-vs-externalid channel on the shipped spcase5 (reference name applied, externalid restored, re-export preserves both; branches and appliances carry the names of the file with the kind label of their build, also on spcase6tap; a generic_branch without a tap_changer row has no tap changer), power-grid-model interoperability (a file with no namespaced block whose sources become the reference, its solved voltages checked against an independently derived model), the strict PGM writer mode, the three-winding nameplate form with its named types and its rejections, the shunt-state and PGM fault blocks, the case-file upload including a rejected foreign JSON, the download route with its refusals (directory escape, missing file), and the service case resolver, SCF as a first-class case format (detection, selector, framework and service runs, case-file configuration precedence), the logging surface in the configuration allowlist, and the Web UI export route including its failure paths. System frequency (meta.f_nom): 60 Hz exports of spcase14 and of the Zeng case14 (six lines with c1, written as 5/6 of the 50 Hz value) read back at 60 Hz with the Y-bus of the original and the power flow of the 50 Hz export, the file wins over a configured key and warns exactly once (naming both values) only when the key was set explicitly, a file without `fnomtakes the key, 0, a negative value,true, text and null are refused with the field named, every shipped case states 50 Hz and imports with it under a 60 Hz key, a plain PGM line withc1follows the key (6/5 times b), the strict PGM export names the droppedfnom, and the warmup MATPOWER case solves bit-identically at 50 and 60 Hz while its conversion writes the key asmeta.fnom. A file without the step of a stored changer, of the typed ratio and phase models and withoutposof a nameplate controller reads them at the neutral step (13 for the stored changer, 0 for the others), marks them and names each in one info line. Written back, the file carriesstepassumed: trueon those changers next to the middle position (13 and 0), the file without them carries no such key; the re-read marks the same changers at the same steps and live taps, names them again, and a second write is byte for byte the first. The QSTS carry write path (setmodeltapsteps!`) that moves the typed ratio model to step 1 takes its mark off, and the file then marks only the phase model. A strict PGM file of a net with a regulated external network injection and a slack generator in one island carries one source (the slack, with its setpoint and angle) and the injection as a regulated symgen, and solves to the voltages of the net. Measurement rows keep their origin over a round trip (a derived and a restored row stay protected from bad-data elimination); a set of readings writes no origin key. |
scf_series | test/test_scf_series.jl | SCF time series on the shipped data/qsts/sp_case14_day.qsts.zip: the check mode of tools/build_scf_series.jl passes, 96 steps and 968 rows, the base entry is sp_case14.scf.json byte for byte; write and read keep the three entries byte for byte (also a series without timestamps, with an empty value and a bus op), the entries are deflated; each load-time rule of delta.csv in a table with the CSV line in the message, plus the header, the entries and the manifest; a base case with a status-0 load parks it in place, a step without set in_service 1 leaves it parked, a step with it brings it back with its base values, status 0 still deletes, the zip keeps the parking; apply! and restore! return the base net bitwise on all 96 steps; every step solves with runpf!(net, 25, 1e-8, 0) and the outage sits in steps 57 to 64; _detect_case_format gives :scf_series for the zip (also renamed) and :cgmes for the SmallGrid zip, import_case builds the base net, run_sparlectra on the zip gives the result of sp_case14.scf.json, and a service run succeeds with the series named in run.log; data/qsts/sp_case14_day.control.yaml attaches the Wehrden_110_20 tap controller next to the one from the case, gives the case controller of Moorau_110_20 its control range from 1.0 and puts the bank at Moorau_20 behind it at rank 1 with target 1.01 pu (no warning about the shared bus, the target lies on the edge of the tap band); step 77 (evening peak) solved with the outer control loop leaves the Moorau tap at its range limit with one block of the bank in, the voltage back in the tap band, and moves the Wehrden_110_20 tap, step 29 (07:00) leaves the bank off with the Moorau tap in its band, and step 77 under 1.4 times its loads ends :blocked with the bank at its last block, the voltage below 0.99 pu and the voltages of a single solve; the snapshot run runQsts (mode A): every step and the base case converge, without qsts.snapshot_controls no controller runs, the line out has no rows in steps 57 to 64, parallel runs with 2 and Threads.nthreads() tasks, five times each, equal the serial run with isequal on every value and step and write byte-identical files (threaded in the threads profile), step 57 equals a solve by hand bit for bit (base solution as start, delta, step configuration) and its transformer flows equal the model flow of the live tap, the long table has as many rows as qsts_values.csv, qstsValues reads a step and a branch series, DataFrame of the long table only when Base.find_package("DataFrames") finds it (RAN or SKIPPED line), the manifest carries format_version 1.0; the tap of the regulated transformer stays at the value of the delta in every step without qsts.snapshot_controls and moves in at least one step with it; a tap_pos op on that transformer sets its tap in the step without the key and is refused with it, also on a transformer whose controller comes from control.controllers; a tap that starts outside its control range gives one warning in a run over the base case and three steps; a step with the loads times 50 ends :not_converged with only its four step rows while the steps after it solve, and qsts.mode = off is refused with the key named; a step with every load times 2.2 converges with Torfloh_20 at 0.572 pu and stays :solved, gets n_low_vm 3 (0 in the other steps), one note and one warning naming the step, the bus and its voltage (captured with @test_logs), and with power_flow.plausibility.vmin_warn = 0 no n_low_vm value, no note and no warning; a bus behind a closed link keeps the values of its link group while the group is fed and has none once the step cuts the group off; a step that switches off the only unit of an island, and a step that cuts off three load buses, solve with those buses isolated (no values, a note with the bus count and the unsupplied load), and the step that brings the unit back equals the step before it; a step with the cut and the loads times 50, in which both islands miss convergence, ends :not_converged with the iterations of the first island and each island with status, iterations and reason in its message (not :solver_error with 0 iterations); mode A writes none of the step and controller quantities of mode B and only its four files; the sequential run runQsts (mode B) with the example controls: all 96 steps solve, step 1 equals the step of a snapshot run with the same controllers bit for bit, the Moorau and Wehrden tap positions and the bank per step as in the first run, the switching list is a chain (each row from the position of the step before to the one of its step, a row for every change, switch count the sum of the counted steps), loss energy, six files and the manifest keys of mode B; a restart from step 40 with the carry of step 39 equals the whole run, a step with the loads times 50 ends :not_converged and holds the carry, the step after it equals the step of a series without it, qsts.resync_every = 8 lists moves only as resync in steps 1, 9, ..., 89, qsts.dead_time_steps = 2 keeps counted moves of a controller three steps apart and locks it in between; _qsts_hunting on a table (patterns, overlap, gap, window 3 and 4, reset, window 2 refused), a load swing on sp_case14 with five hunting patterns of the Moorau tap, none with one step of dead time, the run counter equal to the pure function; three series of 24 steps in parallel with 2 and Threads.nthreads() tasks, five times each, equal to the serial run in values and file bytes (threaded in the threads profile) and one progress tick per step; the event list: each reader rule with the CSV line in the message (fields, step, empty id, action, value, two events of one element in one step, header), an action that does not fit the class, an unknown id and a step beyond n_steps, the full delta per step (a state holds until the next event, a unit goes out by parking, a return to the base state drops the op), the round trip through write_scf_series with the event record, the run on sp_case14 with the example controllers where opening Moorau_Hassel cuts off three load buses: n_islands 2, n_isolated 3, shed_load_mw 12 in those steps, the Moorau tap moves in the step of the cut and the control pass after the isolation solves, the buses without values, the record in the manifest, and the refusal of a snapshot run and of the snapshot start; qstsChart on the mode B day: one point and one tooltip per solved step at Moorau_20, the voltage band as two dashed lines, no script, show as image/svg+xml gives the SVG, no band for a branch flow and the upper limit for the loading, a controller and a step quantity, the line out breaking the flow line into two, a one-sided band, equal bytes for equal calls, an unknown element and a wrong band refused |
dc_powerflow | test/test_dc_powerflow.jl | Standalone DC power flow (rundcpf!, power_flow.solver=:dc): the reference values against the independent solution (3-bus hand-verified fixture, spcase9 against the DC solution in its header) moved to the fast groups `handcalculationsandmatpowerheader`; the hand-checkable spcase5 DC dispatch (slack exactly 32 minus 12 MW), phase-shifter (Pfinj) coverage via a synthetic phase-shifting-transformer fixture, lossless power-balance property checks on the tracked warmup case and the shipped spcase5, two-island independent-solve coverage, `powerflow.dc.*/powerflow.solverconfig validation, active-outer-loop-controller rejection (mirrors theapslfrejection test),runsparlectradispatch (method=:dc,diagnostics.solver=:dc),anglereferencedegexact-uniform-shift behavior, thedcpfstatus/rectangularpfstatusregistry separation,rundcpf!(net; seedacstart=true)DC-seeded AC Newton-Raphson convergence, the configured DC seed under a flat start (the solve starts from the seeded angles), and the one-specification-source contract (a node-sum edit moves neither solver, a prosumer edit moves both, DC injections equal the real part ofbuildComplexSVec`) Closed busbar couplers are contracted to one DC node (spcase60, warmupcasePST). The DC start on sp_case9 against a hand calculation: the losses shared by the generators in proportion to Pg (the angle across each generator transformer), PQ buses at the mean setpoint 1.03 pu in the DC and the flat start, also after a Q limit moved the PV bus 2 to PQ. |
distributed_slack | test/test_distributed_slack.jl | Distributed active-power slack: per-bus residual conservation (alpha .* lambda_P pattern, REF/load buses untouched), REF-equivalence (explicit weight fully on the reference bus reproduces the classical solution and lambda_P equals the classically REF-absorbed power), mode agreement (pg_weighted vs matching explicit), MATPOWER APF column import (:imported shares proportional to APF; APF presence never changes disabled results), fallback behavior (error throws, ref_only warns and matches classical), Q-limit interaction (PV→PQ switch keeps participation), the config-load regression for the weights: {} placeholder plus block-style weight tables (the minimal YAML reader has no flow-mapping support), independent per-island lambda_P via the AC-island solve path with the participation of all islands in the bus and unit numbering of the net, and the result values on a lossless 3-bus hand case, plain and behind a bus link (Pg schedule and Pg eff delivered generation in the printed table, the reference bus included, delivered p_gen_MW in the report rows, pRes per unit after distributeBusResults!). The CGMES normalPF arrival through importCGMES is not covered by a test. |
island_diagnostics | test/test_island_diagnostics.jl | AC island diagnostics reporting regressions (source: a 6209-bus CGMES delivery with 158 single-bus islands): the island failure message reports the failing island's own iteration count and stage (never the iterations=0/stage=before_nr fallback while a per-island record exists), the failing island is looked up in :ac_island_solver_statuses when the combined status is untagged, never-attempted islands render as not_attempted with unavailable mismatch fields instead of inheriting the failed island's statistics, per-island solver.log/mismatch_history.csv artifacts are written only for attempted islands, q_limit_processing_status does not alias failure_reason, and the single-island combined-status fallback keeps working; also the no-slack diagnostics (all-isolated vs. isolated-slack vs. never-registered messages) and the power_flow.auto_slack promotion (keyword and config path, ENI-over-generator ranking, no-op on a registered slack), and an island without unknowns: a PV generator left alone on its island converges in 0 iterations with no_unknowns in its status instead of failing the run, and the N-1 engine on the shipped sp_case60 cuts off a generator bus and a pure load bus without error, each with its own note |
short_circuit | test/test_short_circuit.jl | IEC 60909-0 short circuit (runShortCircuit!): hand-derived analytic reference cases with the full derivation in the test comments (series line impedance added on top; synchronous-machine x''d conversion incl. §6.6.3 fictitious resistance; kappa/ip with the method-b cap; line charging proven irrelevant), IEC Table-1 c-factor selection and the scalar override, the safety-flag contract as a three-way assertion (documented default + log warning + per-row flag), the size behind the default reactance of a machine without `x''d(rated power, else maximum active power, else network base; a maximum of 9999 MW and a rated power of 9999 MVA and above are placeholders, the reason names a placeholder rated power, a statedx''dnext to one takes the network base, and the service counts a machine with only such a rating as a source without data, and a machine on a wind or solar unit not as a machine), the typedlowerboundrow flag on two islands (a placeholder machine on a default reactance is flagged but no lower bound, a skipped feeder makes its island a lower bound in the maximum case only; the service outcome reads the flag; the run status on the result,warningwithshortcircuitpartialdefaultsthere,succeededwithout a reason when every source has its data,failedwithshortcircuitdatamissingwithout any source, and the head line the printed table starts with), asynchronous-machine skip with island-wide Ik''max lower-bound flag (max case only), the converter current source on a 110 kV chain (Ik''rises bymaxIFault·ratedS/(√3·ratedU)at the converter bus and the bus between it and the feeder and by the hand-derived share|Zij|/|Zii|beyond it,zk, R/X and kappa unchanged, the peak current takes the converter part without kappa, the Takahashi sweep agrees, the threaded sweep gives the serial rows bitwise over five repeats (RAN or fallback stated), a missingratedUis replaced by the bus voltage and flagged, the minimum case unchanged; withoutmaxIFaulttheconvertercurrentfactorgivesktimes the rated current with the same shares, rows flagged as a substitute and not as a lower bound, a statedmaxIFaultwins over it (a stated 0 feeds nothing and flags the island with its value), a negative factor is rejected, the service outcome names substituted rows no lower bound; withoutmaxIFaultand the factor off, withoutratedSand for a converter prosumer without a record no share and the island flagged),:nosource/:isolatedrow statuses, an island of a converter and a machine on a wind unit alone (k = 1.2: every bus:okwith the hand valueIk'' = k·(S1 + S2)/(√3·110 kV),ip = √2·Ik'', flagged with the converter-only reason, no lower bound; factor off::nosource), closed-link groups contracted as in the power flow (a bus on a closed link only reports theIk''and island of its group, ring and radial, max and min; a feeder on it raises the neighbour by the hand-derived amount, with equal R/X exactly its declared current, Takahashi agrees; a linked pair without a branch stays:isolatedin one island),shortcircuit.cfactorandshortcircuit.convertercurrentfactorconfig coverage (default, valid value, rejected value; the factor read from a case configuration file and accepted as an API override), and the WebUI data-check gating helper (webuicasehasshortcircuitdata: marker found / not found / cached / unresolvable path stays enabled); the Phase 3 parallel all-bus sweep identity guard (serial vs parallel rowsisequal-identical for max/min case withmaxtasks=1` and auto on a three-island fixture and on the shipped spcase60 with buses = :all; RAN/SKIPPED stated per run; plus the sweep_method = :takahashi selected inverse: machine-precision agreement with :solves on values, identical statuses/flags, serial and parallel, deterministic repeats, invalid method rejected) A line from per-km capacitance on a net at 50 and at 60 Hz gives 6/5 times b and bit-identical Ik'', κ and i_p (method b has no frequency term). |
parallel_foundation | test/test_parallel_foundation.jl | Thread-safety foundation and parallel island path of the multi-core work (Phases 1 and 2): the parallel_max_tasks resolver, the per-worker performance-profile helpers (_perf_profile_child excludes the orchestrator-only :phase_callback, _perf_profile_merge! sums timings under unchanged phase names, appends iteration rows, prefixes per-worker scalars, and swallows nothing children/parents), and the solve_parallel island identity guard: bitwise-equal voltages and iteration counts vs solve_independent with max_tasks=1 and auto on a five-island fixture, identical phase-name sets plus parallel_wall_time, per-island prefixed scalars, and the parallel failure semantics (all islands report their real status, no skips); the GC pause of a run (with_gc_paused, runtime.gc_pause): nested runs count, the GC does not collect while a run is active and collects again after the last one, also after an error in the run and in runpf!, enabled = false counts nothing, the memory guard collects once above its limit, and runs on several threads leave the GC on when all have ended (RAN or SKIPPED with one thread); collections are read from the GC counter. The island identity tests (run_parallel_island_tests) run threaded in the threads profile. |
scenarios | test/test_scenarios.jl | Scenario patch model: validation surface (status, set, scale with their target classes and fields), rejections with scenario name and op index (unknown id, class mismatch, inapplicable field, empty ops, duplicate names), the sparlectra.scenarios file round trip through the typed case, the ScenarioIndex of every shipped data/scf/*.scf.json resolving each component to the element on its buses (the scenarios block of feeder3_hardpv_vsPGM applies), the removed contingencies block failing on load with the scenarios block named, the N-1 expansion equality with generateN1Branches and generateN1Generators on the tracked warmup case including exclusions (a three-winding transformer expands to one scenario that opens its three legs and gives the result of its N-1 case), apply!/restore! with the undo log (tap patch on an unregulated transformer changes the solver-visible ratio and restores it, takes the mark of an assumed step off and restore! puts it back, a tap patch on a regulated transformer is rejected with the controller named, set angle_deg on the external grid of feeder3_hardpv_A writes the source and bus angle, restores both, and after a solve every bus angle moved by the value with the magnitudes unchanged, and the acceptance test: for the tracked warmup case, the shipped spcase60/spcase188 and the tracked SCF fixture, every N-1 branch and generator scenario leaves the working copy BITWISE equal to the base after apply! plus restore!, checked with scfroundtripfielddiffs), the engine worker resets bitwise between evaluations WITH solves (branch outage, generator outage, patch scenario against the engine template), and runScenarios! with mode n1all writes the identical result CSV as runContingencies! on the generated case list (the case118 byte gate against the 7438b6e fixture is the extended group scenario_engine); the screening surface: :off keeps the historical ContingencyResult rows and CSV bytes, :flag returns ScenarioResult rows with no violating case screened away, screened rows read start_used = :screen with an estimate attached, the screening CSV appends exactly the screened/screening_estimate columns, and :only reports estimates without full solves where an estimate exists; correlated events (#355): two generator outages in one scenario give the same result in either op order and through the patch path (D1), a coupler outage runs and names the link, markIsolatedBuses!(links = true) marks by the link groups of the power flow (a coupler bus whose branches are all open stays in service through the coupler while the default isolates it, both coupler buses with all branches open are isolated, and on a synthetic net with a bus behind a link, a branch-less link group, a group whose only branch runs inside it, an open link and a link chain the marking equals the isolation of _merged_pf_net bus by bus), runScenarios! with branch outages on the link group net cuts off the bus behind the link with its group (15 MW in the radial net, nothing in the ring), a generated double circuit equals the hand-written scenario of the same ops, a three-winding transformer through the member item equals the patch path; the event generators on the shipped demo cases (spcase14 one double circuit with its name group removed as duplicate, spcase60 six double circuits, the coupler, the Neubach busbar sections and station, the NeubachWaldsee name group, spcase188 seven double circuits, the coupler, the EichriedFalkwik name group and the Falkwik station, no name group across voltage levels, one member set per class) and the pair generator (136 and 2701 pairs, the double-circuit pair listed once, the cap); the QSTS vocabulary (stage 3 of the CGMES series) on spcase60 with a hand-built :cgmes_series index: every new :set field applies (a tap_data record included) and restore! returns the net bitwise (scalar fields with isequal, tap controllers included), parking keeps the unit in place and moves the bus load sum, unparking copies the parked values back, a bus isolation writes a new isoNodes vector, a bus isolated by the op keeps its type through markIsolatedBuses! with its branches in service, while a bus the marking isolated itself is typed back once a branch reaches it again, an :scf index rejects every QSTS op with the op named, a shuffled delta gives the same net, the branch parameter ops write r and x with their base fields and the terminal shunt values with the totals, apply! rejects r = x = 0 and an r/x write on a typed tap model with the net unchanged, and judges a single r or x op against the other field of the net (r = 0 or x = 0 alone accepted, r = 0 on a branch with x = 0 rejected), and line 1 patched with other r, x and charging equals the case built with these values, net and power flow bitwise |
demo_cases | test/test_demo_cases.jl | The shipped demo cases (data/scf/sp_case*) read through import_case like any other SCF file: per case the power flow converges without a linear-solver fallback (a regular Jacobian also with a closed coupler, as in spcase60 and spcase188), the state estimation on the measurements the file carries (spcase6tap: its measurement table) converges, every case but spcase5 carries controllers, and those controllers settle. The format fixture spcasePST (closed coupler) solves without a linear-solver fallback as well. For spcase6tap also its bus and branch names, the ratio changer of T2 (+-12 steps of 1.25 percent, position 0, no controller) and the three control targets inside their deadbands (U Kreuzau110 and U Lindenau20 at 1.00 pu, 60 MW over T1). For spcase16islands: 16 buses and 18 branches, the spcase6tap part with the per-unit values of spcase6tap, the power flow of the base state, its measurement table with two observable islands (11 and 5 buses), the tie OstheimHaldorf unobservable and the deficit 1 (angles 1, magnitudes 0) derived by hand, the scenario with that tie open (two network islands, the power flow converges, no deficit), and the scenario with both ties open (three network islands; with the rows of the sourceless network C taken out it is reported as not measured and adds no deficit). The file checks (provenance line, case configuration with `powerflow.tol, size budget, bad-data twin) are inrepository_hygiene`. |
contingency | test/test_contingency.jl | N-1 contingency batch API (multi-core Phase 4): case generation (all in-service branches, transformer filter via component type or nonzero ratio, parallel-circuit disambiguation name#branchIdx with a shared-name fixture, FOR001 mapping incl. unresolvable names, Phase 2 screening filters min_vn_kV/min_sn_MVA/name_pattern on a 380/110 kV fixture, and per-case weight validation), spcase14 full N-1 with serial vs parallel field equality (`maxtasks=1and auto) and base-net immutability, theprogresscallback (one call per finished outage, every value of1:totalexactly once with the right total, results unchanged, repeated 5x serial and 5x parallel), islanding semantics (a load-only island reports the specificislanded: load-only, X MWcause, a PV island is promoted and solves; a bus behind a closed link is cut off with its link group: no branch outage of the ring cuts it off, opening the link sheds its 5 MW, the radial outage sheds both buses' 15 MW), the reference priority in N-1 (the outage of the slack on the shipped two-island case hands the island to the unit with the stated priority, without priorities to the largest unit), non-convergence and unknown elements reported not thrown, three-winding transformers (one:transformer3wcase per transformer and no single-winding case by default, the isolated star point dropped silently with only the real bus behind it reported, the star point never in the voltage band), the table printer plus CSV writer, and the Phase 1 start-value ladder (contingency.rescueladder:startusedreported per case, ladder validation of the empty/duplicate/unknown-stage inputs at both the keyword and the config-section level, a longer ladder never losing a warm-converging case and staying serial-vs-parallel identical, the deprecatedretryflatstartalias, and a non-converged base case routed through the solver rescue ladder before the flat fallback, verified via a bad-seed fixture whose plain solve diverges and whose no-flat-fallback warning is asserted), and the Phase 2 case weights (applyContingencyWeightsby name with a default,readContingencyWeightsCSVfor semicolon/comma/header/comment/negative rows, weight 0 as a pure ranking weight that still solves, and the weight carried into the result and shown in the table/CSV), and the Phase 3 generator outages (generateN1Generatorscount/kind/Pg-name filters, a generator outage solving with the slack absorbing the loss, the slack-unit outage reported as "no slack bus" by default and rescued byautoslack,distributedslackenabledflowing through, serial-vs-parallel identity, unknown-generator reporting, and a non-pegase stranded-generation fixture where removing a bus's PV unit leaves its island with injection but no reference), and the Phase 4 overload reporting (structuredOverloadRecordloadings with base loading and delta on a two-parallel-line overload fixture,severity = weight * max(0, loading - 100)with the result table severity-ranked failures-first,shedloadmwas a structured field on a load-only island, andbuildContingencyReport/printContingencyReportaggregating outcome counts, worst loading, worst severity, and total load shed), and the Phase 5 Web UI service (runcontingencyservicefor branch and generator kinds on the shipped sp_case14: succeeded status,contingencyn1.csv+run.logartifacts,runmode/kind/counts metadata, the slack-unit outage named in the summary badge, and an invalid kind rejected not thrown) From the former legacy group: case generation counts and filters on sp_case14, case weights (applyContingencyWeights,readContingencyWeightsCSV`), generator outages with the reference hand-over and reference priority, the overload report and its severity formula, the printer row limit and the CSV writer header in both formats, the start-value ladder and the rescue of a non-converged base case. |
external_grid | test/test_external_grid.jl | External-grid element: the external-grid/distributed-slack mutual-exclusion configuration error (both cover the same imbalance; YAML pair rejected, single option loads), the duck-typing contract guard (NativeShortCircuitData field-identical to CGMESShortCircuitData by name, order, and type; machine-checked, not comment-checked), PF invariance (an addExternalGrid! slack with finite Sk'' reproduces the manual slack path to machine precision; carried SC data changes no power-flow result, incl. the full ENI record contract), min-case semantics (sk_min used unflagged with the rx_min→rx_max default, explicit rx_min wins, missing sk_min skips the feeder with the engine's :no_source flag), parallel-feeder stacking with unique, removal-safe mrids (suffix continues after the highest surviving id, incl. the same-prefix-bus guard), input validation (ArgumentError table), the convertSlackToExternalGrid! demotion (self-consistent bus types right after the demotion, conversion note contents, no-slack/non-slack-bus ArgumentErrors), the connection statement in the classical result print (Grid connection: prose line naming slack vs. source incl. Sk''/R-X and the internal slack bus; type column SOURCE instead of SLACK on the internal bus, also in the structured report rows), and the internal_impedance variant (slack moves to the tagged auxiliary bus, stiff Sk''→∞ limit reproduces the ideal solution below 1e-8 pu, realistic Sk'' droops voltage and shifts angles, the feeder record stays anchored at the physical connection bus, one internal-impedance grid per bus) |
controls | test/test_voltage_dependent_control.jl, test/test_transformer_phase_shift.jl, test/test_tap_controller.jl, test/test_series_reactance_control.jl, test/test_upfc_control.jl, test/test_hvdc_pair_control.jl, test/test_tap_changer_model.jl, test/test_phase_tap_changer_model.jl, test/test_phase_tap_table.jl | the control-loop console contract (inner-solver diagnostic blocks once per run, one summary line per later pass and one closing line when the loop ends :blocked, no wrong-branch block with the detection off, control.verbose_passes for the full per-pass output, the result header naming the passes, the AC island table once per run on a net with two AC islands whose control passes and tap probes solve it several times, with compact and full console diagnostics, once in an auto-mode run over several escalation stages, under auto_slack after the promotion line and naming the promoted slack as the reference, and from a direct positional runpf! only with verbose > 0), Voltage-dependent controls, transformer phase-shift control, tap-controller behavior (also on a net with two AC islands that both have branches: the direction probes solve under the run configuration, the controlled island ends as the same island alone, and a failed probe solve answers as on one island and restores the branch; a tap ending at tapmin leaves the voltages of a single solve at that tap after the closing solve of a :blocked run, whose iterations count in the total; a bus without a branch stays Isolated through every control pass and a second runpf!, and the run ends with the tap and voltages of the same net without that bus), YAML controller instantiation (round-trip via the real YAML reader against the programmatic twin, load-time and apply-time validation, idempotent re-apply), machine remote voltage control (MachineVoltageControl: API validation, secant convergence onto a remote target, the runtime.parallel switch of the run configuration deciding the island fan-out of the control solves on a two-island net, for a SparlectraConfig passed to `runcontrol!and forrunsparlectrawith and without the DC seed (in a child process with two threads, since gates and CI start one), honestatlimiton the reactive bounds), the STATCOM current-limit mode (registration validation incl. rating exclusivity and theimaxkaconversion, at-limitQ = V * Smaxtracking with live bounds across operating points, deadband-level in-range equivalence with the constant-Q mode, inert mode fields on constant-Q controllers,STATCOM (VSC)element vocabulary) and the SVC-vs-STATCOM limit contrast on one sagging corridor (acceptance: delivered Q asserted againstV^2 * BversusV * Smaxnumerically), the FACTS config surface (smaxmvaSTATCOM andvinjmaxpuSSSC entries instantiate viaapplyConfiguredControllers!, re-apply skips both; regression: the series idempotency check crashed on wrong field names instead of skipping), successful baseline PF preservation when controls are disabled (the iteration total of that solve also on:disabledand:noactivecontrollers), theconventioncheck, the neutral voltage and the ratio-tap hand values (calcRatioTapRange,calcRatioTapCorrection,calcTransformerRatio), the CGMESPhaseTapChangerModel/calcPhaseTapFraction/calcPhaseTapAngleRatio/calcPhaseTapReactanceformulas plus the DTF importer migration onto them, and the tabularTapTablePoint/kind = :tabular/calcPhaseTapTableoverride path including the formula-vs-table round-trip regression; the PST X(α) coupling (winding-resolved model lookup, continuous-angle formula evaluation, nearest-row tabular mapping, accepted moves updatexputo the model value at the final angle, devices without reactance data stay static, probe direction consistent with and without tracking incl. angle/reactance restore) and the cross-type warning when a tap controller already regulates a machine controller's target bus; the master/slave transformer group (circulating-Q physics on misaligned parallel units, group stepping with aligned taps and near-equal reactive split under a group-sized deadband, follower exclusivity/self-follow/double-follow/mode validation, the same-target-bus warning,followersthrough the config surface,(+N followers)element label; the CGMES side lives in the importer suite: a patched MicroGrid copy with two RatioTapChangers on ONE TapChangerControl imports as one master with one follower); the SVC shunt voltage controller (API validation, in-range secant regulation onto the setpoint with the actuated shunt carrying the same susceptance, honest constant-Batlimiton an unreachable target,clearShuntControllers!); the MSC/MSR discrete bank mode (registration validation incl. step sign and no-admissible-block range, start-value snapping onto the block grid, whole-block truncated stepping that parks withstatus = :parkedbefore crossing the target without exhausting the outer budget,atlimiton the outermost block,MSC/MSR (switched shunt bank)element vocabulary withdiscrete = trueand step fields on the report row,stepmvarthroughapplyConfiguredControllers!incl. idempotent re-apply, continuous-SVC regression, and a bank on its top block next to a tap controller on the same bus that switches back once the tap lifts the bus over its band,atlimitonly with the error pointing out, and the same bank not left parked outside its band when the tap moves the bus, from block 0 and from the top block); the controller priority (a bank at rank 1 behind the tap of its bus waits in the first pass while the tap moves, acts in the pass after the tap reachedtapmin(the snap onto the limit is a move along it) and ends inside its band; a tap locked by the dead time of a sequential run (locked) moves nothing and writes no trace row, holds the bank at rank 1 while it is outside its band and not at its limit, and lets it act in its band or attapmin; equal ranks, both 0 or both 3, give the same run with the bank moving in the first pass; the cross-type warning at equal rank and for a bank with another target at rank 1, none for a bank target on the edge of the tap band;priorityin every config type, a negative rank failing at apply with the entry named; a bank at rank 1 behind a STATCOM switching in the pass after the STATCOM reached its current limit and converging within the default budget; a tap control range inside the physical one stopping the tap at its end with the bank switching in the pass after, also on a tabular changer at the last table point inside the range, set on the tap controller of the case throughcontrol.controllerswith a side left out keeping its value, a range outside the physical one or an empty range failing with the entry named, a start ratio outside the range going onto its nearer end in the first pass whatever the voltage error, on the plain step grid, on a modelled transformer whose range ends between two steps and on a tabular changer, which stays on its table points, with the warning naming the transformer, start ratio and step, the limit and the new ratio) and the generic controllable-element view (controllableElementsrows for tap, machine, and shunt controllers incl.ControlRunResult.elements); the TCSC series-reactance controller (SeriesReactanceControl: loop-network target tracking within the deadband, honestatlimitclamping on an unreachable target, registration validation incl. transformer rejection and theepszimpedance guard, and the no-move deadband case; SSSC injected-voltage mode, limit-form exclusivity validation, converged operation inside the live current-dependent windowxbase ± vinjmax/|I|, pinned operation with the effective injected voltage atvinjmax, live window bounds on the element row, mode fields on the report row, summary printer naming the SSSC limit, and TCSC-mode regression); the UPFC stationary quadrature composite (addUpfcControl!: exact equivalence with the manually registered SSSC+STATCOM pair on a two-corridor fixture, both limit characteristics at their clamps, composite-level rejections (the full-model registration errors among them) and the series-side rollback leaving the net untouched, YAML typeupfcincl. the double-apply no-op) and the full DC-link-coupled model (model = :full: independent line P and Q reached simultaneously with the DC-link residual closed on a meshed sending-bus fixture, the series active injectionPsenonzero,seriesphase = :quadraturereducing to a standalone SSSC withPse = 0, theUPFC (full, DC-link coupled)element row, per-model registration validation, the YAMLmodel: fullround trip with the double-apply no-op, the low-currentzaddguard keeping the branch finite at its base impedance on a near-dead line, and the negative-resistance branch left by the full model being rejected loudly by a subsequent IEC 60909 short circuit while the base network runs); the HVDC pair controller (HvdcPairControl: registration validation incl. slack and PV guards, exact pairing invariant on a two-island fixture, reversed transfer, rating clamp with honestatlimit, per-side voltage-target secant incl. unreachable-target clamping, bit-identical baseline with a disabled controller, MATPOWERpairedcontrolmode with thepfinjectionsconsistency anchor, every MATPOWER type-3 bus as its island's reference (a second one in the same island stays PV with a warning) with reference priority 1 on the units of every type-3 bus in the direct import and the SCF conversion, YAMLhvdcpairround trip, element-row vocabulary:hvdcptransfermw/:hvdctransfer, the grid-formingmode = :islandfeedincl. mode-dependent validation, the island-draw mirror (a load on the PCC itself counted once), the rating clamp, and the YAMLmode: islandfeeddeclaration; the persistentHvdcLinkrecords (net.hvdcLinksfills for MATPOWER Stage-0/paired andaddHvdcLink!, controller attach/detach round trip), theHVDC Link Flowsresult surface (table, header count, converter-loss line,ACPFlowReport.hvdclinks), and the one-reference-per-synchronous-island rule (multi-reference error naming the buses, setpoint pair as parallel PQ path next to an AC tie,invalidtopologyfor a demotedislandfeedreference)) Since 0.20.0 a typed:asymmetricalphase model on a winding drives the branch (the model shift at its step, the precedence line innet.tapModelNotices`) and a phase controller moves the model step (3 to 5) to the flow of a branch built at step 5. |
Group reference: surface, service and fixture groups
| Extended addition | File | Main checks |
|---|---|---|
workshops | test/test_workshops.jl | Every docs/lit/workshop_*.jl runs top to bottom in its own module with output and logging silenced; a failing @assert in a workshop fails the test. The @assert lines carry #src: they run here and do not appear in the notebooks and generated pages. The generated notebooks and pages cannot drift from the library unnoticed. About 50 s. |
install | test/test_install.jl | The installation path of a fresh checkout: a copy without the application manifest, start_webui.jl --env-only run twice as child processes offline against the depot; the first start reports the environment setup and the compile, the second reports both environments up to date and the packages compiled. The develop step of tools/build_sysimage.jl runs in a child against a temporary environment that holds both packages from a stand-in checkout of another version, and must take both from the new one. The workshop installer (tools/install_workshops.jl, without network and Jupyter): two folders get two kernels, the same folder the same one; a notebook the installer wrote and nobody touched is replaced without a backup, a changed one is kept with a date stamp and an earlier backup stays; a failed install of Sparlectra (child process, offline, stand-in checkout) restores Project.toml and Manifest.toml. |
webui_state_estimation | test/test_webui_state_estimation.jl | The state estimation surface of the Web UI on warmupcasePST in ten sections that share one case directory: measurement upload and set selection, the generator and set storage, the sigma table in the form, generator options and tap deviations (the resolution fields at 0 give the set byte-identical to the default; with a resolution every telemetry value is a multiple of its step and the header carries the # resolution: line; a negative step is rejected), page state and the value editor, the run summary and topology panel, service SE runs with topology, tap and bad-data checks (a weakly observable set no longer stopping the run: the class at the estimated state marks the result unusable in the metadata, the message and run.log, and leaves the estimated flows empty in `sedeltas.csv, the bound from the configuration file of the run; the same set with the default bounds stays usable;setapestimates.csvwith one row per tap changer, warmup_casePST without itsmpc.sparlectra.tapchangersblock giving no tap state, no tap row and the run.log note on the documented deviation, identification and the three step columns first with a number in every step cell, and a machine row with statuscalculated, the deviation of the asymmetrical regulator and of the PST, the regulator count in the summary, the "estimate taps" and "tap fallback" boxes posted false becoming the two overrides, and a run withtapestimation.enabled = falsegivingdisabledrows and the hint for a set that documents a tap deviation; the tap estimation table of the Case page: two rows with the machine transformer unchecked, a save with the PST unchecked writingstateestimation.tapestimation.excludeinto the case configuration, the reloaded page posting the same choice, the next SE run with the PSTexcludedand its run.log line, a checked machine transformer settingincludemachinetransformers, the defaults removing both keys, a machine transformer named inexcludeby the case configuration kept there by a save without touching the table andexcluded(not calculated) in the next run, and the run.log warning for an entry without a transformer), generator variants and zero injection (0.60.0: a run underonreports the gain matrix and its condition number in the metadata and the run.log numerics line and writes no multiplier file, the fieldsezeroinjectionsigmamvabecomes the overridestateestimation.zeroinjectionsigmamva, a run with that override at 0.01 on the set without its ZI rows adds them at 0.01 (run.log line and the sigma of every ZI row ofmeasurements.csv, under a process default of 1e-3), a run of the case onconstraintreports the KKT matrix and writessezeroinjectionmultipliers.csvwith one finite P and Q multiplier per bus, here the fused coupler bus aslinkaggregate), thresholds and request options, and the chain to power flow and N-1; the fieldserotatebehindpstpostsstateestimation.startmode.rotatebehindpst` as a configuration override; observability gaps on the shipped spcase14 with transformer Wehrden11020 unmeasured (two observable islands, deficit 1 by hand): abort fails with se_observable_islands.csv, se_unobservable_branches.csv and the run.log line, its result page carries the Observability section, and the POST bodies of its two repeat buttons run observable_islands (two islands estimated, Wehrden20 relative, the operation-log line) and scheduled (one restored P row with origin `pseudorestorein the verdict); the placement page posts one injection step (se_placement.csv, run.log and performance.log lines); a small result table has a count and no slider, an unobservable-branch table above the row cap renders exactly the cap with the slider, the count and the CSV link. A backup copy of a series zip (.qsts.zip.replaced-<date>`) is not offered as a case. |
webui | test/test_webui.jl | Focused Web UI coverage for form parsing and backend validation, result rendering, active and terminal timing cards, commit-span omission, tolerance-step hook, path traversal rejection, DTF upload role classification, primary-case and FOR002 selector filtering, the CGMES-export run option (form checkbox + help topic, export_cgmes request flag incl. hidden-false/absent-field defaults, and the result-page summary row for completed/failed/absent export metadata), the last-edit-wins precedence between the configuration file and saved case settings (a newer YAML wins for its own keys and sets the notice flag, an older one keeps the sidecar values), the SE phase-5 chain (measurement-set upload classification via content sniff, the set list of a run offering only the sets of the selected case (by # case: line, by the # cgmes_model: line against the EQ model id of a CGMES case on the SmallGrid fixture, the id read from the file headers and checked against the full RDF reader, else by file name), the assign switch of the measurement upload (the stored copy bound to the selected case with CRLF kept, armed for the next run, a measurement file of the same name replaced, a CSV without version line refused), a measurement table recognized on upload, offered, shown with its row counts per type, opened in the text and value editors (a quoted cell stays one cell) and handed out by the download route, the generated sets read back as tables (U in kV giving back the pu value of the truth run bit for bit, zero-injection rows marked by their source token), a table of another version offered without counts, the SE section of the Runs page (/stateestimation is a redirect onto its anchor) and demo generator, the service-level SE run with artifacts and history kind se, the SE-started PF and N-1 with the SE run id in the metadata and result parity against a manual run), the measurement generator v2 chain (truth state fresh-solve/from-run with bit-exact state adoption and the rejection paths, deterministic balance-aware single flow ends, passive nodes at a configured sigma or as protected ZI constraints, the sedeltas.csv artifact, and the bad-data threshold surface with staged/legacy service parity and invalid-mode rejection; plus the Delta-u PST chain on the tracked warmup case: generator targets the additional-voltage stepper, the mass release estimates it :pst along the nameplate psi, the fixation lands on the injected step, and the machine trafo stays calculated), the refresh of shipped case copies at Web UI start (a CRLF copy of an earlier committed version is replaced, kept as <name>.replaced-<date> and logged with the old hash, also for a packed CGMES demo ZIP; a copy the user changed and a current copy, also one in CRLF, stay untouched; `data/shippedhashes.tomlcarries the current content of the staged sp_case14 files and of the ZIP the Web UI packs; a write that fails with a full disk leaves the copy and no temporary or kept file, an unexpected failure is rethrown with the same cleanup; a hash list with a value of the wrong type or broken TOML is reported as damaged), the buildSysimage one-call dry run, the sysimage launcher decision from tools/sysimage_launcher.jl (image/metadata present, Julia version, Manifest hash, a src file newer than the image, and the no-terminal default) together with a parity check thatSparlectra.webuisysimageproblemreturns the identical verdict for every one of those states (the two implementations cannot share code, because the launcher runs before the package is loaded), the sysimage build-progress contract (a build that stopped reporting for more than a minute counts as gone, so a crashed builder cannot lock the refresh button) and the Sysimage page rendering idle, running, and failed including its build-log tail, a parse check of the generated app CLI driven from the checkout tool, and stubbed route checks without a real asynchronous solver run. The update check of the Info panel runs on a stubbed fetch, never the network: up to date (also a checkout ahead of the release), newer, no network, timeout, rate limit and answers without a release tag; the layout detection (git checkout, worktree pointer file, installed copy, unknown for the app, a renamed download and a folder without the install script); the unattended answers from the sysimage and launcher on disk; the check page per layout; and the install action, which starts nothing for a git checkout, an unknown layout, a REPL session, a missing confirm, a stale token or an active run, and for an installed copy hands the detached command to a stub (the updater script checked withsh -n, never run); the sh installer in workshop mode outside a checkout, with a fakejuliaandcurl, passes a folder name with a space and a glob character and a–revwith a space as one argument each and removes its downloaded copy of the workshop script, plus the Windows plan with itsstartline and CRLF batch file. Real asynchronous PowerFlow job lifecycles, artifact preview/download/ZIP/history/delete matrices, the number display of the CSV artifact table (significant digits with a default of 5, power columns in whole W/kW/MW with 1.98e-16 MW showing 0, a pu column and integer cells unconverted, a semicolon file read and shown with the decimal comma, the choice from?digits=&power=with a silent fallback on bad values, carried on the links to the other CSV files and the raw view, file and download unchanged), the sort of number and text columns, the header alignment and the hidden columns of?hide=on the sort links, the Apply form and the raw view, browser-launcher platform matrices, socket/server lifecycle checks, Markdown help/documentation cross-product validation, repeated real MATPOWER runs, and the scenario editor flows (a three-op scenario created through the form on the shipped sp_case60 bundle (staged copy switched to explicit-list mode), saved, reloaded and run with:flagshowing the row and the screening columns; the result page's N-1 table showing a screened row with its estimate detail after:flag, no screened column after:off, and a failed case's error text in the row; atapposop on a regulated transformer rejected with the controller named and NOT written to the file; a MATPOWER case getting the export hint with no editor, nofileblockoption on the main form, and an SCF case getting both), and the outage counter of a running N-1 job (a real job held after its first finished outage:progressdone/progresstotalin the job snapshot, the counter element with those numbers inside the polled status page,done == totalat the end, an abort during the batch still ending the job as aborted, no operation-log line per outage) are extended-only inwebuiextended. Since 0.20.0 the state-estimation part takes the written set names from the redirects: every generation and noise action writes a new time-stamped file that the redirect arms, the newest bound set is armed without an explicit choice, and the delete route removes measurement sets only (plain names, never a case file). The help ships as two pages (/helpfromwebui.md, at most 1500 words, and/help/referencefromwebuireference.md); every target of the search index and every link between the two pages lands on a heading its page carries. The help search (/help/search?q=) is checked on its hits forxiidm,short circuitandcgmes:with their anchors, on two words narrowing the hits of one, on the marked words of the snippet, on a query without hits (the statement and the link to the published documentation), on queries with markup (escaped), on the hit list alone (fragment=1) and on the search form in the header of a page. Inwebuiextendedthe SE form settings resolve by their configuration key path, the nestedtapestimation.impedancecorrectionincluded, and an SE run with that override atoffcarriessetapimpedancecorrectionin its metadata. Inwebuiextendeda power-flow run on an uploaded.xiidmwrites the import reportpowsyblimport.logwith the slack of the component and names it inrun.log, and the pageshow handler of the run form, evaluated on the buttons of the rendered page, keeps the Short circuit button that the server disabled for a case without short-circuit data disabled and enables the others. T13 (0.60.0): the QSTS button onspcase14day.qsts.zip(enabled only for a series, the mode select rendered only for a series and the options of the other formats left out there, staged with its control file,runmodeqsts, files and one SVG per element, a point per solved step, the chart route returns the same bytes,qstsnoseriesfor a case without a series). Short-circuit status levels on a synthetic SCF case with one placeholder machine (nox''d, ratedS 141421.2 MVA) and one feeder without a current: statuswarningwithshortcircuitpartialdefaults,scflaggedrows4 andsclowerboundrows2, the CSV columnlowerboundtrue only on the island of the skipped feeder, the placeholder named in the reasons of the rows it feeds, both counts on the result page; the head line of each case (run status, flagged rows, lower-bound rows) directly above the table title inrun.log, in the metadata (scstatuslinemax/min), on the result page and above the table of both CSV artifact pages. The format-bound options of the Case page: a MATPOWER case renders the MATPOWER options and the frequency select disabled at the configured key, a posted frequency is not stored for it, a value stored before shows in the disabled select and the next save from its page removes it; an SCF time series (spcase14day.qsts.zip, base case at 50 Hz without linec1) and an SCF file withoutmeta.fnomand without linec1show the select disabled and do not store a posted frequency; an SCF file stating 60 Hz renders no MATPOWER options (Export Solution stays), names the left-out count and shows the select disabled at the file's 60, an SCF file withoutmeta.fnombut with linec1shows it enabled at the configured key; a save from the SCF case page, with the fields the page renders, keeps amatpowerimport.ratiosaved before and stores no frequency. The form state takes an SCF file'smeta.fnom(60 Hz, and for a bundled case not yet in the case directory its own 50 Hz), a configuration file seeds the select, and a posted value reaches the run configuration as an explicitly set key; run on a 60 Hz file, no stored frequency gives no frequency warning inrun.log, a 50 Hz written into the case file before the lock gives exactly one,result.jsoncarries the file's 60 Hz both times while the frequency line says it is not used (no linec1), and the next save of the case options removes the stored 50. The sigma table of the SE section posts one row per nominal voltage of the case, Save settings writes the table into the case configuration (the general file stays untouched), the reloaded page shows the saved value, the file keys the row by the nominal voltage and the form of the reloaded page gives the saved table again, a 15.5 kV level saves as the row15.5:and loads back, a run request carries it as an override and a request without it does not, a zero sigma is refused with the case configuration unchanged, and an empty table saves an empty mapping; a stored table in flow style is named on the page and the form posts no table (so the run stops with the error instead of running on empty cells); the cells show the case configuration only (empty without one, also when the general file sets the key), the page marks a stored table so that clearing its cells clears it, and an empty table that was empty on the page posts nothing; before the first measurement set the section shows the table in a save form of its own. At Web UI start a key this version no longer reads (the absolute Q-limit thresholdviolationthresholdpuin an old copy of the configuration) is removed from the configuration file, also when the Web UI saved it, with a backup and one report entry, and the file then loads without a warning. Remote mode: thewebui.remote*keys load with the SSH tunnel as default and refuse a mode, port, token or bind address the server cannot use (an unquoted token of digits and an unquoted bind address::1or::are refused with the key named and the hint to quote them, digits beyond Int64 fail at the line naming the key, the quoted token keeps its leading zero, the quoted::1reads back), and the launcher hands–remoteto the process relaunched on the sysimage; inwebuiextendeda start withremote = truecalls no browser opener and keeps the browser-close shutdown off,webuiconnectioninforeturns host, bind address, port and mode for an SSH, a local and a direct start, Stop in remote mode saves no window geometry, the direct mode refuses a request without the token or with a wrong one (401, logged aswebuiaccessdenied), accepts the token once by URL with a redirect and a cookie and then serves pages that do not show it, two servers in one process answer interleaved requests each with their own port in the Info menu and their own mode in the footer, an empty configured token gives a new 128-bit token per start, the SSH mode withremotesshrequiretokenrefuses a request without the token and its console lines (webuiconnection_lines`) carry the address with the token, and the Info menu shows the tunnel command in the SSH mode only, never the token. |
contingency_extended | test/test_contingency.jl | N-1 identity slice on the shipped spcase1354 (first 60 branches): serial vs parallel field equality with `maxtasks=1and auto, plus a:flat` ladder stage leaving converged cases unchanged |
scenario_engine | test/test_scenarios.jl | The screening acceptance on the shipped spcase60 (all branches, all generators): with `screeningmode = :flagand margin 10 no case the full run reports as violating (or failed) is screened away (false-positive count and full-run share are printed, not gated), the:flagrows keep the order of the full run with the estimate on a screened row, the screening CSV appends the two screening columns, and:onlyruns no full solve where an estimate exists; the same acceptance with distributed slack enabled (augmented lambda system, renormalized participation on a generator outage, screened share and seconds printed); the sp_case300 acceptance per the test-network rule (operated grid, no false negatives at margin 10 with the 0.005 pu trust gate; loud SKIPPED without the local case file); the sp_case1354 run measures runtime SCALING only and runs withSPARLECTRATIMINGTESTS=1(a SKIPPED line otherwise) (:off/:flag/:onlyseconds, gated onSPARLECTRALARGECASESDIR, no screening-quality claim, see the test-network rule); the service sources: an SCF case with its own scenarios block runs viascenariosource = fileblock(screening metadata plus the two CSV columns), an external scenario JSON viaexternalfilewithscreeningmode = offkeeping the classic columns,n1generatorsrecords itself as the case source, unknown sources or a missing scenario file reject asinvalidrequest`, and a CGMES delivery with an id-addressed scenario source is rejected with the way out named (export as SCF once, then reference its component ids); on spcase60 the warm active set gives the violation list of the cold run, the cold check with a margin over every outage leaves no outage more favourable than the cold run, and the order of "less favourable" (a failed result never wins, more violations, lower lowest voltage, higher loading); event and pair screening (#355): no false negative against the full solve for every generated event and every N-2 pair on spcase14, spcase60, spcase188 and the events of spcase118 (the large lists solve only the cases the screening keeps), the reasons :link and :splits_graph, the Woodbury rank limit; the service with contingency.events.* and contingency.pairs.* on spcase14 (counts by kind, file names in the rows, the pair cap, a MATPOWER case running plain N-1 with the reason in run.log); the injection batch (`runinjectionbatchtests) on the shipped sp_case14: the seeded random factors repeat and stay in the band, the ramp has its end points, every scenario of the CPU batch equals a singlerunpf!on a copy with the scaled loads and the batch configuration (Q limits off, no rescue) in voltages and iteration count bit for bit, the net is not changed, the threaded batch equals the serial one in five repeats (RAN or SKIPPED with one thread), the warm start (start = :base) equalsrunpf!from the solved base case bit for bit, power mode with warmed workers gives the same states, the executor rule (autotakes processes on a large network, threads or serial on a small one and on a network too large for two workers in the free memory,parallelenabled = falseis serial), the process batch on two worker processes equals the serial batch bit for bit twice on the same pool (the second batch reuses the worker state), with the warm start and in power mode (the workers warm their copy) as well, the N-1 batch in processes equals its serial run with screening off and on, an abort set while items run on the workers stops the running items and the batch throwsPowerFlowAbortedwithin 20 s (the probe item would run 60 s), a worker that has left the pool is no longer listed bybatchprocessids, and the pool is stopped afterwards, a GPU request without the CUDA extension runs on the CPU with the reason and a warning or throws withgpufallbacktocpuoff (RAN when the extension is not loaded), a two-phase request on the CPU backend throws, and with the extension loaded (the GPU environmentbenchmark/gpu) the three GPU strategies match the CPU batch (convergence, iterations, Q-limit counts, voltages within 1e-9 pu and 1e-6 deg), the uniform batch without the mask, float32_mixed and the warm start match as well, the two-phase variants:g5,:g5rand:g6` reach the tolerance with the CPU convergence and agree with each other to 1e-9 pu, and the default repeats bit for bit (RAN or SKIPPED) |
example_infra | test/test_example_suites.jl | Example suite runner infrastructure: CLI parsing, skip and filter logic, CSV and Markdown escaping, registry integrity, and a –help smoke test of the generated runners |
matpower_examples | test/test_matpower_example.jl | MATPOWER example runner path on the shipped data/mpower/sp_case9.m (no download): the standard path with its warmup runs, output routing, performance/profile rendering, the compact summary, runtime thread status, and the benchmark mode as a package extension (with BenchmarkTools loaded the extension is there and the routing test runs; in a process of its own in the library environment alone the mode stops before the case is read and names using BenchmarkTools) |
synthetic_grids | test/test_synthetic_grids.jl | Synthetic network generation and larger synthetic-grid regression coverage |
configuration_docs | test/test_configuration_docs.jl | Configuration documentation and docs/config consistency checks |
cgmes_importer | test/test_cgmes_importer.jl | CGMES importer on synthetic in-memory deliveries and on the checked-in deliveries under data/cgmes_demo (exported by tools/gen_cgmes_fixtures.jl from spcase14, spcase118 and spcasePST). Synthetic: generic reader semantics (profiles, overlays, references, DifferenceModel skip), the base-voltage inference (without it the import aborts and the power-flow and short-circuit services write the analysis into `cgmesimportreport.md;inferbasevoltagesreconstructs stripped catalogs from the SV state, one summary warning, net still solves; without the option the typed abort stays), the self-loop line guard (its charging kept as a shunt addressed under<line mRID>#charging), theEquivalentBranchmapping on the synthetic delivery oftest/cgmessynthebfixture.jl(one level: a branch withr,xon that base; across levels: per-unit ratio 1 and the impedance on the base of terminal 1; withr21,x21a pure rotation ofr,x, one on each level kind, the second parallel to a lineEquivalentBranch: ratio 1, shiftarg(z21/z12)/2, series impedance and shunt arms equal to the stamp withY11,Y12,Y22exact to 1e-15, no tap controller and an empty tap changer set,EQBandEQBTkeys apart, the delivered values inequivalentbranchmetadata(also in adeepcopy); a self-loop and a disconnected object skipped; one notice with the counts and the stamped objects; with every object out of service all five are skipped and the class gets no row in the table of classes not mapped; the SV profile is the exact two-port model solved by the fixture itself;compareWithSVflow rows of the branches below 1e-6 MW and voltage magnitude and angle deviations below 1e-6 at the SV state and afterrunpf!; the net solves without isolated buses; with|z21| = 1.01 |z12|the notice names two such objects and the maximum 0.01, at the SV state the terminal flows miss by|V1| |V1 - V2| (1 - 1/sqrt(1.01))/|z12|and|V2| |V1 - V2| (sqrt(1.01) - 1)/|z21|, afterrunpf!the voltages lie below 2e-4 pu and 0.02 degrees from the SV; anEquivalentBranchwith negativerkept unchanged, solved, namedequivalentbranchin the result rows with its negative loss (EqBrin the printed table), exported and taken by the short circuit with its count line; the phase stamp withz21 = -z12andz21 = -0.99 z12: stamp angle 90 degrees,Y12 Y21exact,Y11,Y22off by the square root of the magnitude ratio, and a three-bus net solved within 1e-3 pu of the exact two-port, 1e-9 for-z12; anEquivalentBranchwith an impedance of 1e-8 pu becomes a bus link with its notice and a count in the summary, and stays a branch withequivalentbranchminzpu = 0(keyword) or1e-9(configuration, default1e-6, a negative value refused)), a three-winding leg with negativer(synthetic star delivery) passes the CGMES export and re-import with the samerand power flow, the MATPOWER export, and the short circuit with its count line and an LV fault impedance equal to the HV grid impedance plus legs 1 and 3, while a line and a two-winding transformer with negativerstill abort both exports and the short circuit, the import-failure analysis (importFailureAnalysisnames supplied models, missing vs. satisfiedmd:Model.DependentOnprerequisites, and the verdict; theimportanalysismodeservice run succeeds on an importable delivery, fails withimportanalysisnotimportableon a missing declared dependency with theimportanalysis.txtartifact written, rejects non-CGMES cases, and excludes the other modes),ReactiveCapabilityCurveinterpolation, result-table alignment with long names, the Web UI documentation wiring, test-set alias/border bookkeeping (table consistency only, no fetch), the synthetic 3W star delivery (3W-leg tap controller fromTapChangerControlwith control-loop convergence, legs and controller addressed inelementbymrid, the star point start from its own node balance with an end-1 tap 8 % off neutral, a magnetizing admittance on every end and an SV written from the solved model (each end's admittance at the star node and none at the side bus, for the tapped and the untapped legs, no star current at the start, the three leg flow rows ofcompareWithSVequal to the SV, a side with SV voltage 0 keeps the end-1 start; with the side terminal of the tapped end 2 or the untapped end 3 open the leg stays open at its side bus with the end's admittance as its input admittance at the star, the two closed legs feed that admittance after the solve, and the export writes the terminal withconnected = falseand re-imports the leg open at the same bus with the same power at the star and the same voltages at the other buses),NonlinearShuntCompensatormapping and itscompareWithSVflow row, the multi-valued reference notice; a heavily loaded variant with two solutions, started from the SV of its low-voltage solution (a synthetic trigger: on the corrected star-point start and tap side the HV-side star start no longer leads there): the run stays converged, carriesplausibilitystatus = lowvoltagewith the MV bus and its voltage and logs the warning, passes atvminwarn = 0.4, is not checked at 0, the flat start reaches the operating solution without a warning, and a service run on the same delivery writes the warning intorun.logand the metadata), a synthetic two-winding delivery with aRatioTapChangerTablewhose point at the tap position differs from the linear step formula (branch ratio equal to the table point, transformer flow rows at the SV start and the solved state equal to the SV profile, withtapcontrol = truestart ratio, range and step from the table and the control loop ending on a table ratio for targets between two table points, per-step r/x corrections named once in the messages and the point of the tap position applied to the series reactance), the tap at the terminal of its own end (a 3W tapped at end 1 and a 2W tapped only at end 2, both off neutral, with an SV computed in that arrangement, the 3W magnetizing admittance of a tapped and an untapped end at the star node: the tapped leg runs side bus to star, the 2W end 2 to end 1, and the transformer flow rows ofcompareWithSVstay below 1e-6 MW, for the 2W at the SV state, for the 3W at the solved state; the 2W with aRatioTapChangerTablepoint carrying r, x, g, b deviations gets r, x, b, g scaled by them and matches its SV the same way; the tap changer sets of the state estimation that the import stores per transformer (tap changer sets of the tap estimation: the own export of typed asymmetrical, symmetrical with an xMin/xMax curve and tabular phase models, a RatioTapChanger and a transformer tapped on both ends, the synthetic 2W RatioTapChangerTable with r, x, g, b on every point and the synthetic 3W with two tapped legs; kind, side, increment, direction, band and step of each changer, and at the import step and two other steps the ratio, shift and impedance of a re-import; an empty set for a transformer without changer and for the export's single-step PhaseTapChangerLinear of a fixed shift, which stays a changer and is released as a phase shifter when one of its five values or thePTCsuffix differs; a changer whose table has a step that is not whole stays in the set as a fixed part, so the set still gives the branch at the import steps), sp_casePST with a Delta-u phase shifter in SCF and none in CGMES (spcasePST: the CGMES and the SCF tap changer sets differ, the difference pinned); under a voltageTapChangerControlthe controller moves the tap off the start step and the branch carries the table point of the step it reached), remote-regulating machines (default held-PV fallback,machinecontrol = truecontroller wiring + control-loop convergence, the voltage-held-target fallback, a machine withcontrolEnabled = falseas a PQ bus without held-PV fallback in the default import and without controller undermachinecontrol = true), theshortcircuitmoderejections (MATPOWER rejected withshortcircuitrequirescgmes, mutual exclusion withdiagnosemode),cgmesimport.startvalueshaving no effect on a MATPOWER run, and the invertedvsetminpu/vsetmaxpuband as anArgumentError. Checked-in deliveries:summarizeCGMES(version 2.4.15, no unresolved reference, no boundary hint),importCGMESon the folder and on a zip packed at run time (bus, branch and link counts, slack, no bus without SV, no importer warning), anSvVoltagewithv = 0taken as no SV (bus started at the voltage of its neighbour over the branch or link of the smallest impedance, listed innosvbuses, one notice; on a copy with every SV angle shifted by -40° a leaf bus withv = 0behind anEquivalentBranchstarts at its neighbour voltage and solves there instead of at 0 V; a listed three-winding star point is left alone, and a listed bus reachable only through it keeps its start), a bus that keeps only its switch to a loaded bus and is the smallest bus of its switch group (shared fixtureisolatedfirstnetintest/testrunnerhelpers.jl, exported and re-imported with its line open) is marked isolated but starts at the voltage of that bus, andrunpf!` ends on the high-voltage solution of the same net instead of the low-voltage branch a 0 V start reaches, on a copy of spcase14 an SvTapStep four steps off the SSH step the SV was solved with (one import notice, the tap changer in sv_tap_step_fits with both steps, none on the fixture itself), the SV profile and the source case's solution reproduced from the SV start and from a flat start (compareWithSV max |dvm| and |dva| below 1e-6, flow rows below 1e-6 MW, bus-by-bus agreement with the source net solved the same way, Q limits on), the OLTC of spcase14 arriving as a voltage tap controller only with `tapcontrol = true(same target bus, target and deadband as the source case, transformer on the same buses with its tap machinery, control loop converged within the deadband), the PST of sp_casePST keeping its negative shift and its bus link (addressed under the Breaker mRID), the angle alignment ofcompareWithSVper electrical island (on sp_casePST the buses behind the closed breaker, an island of their own in the branch-only view, keep the offset of the whole delivery, so a 2 degree deviation there is reported), the sp_case118 synchronous condensers arriving as regulated zero-P units and the asymmetricminQ/maxQpairs arriving as the Stage-1 hull, the SCF export of a delivery (mRIDs asexternalid, deterministic file, re-import to the same solution),runsparlectraapidispatch on a delivery zip (format and version metadata, the sections ofcgmesimportreport.mdand itstext/markdownartifact type, SV comparison artifacts of the auto start,startvaluesflat and sv winning over a hostilepowerflow.flatstart, the report written when the solve fails), theimportanalysismodeandshortcircuitmode` service runs (the short-circuit run completes with every row flagged as a lower bound and names the missing machine data, because the exporter writes no x''d, ratedS or ratedU), and the fixed-reference self-check (SV start verbatim under a flatstart: true base config, start residual at noise level, residual CSV, transformer adjacency, no-SV buses: 0; on the spcase14 copy with the SvTapStep four steps off, the tap changer listed in `selfcheck.logwith both steps). ENTSO-E SmallGrid (test/fixtures/cgmessmallgrid, with boundary set):elementbymridnames for every line, transformer (the one with tap changers only at end 2 running end 2 to end 1), load, machine, equivalent injection and shunt the element on the object's buses, indices unique per kind and every branch, prosumer and shunt addressed; the Q limits of anEquivalentInjection(SmallGrid states none; on a store copy aminQ/maxQpair arrives as its hull, aReactiveCapabilityCurveoutranks the pair with one notice, the pair 0/0 leaves none; itsminP/maxParrive as delivered, in generator sign, none from 0/0); P limits of 9999 MW and above as no limit (on a store copyminOperatingP/maxOperatingPof ±99999.9 on the unit of DeerCrk SM and one such side of anEquivalentInjectionpair: no P limits on either, one notice counting them per class, the machine's Q pair of ±99999.9 kept, the import slack unchanged,ensureSlack!without the slack unit and without the external units takes an 800 MW machine, and thepmaxweightedandheadroomweighteddistributed slack gives the machine no weight); a store fromloadCGMESbuilds the same network as the path and stays unchanged, also without TP and SV, where the topology processor runs on a copy;importCGMES(config; ...)takesignoreconnectedfrom the configuration unless passed; in a store copy a machine withcontrolEnabled = falseis a PQ unit at its negated SSHp/qwith the Q limits of the plain import, a machine without the attribute regulates as before, and the slack machine withcontrolEnabled = falsekeeps the slack role and holds the SV voltage of its bus instead of its control target, each with its notice; the same flag on an addedStaticVarCompensatorwith an enabled voltage control makes it a PQ unit at its SSHq, and on theExternalNetworkInjectionofspcase14keeps the slack role at the SV voltage, or gives a PQ bus once the priority sits on a machine; the threeEquivalentInjectionobjects with a target at their SV voltage regulate only withregulationCapabilityandregulationStatusboth true (status alone gives a PQ unit), and a capable unit without a status is a PQ unit counted in one notice; twoEnergySourceobjects added in memory (terminal andSvPowerFlowon the nodes of two loads, one out of service) stay out of the network by default (listed as skipped, one notice naming the switch, nocompareWithSVunit row, terminal not modelled for measurements) and withmapenergysource = true(keyword, configuration and YAML loader) the in-service one becomes a:generatorPQ injection on its node withp = -SvPowerFlow.p, no regulation, no Q limits and not the import's slack, the other is skipped and counted; moved onto the bus of a regulating machine it shifts the bus Q band by its fixed Q instead of opening it to -Inf/Inf; an island added in memory whose only source is anEnergySourcegets that source as its slack (largest infeed, one warning), and withmultislack = falsestays without slack, is named in one notice, anddetectacislandspromotes that source to the island reference; islands added in memory next to SmallGrid: three two-bus islands without a source, one with a load and an equivalent injection with P = 0 and no regulation, one with a load and an equivalent injection that draws power, one with an equivalent injection that draws power and a load that feeds power in, are de-energized (buses isolated at 0 pu, injections zeroed, line out of service, one message each and one count notice with the unsupplied load, which includes the drawn power, and the power the load fed in reported apart as dropped), and islands with infeed but without slack or voltage-regulating unit get one unit with infeed as slack at the SV voltage of its bus, with one warning each and one count notice: the unit withreferencePrioritybefore a larger infeed and before a drawing machine with a stronger priority, the largest active power reserve off the degree-1 buses of a three-bus chain before a drawing network injection with a larger reserve, the largest infeed when both buses of a two-bus island have degree 1 (that island solves, its slack covers the drawn 70.3 MW plus the line loss), and the infeed on a degree-1 bus before a unit that draws power on the inner bus of a three-bus chain; withmultislack = falseno island slack and no warning; withDynamicDataunit types set on these islands a grid-following unit is no slack candidate (a synchronous unit takes the slack before the stronger priority, a grid-forming unit keeps its choice), an island of grid-following units only is switched off with its warning, dropped generation and unsupplied load, and an island where grid-following units carry all the infeed gets no slack and a warning; an island whose two sides meet only at a bus without a branch, through two closed switches, keeps that bus isolated by the branch-only marking but gets one slack (the larger infeed) and solves with one reference, the bus at the voltage of its switch group, andcgmesMeasurementKeysresolves its node to that bus; and with the SV of one side written 2 degrees off the solved statecompareWithSValigns the angles with one offset for the whole island and reports the 2 degrees on that side; a two-bus island whose only source is a drawing machine that regulates the voltage of the load bus stays energized, by default and withmachinecontrol = true, and holds the machine PV at its own bus without a controller (one notice); the import messages carry oneclass not mapped:row forEnergySourcewith count and SSH P sum below one header stating the load sign when the key is off and neither when it is on, SmallGrid itself has none (its switches and busbar sections are consumed by the topology), and the class count leaves boundary objects out and counts objects without SSH P without adding to the sum; aGroundadded in memory (terminal on a load node, no SSH value) gets a row without P sum, an out-of-serviceStationSupply(a class the importer maps and skips) gets none;PowerElectronicsConnectionobjects added in memory on load buses the plain import leaves PQ (terminal, SSH p and q,SvPowerFlow) stay out of the network by default (listed as skipped, one notice naming the switch, oneclass not mapped:row with count and SSH P sum, nocompareWithSVunit row, terminal not modelled for measurements, no short-circuit flag) and withmappowerelectronics = true(keyword, configuration and YAML loader) become:generatorprosumers withp = -p,q = -q: without a control a PQ injection with theminQ/maxQhull and the summedminP/maxPof aPhotoVoltaicUnitand aBatteryUnit, with an enabled local voltageRegulatingControla PV bus at the target (wide Q limits fromratedS/baseMVAwith a notice, held afterrunpf!), PQ without Q limits whencontrolEnabledorRegulatingControl.enabledis false, a remote target held PV at its own bus by default and an outer-loop controller withmachinecontrol = true, an out-of-service one skipped; one notice counts them, the class has noclass not mapped:line,compareWithSVand the measurement keys count it as a unit, an island whose only source is one gets that connection as its slack by the island rule (one warning), not through the SV angle reference on its node, and withmultislack = falsethe island notice with the connection staying PQ; in the short circuit a connection with aPhotoVoltaicUniton the bus of a machine withoutratedSandmaxOperatingPleavesIk''and the machine's reason unchanged and flags the row as a lower bound, and withmaxIFault,ratedSandratedUraisesIk''there bymaxIFault·ratedS/(√3·ratedU)without a flag of its own; the short-circuit harvest holds the mapped connections only, on the result and on the network; a machine with a disconnected terminal and a network injection out of service, both with full short-circuit data on a live bus, leave no record andIk''and the reasons there unchanged, while their records put back would feed that bus; a machine whose unit becomes aWindGeneratingUnitorSolarGeneratingUnitin a store copy is a converter current source: its record names the class, withshortcircuit.convertercurrentfactoroff it feeds nothing and flags the row as a lower bound, with the factorIk''at its bus rises byk·ratedS/(√3·ratedU)over that (the substitute named, no lower bound,zkand kappa unchanged), withoutratedSbyk·maxOperatingP/(√3·ratedU)(solar), with the placeholders sqrt(2)·99999.9 MVA and 99999.9 MW not at all and with the lower bound, never in the minimum case; the thermal machines of the plain import carry no mark, and the factor changes no row there; an SCF export and import keeps the mark and theIk''; a CGMES export and re-import of a copy with one machine on an offshoreWindGeneratingUnitand one on aSolarGeneratingUnitgives both units back with their class, mRID andwindGenUnitType, and the machine is a current source again. Not covered, because neither the exporter nor SmallGrid carries it: DifferenceModel, CGMES 3.0 deliveries, HVDC, machine short-circuit attributes, the quirks of real deliveries; bank regulators behindcgmesimport.shuntcontrolon the SmallGrid: without the switch none, with it 13 of the 14 banks take over their imported shunts (no shunt added, the shunt keeps its admittance), the bank on a PV bus stays fixed with its notice, the count notice, the block, range, start, target and deadband of Sprigg SC frombPerSection,maximumSections,sections,targetValueandtargetDeadband, the run with the controllers converges with every bank in its band, the configured import, the YAML key and the adapter options forward the switch, andaddShuntVoltageControl!withshuntidxrefuses an index out of range, a shunt on another bus and a shunt with a conductance and snaps a start off the grid; the DY profile behindcgmesimport.readdynamicson a SmallGrid store copy with DY objects added in memory and on a DY file next to the SmallGrid zips (switch off: noDynamicData, one DY notice naming the switch, the DY file skipped by name, the network of the plain import; on: inertia, damping, EQ rating and theGovSteam1droop converted frommwbaseto the rating with its governor lag on the right machines, aGovSteam0droop onmwbase0 left out, a disabled model, a machine model and a governor on a missing machine, an excitation system and load models counted in one line per DY class, a record with negative inertia dropped with its warning, nothing else of the network changed, the configured import, the YAML key and the adapter options forwarding the switch, the data bit for bit through SCF, and the DY section ofdynamicsReportLinesand ofcgmesimportreport.mdin a service run: the import counts and the machine names with the switch, one line without it, none without a DY profile; on MicroGrid BE and NL from the CGMES cache, with a RAN or SKIPPED line, two and three units withDynamicData, one perSynchronousMachineTimeConstantReactancerecord of the DY file); the slack on the SV angle reference of MicroGrid BE (CGMES cache, RAN or SKIPPED line): the X-nodeTNBorderST23with itsEquivalentInjectionis the slack at its SV angle, BE-G1 stays PV, the SV comparison within 8.1e-5 pu and 5e-3 deg raw offset; withcgmesimport.equivalentinjectionassourcethe five X-node injections are sources at their SV voltage and angle, a copy withr/xon the reference injection statesskandrxratioin the SCF source as computed by hand, the SCF round trip is a fixed point with one short-circuit record, and the copy without its SV file takes the largest machine with the notice naming the electrical island; the key forwarded by the configured import, the YAML loader and the adapter options; SmallGrid (test/fixtures/cgmessmallgrid) imports at 50 and 60 Hz with the key in the field, an identical Y-bus and a bit-identical power flow, andconvertcasewritesmeta.fnomfrom its options. The synthetic RatioTapChangerTable delivery without SvTapStep and SSH step sits at its neutral step (2) or, withoutneutralStep, at the band middle 3 of 1..5: the ratio is the table point, the stored changer is marked and one notice names it; its CGMES export adds exactly one notice naming the transformer, the delivery with a step none. Withtapcontrol, a controller run that moves that changer off the middle position (target 19.4 kV) takes the mark off the stored changer and the export names no assumed step; one that leaves it there (19.73 kV) keeps the mark and the one notice. Bus areas on the hand-written CGMdata/cgmesdemo/spcase6igm(two operator models and a boundary set), against the fixture definition: per bus and name formodelauthority,subgeographicalregion,geographicalregionandnone, the X nodes by their first line, the four TieFlow terminals at border buses, an unknown value refused, the key through configuration and adapter options, and the CGMES to SCF round trip keeping numbers and names. On MicroGrid assembled and FullGrid of the CGMES cache (RAN or SKIPPED line): every bus of an operator TN in the area named after its file'smodelingAuthoritySet`, every bus with an area, the one-operator notice. |
cgmes_export | test/test_cgmes_export.jl | CGMES export identity and roundtrip contract (writeCGMESFiles, EQ+TP+SSH+SV + optional delivery zip): structural keys in net.cgmes_ids with lexicographic bus-pair normalization and first-seen parallel-line numbering, deterministic uuid5 minting (id equals uuid5 over the key), byte-identical re-export and independent-build determinism with a pinned created stamp, renaming a component never changes its mRID, the duplicate-mRID guard aborting before any file is written (both offending keys named), the power-flow-identical self-roundtrip over every exported class (three PI-model lines, transformer with off-nominal ratio + 2° phase shift + ratio-tap machinery, PV machine, slack ExternalNetworkInjection with an asymmetric P band that comes back as written (not as its hull), SVC with rating-derived Q limits, load, shunt, bus link → export → importCGMES → compareWithSV flow rows below 1e-6 MW at the SV start, runpf matches the original within 1e-8 and starts from the exported SV in ≤ 2 iterations, empty notice list, the reference priorities of slack infeed and PV machine back on their units; with the ratio step of the transformer marked as not transferred the export writes SSH step 2, its notice list is exactly the one notice naming the transformer, the default call logs it as a warning, and the re-import names no assumed step), tool provenance in every file (Generated by Sparlectra.jl v<version> comment + md:Model.description, stamp = pinned created), SSH content (machine sign convention, referencePriority on the slack unit, RegulatingControl.targetValue in kV, shunt sections, bPerSection) and SV validation (compareWithSV of the re-import: dvm/dva < 1e-12, flow rows < 1e-9; a bus joined to the rest by a closed switch alone is marked isolated by the import, but its voltage and shunt are compared at the voltage of the switch group and the unit on it is balanced over the group, at the SV start and after the solve; the SV export of that import keeps the bus voltage and its rows, and N-1 on it reports no cut-off and no shed load), the regulated tap group (master + follower export ONE shared TapChangerControl with controlEnabled on both, reimport regroups them with target and deadband intact), the converter units (one PQ and one voltage-regulating prosumer of type PowerElectronicsConnection leave as two EquivalentInjections with their P and Q limits, regulationCapability, regulationStatus and regulationTarget in kV, IdentifiedObject.description PowerElectronicsConnection, one notice counts them, no RegulatingControl and no SynchronousMachine for them; the re-import has two EquivalentInjections addressed as :external_grid with the same P, Q, P limits (-5, 15 stays -5, 15), Q limits and regulation and the converter component type, the SV validates with a unit row per bus, the power flow matches the original from the SV start, a second export writes them the same way; a regulating converter whose Q limit binds ends PQ at the limit before the export and after the re-import with the same solution; the short-circuit harvest has no machine and no equivalent record for them, Ik'' equals that of the same net exported without them, and every row carries the converter lower-bound flag), an imported EquivalentBranch on one level, across two levels and phase-stamped (delivery of test/cgmes_synth_eb_fixture.jl, with |z21| = |z12| and with |z21| = 1.01 |z12|) exported as EquivalentBranch with its mRID and the delivered r, x, r21, x21 (also after the typed case of the service path, net_to_scfcase and build_net, which keeps equivalent_branch_metadata), the notice counting the objects whose model and export values differ, and re-imported to the same values, the same branch bit for bit and the same solution, and zip re-import, all on nets built in memory; a three-winding transformer whose tapped end-1 leg runs side bus to star exports as one PowerTransformer with three ends, no notice, and the re-import solves to the same voltages with its SV flow rows below 1e-6 MW and the magnetizing admittance at the star node before and after; and the export-import-export identity on the checked-in deliveries (each fixture imported, solved from its SV start with Q limits on, re-exported with the fixture's header stamp, and compared object by object against the fixture: header verbatim, every mRID present, every attribute equal with numeric values to 1e-9 relative and SvPowerFlow rows to 1e-6 MW; IdentifiedObject.name is compared on every object, so the importer must carry the delivery names of lines, transformers, loads, machines and shunts into the net). Named as the fields the importer does not carry, and excluded: the RatioTapChanger and TapChangerControl objects (the importer folds the ratio-tap step into the branch ratio; the exporter writes tap machinery from the winding record only), PowerTransformerEnd.ratedU of an end that carried a ratio tap changer (the fixture absorbed the step correction into it), and SynchronousMachine.minQ/maxQ (read as the hull) |
cgmes_series | test/test_cgmes_series.jl | Series check of CGMES snapshots (checkCGMESSeries, qsts.series.*) on snapshots derived in memory from the SmallGrid fixture under test/fixtures/cgmes_smallgrid: renamed topological nodes and lines are matched again by fingerprint (none ambiguous, overlap stays 1), a removed machine counts as injection churn and not as structure, a PowerElectronicsConnection with its PhotoVoltaicUnit new in a snapshot counts as injection churn of both classes and a new SSH p and q of it in the next snapshot as neither churn nor drift, removed lines lower the structural overlap to common over union of the documented classes and split the series below min_structural_overlap, a step above max_gap splits every pair, max_injection_churn only flags, the text report and the CSV name every pair, parameter drift (a new r on three lines gives 3 drifted lines and 0 in every other class, a renamed line with a new x counts as drifted, a change within the relative tolerance 1e-6, opened breakers, new SSH p and q of loads, machines and equivalent injections, new referencePriority, regulationTarget and normalPF and a new initialP of the generating units give none, a new stored energy and battery state of a BatteryUnit behind a PowerElectronicsConnection give none and a new rated energy one, drift leaves overlap, churn and series unchanged, the text report lists a class whose only difference is drift, the CSV carries the drifted column), a switch closed again in the SSH while the TP keeps its two sides apart counts once as SSH against TP (case 3) and the report names the snapshot, a store and a file list take model key and scenario time from the headers, and a case configuration file overrides the configuration file; union network of a three-step series (buildCGMESSeriesUnion: one line switched off at both ends, loads scaled, one machine dropped, a PowerElectronicsConnection mapped with map_power_electronics = true at another SSH p and q in the second step): two extra union nodes, the two opened switches as links with state 1, 0, 1, no _TPL coupling, two switch link changes and no _TPL change in the second step; the same second step with one load terminal on the node of another load gives two _TPL couplings, both changed in that step next to the two switch links, and is reproduced, one p and one q op on the connection in the second step and none in the third, every step reproduced by template plus delta in the model (compareSnapshotReproduction, which also flags a wrong snapshot) and in the solved bus voltages, machine_control refused, and a qsts.base_step of the configuration beyond the series refused as the default base step; a three-winding transformer missing from one step: its star point is addressed as <PowerTransformer mRID>#star, isolated in that step, and both steps are reproduced (fixture shared with cgmes_importer in test/cgmes_synth3w_fixture.jl); a mRID that comes back with another class (a generating unit replaced by an equivalent injection with its mRID): both objects are kept, the second under <mRID>#<class>, the machine is parked and the injection unparked, and both steps are reproduced; with a base step that has neither of them, the reuse falls between two other steps: the unit of the earlier step keeps its mRID, the injection takes the alias, both are parked in the template, and all three steps are reproduced; a line outage that leaves a generator island without slack (start voltage of that island shifted in the snapshot): the delta carries the start values of the island, and the solved voltages and angles equal those of the direct import, also when the island machine loses its voltage control and the import makes it the island slack (the delta then carries the start of that slack bus); mode A starts each step from its own SV: a second snapshot with loads 10 % up and its own solved state as SV gets start_ops that start every live union bus exactly at the start of its direct import while the base solution lies more than 1e-3 pu away, and its step in the snapshot run needs at most one Newton iteration; a two-step union from path sources (the fixture files and a written copy with scaled loads, read one snapshot at a time) has the same index and deltas as the union of the same snapshots given as stores, and both steps are reproduced; three lines with changed r, x and bch in the second step: the delta carries r_pu, x_pu and charging ops for exactly these lines, no residual, and both steps are reproduced; a phase-stamped EquivalentBranch of test/cgmes_synth_eb_fixture.jl with other r21, x21 in the second step gets a shift_deg op of its own, the element list names the four equivalent branches of the union (which builds every element whatever its SSH state) equivalent_branch, and both steps are reproduced; a tap step changed in the SSH of the synthetic three-winding delivery: the SSH steps are kept per step, the leg ratio goes to control_ops with tap_control = true and to ops without, and the step is reproduced; tap changer data that differs from the template (the regulated leg with a shorter range, then with its regulator off, and a two-winding transformer whose table has other ratios and r, x, g, b deviations) goes into a tap_data record, and each step carries the tap fields of its direct import exactly; the snapshot run on the three-step union (runQsts, qsts.mode = snapshots, tol 1e-10): every step converges, every union bus equals the solved direct import (1e-8 pu, 1e-6 degrees), the SV metrics (sv_n_nodes, max and RMS of voltage and angle, angle offset) equal compareWithSV of the solved direct import to 1e-8, the voltage spread inside one topological node is 0, the line switched off in s2 has rows in step 1 and none in step 2, qsts.mode = off and a cgmes_import key other than the one of the union are refused with the key named; SV flows: two snapshots get one SvPowerFlow per line terminal with the model flow of their solved direct import, the union keeps one reference entry per terminal (two fewer in the step whose line ends sit on dead buses), and the snapshot run gives flow differences at most 1e-6 MW and MVAr on both sides of each line; a bus behind a closed switch (exported and re-imported link group net) gets the values of its group in mode A on the union and none once the switch opens; a bus that a step isolates (its line opened, only its switch to a loaded bus left) and that is the smallest bus of its switch group starts at the voltage of the live member, and the step solves to the high-voltage solution of the same net solved directly instead of the low-voltage branch a 0 V start ends on; an island that the branch-only marking splits only at a switch-only bus counts as one island in mode A (no frozen buses, start values only at the slack bus, values on both sides) and in the angle alignment of compareWithSV; the SV metrics of its base step (nodes, max |dvm|, max |dva|) equal compareWithSV of the direct import, the switch-only bus compared at the voltage of its switch group; extra_link_switches on a two-step SmallGrid series: the two line-end switches inside their topological nodes are no links by default, become links with state 1 in both steps and two extra union nodes, both steps are reproduced, opening one of them on the template gives the solved direct import of the snapshot with that switch open (1e-8 pu, 1e-6 degrees) and moves a voltage by more than 1e-3 pu, and a name that is not a switch is refused |
cgmes_ssh_series | test/test_cgmes_ssh_series.jl | Synthetic SSH series of tools/cgmes_ssh_series.jl (generateCGMESSSHSeries) on the SmallGrid fixture. The SmallGrid has no open switch and no switch between two topological nodes, so the test first derives a base: one line-end disconnector opened in the SSH and its line-side node split off in the TP; the SSH model id is written as #_<id> and the SV depends on it. From that base it generates 96 bundles in 15 minute steps with loads on the daily profile, the equivalent injections on the wind ramp, the machines thermal (the unit-class key wins over the plain machine key) and an event list that closes the switch at step 40 and opens it at step 60. Checked: every entry but the SSH byte for byte as in the base, scenario times and a new model id per step, the manifest (targets, times, SSH ids in the form of the header reader, the SV's dependency on the base SSH listed as missing, generator table), equal seeds give equal SSH bytes and another seed other values, the reference machine unchanged, the sum of p over all mapped objects at the base within 1e-4 MW, the profiles span their ranges, the default [range] values written out give the values of the run without them, a 12-step run over one day with narrower load and wind ranges keeps every value inside them and bounds the thermal factor so that it binds on both sides, with the rest left to the slack equal to the change of the sum of p and reported per step in the manifest (imbalance_mw, a note) and the ranges in the generator table and the SSH description, a range on one role key (the equivalent injections as loads within 0.9 to 1.1) leaves the consumers on the values of the run without it, a range that reaches no object (range.thermal without thermal objects, range.load when the one load key has its own range) is named in the notes of every bundle, three PowerElectronicsConnection objects added to the base (wind unit, PV unit, battery plus PV unit) take the role of their unit-class key (wind ramp, load profile within the key range 0.9 to 1.1) or, with units of two classes, the plain key with a note, and stay in the thermal balance, checkCGMESSeries finds one series with overlap 1 and churn 0 and names the switch as SSH against TP (case 3) exactly in steps 40 to 59, buildCGMESSeriesUnion has one union node per TN of the base (boundary included), no _TPL, the switch as the one link, only p/q ops on loads, generators and external grids plus one link op in steps 40 to 59, and compareSnapshotReproduction is empty for all 96 steps. A two-step run from the two fixture zips, the boundary zip given twice, checks the zip entries byte for byte, the zip!entry sources, the urn:uuid SSH id and the note for the left-out copy. Bad event lines (also the header with the old column name element_mrid), an unknown role class, a unit-class key on a class without units or with a unit class of another class, a range with low above high, a range on a key that is not in the mapping or has role thermal, two files of one name with different content and a thermal balance without a solution fail with the cause named and leave no output directory; QSTS mode B with sequential_start = previous on the union of the 96 bundles, once serially, with one tap controller from the configuration (branch 180 holding its 132 kV bus at 1.0 pu): all steps solve, the reference is the base step (-2) in every step, dpos_ref is the simulated position minus the base step and matches the 96 values of the first run, max_abs_dpos_ref and rms_dpos_ref follow from them, the switching rows chain the positions from the base step (31 rows, 30 counted with 34 steps, no hunting), the bus inside the deadband, SV comparison in every step; the start from the step before: on a union of the snapshots 1, 2, 2 the repeated step needs one iteration, moves no tap and keeps the values of step 2; two unions in parallel equal the single run (threaded in the threads profile) and the vector writer puts them into series_1 and series_2 with series and n_series in the manifest; an event series on the union over 12 steps (L1 open in step 3 makes L2 a bridge, L2 open in 6 and closed in 9): all steps solve, n_islands rises in step 6 and falls in step 9, the three cut-off buses without a source are isolated with n_isolated and shed_load_mw and have no values, the manifest records the event list, a snapshot run and the snapshot start are refused, an unknown switch is named with its line |
powsybl_importer | test/test_powsybl_importer.jl | PowSyBl adapter on the five reference bundles under test/fixtures/powsybl (ieee14, ieee57, foursubstations, microgridbe, eurostagtielines): bundle reader failures (missing required column named with its table, wrong format version), the bundle round trip (every column equal with NaN, element types kept), builder structure (bus count against the bus-breaker rows, links against retained switches, branch count against the built elements, island count against the synchronous components, paired dangling lines skipped into their tie line, bus-view id in the external-id channel), the power flow against the OpenLoadFlow bus voltages within the task bands (ieee14 and ieee57 1e-6 pu and 1e-4 deg, the others 1e-5 pu and 1e-3 deg, run with islands, OLF's balance through the imported participation factors, no Q-limit hysteresis, remote regulation on microgridbe) plus a flat-start convergence, patched fixtures on foursubstations (one-sided open line, open retained switch as an open link, remote regulation held local with the report entry and as PQ, a refused remote control, alone and with two more units on its bus, building the net and the SCF export of the hold_local import), the slack override with its override reason, and the import_case dispatch on the bundle and on the .xiidm file with the service entry on both. Since 0.20.0 the native IIDM reader (read_iidm_tables) is checked on every fixture: its tables equal the bundle's in every schema column except the state columns (rows joined by the index columns), the power flow from the .xiidm lands in the same bands as from the bundle, microgridbe's stale file state (solved at other tap positions) is dropped with the notice in the report while ieee14's state seeds the start, and a compressed file or a non-IIDM XML is refused with the construct named; the shunt count equals the shunt_compensators rows (no branch-derived bus shunt), the N-1 outage of the foursubstations PST takes exactly the PST two-port entries out of the Y-bus with the shunt list untouched, the MATPOWER export of microgridbe carries `mpc.sparlectra.branchshuntsand reads back with the Y-bus at 1e-12 and the parts removable per branch, the CGMES export of micro_grid_be writes the one-sided admittance of its five dangling lines as shunt compensators (one notice per line) and the delivery solves to the voltages of the source within 1e-10 pu, the SE self-test on ieee14 and micro_grid_be passes the global test, and the four IIDM files underdata/powsyblare offered and staged by the Web UI selector (a bundle is not), each equal to the file of its fixture.; the MATPOWER reimport with branch shunt parts (micro_grid_be) also runs as a scenario through the converted SCF index: a branch outage on the patch path removes the part and restores it, and equals the outage path (D2 of #355); a generator withenergySourceWINDcarries the converter mark in its short-circuit record and feedsk·ratedS/(√3·Un)withshortcircuit.convertercurrentfactork;convertcasewrites the frequency of its options (frommodel.nominalfrequencyhz) asmeta.fnom`, and the case read back has the same Y-bus as the 50 Hz conversion. The tap changer sets of the state estimation (0.60.0): every ratio and phase tap changer of foursubstations, microgridbe and eurostagtielines gives at its import step and at both table ends the ratio, shift and impedance of a re-import of the .xiidm at that step (1e-12), the bundle gives the same sets, the foursubstations changers carry their neutral, band, side and roles, the untapped 3W legs, the transformers without changer and the lines across voltage levels of ieee14 an empty set, and a phase changer with an unusable step row is left out with a notice and its import factor kept fixed. A phase tap changer without tapPosition (foursubstations) sits at the middle of its step list, 16 of 0..32: the branch equals the re-import at tapPosition 16, the stored changer is marked and the import report names it; the bundle with the tap cell of that changer emptied gives the same branch (1e-12), the same set and the same report line. A remote control the framework refuses (empty reactive range) falls back to the net the hold_local mapping builds: bus types, node voltages and power sums, the units and the Q limits equal, and the same solution. |
apslf | test/test_apslf.jl | APSLF (AnalyticLoadFlow.jl) integration: the PV-bus regression (ring3 and spcase5 through `runsparlectra, NR against APSLF without polish to 1e-6 pu, radius GRN; guards the series result itself), the diagnosis of a non-converged run (sp_case5 at order 4: reason in the status, none on a converged run; the reasonprecisionlimitthrough the status path, and on case6495rte at order 32 when the MATPOWER cache has it, RAN/SKIPPED stated),powerflow.apslf.precision = doubledouble` on spcase5 against NR and the Float64 default equal to a plain AnalyticLoadFlow call bit for bit, the APSLF workshop (docs/lit/workshop_apslf.jl) executed with its assertions on the shipped data/mpower/sp_case118.m (no download, no gate), the residual judged against the final active set (a machine clamped at Qmax solves, is logged as a Q-limit event and the run converges), the reactive limits (spcase118: APSLF ends on Newton's clamp set and voltages with limit status and stability check ok; the same case solved with the generator band in place of the injection band fails the band check with buses 4 and 85 outside; a fixed-Q generator next to the regulating machine clamps at the same generation as Newton; a machine 0.05 MVAr over Qmax, inside the switching margin of the active set, fails the APSLF band check (fixed tolerance); the Qmin side, a machine below its narrowed band clamped at Qmin by both solvers; node-only loads from addBusLoadPower! move neither APSLF nor Newton, both agree to 1e-12 pu), the convergence radius in the status/header and its off switch, outer-loop-controller rejection with solver=apslf, the standalone spcase5 convergence against NR, and the start-value-generator guard including nr_polish=false. Nothing here is conditional: AnalyticLoadFlow.jl is a required dependency, so the whole surface runs in every profile that includes the file. The Q-limit stability check of an APSLF run agrees with its band verdict (run level on ring3), and for an APSLF status it counts the machine 0.05 MVAr over Qmax that the margins of the active set keep inside. |
core_model_extended | test/testgrid.jl | The MATPOWER matrix-block scanner on a large body (run_grid_extended_tests) |
repository_hygiene | test/test_repository_hygiene.jl | Tracked-path and content hygiene scans, the reference-page coverage assertion (every tracked src file on one reference page or on the exclusion list), Web UI layering and demo case files |
webui_extended | test/test_webui_extended.jl | The Web UI with a running local PowerFlow service: configuration refresh and editor save, case-specific settings profiles, case and configuration selection, case file import, manual path resolve and delete, help links, formulas of the help (no $ and no TeX command outside code on /help, /help/reference and any topic page, the bad-data normalized residual converted to r<sub>n,i</sub> = r<sub>i</sub> / √Ω<sub>ii</sub>, a command the converter does not cover named by the excerpt check), SE settings (a request value of the wrong type is invalid_request), scenario editor, QSTS run, short-circuit status levels, the solver-backend switches (dishonest Newton, power-mode LU, fixed Jacobian pattern) from the form to effective_config.yaml, run.log, the case settings and the N-1 and scenario worker keywords |
dtf_extended group
dtf_extended is a formats group that owns five DTF test files and invokes each run function once:
| File | Run function | Main checks |
|---|---|---|
test/extended/test_dtf_importer.jl | run_dtf_importer_tests | DTF format parser and direct Net-builder coverage, including voltage-level-index branch conversion, transformer controls, bus-type semantics, parsed outage metadata, the persisted typed phase-tap model on controlled windings (FOR001E skew/longitudinal regulators carry phase_taps with the winding connection angle), and the shipped demo deck data/dtf_demo/sp_dtf5.DAT through the text path (card counts, the tap control, the solved voltages, both outage records resolved and solved, the same deck through import_case and run_sparlectra without a named format), the slack name of the size card (what follows the counts: a plain name, a name with a blank, a card with a fifth number; the local decks where present), and the format detection by content (the deck under another name is taken; plain text, a result report, an outage list without a network, a deck shorter than its size card says and a deck without a slack bus card are refused; the local decks under data/DTF where present, RAN or SKIPPED is printed) A transformer control without the actual step gets its typed model at step 0, the branch keeps the base ratio, the step is marked and named in one info line. |
test/extended/test_dtf_for002_validation_example.jl | run_dtf_for002_validation_example_tests | DTF format -> current Julia compatibility module DTFImporter -> Net -> power-flow validation example smoke coverage against FOR002 diagnostics; verifies generated CSV/Markdown artifacts, lightweight default result/concise CLI output, explicit detailed diagnostics mode, and does not invoke the fast suite |
test/extended/test_dtf_for002_outage_validation_example.jl | run_dtf_for002_outage_validation_example_tests | DTF-listed outage validation against FOR002 outage reference reports for the Testnetz13 cases |
test/extended/test_dtf_matpower_export_validation_example.jl | run_dtf_matpower_export_validation_example_tests | DTF format -> Sparlectra.Net -> existing writeMatpowerCasefile -> MATPOWER import roundtrip validation for the Testnetz13 base case and outages listed by the DTF file |
test/extended/test_dtf_api_webui_integration.jl | run_dtf_api_webui_integration_tests | DTF format input through the API and Web UI paths |
Optional external FOR001/FOR002 fixtures skip cleanly (as Broken, not failed) when absent. test/extended/runtests_extended.jl is an optional standalone runner that includes the same five files:
julia --project=. test/extended/runtests_extended.jlDTF validation examples with FOR002 reference reports
The native DTF examples validate Testnetz13 through the direct DTF path DTFImporter.read_dtf -> DTFImporter.build_net -> runpf!, without a MATPOWER intermediate; FOR002 is a legacy textual reference report. External FOR001/FOR002 datasets are not shipped: place them under data/DTF/, set SPARLECTRA_DTF_DIR to their directory, or pass --dtf-file and --for002-file; without them the scripts stop with a missing-data message.
examples/run_val_dtf_suite.jl is the CLI runner for the base, outage and MATPOWER-export checks plus the DTF import audit. It dispatches to examples/dtf/ (dtf_validation_base.jl, dtf_validation_outages.jl, dtf_validation_matpower.jl, dtf_validation_audit.jl), one implementation per check shared by the CLI, the suite and the extended tests; each module also runs on its own (for example julia --project=. examples/dtf/dtf_validation_base.jl --dtf-file=... --for002-file=...).
Base-case validation:
julia --project=. examples/run_val_dtf_suite.jl --mode=base --case=A --data-dir=data/DTF --output-dir=examples/_out/dtf_for002_native_validation --write-csv=true --write-markdown=trueOutage validation:
julia --project=. examples/run_val_dtf_suite.jl --mode=outages --case=A --data-dir=data/DTF --output-dir=examples/_out/dtf_for002_native_outages --write-csv=true --write-markdown=trueMATPOWER export validation (DTFImporter.build_net -> writeMatpowerCasefile -> createNetFromMatPowerFile, checking that the roundtrip does not materially change the solved result; FOR002 is not its reference):
julia --project=. examples/run_val_dtf_suite.jl --mode=matpower --case=A --data-dir=data/DTF --output-dir=examples/_out/dtf_matpower_export_testnetz13 --write-csv=true --write-markdown=true --write-matpower=true --run-outages=trueEach command writes console output plus CSV and Markdown files in --output-dir: the Markdown files summarize the run, the CSV files keep row-level bus, generator, branch, KCL, state-residual and metric diagnostics. The export validation writes dtf_matpower_export_summary.md, dtf_matpower_export_metrics.csv, comparison CSV files and the exported .m cases. The exporter uses the optional MATPOWER metadata fields mpc.bus_name, mpc.branch_name, mpc.branch_kind and mpc.for001_contingencies, so DTF bus names, branch kind (L/T) and the parsed outage cards survive MatpowerIO.read_case_m. The roundtrip import keeps DTF PQ generators as fixed injections (no controller reinterpretation), and the exporter writes TAP 0.0 for line rows and the ratio in effect for transformer rows.
Metrics:
converged: whetherrunpf!reported convergence.iterations: Newton iterations of the native solve.final mismatch: infinity-norm mismatch recomputed from the solved state.max voltage deviation: largest voltage magnitude or angle difference from the FOR002 bus values.max branch P/Q deviation: largest directed branch endpoint-flow difference from FOR002.max generator/slack Q deviation: solved generator/slack reactive output against the FOR002 generator-Q reporting.state residual P/Q: injection residual from forcing the FOR002 voltages into the native Ybus; CSV only (dtf_state_residual.csv,dtf_validation_metrics.csvand the outage equivalents), because its rounding-noise floor sits far above real model deviations.
Testnetz13 interpretation: branch-flow deviations are the strongest validation signal; slack Q is solved by the power flow and must not be compared with the specified input Q; outage validation executes only the outages listed in the DTF file, and unmatched FOR002 outage blocks are reference text, not executed scenarios.
Pre-merge verification gate
For branches that touch central configuration, MATPOWER runner behavior, output routing/formatting, performance reporting, or documentation/config consistency:
julia --project=. -e 'using Pkg; Pkg.instantiate()'
julia --project=. test/runtests.jl
SPARLECTRA_TEST_PROFILE=extended julia --project=. test/runtests.jl
julia --project=docs docs/make.jlPowerShell:
julia --project=. -e 'using Pkg; Pkg.instantiate()'
julia --project=. test/runtests.jl
$env:SPARLECTRA_TEST_PROFILE="extended"
julia --project=. test/runtests.jl
Remove-Item Env:SPARLECTRA_TEST_PROFILE
julia --project=docs docs/make.jlDTF input through the API and the Web UI
The PowerFlow service and the Web UI accept the DTF format as an internal input path for diagnostics and validation. case_format = :dtf_for001 names the format; with case_format = :auto a deck is recognised by its content, and a .DAT file that is no network deck is rejected. The path is DTFImporter.read_dtf -> DTFImporter.build_net -> Sparlectra.Net -> run_sparlectra/runpf!, without a MATPOWER intermediate. In the Web UI the selector sits in the Input format section. FOR002 is a reference file, not a runnable case: FOR002-like .DAT files are hidden from the primary case selector, can be chosen as the optional FOR002 reference file, and are never auto-paired with FOR001. DTF-listed outages can be requested as all outages or by label/index; the default is base-case only.
Artifacts use the PowerFlow run artifact mechanism: dtf_import_summary.md, dtf_import_summary.csv, dtf_for002_base_comparison.md, dtf_for002_base_metrics.csv, the <case>_calc_<date>.m export, and per-outage files such as dtf_outage_1_summary.md and dtf_outage_1_metrics.csv. DC lines, HVDC links and active MATPOWER mpc.dcline data are not modeled by this path; they fail with structured unsupported-DC-line diagnostics instead of being approximated or dropped.