Skip to content
Stable.lps@modelscript/lps 12 diagnostic rules
Parser WASM GLR
Diagnostics 12 rules
DAE Arena Lowering
Simulation Native Solvers
Projections Modelica, SysML v2
Live ExampleTranscontinentalGasMainline.tgn

PipelineStudio High-Pressure Gas Transmission & Compressor Station

Steady-state and transient natural gas hydraulics deck with receipt supply, centrifugal compressor station, and city-gate delivery.

Playground
Source (14 lines)
1# PipelineStudio (TGNET) Natural Gas Transmission Mainline
2CASE TranscontinentalGasMainline TITLE "Transcontinental 36-Inch Gas Mainline"
3SIMULATION TGNET
4COMPOSITION CH4 0.925 C2H6 0.042 C3H8 0.013 CO2 0.012 N2 0.008
5 
6SUPPLY N_Inlet ELEVATION 120m PRESSURE 62bar MAOP 85bar
7JUNCTION N_CompSuc ELEVATION 185m MAOP 85bar
8JUNCTION N_CompDis ELEVATION 185m MAOP 85bar
9DELIVERY N_CityGate ELEVATION 95m FLOW 105.0 MINP 48bar MAOP 85bar
10 
11PIPE Mainline_Seg1 FROM N_Inlet TO N_CompSuc LENGTH 68km DIAMETER 914.4mm ROUGHNESS 0.000018 MAOP 85bar
12COMPRESSOR CS01_Boost FROM N_CompSuc TO N_CompDis POWER 14500000 RATIO 1.42 EFF 0.84 SETPOINT 82bar
13PIPE Mainline_Seg2 FROM N_CompDis TO N_CityGate LENGTH 92km DIAMETER 914.4mm ROUGHNESS 0.000018 MAOP 85bar
14INTEGRATION START 0 END 86400 DT 60 EOS AGA8
PipelineStudio Hydraulics & Compressor Schematic
Mainline_Seg1: 68 km Mainline_Seg2: 92 km CS01_Boost ▲ SUPPLY N_Inlet 62.0 bar ● JUNCTION N_CompSuc 60.0 bar ● JUNCTION N_CompDis 60.0 bar ▼ CITY GATE N_CityGate 60.0 bar Transcontinental 36-Inch Gas Mainline
Drag to pan · Click % to reset

PipelineStudio (LPS / TGNET & TLNET) ​

ModelScript provides first-class, polyglot support for Emerson / Energy Solutions PipelineStudio, including its dual simulation kernels:

  • TGNET (Transient Gas Network): Compressible gas hydraulics, real-gas equations of state (AGA-8 Detailed Characterization & Peng-Robinson), line pack dynamics, compressor stations, gas heating value tracking, and hydrogen blending.
  • TLNET (Transient Liquid Network): Incompressible/liquid hydraulics, multi-product batch tracking (gasoline/diesel/jet fuel interfaces), transmix dispersion, pump stations, drag-reducing agents (DRA), and water hammer / acoustic surge analysis.

Supported File Formats ​

FormatExtensionDescription
PipelineStudio Project.lps, .xmlComplete graphical network model defining nodes, pipes, compressor stations, pump stations, regulators, and study scenarios.
TGNET Gas Study.tgx, .psgDedicated compressible gas transmission network studies with gas composition and line pack profiles.
TLNET Liquid Study.tlx, .pslDedicated liquid transmission network studies with batch injection schedules and fluid property libraries.
Legacy Keyword Decks.tgn, .tlnStandard industrial keyword decks specifying network geometry, equipment ratings, and boundary conditions.

3-Tier Execution Architecture ​

ModelScript implements a 3-tier operational execution framework for pipeline networks:

Rendering diagram...

1. Tier 1: In-WASM DAE Solvers ​

  • Zero Intermediate Allocations: Lowers directly into ModelScript's DAEBuilder linear memory arena.
  • High-Accuracy Thermodynamics:
    • AGA-8 (ISO 20765-1): High-precision calculation of compressibility factor Z(P,T,y), molar density, speed of sound, and Joule-Thomson cooling.
    • Hydrogen Blending: Native support for H2 blending in natural gas from 0% to 100%, capturing density drop, speed of sound increases, and compressor power shifts.
    • Peng-Robinson Cubic EOS: General flash calculation for heavy hydrocarbons and dense-phase supercritical CO2 pipeline transport.
  • Transient Compressible Gas Dynamics:
    • Solves 1D staggered-grid continuity and momentum equations:∂P∂t=−a2A∂w∂x∂w∂t=−A∂P∂x−fw|w|2ρDA−ρgAsin⁡θ
    • Simulates dynamic line packing, demand drafting, and decompression acoustic waves.
  • Water Hammer & Surge Analysis:
    • Solves Joukowsky acoustic wave propagation (ΔP=ρaΔv) during rapid emergency shutdown (ESD) valve closures and pump trips.
    • Monitors transient pressure spikes against ASME B31.4 limits (P≤1.1×MAOP) and screens for liquid column separation / cavitation.
  • Multi-Product Liquid Batch Tracking:
    • Tracks discrete fuel slugs (Diesel, Regular Gasoline, Jet-A) along transmission pipelines.
    • Austin-Palfrey interface mixing length and transmix volume calculation at delivery manifold cut-points.

