Menu

#94 .save all nodes voltage after .op for .nodeset or .ic

open
nobody
None
5
2023-09-08
2023-08-24
Laurent
No

In most of spice simulator, there is command to save all node voltage after the initial operating point convergence calculation to avoid extensive calculation to find it when re-running a simulation : the syntax is directly in the proper format : .NODESET V(node001)=.. V(node002)=..

For exemple in XYCE or HSPICE, the syntax is :
.save TYPE=NODESET my_file_of_OP_voltage.txt
In LTspice, it is : .SAVEBIAS my_file_of_OP_voltage.txt
Optionally, a time can be specified if a transcient simulation is run to save the voltages at a given time.

It is so convenient for large circuit, that it would be nice to have the same feature in NGSPICE :)
Laurent

Discussion

  • Holger Vogt

    Holger Vogt - 2023-08-25

    See manual chapter 17.5.100, command
    wrnodev [ file ]
    to be used in a .control section.

     
    • Holger Vogt

      Holger Vogt - 2023-08-25

      A typical control section might be

      .control
      stop when time = 200n
      tran 1n 500n
      wrnodev data.txt
      resume
      plot allv
      .endc
      
       

      Last edit: Holger Vogt 2023-08-25
  • Laurent

    Laurent - 2023-09-07

    Hi Holger,

    The commands works fine for the toplevel, I was looking for it at the chapter 15.2 about .nodeset and .ic : it would be nice to add a word about wrnodev in this chapter 15.2.
    Also, the only nets voltage saved are the ones at toplevels, not those of the sub-circuits : how to save all nets voltage, even those inside the subckt, after the operating voltages calculation ?

    Thank you, BRgds,
    Laurent

     
  • Giles Atkinson

    Giles Atkinson - 2023-09-08

    A trivial example shows that the command can save subcircuit nodes:

    Save subcircuit nodes
    
    .subckt divide in out
    r1 in inner 1k
    r2 inner out 1k
    r3 out 0 1k
    .ends
    
    vx one 0 1
    x1 one two divide
    x2 two three divide
    
    .control
    op
    wrnodev test.file
    .endc
    .end
    

    produces the expected output:

    * Intermediate Transient Solution
    * Circuit: save subcircuit nodes
    * Recorded at simulation time: 0
    .ic v(one) = 1
    .ic v(x1.inner) = 0.636364
    .ic v(two) = 0.272727
    .ic v(x2.inner) = 0.181818
    .ic v(three) = 0.0909091
    

    But that is no solution to the problem. To be useful, the output file must be read by the netlist parser after subcircuit expansion, when nodes such as x1.inner have been made to exist. At first sight this is impossible, as .include is processed early, but I believe there is a way.

    I have not tested this, but the event-node auto-bridge feature (manual 12.6) works by generating new lines of the netlist after parsing is complete and then parsing them, with results added to the original circuit. By setting certain variables (pre_set command) and adding a redundant digital device to the circuit, a .include line for the wrnodev output may be processed at the right time.

    I do not suggest that this horrific kludge is a solution, but it does suggest one. Some parts of existing code might be adapted to make a new ".late_include" command that will do the right thing. A documentation requirement that late-included files contain only comments and ".ic" commands may be necessary.

     

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.