Import and Export Reference
Sparlectra.writeMatpowerCasefile — Method
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.busVM/VAreflect the solved node state, andmpc.branchgains 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) readsmatpower_export.write_solutionfrom the active configuration (defaulttrue, seeMatpowerExportConfig). Whentruebut the network has no solved branch flows, the exporter warns and falls back to the historical 13-column model-onlympc.branchexport instead of writing empty result columns. Whenfalse, the export is a pure model file:mpc.branchkeeps 13 columns andVM = 1.0/VA = 0.0for all non-slack/non-PV buses (slack and PV setpoints are preserved).
Example
net = Net(...)
writeMatpowerCasefile(net, "casefile.m")Sparlectra.FetchMatpowerCase — Module
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.
Sparlectra.FetchMatpowerCase.emit_julia_case — Method
emit_julia_case(mfile, outdir; legacy_compat=true, overwrite=false) -> jlfile::StringParses a MATPOWER .m case and writes a Julia NamedTuple (.jl) compatible with MatpowerIO.readcasejulia().
Sparlectra.FetchMatpowerCase.ensure_casefile — Method
ensure_casefile(casefile; outdir=nothing, overwrite=false, to_jl=true) -> StringEnsure a MATPOWER-compatible case file exists locally.
- If
casefileis an existing path, it is returned unchanged. - If
casefileis a bare filename (e.g.case14.m), it is downloaded intooutdir. - If
casefileends with.jland is missing, the corresponding.mis downloaded and.jlis generated.
Returns the local path to the requested case file.
Sparlectra.FetchMatpowerCase.ensure_matpower_case — Method
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.
Sparlectra.FetchMatpowerCase.fetch_matpower_case — Method
fetch_matpower_case(url, outdir; overwrite=false) -> mfile::StringDownloads 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.
Sparlectra.FetchMatpowerCase.main — Function
main(args=ARGS) -> nothingCLI entry point. If no –url is provided, it prints help and returns without error.
Per-terminal branch status in import and export (r0.9.10)
- CGMES:
Terminal.connectedmaps per terminal ontofrom_status/to_statuson 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 = falsestill counts as both terminals open. The export writesACDCTerminal.connectedper terminal from the flags, so a roundtrip preserves the partial state. - MATPOWER:
BR_STATUShas no partial state. A partially open branch exports asBR_STATUS = 0plus its exact input admittanceY_inas a bus shunt (GS/BS) at the closed bus, with anopen_terminal=to(orfrom) 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).