From 0d4bbaeed8b678ed40c81daa91de4326726e6ba1 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 2 Aug 2026 00:49:07 +0200 Subject: [PATCH] Read and fit S-parameters, then run a transient analysis and compare. --- examples/sp/file_nport_tran.cir | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 examples/sp/file_nport_tran.cir diff --git a/examples/sp/file_nport_tran.cir b/examples/sp/file_nport_tran.cir new file mode 100644 index 000000000..6bff29f42 --- /dev/null +++ b/examples/sp/file_nport_tran.cir @@ -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