Skip to content
Stable.pscx@modelscript/pscad 17 diagnostic rules
Parser WASM GLR
Diagnostics 17 rules
DAE Arena AST Only
Simulation Native Solvers
Projections Modelica, SSP
Live ExampleIbrTransmissionFault.pscx

PSCAD Grid-Following Inverter & 230 kV Transmission Fault

EMT power system schematic with a 3-phase Thévenin grid source, step-up transformer, pi-section line, timed fault breaker, and RLC load.

Playground
Source (19 lines)
1<project name="IbrTransmissionFault" version="5.0">
2  <definitions>
3    <definition name="Main">
4      <schematic>
5        <Bus id="Bus_Grid" name="Grid_230kV" x="140" y="140" BaseKV="230.0" />
6        <Bus id="Bus_PCC" name="PCC_34kV" x="380" y="140" BaseKV="34.5" />
7        <component id="Src1" type="Source3Ph" name="GridThevenin" x="60" y="140" Vbase="230.0" freq="60.0" />
8        <component id="Xfmr1" type="Transformer2W" name="MainStepUp" x="260" y="140" MVA="150.0" Xl="0.10" />
9        <component id="Brk1" type="Breaker3Ph" name="FaultBreaker" x="500" y="140" tOpen="0.15" />
10        <component id="Load1" type="RLCLoad" name="FeederLoad" x="620" y="140" P="85.0" Q="24.0" />
11        <Wire id="W1" src="Src1" dst="Bus_Grid" />
12        <Wire id="W2" src="Bus_Grid" dst="Xfmr1" />
13        <Wire id="W3" src="Xfmr1" dst="Bus_PCC" />
14        <Wire id="W4" src="Bus_PCC" dst="Brk1" />
15        <Wire id="W5" src="Brk1" dst="Load1" />
16      </schematic>
17    </definition>
18  </definitions>
19</project>
PSCAD Single-Line EMT Schematic
Grid_230kV (230 kV) PCC_34kV (230 kV) «GridThevenin» GridThevenin «MainStepUp» MainStepUp FaultBreaker «FeederLoad» FeederLoad
Drag to pan · Click % to reset

PSCAD & Electromagnetic Transients (.pscx, .pslx, .pswx, .psmx, .psout, .cfg, .dat) ​

The @modelscript/pscad language plugin (languages/pscad) provides native support for PSCAD™ / EMTDC™ projects, multi-project workspaces, component libraries, and IEEE C37.111 COMTRADE transient waveform recordings. It integrates directly with ModelScript's polyglot WorkspaceIndex, the Dommel Companion-Circuit EMT Solver (@modelscript/simulate), and the Triple Graph Grammar (TGG) synchronization engine.


Supported File Formats ​

ExtensionFormatDescription
.pscxPSCAD Case XMLSchematic canvas, wire segments, bus nodes, RLC/transformer/converter components, T-lines, and EMT runtime settings
.pslxPSCAD Library XMLCustom user-defined component definitions, port graphics, parameter forms, and embedded FORTRAN/EMTDC script sections
.pswxPSCAD Workspace XMLMulti-project workspace manifest indexing .pscx cases and .pslx libraries via PscadWorkspaceIndex
.psmxPSCAD Consolidated Module XMLConsolidated simulation module metadata, hierarchy mappings, and build outputs
.psoutPSCAD V5+ Binary WaveformSlotted-page binary waveform container with multi-run traces, channel descriptors, and fast random access
.cfgIEEE C37.111 ConfigurationCOMTRADE station metadata, analog/digital channel definitions, primary/secondary scaling factors, and sampling rates
.datIEEE C37.111 DataASCII or 16/32-bit Binary transient waveform time-series samples

Architecture & Pipeline ​

Rendering diagram...

1. Schematic & Netlist Extraction (emt-netlist.ts, pscx-parser.ts) ​

