-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add s2p files support for Qucs-S #233
Comments
I'm hoping to get help from the ngspice guys on this issue. The E source format used in the LTspice conversion file looks similar to ngspice. I tried two different s-parameter files, one with DB and the other MAG. Neither worked. LTspice E0101 101 102 FREQ {V(100,3)}= MAG ( 3.000000e+07Hz, 4.147000e-01, -3.320000e+01).... ngspice |
Here is a discussion on LTspice forum about the format for "E" as used in the converter. It's not well documented. E11 11 12 FREQ {V(10,3)} = DB (1.000000e+006,-2.162013e+000,-1.673312e+001)..... |
Article with QuickBasic program on how to convert S-parameter files for PSpice. |
I'll take a look and see if there is a simple way to target ngspice. Will take time as I am traveling a lot these days. |
Dan Thank you for looking into this. Holger and the guys over at ngspice are looking into the E source issue. https://sourceforge.net/p/ngspice/discussion/120973/thread/51228e0b01/ Would it be easier to find a solution if only MAG was used instead of MAG and DB if the method used in LTspice won't work? The original program from decades ago, S2P2LIB1.bas does a unwrap-phase but S2spice doesn't. Can this cause phase ambiguity issues? I tested ATF10236.s2p with the updated S2P2LIB.bas and S2spice. You can compare the formatting differences between the two lib files. |
To help in testing, I created a number of files using Qucs. I used Qucs because Qucsconv has the ability to convert a .dat file (with S-parameter data) to a .s2p file. This should ease verifying a s2p file converted to E sources for ngspice. Files: 137MHz_BPF.dat, simulation data 137MHz_BPF.s2p, created from 137MHz_BPF.dat file using Qucsconv 137MHz_BPF_sfile.sch, test file using 137MHz_BPF.s2p |
3dB_Attenuator files for Qucs-S and ngspice |
There has been some good progress on adding S-parameter file support. I'm hoping the work done by Giles Atkinson and It looks like two things have to happen: 1: Update S2spice to support the format required by the future ngspice release. Jim Mittel has modified S2spice for this format. For Windows users, hopefully Dan Dickey can release a new version that gives the option for a "ngspice compatible" file. 2: A new release of ngspice that supports the file generated by S2spice. https://sourceforge.net/p/ngspice/discussion/120973/thread/51228e0b01/?page=1 |
@tomhajjar Yes, this is good news. I gave advice to the frequency dependent source model developer to submit it to Ngspice upstream. Once it will be available in the Ngspice upstream I will add the S2P device support in the GUI level. It is not a problem to backport the s2spice converter features to the Qucs-S. |
Now I'm confused. Is Ngspice going to support S-parameter files directly? Or is it going to support the LTspice/Pspice like frequency dependent sources upon which s2spice depends? |
It's better to ask this question at the Ngspice forum (see the link for discussion thread above). Currently the frequency dependent table controlled source still be not finished, so I cannot add it to Qucs-S. |
The guys over at ngspice have finished the 1st cut of ngspice supporting S-parameter files created by S2spice. I use Dan Dickeys Windows version of S2spice with GUI interface. Attached is my test project folder with various examples. I'm going to port more projects I have with both S-parameter and Spice files to compare. From Holger: |
Yes, I have seen that frequency dependent E-source is preparing for merge into the master branch of the Ngspice. I am planning to start work on the s2p devices support after releasing of the v1.0.3 package (planned in the next 1-2 weeks). |
So this support will preclude having to use S2spice.exe? |
No, I am planning to include s2spice code in the Qucs-S. There will be no need to install this utility separately. |
It hasn't been an issue for me but S-parameters can be in DB or MAG format. In some versions of S2spice I think there was an option to generate the E-sources in various formats. |
I found a possible issue when simulating circuits like narrow band filters using more than the 100 sweep points that S2spice defaults to. See attached plots using 100 and 500 points. Problem happens for ANY number greater than 100 points. I'm unsure if this is an interpolation issue or some other problem. |
This is sure not interpolating issue related to Qucs-S plotting engine. I have simulated the auto-generated netlist with CLI version of the Ngspice and obtain exactly the same plot. This issue should be reported to the frequency dependent source developer. |
I did some additional testing in Qucs. Not sure if this issue has anything to do with issues using Qucs-S and ngspice. If I generate an S-parameter file of 101 points and then do analysis of the file using 501 points. The Group Delay data has ringing. If I generate an S-parameter file of 501 points and then do analysis of the file using 501 points. The Group Delay data is OK. Side Note: |
I have checked the provided files. It is not interpolation error of the Qucs/Qucs-S plotting engine. The ringing presents in the dataset and comes from the Qucsator simulation kernel. |
Giles over at ngspice spotted an obvious issue with the Group Delay data. Not sure what the solution is yet. It could be S2spice is doing the conversion wrong. Disregard the GD upper ear distortion. The Group Delay plots using Qucs for the LC filter and the s-parameter file I created are the same, 60ns. The Group Delay plots using ngpice via Qucs-S or DuSpice for the LC filter are the same as Qucs, 60ns. The Group Delay plots using ngpice via Qucs-S or DuSpice forthe s-parameter file converted to Spice subcircuit is 600ns, 10x too high. |
Giles over at ngspice found problems with the version of S2spice I was using. Using the version of S2p he used, the problems with group delay or # of test points seem gone. One can still get ringing on the group delay using random # of points. This may be the Qucs issue you noted earlier. Attached are the corrected lib and sch files. I asked for the source of s2p.exe. |
I have made several changes but may be incompatible with ngspice. It turns out that using the E (voltage) source is not efficient compared to the G (current) source. E sources require many more nodes in the admittance matrix than G sources. So I have elected to create the subckt file with G sources. This speeds up LTspice simulations about 5:1 for large multi-port networks. Have a look at the latest here: https://github.com/transmitterdan/s2spice/releases Would be interesting to understand how the number of points matters. The code in s2spice does not have a fixed number of points. It dynamically sizes the arrays as it reads the file. |
@transmitterdan I am planning to start work on s2p files support since the next release of Qucs-S. I considered to add dependency to s2spice utility as the git submodule. But this utility depends on wxWidgets and has GUI-only operation that doesn't fit to concept of the integration in Qucs-S. So I decided to port the |
Dan/Vadim I haven't tried Dan's latest S2spice but how does it relate to the version Giles did, s2p? |
No, my question is not related to work on frequency dependent E-source support that is done by Giles for Ngspice. |
I tested s2spice-2.1.1-win32.exe and it seems to work. What was the rational for changing the suffix to .inc? It's not that common in LTspice and it's not a default in Qucs-S. I realize your target audience is the LTspice user and the suffix is not material. |
Yes, but have a look at the git commit trail after that release to see if any other bugs were fixed after the change to G-source. G-source is more computationally efficient because the node count is more or less N-squared where N is the number of ports. But with E sources the node count goes as N-cubed. For larger devices with many ports (like 8-way splitter/combiner) the memory and execution speed slows down. It also improves numerical stability. |
Some email systems are refusing to transmit files with name ending in .lib. The ending .inc works for LTspice and the email systems don't complain about it. |
The program does have a command line interface so it can be run without opening any windows. |
Frquency dependent E- and G-Sources are supported by ngspice (for now on git pre-master branch). Internally they are converted to A sources with appropriate parameters. |
I have tested three variants of the latest versions of "S2spice" by the following authors: Jim Mittel, @jmittel Jim's version uses A sources. Jim says his is a variation of what Giles created but Giles latest rev uses S sources. I'm a bit confused. Below is a snippet of the resultant lib/inc files. Attached is the latest versions as of 6/16/23. Jim *S11 FREQ R_I
Giles *S11 FREQ R_I Dan S11 FREQ R_I |
What are the results? All he same? Or different, so more work needed? |
Results seem to be the same. I have been testing using the same files. Jim asked me to test S-parameter files in polar format. Qucs only generates rectangular format so I need to test more files. |
I think you may use the vector fitting capabilities of python module scikit-rf to generate a spice circuit from a touchstone file (see at: https://scikit-rf.readthedocs.io/en/latest/examples/vectorfitting/vectorfitting_ex2_190ghz_active.html). |
Majority of Spice files are for active devices with gain.... |
Vector fitting can be applied also to S parameters of active devices. The only difference is that poles of S matrix can stay on right half of the Laplace plane and you must not enforce passivity. Example linked in my previous post is indeed related with an active device. Of course the frequency response of S parameters is valid for small signal regime with a fixed polarization point. |
Closing ticket as completed. The s2p files support will be available since the next release. |
Not working here. Qucs-s Version 2.1.0 two files attached: Both touchstone files are working fine in qucs, the schematic files were created directly on qucs-s. |
Ngspice supports S-parameters simulation since release 37, but the simulation of the
*.s2p
files is not supported. There existss2spice
utility https://github.com/transmitterdan/s2spice designed by @transmitterdan that converts s2p files to SPICE netlists having LTSpice compatible syntax. The similar approach could be used for Qucs-S, but there exists a problem. Ngspice doesn't support the frequency dependent E-source that is used bys2spice
to represent thes2p
files. It's need to find an Ngspice replacement for such source type. Then thes2p
files support could be implemented for Qucs-S.s2spice utiliy uses the following E-source syntax:
The text was updated successfully, but these errors were encountered: