Closed ra3xdh closed 7 years ago
Hi Vadim, your work is great! :)
Fra
Source code is now located on spice4qucs
branch of main Qucs github repository: https://github.com/Qucs/qucs/tree/spice4qucs . You can propose your pull requests for this branch. Build instructions are on wikipage: https://github.com/Qucs/qucs/wiki/QEP%3A-Qucs-schematic-simulation-with-ngspice
Added spice file components support. Now circuits with spice file components could be simulated. Here is simulation example. LM358 spice model from @in3otd was used. Spice code is here http://pastebin.com/1NJpGFYM . See last commits on spice4qucs
branch.
Added three special components. that implement .PARAM
.GLOABL_PARAM
and .OPTIONS
sections of spice netlist. These components could be used when it's need to pass custom parameter to spice simulation kernel directly.
The latest updates:
Added SPICE basic transformer models. These are subcircuits and can be found in Qucs project SPICE_transformer_models_prj in the Qucs examples directory. Two test examples are also included. The Qucs inductance symbol for use in SPICE simulations has been extended to include a DOT at one terminal of the symbol to indicate inductance winding polarity. The transformer symbols are:
The following test examples give an indication of the transformer model use:
Non-linear transformer models to follow soon.
For Qucs users information the following map of a range of SPICE voltage and current generator test circuits give an idea of the capabilities of the new signal generators.
This information will be useful!
Added ngspice and Xyce MESFET component. The MESFET model has been added to allow all three analogue simulators access to the different MESFET models distributed with each simlator. Ngspice level 1 model appears to be common to all three simulators. The following test example shows a set of DC device characteristics obtained from a ngspice simulation of the ngspice level 1 model. Note that the combination of Qucs GUI and the ngspice simulation engine allows one or two component or device parameters to changed while simulating.
This example also illustrates how multi-line component specifications can be attached to a Qucs schematic symbol, for example MESFET Z1.
Qucs-ngspice simulation now works with imported XSPICE code models. The following png screen dump shows how XSPICE analog.cm SPICE 2g6 non-linear POLY() statements can be added to Qucs behavioural G sources located in subcircuits. Note the ngnutmeg codemodel statement is used to load the analog.cm model library.
Added XSPICE Cmeter analogue component. It can be found in the "probes" group. Testing indicates that this component only works with transient analysis and circuits with standard C components connected to individual nodes. The following RCLadder network gives an indication of how the probe works.
Added a lossless transmission line: ngspice and Xyce type T component. The example shown below indicates that the model functions as an ideal lossless transmission line. Please note its parameters are different to the Qucs 2 port, 4 terminal transmission line
Added parameter sweep for 2 variables in nested loops. This works only with Ngspice.
Added the SPICE 3f5 style U type uniform distributed RC transmission line. This model appears to be only available with ngspice.
Added lossy transmission line. Model type LTRA. This line model is implemented in both ngspice and Xyce.
Added Fourier (Ngspice and Xyce) and Distortion (Ngspice)analysis
Added a SPICE diode symbol. The original Qucs diode model (the legacy model ) is retained and continues to work with Qucs, ngspice and Xyce. However, it does not have the SPICE LEVEL selection mechanism implemented. The additional SPICE diode model allows full selection of Xyce models: for example LEVEL = 1 selects the SPICE 3f5 model and LEVEL=2 selects the PSpice diode model. Xyce reverts to the SPICE 3f5 diode model if LEVEL is not defined. Note, the ngspice diode model does not include the LEVEL parameter. Inclusion of the SPICE diode model does provide however, access to all the implemented ngspice diode parameters.
The attached diode test circuit shows a basic example of a diode clamp circuit.
Added npn and pnp BJT three terminal models to spice4qucs. The legacy BJT models are not affected and should work with Qucs, ngspice and Xyce. The new models allow different SPICE BJT models to be selected via the SPICE LEVEL parameter, for example:
The attached sawtooth generator circuit and simulation results indicates how the new SPICE BJT models are used.
Added njf and pjf SPICE models. Again the Qucs legacy models are not affected and should work. The ngspice and Xyce simulators allow the following models to be selected using the LEVEL parameter:
The attached RF single stage amplifier and simulation results demonstrate the use of the SPICE njf model.
Added .NOISE analysis. It creates two variables onoise_total and inoise_total .
Added four terminal nmos and pmos SPICE models. The following LEVELs are defined:
The following simple CMOS AND test circuit demonstrates the use of the nmos and pmos SPICE models (LEVEL 1 default).
Style and colour of spice4qucs device symbols unified in preparation for next Qucs release, see following diagram:
Started to add XPICE analogue blocks to spice4qucs, see following examples:
I have just added PlotVs()
function emulation for spice4qucs subsystem. PlotVs()
support is critical for research tasks. PlotVs()
processing was raised to GUI level instead of translation to postprocessor directives. It allows to unify X-axis variable definition procedure for all used simulators. Also it will allow to use Xyce without limitation, because Xyce has no postprocessor and PlorVs()
invocation could not be translated to postprocessor directives for it. And this solution gives more intuitive interface.
Now special graph variable syntax is used to emulate PlotVs(). X-axis variable should be trailed by @
symbol and X-variable name as following:
Y-axis-variable@X-axis-variable
Old graph variables syntax and Qucs PlotVs()
function are fully compatible with this extension and there is nothing broken.
User can select desired X-variable from drop-down list or leave default X-variable (if no specified).
Attached screenshot explains this concept. You can pull latest commits from spice4qucs_current
branch to test this new feature. The code in the spice4qucs_current
branch is not intended for inclusion in Qucs-0.0.19S release.
Added XSPICE integrator (voltage single ended) model to spice4qucs. The following diagram indicates its use to generate a triangular voltage waveform from a square wave input signal.
Added a double ended (differential) XSPICE integrator to spice4qucs. The following test example shows how it works. This test example also illustrates the use of ngspice .model statements attached to a schematic rather than individual components/ devices.
Added XSPICE single and double ended voltage d/dt models to spice4qucs. The following examples illustrates their use.
Pole-Zero analysis (.PZ) was added. You can plot pole/zero location on complex plane with it. .PZ works olny with Ngspice. Source code is available at spice4qucs_current
branch.
How to use PZ-analysis:
Attached example illustrates poles/zeros location for Cauer passive filter.
I have rebased both rebased_spice4qucs
and spice4qucs_current
branches today to backport several critical bugfixes from master
. Please update your local branches.
Added two and three input XSPICE voltage multipliers. The attached test examples show how they are used with Qucs GUI and Ngspice:
Added two and three input XSPICE voltage summers. The attached test examples show how they are used with Qucs GUI and Ngspice:
Added the XSPICE voltage divide block: Vout = A/B. See XSPICE manual for specification, or Ngspice manual V26, p140. The example shown below indicates how to specify divide model parameters.
Added XSPICE lcouple and core blocks. These blocks allow models of magnetic devices ranging from simple transformers to devices with multiple primary and secondary windings to be constructed. To aid Qucs users understand the principles of magnetic component modelling using lcouple and core an introduction to this important subject will be added to spice4qucs-help. A small library of magnetic components will also be added to qucs-0.0.19S. The following diagrams give an indication of lcouple and core model structures and their application in the simulation of a full wave rectifier circuit where the transformer has core saturation features included.
@timofonic , Thespice4qucs
patchset will be not merged in 0.0.19 release. There are multiple reasons for such solution. There is a group of users that don't need SPICE. We came to the following compromiss solution. Two sets of Qucs packages will be released in parallels:
Merging will be considered during 0.0.20 development cycle. It's need to implement at least a "Default Simulator" setting. It will allow to turn-off Qucsator if user don't need it. And to turn-off SPICE if user don't need it. In other words it will allow to switch between Qucs and Qucs-S during runtime or compile-rime.
Added a transformer library to Qucs-0.0.19 system libraries . This adds non-linear effects in transformers, including resistive losses, fringing inductance and core saturation. The attached diagram shows the new model symbols. A more detailed introduction to these models, with examples of their use, will be posted in spice4qucs-help in the near future.
Added the XSPICE S domain transfer function block to spice4qucs. This component allows filters and control system components specified by S parameter transfer functions to be simulated in the small signal AC and transient domains. The following example gives an indication of how to specify the S domain transfer function blocks. More details can be found in the Ngspice and XSPICE user manuals.
Improved Transformer library drop down parameter descriptions, see diagram below:
Added a library of magnetic cores, with different core materials, to spice4qucs. These allow users to construct a range of non-linear multi-winding transformers. The following Figures show the core synbols, B/H curves and a basic test circuit which illustrates the influence that different core materials have on circuit distortion.
Added single and double ended XSPICE A type limiters. The following test examples illustrate their operation:
@timofonic The merging of spice4qucs
patchset is under discussion. This discussion will be continued after Qucs-0.0.19 will be released. We don't planning merging before 0.0.19. You can use also my unofficial packages ("S"-series) for two platforms to test it: https://github.com/ra3xdh/qucs/releases/tag/0.0.19S-rc4 The latest is RC4.
The next development tasks are:
Added a first test example illustrating how users can construct their own XSPICE CodeModels. The example device is called "diodecap". It emulates a SPICE 2g6/3f5 non-linear diode, modelling Id/Vd, Depletion and diffusion capacitance, reverse breakdown and AREA and Temp effects.
The test model (diodecap.mod and diodecap.ifs) can be found at:
./examples/ngspice/XSPICE_CM/diodecap_prj in the spice4qucs_current branch.
The following test screen dumps give an indication of the test model performance.
Thank you very much for your effort to put spice into Qucs! It was somehow useful even without it, but something important was certainly missed. I compiled and tested qucs-0.0.19S-rc2, then qucs-0.0.19S-rc3, and qucs-0.0.19S-rc4, all those under Linux, with gcc 4.7.2 as this is latest gcc for my Linux distribution (AltLinux P7).
To be able to compile successfully, I had every time do this small change in the code: remove " = default" attribute from the ./qucs-core/src/nodelist.h:47 nodelist_t(nodelist_t &c) constructor as it results in "declared to take non-const reference cannot be defaulted in the class body" error.
After this change I been able to compile & install Qucs, and my models (ngspice as well as Qucsator) mostly work as expected, but some inconsistencies exists nevertheless. Can it be the result of my code patch, and if so, what is the right way to make this code my-compiler-friendly ? I'm not yet ready to switch my Linux distribution to something else (Ubuntu?) just due to this small problem. Sorry if this is not a right place to report this kind of issues. Please point me
@hovercraft-github , Files at qucs-core
subdirectory are related to Qucs simulation engine Qucsator
. Spice4qucs doesn't change anything in qucsator subsystem. Qucsator is kept untouched in Qucs-S packages. I think that your bug also should be represented in master
version of Qucs. It seems it is AltLinux specific bug. I haven't AltLinux now to reproduce it. I am using gcc-4.8.2@Slackware for development and qucsator always compiles successfully. The same for Debian-8. It's need to test it with older GCC.
Your answer obviated my doubts. Probably I'm just using in my model components which not completely compatible with Qucs spice subsystem. Qucsator AC simulation with the following model (red curve) gives relevant results, whereas ngspice gives very weak (about 1e-6) response (blue curve). Very strange, but the same model in the ngspice transient simulation gives more or less correct output waveform.
SPICE may not process switches correctly. Relay contacts may be treated as open. Try to replace relay contacts by short circuit and remove V2 source section.
Ok. Anyway, with your help Qucs becomes interesting and long awaited tool. Thank you.
Hi downloaded the spice4qucs release of qucs from here: here:https://github.com/ra3xdh/qucs/releases/tag/0.0.19S-rc3
I also downloaded Ngspice, and followed basically instructions described here: https://qucs-help.readthedocs.org/en/spice4qucs/BasSim.html
however, all I see in the Simulation console is "Ngspice started..." message, and simulation does not run properly, here is my printout from the Ngspice window which pops up right after i press "Simulate" button:
Initial Transient Solution
--------------------------
Node Voltage
---- -------
_net0 0
_net1 0
_net2 0
l1#branch 0
v1#branch 0
No. of Data Rows : 3996
ASCII raw file
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
No. of Data Rows : 1000
ASCII raw file
exit: no such command available in ngspice
ngspice 1 ->`
Any ideas why would it not work? it also assigned 0 voltages to all nodes...
For reference, I run it all on Win7/10
@r2com , exit
command is defined in spinit
file. Standard location is C:\spice\share\ngspice\scripts\spinit
for Windows. If Ngspice was relocated, it fails to find spinit
file and shows this warning message. You can simple ignore it and press Exit
in Ngspice window. Simulator output will be processed and plots will be shown in Qucs GUI. Alternatively you can install Ngspice into C:\Spice
and this error will gone.
okay, after moving folder to default location, Ngspice did start and exited with exit command, but no simulation seems to be running, the console window shows only "Ngspice started..."
and no output plots either, any idea?
It's not a bug. You are doing something wrong.
Default Windows version of Ngspice cannot output text into terminal and cannot communicate with other processes. Simulator log goes only into Windows GUI for Win ngspice . And Qucs GUI will show only "Ngspice started" message and 100% progress when it will be finished. Ngspice window will be shown only at simulation time and will be closed automatically on Ngspice exit. But you may not see it, if simulation runs very fast. Such Ngspice for Windows behavior may be misleading, but it's normal. You can consider it as featurebug of Win Ngspice. I will consider shipping custom Ngspice Windows build with Qucs-S that will support terminal output and disable Windows GUI.
After simulation is finished, you need to press Exit
button in dialog, drag new diagram, select Ngspice in the diagram dialog, and select curve. Plot will appear. Plots will not appear automatically. After new plot is created it will be automatically replotted at every new simulation.
There may be way to overcome #34 and #41. I started implementation of
spice4qucs
extension. This extension allows you to switch betweenqucsator
simulation kernel andngspice
simulation kernel. You can simulate your Qucs circuits withngspice
using this extension. I am planning to add menu entrySimulation->Simulate with spice
. Spice simulation will be available after execution of this menu. Spice simulation results will be converted to Qucs simulation data and diagrams will be available from the display page. With spice4qucs you can use good old spice to simulate Qucs circuits with it.You can see current state of work at https://github.com/ra3xdh/qucs/tree/spice4qucs
Now implemented only conversion of the Qucs circuit to Spice netlist.
Not all components conversion is implemented. The list of spice-compatible components:
The list of supported simulations:
Sample schematic is available here: https://gist.github.com/ra3xdh/6c554e32e531c25e6e6b
To test
spice4qucs
open this schematic with Qucs, then executeSimulation->Simulate with spice
. Spice netlist is located at$HOME/.qucs/spice4qucs.cir
. Now switch to system terminal and executengspice
:Then run simulation and see waveforms:
The simulation fails for this schematic with Qucs, but ngspice simulates it correctly.
Have you any suggestions? Should I continue work in this direction?
My current task list: