Skip to content
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

FFT and AC are not allowed on the same schematic #463

Closed
tomhajjar opened this issue Jan 16, 2024 · 15 comments · Fixed by #513
Closed

FFT and AC are not allowed on the same schematic #463

tomhajjar opened this issue Jan 16, 2024 · 15 comments · Fixed by #513
Labels
Milestone

Comments

@tomhajjar
Copy link

tomhajjar commented Jan 16, 2024

I cannot get AC, Trans and FFT (Spectrum Analysis) data in the same analysis while AC, Trans and FOUR works.

Comparing C300_FFT plots to C300_FOUR plots:

For C300_FFT:

  1. ac.v(in), ac.v(out) and frequency are listed twice. "frequency" has 301 and 8193 data points. How is Qucs discerning the AC versus FFT data?

  2. Why does FFT use the same start/stop as the AC analysis regardless of settings? FOUR doesn't have this restriction. I can set the start and stop.

  3. The FFT plot is garbage unless I delete the AC analysis.

  4. Why does FFT take much longer than FOUR?

  5. Why do I need the Nutmeg equation, S=db(v(out))?

Also attached is a simple OpAmp inverter with the same issues.

Attached is ngspice netlist of 100watt amp with simultaneous AC, Trans and FFT. It works but the FFT looks OK has low resolution. The ngspice netlist below (100W_ac_tran_fft.sp) is how I would I would the plots to look with Qucs-S.

C300_FFT

C300_FOUR

@ivandi69
Copy link
Contributor

ivandi69 commented Jan 16, 2024

ac.v(in), ac.v(out) and frequency are listed twice. "frequency" has 301 and 8193 data points. How is Qucs discerning the AC versus FFT data?

I stumbled upon that issue too.
Pull request #412 fixes it for custom simulations.

@tomhajjar
Copy link
Author

tomhajjar commented Jan 16, 2024

Pull request #463?

Attached is ngspice netlist of 100 watt audio amp from the ngspice examples folder with simultaneous AC, Trans and FFT.

It works and the FFT looks good. I would like to be able to do this with Qucs-S.

2024-01-15_225414

@ivandi69
Copy link
Contributor

Pull request #463?

Sorry, pull request #412.

@dwarning
Copy link

Only for information - not an answer, sorry: The difference to capabilities of other popular simulators is that ngspice VDMOS model has true self-heating built-in. So you can investigate how the impact is on distortion if the cooling chain is insufficient. E.g. look for the both thermal nodes of the power mosfets in transient analysis.

@ra3xdh ra3xdh changed the title Proper use of FOUR and FFT with AC and Trans FFT and AC are not allowed on the same schematic Jan 16, 2024
@ra3xdh
Copy link
Owner

ra3xdh commented Jan 16, 2024

I am aware about this problem. The usage of FFT and AC in the same time is not allowed. @ivandi69 PR #412 has effect only for script simulation type and doesn't help to resolve this issue. The reason of the conflict of AC and FFT is that both are using frequency as X-axis variable. I cannot figure out how to resolve this conflict. Probably the setting of different plot name for AC and FFT may help. This should be done in Ngspice::createNetlist()

@ra3xdh ra3xdh added the bug label Jan 16, 2024
@tomhajjar
Copy link
Author

tomhajjar commented Jan 16, 2024

The source for DuSpice is available. Maybe it will reveal how Holger does it. The analysis % done is also in the code.

I opened the Pascal source in Lazarus but was lost...

2024-01-16_123952

https://ngspice.sourceforge.io/experimental/ng_gui_sources.7z

@tomhajjar
Copy link
Author

tomhajjar commented Jan 17, 2024

I did more testing. The Nutmeg script required to do AC, Trans and FFT is very simple. In addition Trans and FFT can use different tran statements allowing independent analysis.

As you know inside Qucs-S, FFT frequency "span" is "locked" to the AC analysis start/stop frequency and FFT frequency "resolution" and the Transient analysis are "restricted" to the same Tran statement. These limitations don't exist in ngspice and DuSpice and KiCAD don't have them.

My attempt using a Nutmeg script inside Qucs-S was a failure...

2024-01-16_230534

2024-01-16_234016
2024-01-16_234236
2024-01-16_234257

@ra3xdh
Copy link
Owner

ra3xdh commented Jan 17, 2024

@tomhajjar This could be recommended only as the workaround. It's need to find a way to resolve conflict of the X-axis variable name for AC and FFT. This should be fixed in C++ level but not in documentation level.

