This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

vp.power.read_raw

Read a PSS/E RAW file (revisions 32 to 34) into MATPOWER's arrays.

Part of the distribution vipyr; it runs from a checkout of the repository. Planned on PyPI as pip install vipyr.

vp.power.read_raw reads the network in a PSS/E RAW file: buses, loads, fixed and switched shunts, generators, branches, two-winding transformers, areas and zones, and returns it as MATPOWER's baseMVA, bus, gen and branch arrays, the form every vp.power function takes. A .raw path given to any of them is read this way.

The reader is lib/power/raw.viv. Loads keep their constant-power part as Pd + jQd; their constant-admittance part becomes a bus shunt and their constant-current part is taken at the case's voltage. Line-end shunts and transformer magnetizing admittances become bus shunts. Transformers are read in every winding code (CW 1, 2, 3), impedance code (CZ 1, 2, 3) and admittance code (CM 1, 2), and become a branch with the off-nominal ratio WINDV1/WINDV2 at the winding 1 end. Each generator's source impedance ZR + jZX is kept in machine for vp.power.short_circuit.

Three-winding transformers, DC lines, FACTS devices and induction machines are not read; a file that has any raises.

Signature

vp.power.read_raw(path)

Parameters

path : str, required
A PSS/E RAW file, revision 32, 33 or 34.

Returns

A frozen RawCase. Iterating it gives the fields below in order; it also has params, tests, log and check().

baseMVA : float
The system base, MVA (the RAW header's SBASE).
bus : ndarray[float64]
MATPOWER's bus matrix, 13 columns; loads, shunts and line-end shunts summed per bus.
gen : ndarray[float64]
MATPOWER's gen matrix, 21 columns.
branch : ndarray[float64]
MATPOWER's branch matrix, 13 columns: lines, then switching devices, then transformers.
machine : ndarray[float64]
Per generator: MBASE, ZR, ZX (the source impedance on the machine base).
areas : ndarray[float64]
Per area: number, swing bus, desired interchange (MW).
rev : int
The RAW revision.
success : bool
Always True: a file that cannot be read raises.

Raises

ValueError
An unknown method, a case name that is not shipped, or a case dict without baseMVA, bus, gen and branch.
module.VivStop
The case has no bus that can be the reference, or every generator is at a reactive limit.
TypeError
An argument of the wrong type, or an unknown keyword.
vipyr.VivBuildError
An ImportError: no C compiler, or the program's C does not build.

References

  1. Siemens PTI, PSS/E Program Operation Manual, chapter 'Power Flow Raw Data File Contents' (revisions 33 and 34)
  2. ANDES (H. Cui, F. Li, K. Tomsovic, Hybrid symbolic-numeric framework for power system modeling and analysis, IEEE Trans. Power Systems 36 (2021) 1373-1384), whose RAW reader and sample cases are the reference doi:10.1109/TPWRS.2020.3017019

Examples

import vipyr as vp
from vipyr import _spec
r = vp.power.read_raw(_spec.source("lib/power/cases/raw/case118_v33.raw"))
pf = vp.power.runpf({"baseMVA": r.baseMVA, "bus": r.bus, "gen": r.gen, "branch": r.branch})
print(r.rev, r.bus.shape, pf.success, pf.vm.min())
assert r.check()
33 (118, 13) True 0.943

Each example ran as written when these pages were generated, and the output shown is what it printed.

Checked against

Reference
ANDES 2.0.0's own reader and power flow, and pandapower 3.5.6 on ANDES's conversion, on the seven RAW cases ANDES ships (IEEE 14, WSCC 9, Kundur, IEEE 39, NPCC 140, WECC 179, Nordic 44): the admittance matrices agree to 5 × 10−13 and pandapower's voltages to 3 × 10−11 per unit; and MATPOWER's case14, case118 and case300 written as RAW 33 and 34 in every transformer code read back to their own admittance matrix and power flow (lib/power/compare_study.py, lib/power/COMPARISON.md).

Credits

  • The methods follow MATPOWER's (BSD-3-Clause). The test cases are MATPOWER's case files, each with its source named in its header.

Source