ra3xdh / qucs_s

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

Add SPICE entry for VCresistor #959

Open tomhajjar opened 5 days ago

tomhajjar commented 5 days ago

I updated all the files 9/26/24.

I'm having an issue getting three Voltage Controlled Resistor models in the link below to work in Qucs-S. http://www.ecircuitcenter.com/Circuits/vc_resistor1/vc_resistor1.htm

ngspice: I made three netlists, VCResistor1.cir, VCResistor2.cir and VCResistor3.cir and confirmed they work in ngspice. Normally I edit the Qucs-S generated netlist but this time I edited the netlist from the web page above.

Qucs-S: VCRES2.cir is the same as the original model VCRES2.lib but uses .PARAM R=10k. I cannot get "VRES2_tran.sch" or "VRES2_lib_tran.sch" to work. "VRES2_lib_tran.sch" should be the same as "VCResistor2.cir".

TODO list

2024-09-25_135627 2024-09-25_135604

VCR_prj.zip

ra3xdh commented 5 days ago

The SPICE model is not implemented for VCresistor. It is not a standard SPICE device. It is represented as the equivalent subcircuit in the attached SPICE netlists. Furthermore this device is marked as SPICE-incompatible in Qucs-S, one cannot insert in SPICE mode. It never worked with SPICE backend. I can try to add SPICE model for this device in the future version.

tomhajjar commented 5 days ago

You misunderstand, This project doesn't use VCresistor. It uses all Spice compatible components. I made the symbol from scratch.

ra3xdh commented 5 days ago

Ngspice netlist and Qucs-S schematic uses different VCresistor model. Try setting the low voltage of square wave source to 0.1V and the simulation will work. Otherwise you have division by zero inside the subcircuit equation. It is not Qucs-S error. I can reproduce the same error with Ngspice CLI version after switching the model and setting the low voltage of the PWL source in the netlist to 0.0V.

tomhajjar commented 5 days ago

Did you open the attached project? There is no "VCresistor". The input is a triangle wave.

ra3xdh commented 5 days ago

Yes, I tried the simulation. Everything works after setting U0=0.1V on the source. Otherwise you have division by zero in the model.

image

tomhajjar commented 5 days ago

I updated all the files 9/26/24. The Author recommends using VCRES2. I didn't put extra components like 0.001 Volts/Ohms to stop divide by zero. A little more work and we might have a viable VCR for the library.

There are numerous other VCR models available I didn't test.

VCR_prj.zip

ra3xdh commented 4 days ago

I will add the SPICE entry for the device in the system library in the next release. Also it should be possible to correct Qucsator device entry to make this device ADMS-independent. In fact the VCRes device is a VCCS with equation.

tomhajjar commented 4 days ago

New device should have some protection against "crashing" ngspice or qucsator-rf. Adding some 0.001 resistors or 1mv sources could help.

Another issue is the question of the "resistor" being polarity sensitive. I haven't tested this however. If this is an issue, the new symbol I created should reflect this.

ngspice has a "Behavioral" resistor. This could be an alternative.

2024-09-26_093509