Import and Export Reference

Sparlectra.writeMatpowerCasefileMethod
writeMatpowerCasefile(net::Net, pathfilename::String; write_solution::Union{Nothing,Bool} = nothing)

Write Matpower case files.

Arguments

  • net::Net: Network object.
  • pathfilename::String: Path and filename to write the Matpower case file.
  • write_solution::Union{Nothing,Bool}: Whether to write the solved AC power-flow state back into the export: mpc.bus VM/VA reflect the solved node state, and mpc.branch gains the MATPOWER result columns 14–17 (PF, QF, PT, QT) sourced from the existing branch-flow report path (no flow recomputation in the exporter). nothing (default) reads matpower_export.write_solution from the active configuration (default true, see MatpowerExportConfig). When true but the network has no solved branch flows, the exporter warns and falls back to the historical 13-column model-only mpc.branch export instead of writing empty result columns. When false, the export is a pure model file: mpc.branch keeps 13 columns and VM = 1.0/VA = 0.0 for all non-slack/non-PV buses (slack and PV setpoints are preserved).

Example

net = Net(...)
writeMatpowerCasefile(net, "casefile.m")
source
Sparlectra.FetchMatpowerCaseModule

Utilities for downloading MATPOWER-compatible case files on demand.

Note:

  • Downloaded files are stored locally and are not part of the Sparlectra source distribution.
  • Users are responsible for complying with the license terms of the respective upstream sources.
source
Sparlectra.FetchMatpowerCase.emit_julia_caseMethod
emit_julia_case(mfile, outdir; legacy_compat=true, overwrite=false) -> jlfile::String

Parses a MATPOWER .m case and writes a Julia NamedTuple (.jl) compatible with MatpowerIO.readcasejulia().

source
Sparlectra.FetchMatpowerCase.ensure_casefileMethod
ensure_casefile(casefile; outdir=nothing, overwrite=false, to_jl=true) -> String

Ensure a MATPOWER-compatible case file exists locally.

  • If casefile is an existing path, it is returned unchanged.
  • If casefile is a bare filename (e.g. case14.m), it is downloaded into outdir.
  • If casefile ends with .jl and is missing, the corresponding .m is downloaded and .jl is generated.

Returns the local path to the requested case file.

source
Sparlectra.FetchMatpowerCase.ensure_matpower_caseMethod
ensure_matpower_case(; url, outdir, to_jl=true, overwrite=false, legacy_compat=true, verbose=true)
    -> (mfile::String, jlfile::Union{Nothing,String})

Ensures the MATPOWER .m file exists in outdir by downloading it if missing. Optionally emits a Julia NamedTuple case (.jl).

This is intended to be called from examples and other code.

source
Sparlectra.FetchMatpowerCase.fetch_matpower_caseMethod
fetch_matpower_case(url, outdir; overwrite=false) -> mfile::String

Downloads a MATPOWER *.m file from url into outdir (unless already present). Returns the local path to the downloaded file.

Transient failures (raw.githubusercontent.com rate limits hit CI runners regularly) are retried three times with a short backoff before giving up.

source

Per-terminal branch status in import and export (r0.9.10)

  • CGMES: Terminal.connected maps per terminal onto from_status/to_status on import. A line or two-winding transformer with exactly one open terminal becomes a partially open branch (its exact pi reduction acts at the closed bus); the earlier substitute shunt with half the charging is gone, and one-sided open transformers are no longer dropped. Equipment.inService = false still counts as both terminals open. The export writes ACDCTerminal.connected per terminal from the flags, so a roundtrip preserves the partial state.
  • MATPOWER: BR_STATUS has no partial state. A partially open branch exports as BR_STATUS = 0 plus its exact input admittance Y_in as a bus shunt (GS/BS) at the closed bus, with an open_terminal=to (or from) marker in the per-branch comment. A MATPOWER solve reproduces the same Y-bus; the roundtrip loses the partial state by design (the branch comes back out of service plus a shunt).
  • DTF: outage cards identify whole branches; the format carries no per-end switch field (see the DTF format notes).