2. Tier 2: Gas-Power Sector Coupling & Co-Simulation ​

Enables cross-vector energy system co-simulation via FMI 2.0/3.0 and SSP:

  • Coupled with @modelscript/psse: Simulates how rapid ramp-up of gas-fired combined-cycle power plants (CCGTs) draws on pipeline line pack, ensuring minimum delivery pressures are sustained during electric grid peaks.
  • Coupled with @modelscript/pscad: Evaluates fast sub-second electrical generator trips and their acoustic pressure waves on pipeline fuel supply manifolds.
  • Power-to-Gas: Simulates green hydrogen injection from wind/solar electrolyzers into regional gas grids.

3. Tier 3: Industrial Engine Orchestration ​

Automates invocation of local Emerson PipelineStudio CLI engines (tgnet.exe / tlnet.exe), dynamically ingesting results into ModelScript for unified verification.


Pre-Flight Pipeline Diagnostic Linter ​

12 rules6 error6 warning Run with msx lint

CodeRuleSeverityMessage
M8001maop-exceedederrorPipe '<pipeName>' operating pressure (<value> bar) exceeds Maximum Allowable Operating Pressure (<value> bar).
M8002compressor-surge-hazarderrorCompressor '<compName>' operating flow (<value> m\xB3/h) is below the aerodynamic surge limit (<value> m\xB3/h).
M8003compressor-stonewall-limitwarningCompressor '<compName>' throughput (<value> m\xB3/h) approaches sonic choke/stonewall limit (<value> m\xB3/h).
M8004unconnected-pipeline-nodeerrorNode '<nodeName>' is isolated and has no connecting pipes or equipment links.
M8005delivery-pressure-deficiterrorDelivery node '<nodeName>' is hydraulically unreachable from any supply or storage cavern.
M8006erosional-velocity-hazardwarningGas velocity in pipe '<pipeName>' (<value> m/s) exceeds API RP 14E erosional limit (<value> m/s).
M8007liquid-column-separationerrorTransient pressure in pipe '<pipeName>' (<value> bar) drops below liquid vapor pressure (<value> bar), risking cavitation.
M8008hydrogen-embrittlement-riskwarningHydrogen blend fraction in pipe '<pipeName>' (<value>%) exceeds 10% on steel without fracture toughness certification.
M8009batch-transmix-excesswarningBatch transmix interface on pipe '<pipeName>' exceeds allowable contamination threshold: <detail>.
M8010joule-thomson-freezingwarningJoule-Thomson throttling across regulator '<regName>' reduces outlet temperature to <value>\xB0C, risking ice/hydrate blockage.
M8011pump-npsh-deficiterrorPump '<pumpName>' net positive suction head available (<value> m) is below required NPSHr (<value> m).
M8012line-pack-depletion-riskwarningNetwork total line pack is depleting rapidly: <detail>.

Generated from languages/lps/src/errors.ts. All languages →


Programmatic Usage ​

typescript
import {
  parseLps,
  lintLpsModel,
  SteadyNetworkSolver,
  LinePackEngine,
  GasEulerDaeSolver,
  lpsToSysml2,
  PipelineVerifier,
} from "@modelscript/lps";

// 1. Ingest PipelineStudio XML or ASCII keyword deck
const model = parseLps(sourceText);

// 2. Run Pre-Flight Diagnostic Linter
const diagnostics = lintLpsModel(model);

// 3. Solve Steady-State Network Hydraulics
const steady = SteadyNetworkSolver.solve(model);

// 4. Evaluate Line Pack Storage & Deliverability Reserves
const linePack = LinePackEngine.analyze(model, steady);
console.log(`Total Line Pack: ${(linePack.totalLinePackSm3 / 1e6).toFixed(2)} MMSm3`);
console.log(`Energy Stored: ${linePack.totalEnergyStoredGWh.toFixed(1)} GWh`);