@tomhajjar
Copy link
Author

Wouldn't the source for DuSpice reveal how Holger did it?

@ra3xdh
Copy link
Owner

ra3xdh commented Jan 17, 2024

The sources of DuSpice will not help. DuSpice doesn't convert schematic to netlist. It only provides an interface for the console Ngspice. You can run Ngspice in terminal and obtain the same result as using DuSpice. Plot and write uses different concept. Probably the setting of the plot name will help (chapter 17.3 of the Ngspice manual). Nutmeg script syntax is not obvious and I cannot to figure out how to resolve the X-axis variable name conflict.

@tomhajjar
Copy link
Author

tomhajjar commented Jan 17, 2024

I'm confused...

I tested OpAmp_ac_trans_fft.sch and generated a netlist -> OpAmp_ac_trans_fft.qucs

Edited OpAmp_ac_trans_fft.qucs by adding plot statements and deleting destroy all and reset creating -> OpAmp_ac_trans_fft.sp.

Used DuSpice on OpAmp_ac_trans_fft.sp creating the three data files for ac/tran/fft and multiple plots which are all correct.

If the data files "ac", "fft" and "tran" are correct and "frequency" and # of points is different for the ac and fft txt files, why are the ac and fft plots BOTH using "frequency" and # of points from ac.txt when fft should be using frequency and # of points from fft.txt?

Isn't the problem that the Qucs-S FFT plot is using the amplitude data from OpAmp_ac_trans_fft_fft.txt but the frequency data from OpAmp_ac_trans_fft_ac.txt? Not only is the fft "frequency" wrong, thousands of data points in OpAmp_ac_trans_fft_fft.txt are missing from the plot.

2024-01-17_100654
2024-01-17_100209
2024-01-17_101753

@ra3xdh
Copy link
Owner

ra3xdh commented Jan 17, 2024

Isn't the problem that the Qucs-S FFT plot is using the amplitude data from OpAmp_ac_trans_fft_fft.txt but the frequency data from OpAmp_ac_trans_fft_ac.txt?

All SPICE datasets are assembled into one Qucs XML dataset. If there exists two X-variables with the same name, it will be conflict. It is not a straightforward task to resolve this issue. I don't expect this to be fixed by the next release.

@tomhajjar
Copy link
Author

tomhajjar commented Jan 18, 2024

I created a test project. It compares data files from Qucs-S and ngspice. I had DuSpice generate data using netlist "OpAmp_ac_trans_fft.sp".

Comparison shows the FFT data set size and the v(in), v(out) data is the same for the Qucs file "OpAmp_ac_trans_fft.dat.ngspice" and ngspice file "OpAmp_ac_trans_fft_fft.txt".

In "OpAmp_ac_trans_fft.dat.ngspice", "frequency" is stated on the following lines:

indep frequency 607
dep ac.v(in) frequency
dep ac.v(out) frequency
dep ac.gain_db frequency
dep ac.phase_rad frequency
dep ac.phase_deg frequency
dep ac.group_delay frequency
indep frequency 129
dep ac.v(in) frequency
dep ac.v(out) frequency

Can the 2nd "indep frequency" and 129 versus 607 be used to help solve this issue? Obviously more examples need to be created.

@tomhajjar
Copy link
Author

tomhajjar commented Jan 19, 2024

Only for information - not an answer, sorry: The difference to capabilities of other popular simulators is that ngspice VDMOS model has true self-heating built-in. So you can investigate how the impact is on distortion if the cooling chain is insufficient. E.g. look for the both thermal nodes of the power mosfets in transient analysis.

@dwarning
Do you know the original source for the ngspice example 100W.sp? It's in the same vmos folder as 100W_wingspread.sp.

I found a number of issues with it. Gain and Phase plots are wrong and the use of "fourier 1K V(out)" doesn't seem to do anything. Deleting it doesn't effect the plots. I recreated the schematic in LTspice and Qucs-S.

I assume due to the extra voltage source V3 in 100W.sp is set up to use the Tian probe method. It is used to calculate Gain/Phase and the results are wrong.

ivandi69 pushed a commit to ivandi69/qucs_s that referenced this issue Jan 31, 2024
@ra3xdh ra3xdh added this to the 24.1.0 milestone Jan 31, 2024
ra3xdh added a commit that referenced this issue Feb 1, 2024
@ra3xdh
Copy link
Owner

ra3xdh commented Feb 1, 2024

Fixed via #513

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants