Central Configuration
Sparlectra uses one central, typed configuration model.
The main entry point is Sparlectra.load_sparlectra_config(...), which:
- loads YAML defaults,
- optionally overlays a user YAML,
- applies programmatic overrides,
- validates key names and value domains,
- builds a typed
SparlectraConfigobject used by runtime modules.
Configuration files and selectors
| Item | Path / mechanism | Role |
|---|---|---|
| Default config | src/configuration.yaml.example | Version-controlled baseline for all options. |
| User override | examples/configuration.yaml | Local override file (project default user path). |
| Explicit config path | load_sparlectra_config("/path/to/file.yaml") | Replaces default user override path for that load call. |
| Environment-based path selection helper | SPARLECTRA_CONFIGURATION_YAML via configuration_path_from_inputs(...) | Used by script/example path resolution workflows. |
Merge precedence
Configuration precedence (low → high):
src/configuration.yaml.exampleexamples/configuration.yaml(or explicituser_path)cli_overridesoverrides
Unknown keys are rejected during validation. Removed keys are also rejected with migration hints (for example matpower_import.benchmark → benchmark.enabled).
Typed central object
The merged YAML is converted into:
SparlectraConfigpowerflow::PowerFlowConfigstate_estimation::StateEstimationConfigmatpower::MatpowerImportConfigperformance::PerformanceConfigbenchmark::BenchmarkConfigruntime::RuntimeConfigdiagnostics::DiagnosticsConfigoutput::OutputConfigcontrol::ControlConfig
This typed model is the canonical internal representation that should be consumed by power-flow, MATPOWER import, state estimation, output/reporting, performance profiling, benchmark runners, and future modules.
YAML structure (section map)
| YAML section | Typed section | Purpose | Status |
|---|---|---|---|
power_flow | PowerFlowConfig | Rectangular power-flow solver controls, start mode, Q-limits | Public / supported |
matpower_import | MatpowerImportConfig | MATPOWER case path + import interpretation options | Public / supported |
state_estimation | StateEstimationConfig | State-estimation runtime controls | Public / supported |
output | OutputConfig | Console/logfile behavior and result table sizing | Public / supported |
performance | PerformanceConfig | Profiling/reporting toggles and diagnostic volume controls | Public / supported |
benchmark | BenchmarkConfig | Repeated benchmark-run controls | Public / supported |
control | ControlConfig | Generic controller outer-loop orchestration controls (control.controllers reserved for future YAML definitions) | Public / supported |
runtime | RuntimeConfig | Julia/BLAS thread control knobs for entry workflows | Public / supported |
diagnostics | DiagnosticsConfig | Effective-config logging and diagnostics render controls | Public / supported |
extensions | reserved (not mapped to typed runtime fields) | Future extension placeholder | Reserved |
Supported power-flow path
The supported public power-flow solver path is rectangular (power_flow.method: rectangular).
Option lifecycle and compatibility policy
Sparlectra docs distinguish option categories:
- Public / supported: keys in
src/configuration.yaml.exampleand typed section constructors. - Reserved: schema placeholders such as
extensions.reservedfor forward compatibility. - Deprecated compatibility aliases: accepted for migration but not preferred in new YAML (for example
max_iteand some start-projection alias keys). - Removed: explicitly rejected keys with migration error guidance (for example
matpower_import.benchmark). - Internal-only implementation details: not documented as stable external user API.
Prefer canonical nested keys shown in the example YAML and module pages.
Loader and validation behavior
Key validation
- User YAML keys and override keys are validated against the default-schema tree from
src/configuration.yaml.example. - Unknown keys throw
ArgumentError. - Type/domain checks are applied while constructing typed config objects (for example Symbol allow-lists and positivity checks).
Alias handling
Some legacy aliases are accepted in constructors for migration convenience, but canonical docs and examples use structured section keys.
Caching
load_sparlectra_config(...) caches the typed result when loading from unchanged files without overrides. File hash/mtime changes invalidate cache reuse automatically.
Module consumption model
The central typed config is intended to be consumed by each module from its own section:
- Power flow: reads
config.powerflow(solver controls, start mode, Q-limit controls). - MATPOWER import: reads
config.matpowerand combines with PF/output/performance sections as needed by example/runner paths. - State estimation: reads
config.state_estimationfor method/tolerances/observability toggles. - Output/reporting: reads
config.outputandconfig.diagnostics. - Performance profiling: reads
config.performanceandconfig.benchmark. - Future modules: should add a dedicated typed section and canonical YAML subtree.
Minimal example YAML
power_flow:
method: rectangular
tol: 1.0e-5
max_iter: 80
autodamp: true
autodamp_min: 0.05
start_mode:
angle_mode: dc
voltage_mode: profile_blend
profile_source: matpower_reference
start_projection: true
try_dc_start: true
try_blend_scan: true
blend_lambdas: [0.25, 0.5, 0.75]
dc_angle_limit_deg: 60.0
qlimits:
enabled: true
start_iter: 3
start_mode: iteration_or_auto
matpower_import:
case: case14.m
auto_profile: recommend
pv_voltage_source: gen_vg
state_estimation:
enabled: true
method: wls
output:
console_summary: true
logfile_results: full
performance:
enabled: true
level: iteration
benchmark:
enabled: true
methods: [rectangular]
runtime:
julia_threads: keep
blas_threads: keep
extensions:
reserved: trueFor complete key references and allowed-value tables, see the module-specific pages below.
Control configuration (generic outer loop)
control:
enabled: true
max_outer_iterations: 20
trace: true
log_iterations: true
stop_on_pf_failure: true
controllers: []| Key | Type | Default | Meaning |
|---|---|---|---|
enabled | Bool | true | Enables the generic outer-loop control framework. |
max_outer_iterations | Int | 20 | Global outer-loop cap. Does not control inner NR iterations. |
trace | Bool | true | Collect machine-readable control trace rows. |
log_iterations | Bool | true | Enables optional per-iteration control logging hooks. |
stop_on_pf_failure | Bool | true | Stops control orchestration when inner PF fails. |
controllers | Vector | [] | Reserved for future YAML controller definitions; leave empty for current programmatic controller setup. |
In Stage 1, controllers are typically attached programmatically via addTapController! / addPowerTransformerControl!.
Demo controller YAML vs. central control.controllers
The tap-control demo may read examples/tap_control_demo_grid.yaml for example setpoints and transformer tap/phase parameters (oltc, pst, schraeg). This is an example-specific input file consumed by examples/tap_control_demo_grid.jl.
It does not define the central control.controllers schema. Today, control.controllers remains reserved/future and should be left as [] in central configuration files.
Migration notes
| Legacy / old key | Canonical key | Notes |
|---|---|---|
matpower_import.benchmark | benchmark.enabled | Removed from matpower_import; now top-level benchmark section. |
methods (top-level legacy path) | benchmark.methods | Keep benchmark methods in benchmark. |
max_ite | power_flow.max_iter | Legacy alias; prefer canonical nested key. |
Detailed references
- Power-Flow Configuration
- MATPOWER Import Configuration
- State-Estimation Configuration
- Performance and Profiling Configuration
Complete default-key index
The following canonical keys are currently present in src/configuration.yaml.example:
benchmarkbenchmark.enabledbenchmark.methodsbenchmark.samplesbenchmark.secondsbenchmark.show_oncebenchmark.show_once_max_nodesbenchmark.show_once_outputcontrolcontrol.controllerscontrol.enabledcontrol.log_iterationscontrol.max_outer_iterationscontrol.stop_on_pf_failurecontrol.tracediagnosticsdiagnostics.console_auto_profilediagnostics.console_diagnosticsdiagnostics.console_max_rowsdiagnostics.console_q_limit_eventsdiagnostics.console_summarydiagnostics.log_effective_configdiagnostics.logfile_diagnosticsextensionsextensions.reservedmatpower_importmatpower_import.auto_profilematpower_import.auto_profile_logmatpower_import.bus_shunt_modelmatpower_import.casematpower_import.compare_voltage_referencematpower_import.enable_pq_gen_controllersmatpower_import.preallocate_min_busesmatpower_import.preallocate_networkmatpower_import.pv_voltage_mismatch_tol_pumatpower_import.pv_voltage_sourcematpower_import.ratiomatpower_import.shift_signmatpower_import.shift_unitoutputoutput.console_auto_profileoutput.console_diagnosticsoutput.console_max_rowsoutput.console_q_limit_eventsoutput.console_summaryoutput.logfile_diagnosticsoutput.logfile_performanceoutput.logfile_resultsoutput.logfile_warningsoutput.result_table_large_case_modeoutput.result_table_large_case_threshold_busesoutput.result_table_max_rowsperformanceperformance.compact_loggingperformance.compare_cold_warmperformance.enabledperformance.levelperformance.max_diagnostic_rowsperformance.print_to_consoleperformance.representative_warmup_runsperformance.show_allocationsperformance.show_iteration_tableperformance.skip_branch_neighborhood_reportperformance.skip_expensive_diagnosticsperformance.skip_reference_comparisonperformance.write_to_logfilepower_flowpower_flow.autodamppower_flow.autodamp_minpower_flow.flatstartpower_flow.max_iterpower_flow.methodpower_flow.qlimitspower_flow.qlimits.auto_q_delta_pupower_flow.qlimits.cooldown_iterspower_flow.qlimits.enabledpower_flow.qlimits.guardpower_flow.qlimits.guard.accept_bounded_violationspower_flow.qlimits.guard.enabledpower_flow.qlimits.guard.freeze_after_repeated_switchingpower_flow.qlimits.guard.logpower_flow.qlimits.guard.max_remaining_violationspower_flow.qlimits.guard.max_switchespower_flow.qlimits.guard.min_q_range_pupower_flow.qlimits.guard.narrow_range_modepower_flow.qlimits.guard.violation_modepower_flow.qlimits.guard.violation_threshold_pupower_flow.qlimits.guard.zero_range_modepower_flow.qlimits.hysteresis_pupower_flow.qlimits.lock_pv_to_pq_busespower_flow.qlimits.start_iterpower_flow.qlimits.start_modepower_flow.qlimits.trace_busespower_flow.rectangular_preallocate_workspacepower_flow.rectangular_workspace_min_busespower_flow.rectangular_workspace_reuse-power_flow.start_modepower_flow.start_mode.accept_unmeasured_dc_startpower_flow.start_mode.angle_modepower_flow.start_mode.blend_lambdaspower_flow.start_mode.branch_guardpower_flow.start_mode.dc_angle_limit_degpower_flow.start_mode.measure_candidatespower_flow.start_mode.profile_sourcepower_flow.start_mode.reuse_import_datapower_flow.start_mode.start_projectionpower_flow.start_mode.try_blend_scanpower_flow.start_mode.try_dc_startpower_flow.start_mode.voltage_modepower_flow.tolruntimeruntime.blas_threadsruntime.julia_threadsruntime.print_thread_configstate_estimationstate_estimation.enabledstate_estimation.flatstartstate_estimation.jac_epsstate_estimation.max_iterstate_estimation.methodstate_estimation.observabilitystate_estimation.observability.enabled-state_estimation.tolstate_estimation.update_net