ra3xdh / qucs_s

Qucs-S is a circuit simulation program with Qt-based GUI
https://ra3xdh.github.io/
GNU General Public License v2.0
853 stars 109 forks source link

Different Data for three "identical" circuits using Qucsator #982

Closed tomhajjar closed 1 week ago

tomhajjar commented 1 week ago

I ran into an issue testing an old Qucs-S project that was previously converted from Qucs. First issue was the 4-pin Blue BJTs were removed from Qucs-S. I then converted to 3-pin Blue but then the "old" Nutmeg equations didn't work because of other changes to Qucs-S. It wasn't obvious what changes were needed to the Nutmeg equations so I went back to Qucs and the original project.

This is when I found I couldn't get "Rout" for "mirrorwilson.sch" in different project folders to be the same. I renamed each file and placed them in the same folder "Mirrors_qucs_prj". I confirmed the Rout data for each version of "mirrorwilson.sch" was different when tested in either Qucs or Qucs-S so qucsator/qucsator-rf wasn't the issue.

1) Can you spot why the seemingly identical files have different Rout? I didn't see anything in a text editor. 2) My "names" for the various files "correct", "Wrong1/2" may be wrong. ;-) 3) I have to redo the Nutmeg equations to see what Rout will be under the latest Qucs-S/ngspice. I found a PC running Qucs-S 0.0.24 and ngspice 39+ and the Rout data is different but maybe correct?

TODO list

2024-10-04_101326 2024-10-04_101309 2024-10-04_101250 2024-10-04_110105

ra3xdh commented 1 week ago

First issue was the 4-pin Blue BJTs were removed from Qucs-S.

It is not removed. It is hidded for Ngspice by mistake. I will revert this device in the next patch.

Can you spot why the seemingly identical files have different Rout? I didn't see anything in a text editor

It is not a bug. The result form Qucsator and SPICE may be different. You have ideal BJT model. It acts as the ideal current source and you have dI=0 in the R=dV/dI equation. The dI=0 may give an unstable result and random noise when approaches to machine epsilon. The SPICE model may act differently and give different result. Set the VAFparameter of the BJT or use the real SPICE model instead of ideal and get the different result. The same is valid for the initial part of the Rout curve. The BJT again acts as the ideal source.

image

I have to redo the Nutmeg equations to see what Rout will be under the latest Qucs-S/ngspice.

It is again not a bug. You have to specify the simulation name instead of dc in the Nutmeg equation. The DC is a valid simulation name for DC OP analysis. See #463, #513, and #124. You have to specify the SW1 to attache the equation to DC OP. After making these corrections everything works as expected.

image

ra3xdh commented 1 week ago

The PR #983 makes BJTsub device available.

tomhajjar commented 1 week ago

Updated ngspice and qucs versions of the project. Might be useful for someone.

Currrent_Mirrors.zip

ra3xdh commented 1 week ago

The SPICE behavior depends on GMIN setting. The default GMIN=1e-12 works fine, but random noise starts from GMIN=1e-14. The GMIN=1e-16 fails to converge. The Qucsator have another behavior. I didn't find GMIN setting for Qucsator DC.

image

tomhajjar commented 1 week ago

https://qucs.sourceforge.net/tech/node29.html#SECTION00762200000000000000