From 2d6ca92a7e5d27c5daf0bbc4ba759f3019ed9b18 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 2 Aug 2026 15:44:44 +0200 Subject: [PATCH] Examples: nport instance and command 'sp' are not compatible. files.cir uses sp, the others the given 137mhz_bpf.s2p --- examples/sp/file.cir | 12 ++---------- examples/sp/file_nport.cir | 10 +++++----- examples/sp/file_nport_tran.cir | 26 ++++++-------------------- 3 files changed, 13 insertions(+), 35 deletions(-) diff --git a/examples/sp/file.cir b/examples/sp/file.cir index 7a047bea8..0d1686019 100644 --- a/examples/sp/file.cir +++ b/examples/sp/file.cir @@ -30,14 +30,6 @@ ri net1 sin 50 X1 sin sp_model_out 0 s2p_generic touchstone="137MHz_BPF.s2p" ro sp_model_out 0 50 -* A version derived from extracted s-parameters using the nport - -VP4 net2 0 dc 0 ac 0.316228 ; Same as VP1 but that must not be loaded. -ri2 net2 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 @@ -55,8 +47,8 @@ alter vp2 ac = 0 AC LIN 71 107MEG 167MEG set xbrushwidth=2 display -plot group_delay(filter_out) sp1.Group_Delay group_delay(sp_model_out) group_delay(np_model_out) -plot db(filter_out) cph(filter_out) db(sp_model_out) cph(sp_model_out) db(np_model_out) cph(np_model_out) +plot group_delay(filter_out) sp1.Group_Delay group_delay(sp_model_out) +plot db(filter_out) cph(filter_out) db(sp_model_out) cph(sp_model_out) .endc * Subcircuit for SP behavioral device diff --git a/examples/sp/file_nport.cir b/examples/sp/file_nport.cir index 3a7514c97..5dc8a1192 100644 --- a/examples/sp/file_nport.cir +++ b/examples/sp/file_nport.cir @@ -25,7 +25,7 @@ L1 0 _net2 66N VP4 net2 0 dc 0 ac 0.316228 ; Same as VP1 but that must not be loaded. ri2 net2 sin2 50 N1 sin2 np_model_out 0 mymodel -.model mymodel nport(file="new_137MHz_BPF.nport") +.model mymodel nport(file="137mhz_bpf.nport") ro2 np_model_out 0 50 * Control section, run simulations. @@ -34,10 +34,10 @@ ro2 np_model_out 0 50 * 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 -let Group_Delay = -1*deriv(cph(S_2_1))/(2*pi) -wrs2p new_137MHz_BPF.s2p -pre_snp -native new_137MHz_BPF.s2p +*SP LIN 71 107MEG 167MEG +*let Group_Delay = -1*deriv(cph(S_2_1))/(2*pi) +*wrs2p $inputdir/new_137mhz_bpf.s2p +pre_snp -native $inputdir/137mhz_bpf.s2p * Now run AC analysis diff --git a/examples/sp/file_nport_tran.cir b/examples/sp/file_nport_tran.cir index 6bff29f42..6532d0bca 100644 --- a/examples/sp/file_nport_tran.cir +++ b/examples/sp/file_nport_tran.cir @@ -1,24 +1,13 @@ 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 +* This file contains an an analog filter circuit. +* It reads a previously created Touchstone file 137mhz_bpf.s2p +* 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) @@ -36,17 +25,14 @@ 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") +.model mymodel nport(file="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 +* Use given 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 +pre_snp -native $inputdir/137mhz_bpf.s2p ; read S parameters, fit, create new_137MHz_BPF.nport tran 0.1n 1u set xbrushwidth=3