PSCAD .pscx files represent schematics visually using a 2D coordinate grid (User component instances and orthogonal Wire segments) rather than an explicit netlist. @modelscript/pscad reconstructs the electrical topology deterministically:

  1. Local master.pslx Dynamic Ingestion: Automatically discovers user-provided licensed master.pslx files via PSCAD_MASTER_LIB_PATH or workspace roots (master.pslx, .pscad/master.pslx, .cache/pscad-corpus/). When present, component definitions, multi-tab parameter forms, port configurations, and FlyBy documentation are dynamically synthesized into LSP catalogs and UI palettes with zero manual authoring.
  2. Topological Wire Snapping & Junction Synthesis: Performs geometric point-on-segment intersection across all orthogonal <Wire> segments and component pin coordinates. Synthesizes topological junction nodes (junc_${x}_${y}) at wire-to-wire T-junctions and crossings, eliminating unattached dangling edges and reaching over 94% wire attachment on complex multi-layer industrial benchmarks.
  3. 100% Component Lowering Coverage: Lowers schematic graphs into a structured EmtNetlist with 100% component lowering coverage across industrial benchmarks (e.g. DC_EMT_compare.pscx with 1433/1433 lowered components and DC_EMT_demo.pscx with 597/597 lowered components):
    • AC/DC Thévenin sources, battery energy storage systems (battery), controlled current sources (src_ccin_1)
    • 6th-order synchronous machines, 5th-order induction/DFIG wind machines, and wound-rotor induction machines (wound_rotor)
    • Distributed-parameter Bergeron traveling-wave lines, lumped π-sections, and multi-conductor cables
    • Non-linear MOV surge arresters, VSC PWM converters, 6-pulse thyristor bridges, and MMC converter stations
    • 20+ CSMF control transfer-function blocks (const, gain, pi_ctlr, realpole, leadlag, limit, sum, rms3ph, abcdq0) and black-box vendor IBR FMUs.
  4. Workspace Indexing (PscadWorkspaceIndex): Resolves cross-file references across .pswx workspaces, linking custom <Definition> blocks in .pslx libraries to <User> instances in .pscx cases.

2. Pre-Flight Electrical Lint Rules ​

@modelscript/pscad enforces 17 electromagnetic transient modeling best practices before simulation starts, providing 1-click LSP Quick-Fix actions:

17 rules11 error6 warning Run with msx lint

