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

Ngspice netlist rework, fixes #463 #513

Merged
merged 4 commits into from
Feb 1, 2024
Merged

Conversation

ivandi69
Copy link
Contributor

This rework fixes #463 using the recently added custom prefix feature.
Prefixing is activated only if conflicting simulations are found, so the existing schematics are not affected.

Every simulation has its own output file named spice4qucs.<simulation_name>.extension, ex: spice4qucs.ac1.plot.
If any conflicting simulations are found, ex: AC and FFT, prefixing is activated and when the dataset is built the <simulation_name> prefix applies to all simulations. If a conflicting simulation is added to a schematic the existing diagrams have to be updated with the new prefixed variables.

Other changes:

  • Nutmeg equation now uses a complete or partial simulation name. For example if 'SP' is specified as simulation name the equation is included in all SP simulations and if SP1 is specified it is included in SP1 only. if ALL is specified it is included in all simulations.
  • If a DC simulation is placed in the schematic the operation point is saved in the dataset.

Here are some tests:
463-tests.zip

@ra3xdh
Copy link
Owner

ra3xdh commented Jan 31, 2024

Thanks for the contribution! I will test it in the next few days and post my feedback. I have seen also fix for #124 in this issue (export DC OP to the dataset).

@ra3xdh ra3xdh added this to the 24.1.0 milestone Jan 31, 2024
@ra3xdh ra3xdh self-requested a review January 31, 2024 06:29
@ra3xdh ra3xdh linked an issue Jan 31, 2024 that may be closed by this pull request
@ivandi69
Copy link
Contributor Author

Yes, but for now it works if DC is not the only simulation. I have to figure out how to handle F8.

@ra3xdh
Copy link
Owner

ra3xdh commented Jan 31, 2024

I will remove checker error when the schematic contains DC simulation only. The F8 mode (DC bias) may be left unchanged. Qucsator doesn't export data to dataset using F8 mode too.

@ra3xdh ra3xdh linked an issue Jan 31, 2024 that may be closed by this pull request
@ra3xdh
Copy link
Owner

ra3xdh commented Jan 31, 2024

I have found an issue with Nutmeg equations. Nutmeg equations are not attached to SPICE simulation now. This may lead to computation error and simulation failure. For example look at the attached schematic. The equation for K causes division by zero error when executing TRAN simulation. The intention of the simulation parameter of the Nutmeg equation was to enable short variable notation like v(node) and exclude errors like the mentioned above. The equation for K is valid for AC but not valid for TRAN. Therefore I decided to attach every Nutmeg equation to specific simulation.

image
image

@ra3xdh
Copy link
Owner

ra3xdh commented Jan 31, 2024

I understood how new Nutmeg equation works. It is required to enter the simulation name in the Simulation field manually. This may be not user-friendly. The best solution would be to add a custom dialog with drop-down list for this device. .Unfortunately, there is no way to fill the drop-down list dynamically for such fields. But this will require a significant time effort. At least a new way of attaching Nutmeg equation to the simulation should be documented.

@ivandi69
Copy link
Contributor Author

Nutmeg equation now uses a complete or partial simulation name. For example if 'SP' is specified as simulation name the equation is included in all SP simulations and if SP1 is specified it is included in SP1 only. if ALL is specified it is included in all simulations.

A drop-down list wont allow entering partial simulation name that applies to all simulation of the same type, SP for example. One can have an equation 'db_s21=db(s_2_1)' that applies to all SP simulation and another equation that applies to a particular simulation SP2. A combo-box maybe, I have to look how SWeep does it.

@ivandi69
Copy link
Contributor Author

Just found an ussie, '.INCLUDE ngspice_mathfunc.inc' is the first line in the netlist. Above '* Qucs 24.1.0' line. I removed the '* Qucs 24.1.0' duplication and it was OK, but now I see that it was because there was no ngspice_mathfunc.inc file in the test build. Will fix it as soon as I have some spare time.

@ivandi69
Copy link
Contributor Author

ivandi69 commented Feb 1, 2024

I will remove checker error when the schematic contains DC simulation only.

0625e1e does it.

@ra3xdh ra3xdh linked an issue Feb 1, 2024 that may be closed by this pull request
@ra3xdh
Copy link
Owner

ra3xdh commented Feb 1, 2024

A drop-down list wont allow entering partial simulation name that applies to all simulation of the same type,

I have inspected the componentdialog.cpp code. It should be possible to update the existing dialog without implementing a special dialog for Nutmeg equation. I propose the following logic.

  • Introduce a keyword like {SIMULATION} in the property description. If Qucs-S finds this keyword, the drop-down list will be shown instead of line edit.
  • The dialog looks into the parent schematic of the component and finds all simulation devices. The devices name and ALL keyword are added to the drop-down list.
  • If more than one simulation of the same type was found (like AC1 and AC2), the keyword like AC (simulation name without numbers) should be added to the list.

@ra3xdh
Copy link
Owner

ra3xdh commented Feb 1, 2024

0625e1e does it.

Yes, the DC simulation works as expected now. It makes sense to remove the AbstractSpiceKernel::checkDCSimulation

@ra3xdh ra3xdh mentioned this pull request Feb 1, 2024
2 tasks
@ra3xdh
Copy link
Owner

ra3xdh commented Feb 1, 2024

I have added TODO list #518

@ra3xdh
Copy link
Owner

ra3xdh commented Feb 1, 2024

I have tested this PR with my simulations and found no major issues. I am merging this. The improvement of the component properties dialog could be implemented later. @ivandi69 Please stay connected if some issues related to this PR will raise in the next weeks. And thanks for good job.

@ra3xdh ra3xdh merged commit 4d94d58 into ra3xdh:current Feb 1, 2024
2 checks passed
@tomhajjar
Copy link

tomhajjar commented Feb 8, 2024

I updated the ngspice 100 watt amp example to work with the latest nightly release.

AC, Tran, Four and FFT in a single analysis.

2024-02-08_140403

Amp_100W_ngspice_prj.zip

ivandi69 pushed a commit to ivandi69/qucs_s that referenced this pull request Feb 17, 2024
This fixes a regression in ra3xdh#513. If the only simulation is custom
and it contains custom prefixed output, the custom prefix is not applied.
ivandi69 pushed a commit to ivandi69/qucs_s that referenced this pull request Feb 17, 2024
This fixes a regression in ra3xdh#513. If the only simulation is custom
and it contains custom prefixed output, the custom prefix is not applied.
zergud pushed a commit that referenced this pull request Feb 18, 2024
* Always apply custom prefix enclosed by '#'

This fixes a regression in #513. If the only simulation is custom
and it contains custom prefixed output, the custom prefix is not applied.

* Parse nutmeg scripts to find used simulations

This avoids prefixing when custom simulations don't conflict.

* Relax regexs to allow variable names that include point

Variable names like h2.out are valid so no reason to restrict them in
custom simulation dialog and scalars print parser.

---------

Co-authored-by: ivandi <ivandi@localhost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants