Qucs / gnucsator

This package provides a gnucap based qucsator implementation.
GNU General Public License v3.0
13 stars 4 forks source link

Parameter sweeps #11

Closed ddrake closed 3 years ago

ddrake commented 3 years ago

I can't seem to get parameter sweeps working. Looking at cmd_wrapper.cc, maybe only S-parameter sweeps have been implemented so far. I've tried voltage sweeps and resistor sweeps using linear, log and list options. I'm attaching a simple example: a resistor sweep for a voltage divider.

Here's a sample of the error messages:

R2.dev: short circuit
parameter Rs not specified, using default
parameter Rs value is "NOT_INPUT"
parameter R * (1. + dT*(Tc1 + dT*Tc2)) not specified, using default
Rs 100 5000 544.444 trace=n basic > /home/dow/.qucs/netlist.txt.tmp.dc
^ ? what's this?

netlist.txt

felix-salfelder commented 3 years ago

On Sun, Sep 26, 2021 at 10:12:46AM -0700, Dow Drake wrote:

I can't seem to get parameter sweeps working. Looking at cmd_wrapper.cc, maybe only S-parameter sweeps have been implemented so far.

Better look at tests/*, they should give both an idea of what is implemented, how to use it and what to expect. Untested stuff is often broken...

I've tried voltage sweeps and resistor sweeps using linear, log and list options. I'm attaching a simple example: a resistor sweep for a voltage divider.

Qucs makes sweeps look like parameter sweeps. But as far as Gnucsator goes, they are component value sweeps (as in DC sweep). For technical reasons, sweep parameter name and sweep device name need to match so Qucsator and Gnucsator outputs match.

Not obvious how to proceed, but please try and see if you can solve it.

ddrake commented 3 years ago

Better look at tests/*, they should give both an idea of what is implemented, how to use it and what to expect.

Good point -- will do! The tests are easy to read. The output format seems a bit cryptic -- I need to dig into it a bit more, but it's clear that a test passed if its diff is empty. I don't understand why some test files, such as 'bjt_pulse0.net' don't generate .v.out and .v.diff files when I run make check. Does each new test file need to be added to one of the 'Makefile.in' or are all tests in the directory included automatically? I also haven't figured out how to generate a reference file for a new test.

Qucs makes sweeps look like parameter sweeps. But as far as Gnucsator goes, they are component value sweeps (as in DC sweep)

I may have misused the phrase 'parameter sweeps' in this context. I think component value sweeps are what I typically need (e.g. sweep a range of values for a property of a resistor or source). I've often found it useful to combine these with transient simulations.

For technical reasons, sweep parameter name and sweep device name need to match

That helps a lot. It's not a problem to follow that naming convention now that I know it's required. That fixes the issues for several circuits, including the example I used to start this issue report. But there are some remaining related issues to resolve:

Not obvious how to proceed, but please try and see if you can solve it.

Sounds good -- I'll do my best!

netlist.txt

felix-salfelder commented 3 years ago

On Sun, Sep 26, 2021 at 07:30:59PM -0700, Dow Drake wrote:

Good point -- will do! The tests are easy to read. The output format seems a bit cryptic -- I need to dig into it a bit more, but it's clear that a test passed if its diff is empty. I don't understand why some test files, such as 'bjt_pulse0.net' don't generate .v.out and .v.diff files when I run make check.

Thanks for the feedback.

I have added tests/README now. It should clarify things (and was overdue). Some tests were listed in the wrong file (and not committed). Now this can't happen anymore.

Qucs makes sweeps look like parameter sweeps. But as far as Gnucsator goes, they are component value sweeps (as in DC sweep)

I may have misused the phrase 'parameter sweeps' in this context.

Maybe I started it, see NEWS. Wishful thinking. I will reword it before the 0.0.1 release.

  • combining a transient simulation with a current or resistor sweep doesn't seem to work. The transient simulation works, but it's as if there no sweep was specified. No independent variable is included for the sweep in the data set.

Only spice style DC sweeps (Maybe SP?) are currenty working. With the limitations stated earlier.

I think Qucsator runs transient simulations in a kind of stateless for-loop. This is not implemented, but should. In Gnucap you have more control when running commands interactively, and I never attempted to do much about it.

ddrake commented 3 years ago

I have added tests/README now. It should clarify things

Yes that was very helpful - thanks! I'm wondering if there is something off with my environment or possibly some other uncommitted changes on your end. I'm seeing a few failing tests with the latest develop:

Once I commented those out of MakeList, the remaining tests passed.

I think Qucsator runs transient simulations in a kind of stateless for-loop. This is not implemented, but should. In Gnucap you have more control when running commands interactively, and I never attempted to do much about it.

Thanks -- I'll look at the Qucsator code.

felix-salfelder commented 3 years ago

On Mon, Sep 27, 2021 at 01:48:47PM -0700, Dow Drake wrote:

'common_emitter_degen.net' is not found in /tests (maybe not committed).

Fixed.

  • 'mscoupler.1.gc' in GC_TESTS which fails because of numerical differences (e.g. 30.52015n vs. 30.51651n). This is also in NOTYET_GC_TESTS in MakeList; maybe it should be removed from GC_TESTS.

Yes, it's incomplete. I didn't know it was so bad. Some values are used prior to initialisation. Need more time to analyse.

  • 'wilkinson.net.gc.out' in COMMON_TESTS, which fails because of (maybe) minor numerical differences (e.g. 2.220891E-6 vs. 2.220926E-6)

Will check. Fingers crossed.

felix-salfelder commented 3 years ago

On Mon, Sep 27, 2021 at 01:48:47PM -0700, Dow Drake wrote:

  • 'mscoupler.1.gc' in GC_TESTS which fails because of numerical differences (e.g. 30.52015n vs. 30.51651n). This is also in NOTYET_GC_TESTS in MakeList; maybe it should be removed from GC_TESTS.

The bug was not where I thought it was... It was "just" the paramset parser for qucs language. Units in substrate instances are now parsed correctly.

In particular, Gnucap finally runs unmodified microstrip models written for Qucsator. The SP solver is different, but produces the same result.

felix-salfelder commented 3 years ago

On Mon, Sep 27, 2021 at 01:48:47PM -0700, Dow Drake wrote:

  • 'wilkinson.net.gc.out' in COMMON_TESTS, which fails because of (maybe) minor numerical differences (e.g. 2.220891E-6 vs. 2.220926E-6)

(wilkinson.net is the transmission line unit test)

Actually this is

-0.3333333+ 2.220934E-6* i

vs.

-0.3333333+ 2.220891E-6* i,

far below relative error tolerance. But numdiff does not see it this way, and does not seem to support complex numbers.

Not sure which result is more accurate. s_param calls blas through gsl, and results are expected to vary. Just ignore it.

make -k check will run all rests regardless, and autotools provide a more fancy test harness. I am hesitant to pull in autotools, and I do not feel inventive.

felix-salfelder commented 2 years ago

On Sun, Sep 26, 2021 at 11:00:16PM +0200, Felix Salfelder wrote:

[..]

I've tried voltage sweeps and resistor sweeps using linear, log and list options. I'm attaching a simple example: a resistor sweep for a voltage divider.

Qucs makes sweeps look like parameter sweeps. But as far as Gnucsator goes, they are component value sweeps (as in DC sweep). For technical reasons, sweep parameter name and sweep device name need to match so Qucsator and Gnucsator outputs match.

This is fixed in gnucsator/develop. It can do both now.

Device value sweep are potentially much faster, so it checks for device names first. I might change this later on.