Menu

#66 Using gmin as parameter

v1.0 (example)
open
nobody
None
5
2023-07-01
2023-06-29
No

I am trying to use GMIN as a parameter in a netlist. This is possible in LTspice and PSpice, but when I try to use it in ngspice, there is an error that {gmin} is not a known parameter. Is it possible to include it as a parameter by default? Or at least is there a workaround where you can use GMIN without defining the exact value but let the solver provide it?
Here is an example how I want to use it:

R_1 N007 N006 {gmin}

Discussion

  • Giles Atkinson

    Giles Atkinson - 2023-06-29

    Set PSPICE compatibility mode(manual 16.14.5).

     
  • Iliya Valchev

    Iliya Valchev - 2023-06-29

    Thanks for the reference. If I understand correctly this can in rare cases cause issues with normally working ngspice netlists. Isn't there an alternative solution where you can define and use GMIN?

     
  • Giles Atkinson

    Giles Atkinson - 2023-06-30

    Any such problem would mean that some valid ngspice syntax is altered in compatibility mode. I do not know any examples. Compatibility mode is mostly about changing foreign formats. You can see what it has done to your netlist with "listing e" after loading.

    But if you really just want a single definition that sets option GMIN and a .param with the same name, that can be done by scripting, but is not pretty.

     
  • Holger Vogt

    Holger Vogt - 2023-06-30

    .param parameters are evaluated upfront, before the simulation is started. In ps compatibility mode, ngspice just adds the line .param gmin=1e-12 to the netlist.

    During searching for the operating point, during gmin stepping, gmin is varied by the simulator. I am not aware of any other automatic setting of gmin.

    .option gmin=<value> is available, again only upfront or in a .control language script (unfortunately not for compat mode ps).

     

    Last edit: Holger Vogt 2023-06-30
  • Holger Vogt

    Holger Vogt - 2023-07-01

    A little scripting may help:

    gmin-test
    * run with 'ngspice gmin-test.cir'
    V1 1 0 1
    R1 1 0 1
    
    * set gmin for all devices, a variable gmin is created
    .option gmin=1e-12
    
    .control
    op
    print all
    * change the resistance of R1 by reading variable gmin
    alter R1 1/$gmin
    op
    print all
    * change gmin for all devices
    option gmin=2e-9
    * change again the resistance of R1
    alter R1 1/$gmin
    op
    print all
    .endc
    .end
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.