Skip to content

simplenet.io.psse

Parser for PSS/E .RAW (Power Flow Raw Data) case files.

Targets the v33 layout that the TAMU synthetic grids (ACTIVSg10k.RAW, ACTIVSg70k.RAW, ...) ship in, but is tolerant of v32 / v34 / v35 for the sections used by simplenet:

  • Bus
  • Load
  • Fixed shunt
  • Generator
  • Non-transformer branch
  • Two-winding transformer
  • Three-winding transformer (mapped to a synthetic star bus + three equivalent branches, MATPOWER's standard conversion)
  • Switched shunt (its initial setpoint is folded into Bs)

The result is a :class:simplenet.case.PowerCase using MATPOWER v2 column conventions, so the rest of the pipeline (preprocess, the DC Y-matrix, Kron reduction, ...) accepts it unchanged.

Only the fields the DC modified-Ward pipeline cares about are populated. Items the format carries but the pipeline does not need (area / zone / owner / FACTS / DC links / cost data) are parsed defensively and otherwise ignored. HVDC lines are not converted - they appear instead as zero-injection buses unless you handle them upstream.

load_raw

load_raw(path: str | Path) -> PowerCase

Load a PSS/E .RAW v33-style case file into a :class:PowerCase.

The header line supplies SBASE (which maps to base_mva) and REV (the format version). Versions 32 / 33 / 34 / 35 are all accepted; older versions emit a warning if structural differences cause sections to be misaligned.

Parameters:

Name Type Description Default
path str | Path

Filesystem path to a .raw / .RAW file.

required

Returns:

Type Description
PowerCase

Bus / gen / branch matrices populated using MATPOWER v2 column conventions. Three-winding transformers are exploded into a synthetic star bus plus three equivalent branches.

Notes

Only sections used by the DC modified-Ward pipeline are converted. Cost data (gencost), generator type / fuel labels, and bus names are not present in PSS/E and therefore stay None. HVDC / VSC / FACTS / multi-section / multi-terminal records are ignored.

Source code in src/simplenet/io/psse.py
def load_raw(path: str | Path) -> PowerCase:
    """Load a PSS/E ``.RAW`` v33-style case file into a :class:`PowerCase`.

    The header line supplies ``SBASE`` (which maps to ``base_mva``)
    and ``REV`` (the format version). Versions 32 / 33 / 34 / 35 are
    all accepted; older versions emit a warning if structural
    differences cause sections to be misaligned.

    Parameters
    ----------
    path
        Filesystem path to a ``.raw`` / ``.RAW`` file.

    Returns
    -------
    PowerCase
        Bus / gen / branch matrices populated using MATPOWER v2 column
        conventions. Three-winding transformers are exploded into a
        synthetic star bus plus three equivalent branches.

    Notes
    -----
    Only sections used by the DC modified-Ward pipeline are converted.
    Cost data (``gencost``), generator type / fuel labels, and bus
    names are not present in PSS/E and therefore stay ``None``.
    HVDC / VSC / FACTS / multi-section / multi-terminal records are
    ignored.
    """

    text = Path(path).read_text(encoding="utf-8", errors="replace")
    raw_lines = text.splitlines()
    if len(raw_lines) < 3:
        raise ValueError(f"{path}: too short to be a PSS/E .RAW file")

    header_row = _split_row(_strip_psse_comment(raw_lines[0]))
    sbase = _as_float(_get(header_row, 1), 100.0)
    rev = _as_int(_get(header_row, 2), 33)
    if rev and rev < 32:
        warnings.warn(
            f"{path}: PSS/E REV={rev} is older than v32; section layout "
            "may be misaligned, parser is tuned for v33.",
            stacklevel=2,
        )

    sections = _parse_sections(raw_lines[3:])
    return _build_case(sections, base_mva=sbase)