sweep of a parameter

hox
2013-02-06
2013-06-13
  • hox
    hox
    2013-02-06

    Dear ngspice users,
    I want to change a parameter within a simulation loop.

    .param ph=1.2V
    vaph1  aph1 0 pulse 0v ph .50ns .01ns .01ns .99ns 2ns

    the parameter ph should be changed in a loop

    (start of loop)
    while loop < 5
    let loop =1
    ph=loop  ??????
    tran …..

    let loop=loop+1
    end
    (end loop)

    thanks for help

    ho

     
  • Robert Larice
    Robert Larice
    2013-02-06

    Hello,

      instead of changing a parameter,
         here you might get away using  `alter'

      a sketch for that looks like this

    altering the second parameter of a `pulse' VSRC device
    * (compile (concat "w32/src/ngspice " buffer-file-name) t)
    vaph1 aph1 0 pulse 0v 0.042ns .50ns .01ns  .01ns .99ns 2ns
    .control
    show vaph1
    let pulse_v1 = @vaph1[pulse]
    * print status quo
    print pulse_v1 @vaph1[pulse]
    * alter the second vaph1 pulse parameter
    let pulse_v1[1] = 0.43ns
    alter @vaph1[pulse] pulse_v1
    * verify
    show vaph1
    print pulse_v1 @vaph1[pulse]
    .endc
    

    Robert

     
  • hox
    hox
    2013-02-07

    Thanks Robert, you are great,
    it' running

    ho

     
  • Instead of assigning one at a time, like this:
    let pulse_v1[1] = 0.43ns

    can one assign the entire vector at once?
    let pulse_v1 = [ 0 1 2 3 4 5 6 ]
    ?

    Do I need to synthesize a vector first?

     
  • Robert Larice
    Robert Larice
    2013-06-13

    Hello Abhijit,

    you can create a vector first, I think with
    let pulse_v1 = vector(7)
    and then change elements of this vector with
    let pulse_v1[3] = 42

    or you can `compose' a vector from scratch with
    compose pulse_v1 values 11 12 13 14
    print pulse_v1

    by the way, Don Sauer has quite some examples
    for ngspice on his web page,
    http://www.idea2ic.com/NGSPICE_TEMPLATES/NGSPICE%20TEMPLATES.html

    I think there is an example using alter' to set apwl' voltage source.

    Regards,
    Robert