Skip to content
Preview.sNp@modelscript/touchstone 10 diagnostic rules
Parser WASM GLR
Diagnostics 10 rules
DAE Arena Lowering
Simulation Co-sim / Export
Projections Modelica
Live ExampleCavityBandpassFilter.s2p

Touchstone 2-Port Microwave Cavity Bandpass Filter

Frequency-domain S-parameter matrix ($S_{11}, S_{21}, S_{12}, S_{22}$) from 1.0 to 4.0 GHz referenced to $Z_0 = 50\,\Omega$.

Playground
Source (10 lines)
1! 2-Port 2.45 GHz Microwave Bandpass Filter S-Parameters
2# GHz S MA R 50
3! Freq  |S11|  <S11    |S21|  <S21    |S12|  <S12    |S22|  <S22
41.00    0.94  -22.0    0.18   68.0    0.18   68.0    0.94  -22.0
51.80    0.78  -54.0    0.58   32.0    0.58   32.0    0.78  -54.0
62.20    0.24  -88.0    0.95   -4.0    0.95   -4.0    0.24  -88.0
72.45    0.06 -112.0    0.99  -28.0    0.99  -28.0    0.06 -112.0
82.70    0.28 -142.0    0.94  -56.0    0.94  -56.0    0.28 -142.0
93.20    0.82 -168.0    0.49  -92.0    0.49  -92.0    0.82 -168.0
104.00    0.95  172.0    0.14 -124.0    0.14 -124.0    0.95  172.0
Touchstone RF S-Parameter Magnitude Response
NaN-Port RF S-Parameter Network High-Frequency Scattering Matrix Model [ S ] NaN-Port Network (50 Ω) PASSIVE (||S|| ≤ 1)
Drag to pan · Click % to reset

Touchstone RF & Signal Integrity (.sNp, .ts) ​

@modelscript/touchstone (languages/touchstone) provides high-performance zero-regex parsing, Vector Fitting rational macromodeling, Hamiltonian passivity enforcement, linear DAE lowering, and Modelica 3.x projection for Touchstone 1.0 & 2.0 multi-port RF, microwave, and high-speed digital interconnect decks.


Supported Extensions & Standards ​

ExtensionFormatDescription
.s1p1-Port NetworkReflection coefficient (S11) for antennas, terminations, and single-ended loads
.s2p2-Port NetworkTransmission (S21,S12) and reflection (S11,S22) for filters, amplifiers, transmission lines
.s3p, .s4p, .sNpMulti-Port NetworkMulti-pin connectors, differential transmission lines, crosstalk matrices
.tsTouchstone 2.0Advanced multi-port specification with mixed-mode S-parameters and per-port reference impedances

Key Capabilities ​

1. Multi-Format Parameter Formats ​

  • Parses multi-port frequency grids with automatic unit conversion (Hz, kHz, MHz, GHz) and parameter types:
    • S-Parameters (Scattering matrix)
    • Y-Parameters (Admittance matrix)
    • Z-Parameters (Impedance matrix)
    • H / G Parameters (Hybrid matrices)
  • Supports all standard data formats:
    • DB: Magnitude in decibels (20log10⁡|S|), phase in degrees (∠S)
    • MA: Linear magnitude (|S|), phase in degrees (∠S)
    • RI: Real and imaginary components (Re(S)+jIm(S))
  • Enforces strict Touchstone matrix ordering conventions (e.g., S21,S12 transpose ordering for 2-port networks).

2. Vector Fitting & Rational Macromodeling ​

  • Converts discrete frequency-domain tabulated measurements into continuous-time rational transfer functions via Vector Fitting:Sij(s)≈∑m=1Prms−pm+d+s⋅ewhere pm are complex conjugate pole pairs in the open left half-plane (Re(pm)<0), ensuring stability.
  • Synthesizes a state-space realization:x˙(t)=Ax(t)+Bu(t),y(t)=Cx(t)+Du(t)which lowers directly into ODE time-domain solvers without inverse FFT convolution lag.

3. Passivity Verification & Hamiltonian Matrix ​

  • Verifies that the N-port network does not generate net energy across all frequencies:∥S(jω)∥2≤1∀ω∈[0,∞)
  • Computes the eigenvalues of the Hamiltonian matrix:H=[A+B(I−DTD)−1DTCB(I−DTD)−1BT−CT(I−DDT)−1C−(A+B(I−DTD)−1DTC)T]where purely imaginary eigenvalues identify exact passivity violation frequency crossover points.

4. Direct DAE Lowering & Modelica Projection ​

  • Lowers state-space companion matrices directly into @modelscript/runtime's DAEBuilder SoA linear memory arena.
  • Projects multiport networks into Modelica.Electrical.Analog pin networks for joint electro-mechanical and power electronic simulations (@modelscript/spice).

Pre-Flight Diagnostics ​

The Touchstone linter checks physical validity and numerical stability:

10 rules8 error2 warning Run with msx touchstone lint

CodeRuleSeverityMessage
M8301passivity-violationerrorN-port scattering matrix violates passivity criterion (spectral norm <norm> > 1.0) at frequency <freq>.
M8302causality-violationerrorKramers-Kronig causality relation violated across frequency sweep: '<detail>'.
M8304frequency-grid-non-monotonicerrorFrequency grid is not monotonically increasing: step from <prevFreq> to <currFreq> is non-increasing.
M8306missing-option-linewarningMissing '#' option line; defaulting to '# GHz S MA R 50'.
M8307invalid-parameter-formaterrorInvalid Touchstone parameter token or format '<token>'.
M8308incomplete-matrix-dataerrorIncomplete N-port matrix row: expected <expected> values, received <received>.
M8309negative-reference-resistanceerrorReference resistance '<r>' must be strictly positive.
M8310asymmetric-reciprocal-networkwarningAsymmetry in reciprocal S-parameter network: |S<i><j> - S<j><i>| = <diff> exceeds threshold.
M8311no-frequency-pointserrorTouchstone file contains no valid frequency parameter points.
M8312duplicate-frequency-pointerrorDuplicate frequency sample point '<freq>' encountered in sweep.

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


CLI Usage ​

bash
# Inspect Touchstone port count, frequency range, and impedance
msx touchstone inspect BandpassFilter.s2p

# Run pre-flight linting and validity checks
msx touchstone lint BandpassFilter.s2p

# Verify S-parameter passivity and compute maximum singular value
msx touchstone passivity BandpassFilter.s2p

# Fit rational state-space macromodel via Vector Fitting
msx touchstone fit BandpassFilter.s2p --order=6

# Lower state-space model to ModelScript linear DAE arena
msx touchstone to-dae BandpassFilter.s2p

# Project into Modelica 3.x electrical analog component
msx touchstone to-modelica BandpassFilter.s2p -o FilterModel.mo

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