Read and fit S-parameters, then run a transient analysis and compare.

This commit is contained in:
Holger Vogt 2026-08-02 00:49:07 +02:00
parent 0e390e949f
commit 0d4bbaeed8
1 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,57 @@
Example circuit to read a Touchstone-format parameter file.
* This file contains an an analog filter circuit; SP is run
* and the S-parameters are saved in a file.
* It then uses vector fitting for a *.nport file, serving the nport instance
* in a circuit that reproduces the original from its saved S-parameters.
* Results from the two versions are plotted together for comparison.
* Derived from: Qucs 1.0.2 C:/Users/Tom Hajjar/.qucs - S/S-parameter_files_ngspice_prj/137MHz_BPF.sch
* Original circuit for SP analysis
VP2 filter_out 0 dc 0 ac 0.316228 SIN(0 0.316228 136MEG) portnum 2 z0 50
VP1 _net1 0 dc 0 ac 0.316228 SIN(0 0.316228 136MEG) portnum 1 z0 50
C1 _net2 _net1 4.7P
C5 _net3 filter_out 4.7P
C3 _net3 _net2 1P
C4 _net3 0 15P
C2 0 _net2 15P
L2 0 _net3 66N
L1 0 _net2 66N
* input for both filters
VP11 in 0 dc 0 SIN(0 0.316228 136MEG)
* Original circuit for tran analysis
Ri in sin 50
C11 _net21 sin 4.7P
C15 _net31 filter_out1 4.7P
C13 _net31 _net21 1P
C14 _net31 0 15P
C12 0 _net21 15P
L12 0 _net31 66N
L11 0 _net21 66N
R12 filter_out1 0 50
* A version fitted from the extracted s-parameters using the nport device
ri2 in sin2 50
N1 sin2 np_model_out 0 mymodel
.model mymodel nport(file="new_137MHz_BPF.nport")
ro2 np_model_out 0 50
* Control section, run simulations.
.control
* Run an SP analysis, derive group delay, write a Touchstone file
* Use this Touchstone file for vector fitting by pre_snp, thus get a file
* new_137MHz_BPF.nport
SP LIN 71 107MEG 167MEG ; extract S parameters
wrs2p new_137MHz_BPF.s2p ; write S parameters
pre_snp -native new_137MHz_BPF.s2p ; read S parameters, fit, create new_137MHz_BPF.nport
tran 0.1n 1u
set xbrushwidth=3
plot filter_out1-np_model_out ; difference to compare
plot in filter_out1 np_model_out xlimit 0.8u 0.85u
.endc
.END