Spice4qucs (Ngspice and Xyce support in Qucs)

545 views
Skip to first unread message

Vadim Kuznetsov

unread,
Jul 18, 2015, 4:12:51 AM7/18/15
to xyce-...@googlegroups.com
Hello Xyce developers and users,

I would like to inform you that Spice4qucs patchset is prepared for merge in upstream Qucs (https://qucs.github.io) code after 8 months of development. Spice4qucs allows you to simulate Qucs schematic with Xyce or Ngspice backends. Qucs can serve as GUI for Xyce.


There is a pull request https://github.com/Qucs/qucs/pull/275 at Github. You can clone and build this branch to look at spice4qucs closer. Draft documentation is here https://qucs-help.readthedocs.org/en/spice4qucs/ . Documentations is a bit outdated now. All contributions in documentation are welcome. Spice4qucs contains over 280 commits mainly from me and Mike Brinson.

Examples could be found at examples/ngspice and examples/xyce subdirectories.

Discussion threads at Github are here:
https://github.com/Qucs/qucs/issues/226
https://github.com/Qucs/qucs/issues/77
https://github.com/Qucs/qucs/issues/181


There was the following changes (not reflected in the documentation) during last months:
1. Redesigned "Simulate with SPICE" dialog. This dialog is made more user-friendly. Added warning label in the top of dialog with hyperlink for help. Added exit button. Changed font to monospace. Working directory for temporary simulation data saving could set manually. Simulator log redirected to system log.txt .
2. Added Qucs input schematic checker. Checker checks all components on SPICE-comaptibility. If component is SPICE-incompatible (Qucs transmission lines, etc.), then such schematic cannot be simulated with SPICE. User error message is shown and further simulation is blocked
3. Implemented new datasets naming system (more user-friendly) to avoid dataset names conflicts. Now three datasets could be created during simulations scheamtic_name.dat --- default dataset from Qucsator; schematic_name.dat.ngspice --- for Ngspice; and schematic_name.dat.xyce --- for Xyce. Dataset selection list in DiagramDialog shows only the base name of dataset. User needs to select appropriate dataset from ChooseSimulator drop-down list. Only existing simulations are shown in this list. Also variable naming system is changed. Ngspice variables have ngspice/ prefix, Xyce variables have xyce/ prefix.  All examples were updated. It's need to update documentation too. More info at https://github.com/Qucs/qucs/pull/275#issuecomment-122202465

xyce-users

unread,
Jul 18, 2015, 12:51:03 PM7/18/15
to xyce-...@googlegroups.com, ra3...@gmail.com

This is pretty cool, Vadim.  I haven't had much time to look at it yet, but have cloned the git repo, checked out the rebase_spice4qucs branch, and gotten the thing built on my system.  I look forward to experimenting with it.

The one thing I noticed, however, is the way the "Simulate with Spice" settings work for running Xyce in parallel --- they appear to assume that the "xmpirun" script exists for parallel Xyce, and appears simply to tack on "-np # netlist" to that, using the spin box value for number of processors.  But xmpirun is generally only present in binary distributions of Xyce, where the xmpirun script is designed to set environment variables to get distributed shared libraries from the Intel compiler suite loaded.  In a source-built install, this script (which is admittedly a kludge that we'd like to do away with at some point) is not installed and generally unnecessary, and the user is expected to construct their own mpirun command line, e.g. "/path/to/mpirun -np 2 [mpi options]  /path/to/Xyce [xyce options] netlist".  It does not appear possible to set the Simulate with Spice option to use a command line of that form.

An improvement to the dialog might be to allow a more flexible way of specifying how to run Xyce in parallel, perhaps allowing a pattern that could be substituted into, e.g.:

     /usr/local/mpi/openmpi/bin/mpirun -np %p /usr/local/Xyce_Parallel/bin/Xyce

which Qucs could then substitute the number of processors for %p.  And the default command line as you have it now could then be
    /usr/local/Xyce_.../bin/xmpirun -np %p

Vadim Kuznetsov

unread,
Jul 19, 2015, 5:08:24 AM7/19/15
to xyce-...@googlegroups.com, xyce-...@googlegroups.com
Thank you for comments! Added patterns in Xyce-Parallel command-line. See https://github.com/Qucs/qucs/pull/275#issuecomment-122640964 for details.

xyce-users

unread,
Jul 20, 2015, 10:37:26 AM7/20/15
to xyce-...@googlegroups.com, ra3...@gmail.com
Just another quick comment.

Your Xyce example is cool, but when I ran it I discovered that your method of processing HB netlists in Xyce is counting on a bug in Xyce output.  We did not notice this bug until looking at your example, in fact.

You are using ".print hb file=<filename>", an option we have apparently not been testing well.  The output produced by this .print line is not anything like the output we intended, and will certainly be changing as soon as possible.  It is currently outputting two headers, neither of which actually describes the contents of the file correctly, and is concatenating time-domain and frequency-domain output on every line.  This is definitely not what we would have intended, and it has been added to the list of bugs in the output system in general, and in the file= handling in particular.

Most internal users of Xyce's harmonic balance only use the default ".print hb <list of outputs>" variant, which produces separate files for every subset of HB output (startup periods, initial condition, time-domain, and frequency-domain).  These all contain the correct outputs and their headers correctly describe the columns on the lines.  This is the most well-tested part of HB output.

Since rawfile output of HB doesn't work yet and you're stuck parsing the columnar version of output, you'd be best off omitting the "file=" option and parsing the <netlist>.HB.FD.prn file that is produced by default.  This will prevent the inevitable breakage in Qucs when we fix the file= bugs. 

Thank you for posting here, because we were unaware of this particular bug until this weekend, and are only aware of it as a result of looking into how you're running Xyce for HB and parsing its output.  This may also help us justify spending the time to get rawfile output for HB working properly.  Since we are aware of no other code that has harmonic balance analysis and produces rawfiles (and of course there is nothing in the SPICE3F5 rawfile format defining how HB output should look), we never established how to write these rawfiles.

At some point it may also be reasonable to add Qucs-compatible output formats to the Xyce output package, especially if your spice4qucs changes (or some other variant) becomes an official part of the Qucs release.  But that's a discussion for another day, as it will probably require that a Qucs developer create patches to Xyce for us to consider for inclusion.
Message has been deleted

xyce-users

unread,
Dec 9, 2015, 12:18:44 PM12/9/15
to xyce-users, ra3...@gmail.com, xyce-...@googlegroups.com

Vadim:

The bug I mention below, and that you were depending on in the version of spice4qucs back in July, has been fixed in the soon-to-be-release Xyce 6.4.  If you have not updated spice4qucs as I recommended below (omitting the file= on the print line, and using the default output file name), and continue to depend on this broken behavior, spice4qucs will stop working with HB output.

When 6.4 is released, .print HB file=<filename> will now correctly output ONLY the frequency-domain data and frequency-domain header into the named file, and will send time-domain output to the default file name (<netlistname>.HB.TD.prn) rather than scrambling the two together in the named file.  So you'll need to address this in how you process Xyce text output for HB.

Is there any update on the status of the spice4qucs branch?  From the looks of the pull request, it appeared that you were getting some push-back about incorporating these changes back into the main line.  It'd be great to see Xyce support make it into an official release.

Vadim Kuznetsov

unread,
Dec 10, 2015, 7:28:37 AM12/10/15
to xyce-users, ra3...@gmail.com, xyce-...@googlegroups.com
Current version of spce4qucs subsystem works with bot released Xyce version (6.2 and 6.3). When are you planning to make 6.4 release? I will try to prepare fix by this date. I will move HB results parsing to <netlsit-name>.HB.FD.txt as you suggested.

Concerning merging of the Spice4qucs susbsytem into Qucs upstream. Our development team has no common opinion on this subject. Spice4qucs will not be merged before 0.0.19 release. Merging still under discussion. We decided to release two sets of packages in parallels:
1. Usual Qucs-0.0.19 will be shipped only with Qucsator support
2. Qucs-0.0.19S will be shipped with integrated spice4qucs subsystem (Ngspice and Xyce) by default.

Qucs-0.0.19S packages will be formed directly from rebase_spice4qucs branch. I have prepared special builds for Qucs-0.0.19S. You can download it here: https://github.com/ra3xdh/qucs/releases

These two sets of packages will be formed every next release until we will have a final decision on spice4qucs merging.  Merging of spice4qucs will be considered again during 0.0.20 development cycle.

Spice4qucs development is active and now moved to spice4qucs_current branch https://github.com/Qucs/qucs/tree/spice4qucs_current  The https://github.com/Qucs/qucs/tree/rebase_spice4qucs branch is intended for 0.0.19S package. It is frozen and waits 0.0.19 release.

xyce-users

unread,
Dec 10, 2015, 11:56:22 AM12/10/15
to xyce-users, ra3...@gmail.com


On Thursday, December 10, 2015 at 5:28:37 AM UTC-7, Vadim Kuznetsov wrote:
Current version of spce4qucs subsystem works with bot released Xyce version (6.2 and 6.3).

Yes.  Unfortunately, the bug that makes that work was introduced in Xyce 6.2. 
 
When are you planning to make 6.4 release?

It will be in early January.

I will try to prepare fix by this date. I will move HB results parsing to <netlsit-name>.HB.FD.txt as you suggested.

If you do this, it will work with all versions of Xyce.  The bug only existed when a "file=" was given.  When no "file=" is given, frequency domain output goes to the "<netlistname>.HB.FD.prn"  (not "txt") file  and time domain goes to "<netlistname>.HB.TD.prn".  The bug was that when "file=" was given, both outputs were going to the same file, and getting scrambled together.  So some of the things in your code (such as skipping two header lines, and skipping over time-domain data on the lines) are needed only to unscramble what should never have been scrambled in the first place.

In Xyce 6.4, if you specify "file=" on ".print hb" lines, only frequency domain data goes to the specified file, and the time-domain data goes to the default file name "<netlist>.HB.TD.prn".  If one wants to redirect the time domain data to a different named file, one does it with a separate ".print hb_td file=" line, which may have completely different output variables if desired.

Concerning merging of the Spice4qucs susbsytem into Qucs upstream. Our development team has no common opinion on this subject.

That's why I asked --- I've been following some of the comments on the pull request.
 
Spice4qucs will not be merged before 0.0.19 release. Merging still under discussion. We decided to release two sets of packages in parallels:
1. Usual Qucs-0.0.19 will be shipped only with Qucsator support
2. Qucs-0.0.19S will be shipped with integrated spice4qucs subsystem (Ngspice and Xyce) by default.

Qucs-0.0.19S packages will be formed directly from rebase_spice4qucs branch. I have prepared special builds for Qucs-0.0.19S. You can download it here: https://github.com/ra3xdh/qucs/releases

These two sets of packages will be formed every next release until we will have a final decision on spice4qucs merging.  Merging of spice4qucs will be considered again during 0.0.20 development cycle.

Spice4qucs development is active and now moved to spice4qucs_current branch https://github.com/Qucs/qucs/tree/spice4qucs_current  The https://github.com/Qucs/qucs/tree/rebase_spice4qucs branch is intended for 0.0.19S package. It is frozen and waits 0.0.19 release.

Thank you for the information.
 

Vadim Kuznetsov

unread,
Dec 13, 2015, 2:41:44 AM12/13/15
to xyce-users, ra3...@gmail.com, xyce-...@googlegroups.com
I have added fix to provide version-independent behavior of Qucs+Xyce link for HB simulation. Now <netlist_name>.HB.FD.prn file is parsed. See latest commits at https://github.com/Qucs/qucs/tree/spice4qucs_current and https://github.com/Qucs/qucs/tree/rebase_spice4qucs branches. 
Reply all
Reply to author
Forward
0 new messages