CodeRuleSeverityMessage
M6001floating-electrical-nodeerrorElectrical node '<nodeName>' is floating with no closed connections.
M6002transformer-winding-mismatchwarningTransformer '<xfmrName>' <side> rating (<ratedKv> kV) does not match connected bus base (<busKv> kV).
M6003invalid-parameter-boundserrorComponent '<elemName>' parameter '<paramName>' = <val> is invalid: <reason>.
M6004weak-grid-warningwarningPoint of Interconnection '<poiBus>' has low Short-Circuit Ratio (SCR = <value> < 1.5). IBR control stability risks detected.
M6005csmf-unresolved-inputerrorCSMF control block '<blockId>' references unresolved upstream signal block '<missingInputId>'.
M6006line-travel-time-underflowerrorTransmission line '<lineId>' wave propagation delay (<value> us) is smaller than simulation time step (<value> us). Reduce time step or use a lumped pi-section model.
M6007sync-machine-reactance-ordererrorSynchronous machine '<machineId>' violates physical d-axis reactance hierarchy (Xd=<xd> >= Xd'=<xdPrime> >= Xd''=<xdSub> pu required).
M6008mov-arrester-under-ratedwarningMOV surge arrester '<arresterId>' reference voltage (<value> kV) is below connected bus '<busName>' nominal phase-to-ground peak voltage (<value> kV), causing continuous thermal conduction.
M6009duplicate-component-iderrorDuplicate component or bus ID '<id>' declared in schematic module '<modName>'.
M6010bus-voltage-conflicterrorConductive net shorts bus '<busA>' (<kvA> kV) directly to bus '<busB>' (<kvB> kV) without an intervening transformer.
M6011port-domain-mismatcherrorWire '<wireId>' connects control signal port '<sigPort>' directly to 3-phase electrical port '<elecPort>'.
M6012csmf-algebraic-looperrorCSMF control blocks form an algebraic loop with no state or delay element: <cycle>.
M6013parallel-ideal-sourceserrorIdeal voltage sources <sourceIds> are connected in parallel at bus '<busName>', making the nodal matrix singular.
M6014parallel-low-impedance-sourceswarningVoltage sources <sourceIds> are connected in parallel at bus '<busName>' with no declared source impedance; a stiff default impedance is assumed and large circulating currents may result.
M6015limiter-permanently-saturatedwarningLimiter '<blockId>' is permanently saturated: its input stays within [<inLo>, <inHi>] but its output limits are [<limLo>, <limHi>].
M6016component-check-failederrorComponent '<cmpName>' check failed: <reason>.
M6017component-check-warningwarningComponent '<cmpName>' check warning: <reason>.

Generated from languages/pscad/src/lints/index.ts. All languages →


3. IEEE 2800-2022 & NERC PRC-029-1 Grid-Code Verification ​

@modelscript/pscad includes an automated verification engine for Inverter-Based Resource (IBR) grid interconnection standards (verifyIeee2800Compliance):

  • Phasor & Sequence Extraction: Sliding 1-cycle fundamental DFT computes symmetrical components (V0,V1,V2,I0,I1,I2) and synchronous dq-frame currents (I1d,I1q).
  • Mandatory Clauses:
    • Clause 5.3.2 / 7.2.2.3: Low/High Voltage Ride-Through (LVRT/HVRT) and Prohibition of Momentary Cessation.
    • Clause 5.4.1 / 7.2.2.3.5: Fast Dynamic Reactive Current Response (T90%≤50 ms).
    • Clause 5.4.2 / 7.2.2.1: Post-Fault Transient Overvoltage Ceiling (Vpeak≤1.20 pu).
    • Clause 7.2.2.1 / NERC PRC-029-1: Piecewise Time-Voltage Ride-Through Envelope.
    • Clause 7.2.2.3.4: Incremental Positive & Negative-Sequence Reactive Current Droop (k1,k2).
    • Clause 7.2.2.3.5: Post-Fault Active Power Recovery (≥90% within 1.0 s).
    • Clause 7.3.2: Frequency, RoCoF (≥5 Hz/s), and Instantaneous Phase-Angle Jump (≥25∘) Ride-Through.

4. Polyglot Projections & 15 TGG Synchronization Rules ​

Modelica & SSP Projections (projections/modelica.ts, projections/ssp.ts) ​

  • pscadToModelica(doc): Projects a .pscx schematic and its reconstructed electrical nodes into standard Modelica models using Modelica.Electrical.Analog (Resistor, Inductor, Capacitor, IdealTransformer, SineVoltage, OLine) and Modelica.Blocks.
  • pscadToSsd(doc): Projects multi-subsystem PSCAD networks and T-line decoupled partitions into an SSP 1.0 .ssd System Structure Description XML document for FMI Co-Simulation.

Bidirectional TGG Rules ​

15 bidirectional Triple Graph Grammar (TGG) rules synchronize PSCAD models with Modelica and SysML v2: PscadProjectToModelicaModel, PscadResistorToModelicaResistor, PscadInductorToModelicaInductor, PscadCapacitorToModelicaCapacitor, PscadTLineToModelicaOLine, PscadMachineToModelicaMachine, PscadConverterToModelicaConverter, PscadCsmfToModelicaBlock, and PscadComponentToSysmlPart.


5. Dommel Companion EMT Solver (@modelscript/simulate) ​

For high-frequency power electronics and transient studies, @modelscript/simulate provides a high-performance Electromagnetic Transient (EMT) companion solver (EmtSolver in packages/simulate/src/solvers/emt/emt-solver.ts):

  • Dommel Trapezoidal Companion Models: Discretizes inductors (GL=Δt2L) and capacitors (GC=2CΔt) into constant nodal conductance matrices Gv(t)=ihist(t−Δt)+isrc(t).
  • Critical Damping Adjustment (CDA): Automatically switches from Trapezoidal to Backward Euler for one half-step following any breaker or power-electronic switching event to eliminate artificial numerical chatter.
  • Bergeron Traveling-Wave Lines: Decouples sub-networks separated by transmission lines of delay τ≥Δt, enabling parallel sub-grid nodal solves.
  • Grounded Simulation Honesty: Connects passive buses with realistic high-impedance ground conductances (G=10−5 S) without injecting artificial 230 kV reference sources, ensuring true physical fidelity.

6. IEEE C37.111 COMTRADE Reader & Writer (comtrade.ts) ​

Zero-dependency parser and serializer for IEEE Std C37.111-1999 / 2013 COMTRADE files (.cfg, .dat, .cff):

ts
import { parseComtrade, writeComtrade, EmtSolver } from "@modelscript/pscad";

// Export an EMT simulation directly to IEEE C37.111 (.cfg + .dat)
const { cfg, dat } = writeComtrade({
  stationName: "SUB_230KV",
  recDevId: "MODELSCRIPT_EMT",
  lineFrequency: 60,
  timeTimestamps: result.time,
  analogChannels: [
    { id: "VA_BUS1", unit: "V", values: result.nodeVoltages.get(1)! },
    { id: "IA_LINE1", unit: "A", values: result.branchCurrents.get("BRK1")! },
  ],
});

7. PSCAD V5+ Binary Waveform Container (.psout) ​

PSCAD V5+ replaces legacy ASCII .out files with .psout, a high-performance slotted-page binary container format. ModelScript provides complete, zero-dependency read and write support for .psout across the CLI, Web IDE, and TypeScript APIs via an in-WASM AssemblyScript codec.

Slotted-Page Binary Architecture ​

A .psout file is organized into 1024-byte pages:

  • Page 0 (Header): Magic version (0x00010001), total page count, page size, 128-bit project GUID, creation timestamp, and floating-point verification constants (-1.0e-30, 1.0e30, 1.0e-30).
  • Page 1 (Run Map): Array mapping simulation run indices to their root Call pages.
  • Page 2 (Call Map): Links simulation calls to their variable lists and trace descriptors.
  • Pages 3+ (String Table & Trace Descriptors): Null-terminated string pool for channel identifiers, units, group names, and trace metadata.
  • Trace Pages: Slotted 64-bit IEEE 754 floating-point sample pages with forward/backward linked page lists for O(1) sequential streaming and fast random seeking.
Rendering diagram...

Programmatic TypeScript API ​

ts
import { readPscadPsout, writePscadPsout } from "@modelscript/pscad";

// 1. Reading and inspecting a .psout file
const bytes = new Uint8Array(fs.readFileSync("Cigre.psout"));
const doc = readPscadPsout(bytes);

console.log(`Version: ${doc.header.version}, Pages: ${doc.header.pageCount}`);
console.log(`Created: ${doc.header.createdOn.toISOString()}`);

// Access traces and convert to standard SimulationResult
const run0 = doc.run(0);
for (const [id, trace] of run0.traces) {
  console.log(`Channel ${id}: ${trace.name} [${trace.unit}] (${trace.values.length} samples)`);
}

const simResult = doc.toSimulationResult(0);
console.log(`Time vector length: ${simResult.time.length}`);

// 2. Writing simulation results to .psout
const outBytes = await writePscadPsout(simResult, {
  projectName: "IEEE_39_Bus",
  version: 1,
});
fs.writeFileSync("output.psout", outBytes);

Command-Line Interface (msx pscad) ​

1. Simulation Export to .psout ​

bash
# Simulate a PSCAD case and export directly to .psout
msx pscad sim models/benchmark.pscx --format=psout --out=results.psout

2. Binary Inspection & Format Conversion ​

bash
# Print formatted ANSI metadata table and channel telemetry
msx pscad psout results.psout

# Convert .psout to CSV
msx pscad psout results.psout --out=telemetry.csv

# Convert .psout to IEEE C37.111 COMTRADE (.cfg + .dat)
msx pscad psout results.psout --format=comtrade

Web IDE Waveform Studio (modelscript.psoutViewer) ​

When opening any *.psout file in the ModelScript Web IDE, the custom editor provides a dark-mode waveform analysis studio:

  1. Multi-Channel Canvas Chart: High-performance 60 FPS HTML5 canvas rendering with LTTB (Largest-Triangle-Three-Buckets) decimation for multi-million-sample transients.
  2. Dual Measurement Cursors: Live measurement HUD calculating time difference (Δt), instantaneous frequency (f=1/Δt), amplitude change (Δy), and rate-of-change (dy/dt slope).
  3. Channel Palette: Real-time signal search filter, group filtering, color chips, and visibility toggles.
  4. Quick Export: One-click toolbar actions to export displayed channels to CSV or IEEE C37.111 COMTRADE.

Open-Core under the GNU AGPL v3 License; Enterprise Edition (ee/) under the ModelScript Enterprise License. • Trademark Policy