// 5. Verify Formal Safety & MAOP Compliance
const report = PipelineVerifier.verifySteady(model, steady);
console.log("Verification passed:", report.passed);

// 6. Simulate 1D Transient Dynamics
const trajectory = GasEulerDaeSolver.simulate(model, {
  durationSeconds: 7200,
  timeStep: 10,
});

// 7. Generate Formal SysML v2 Architecture
const sysmlCode = lpsToSysml2(model);

Advanced Machinery, Thermodynamics & Physical Models ​

1. Multi-Wheel Compressor Maps & Anti-Surge Control ​

ModelScript supports non-dimensional head-flow parameterization (Ψ vs Φ) for multi-stage centrifugal compressors:

  • Affinity Scaling: Speed governor modulates ω∈[ωmin,ωmax] to maintain target discharge pressure setpoints.
  • Surge Line & Anti-Surge Recycle Valve: Parabolic surge locus detection with automatic recycle valve modulation maintaining a minimum 10% safety buffer.
  • Stonewall (Choke): Detects maximum volumetric throughput beyond which sonic shock waves restrict further flow.

2. Centrifugal Pump Station Curves & NPSH Verification ​

Centrifugal pipeline booster pumps are modeled via cubic polynomial head H(Q) and hydraulic efficiency η(Q) curves with variable frequency drive (VFD) affinity scaling:

H(Q,α)=α2Hrated(Q/α),α=ω/ωrated
  • Computes Net Positive Suction Head Available (NPSHA) against liquid vapor pressure.
  • Triggers diagnostic M8011 if NPSHA<NPSHR(Q), preventing catastrophic impeller cavitation.

3. GERG-2008 Helmholtz Free-Energy EOS (ISO 20765-2) ​

Implements the multi-fluid Helmholtz free-energy formulation α(δ,τ)=α0(δ,τ)+αr(δ,τ) for 21 natural gas components:

  • Covers gas, liquid, supercritical dense phase, LNG cryogenic, and hydrogen blending regimes.
  • Computes speed of sound w, isobaric heat capacity Cp, isochoric heat capacity Cv, and Joule-Thomson coefficient μJT.

4. Slack Line Open-Channel Gravity Flow in Steep Pipelines ​

For pipelines traversing mountain passes with steep downward slopes, liquid column separation occurs when pressure drops to liquid vapor pressure (P≤Psat):

  • Transitions from pressurized pipe flow to open-channel gravity flow governed by the Manning-Gauckler-Strickler equation (Q=1nARh2/3S1/2).
  • Tracks dynamic void fraction αvoid(x,t)=1−Aflow/Apipe and calculates slack collapse re-pressurization surge spikes upon valley impact.

5. 1D Radial Cylindrical Soil Thermal Conduction Mesh ​

Discretizes the ground surrounding buried transmission pipelines into a 10-layer concentric radial cylindrical finite-difference mesh:

  • Solves ρsoilcsoil∂T∂t=1r∂∂r(ksoilr∂T∂r).
  • Captures ground thermal inertia, depth-dependent seasonal phase lag, and pipeline cooldown following emergency station shutdowns.

6. Station Supervisory Multi-Variable PID Overrides ​

SCADA compressor and pump station automation with min/max auctioneering selector gates:

  • Arbitrates between discharge pressure control, low-suction override, driver shaft power limits, and flow dispatch.
  • Integrates velocity PID controllers with anti-windup tracking, synchronizing inactive integrator loops to prevent reset overshoot during control transfer.

7. Hot-Start State Checkpointing (.sav / .rst) ​

Zero-copy state snapshot serialization with SHA-256 integrity verification:

  • Saves all nodal pressures, pipe mass flows, fluid temperatures, soil thermal layers, and controller integrator states.
  • Enables instantaneous resumption of multi-day transient simulations and what-if contingency branching.

Command-Line Interface (msx lps) ​

bash
# Pre-flight safety linting
msx lps lint network.lps

# Steady-state hydraulics with slack line & soil thermal analysis
msx lps solve network.lps --slack --soil --eos=GERG2008

# Line pack inventory & deliverability buffer
msx lps linepack network.lps

# Transient simulation with hot-start checkpointing
msx lps simulate network.lps --duration=7200 --step=10 --save-checkpoint=state.sav

# Resume simulation from intermediate snapshot
msx lps simulate network.lps --duration=3600 --restart=state.sav

# Export formal SysML v2 architectural model
msx lps sysml network.lps -o network.sysml

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