Menu ▾ ▴

#873 .spiceinit does not allow setting random seed

v1.0 (example)
open-fixed
None
5
2026-10-09
2026-10-03
No

None of the options for setting the random seed in .spiceinit seem to work. The attached script prints a random resistance each time, despite three different ways of setting the random seed in .spiceinit:

option seed=1
setseed 1
set rndseed=1

With the above in .spiceinit in the current directory:

for i in 1 2 3 4 5 6 7 8 9 10 ; do ngspice -b spiceinit_fail.cir| fgrep resistance ; done
@r1[resistance] = 9.738833e+02
@r1[resistance] = 8.706737e+02
@r1[resistance] = 8.131219e+02
@r1[resistance] = 1.001660e+03
@r1[resistance] = 9.268301e+02
@r1[resistance] = 8.859511e+02
@r1[resistance] = 1.179932e+03
@r1[resistance] = 9.320947e+02
@r1[resistance] = 8.938548e+02
@r1[resistance] = 1.005027e+03
1 Attachments

Discussion

  • Holger Vogt

    Holger Vogt - 2026-10-04

    Thanks for the report.

    This requires some major overhaul. I have some code ready, but it still needs a lot of testing.

     
  • Holger Vogt

    Holger Vogt - 2026-10-04
    • status: open --> open-accepted
    • assigned_to: Holger Vogt
     
  • Holger Vogt

    Holger Vogt - 2026-10-05
    • status: open-accepted --> open-fixed
     
  • Holger Vogt

    Holger Vogt - 2026-10-05

    I have pushed a fix to git development branch pre-master-48.

    Please test.

     
    • Andrew Sterian

      Andrew Sterian - 2026-10-05

      Looks like it works to set 'setseed N' in .spiceinit

      Thanks!

       
  • Munaut Sylvain

    Munaut Sylvain - 2026-10-07

    The fix in git breaks "option klu" in .spiceinit
    Before the commit, KLU is used. After the patch, SPARSE is used.

     
    • Holger Vogt

      Holger Vogt - 2026-10-09

      Another fix is pushed to git branch pre-master-48.

       

Log in to post a comment.