How can I access the internal matrices?

Help
2012-02-14
2013-06-12
  • Mansour. RD.
    Mansour. RD.
    2012-02-14

    Hi,

    I need to access the matrices that SPICE creates and analyses during the circuit simulation process at each iteration. Is there any way to dump these matrices out? ans save them in a text file?

    Thanks,
    M. R. Darabad

     
  • Holger Vogt
    Holger Vogt
    2012-02-19

    Hi,
    in CVS there is now a command available
    'mdump '
    to dump the matrix onto the console (of no filename given) or into a file.
    Example usage with a transient simulation defined in rc.cir to dump the matrix after 5 transient steps:

    source rc.cir
    step 5  
    mdump outfile.out

    Regards

    Holger

     
  • Holger Vogt
    Holger Vogt
    2012-02-19

    There is another command available now in CVS to dump the RHS of the matrix to the console or into a file:

    'mrdump '

    Holger

     
  • Holger Vogt
    Holger Vogt
    2012-02-19

    Hi,

    final post with a small example:

    * Loop with matrix dumps, 10 times, every 5 steps
    * simple rc
    *
    .options noacct
    .control
      source D:\Spice_general\ng-spice-rework\tests\general\rc.cir $ your path and file here
      let mc_runs = 10                $ number of runs in loop
      let run = 0                     $ number of actual run
    *
    * run the simulation loop
      dowhile run <= mc_runs
        step 5
        set runs ="$&run"              $ create a variable from the vector
    mdump dump{$runs}.out          $ dump matrix
    mrdump dumpr{$runs}.out        $ dump RHS
        let run = run + 1
      end
    .endc
    .end

    Regards

    Holger

     
  • Mansour. RD.
    Mansour. RD.
    2012-02-19

    Hi Holger,

    Many thanks for your kind and helpful response.

    I used to work with HSpice under windows. I have just started using ngspice under ubuntu and am not very familiar with linux-type environments. Could you explain with more details where I should exactly put these commands? (in .cir file or in ubuntu's command terminal?

    I will have access to my linux machine tomorrow and will test the commands you suggested.

    Cheers,
    M. R. Darabad

     
  • marcel hendrix
    marcel hendrix
    2012-02-19

    > in CVS there is now a command available
    > 'mdump '
    > to dump the matrix onto the console (of no filename given) or into a file.

    Interesting. What is the definition/meaning of mdump and mrdump?

     
  • Holger Vogt
    Holger Vogt
    2012-02-20

    Hi,

    ngspice is independent from the OS, Windows, LINUX, or any other will do.

    Firstly you have to download the ngspice source code from CVS, and compile it. Please have a look at the manual for instructions.

    Then simply put my example into a file, e.g. dump_test.cir, and start ngspice with
    ngspice dump_test.cir.

    Holger

     
  • Holger Vogt
    Holger Vogt
    2012-02-20

    Marcel,

    mdump prints the contents of ft_curckt->ci_ckt->CKTmatrix into a file (or to the console).
    mrdump does the same with ft_curckt->ci_ckt->CKTrhs, ft_curckt->ci_ckt->CKTirhs.

    The chain of functions is:
    mdump -> com_mdump -> SMPprint -> spFileMatrix or spPrint
    or mrdump ->  com_rdump -> SMPprintRHS ->  spFileVector

    For details and formats please have a look at src\maths\sparse\spoutput.c

    Holger

     
  • Mansour. RD.
    Mansour. RD.
    2012-02-20

    Dear Holger,

    I have already downloaded and installed ngspice-rework-23. I am running it under ubuntu and it works. But when I use the command "mdump", the error "no such command available in ngspice" occurs.

    Is ngspice source code is something different from ngspice-rework-#? Sould I do any other installations?

    Sorry for asking too many questions but since I am not familiar with CVS I did not understand your explanation about it.

    Thanks,
    M. R. Darabad

     
  • Holger Vogt
    Holger Vogt
    2012-02-20

    yes, they are different.

    Development of ngspice (and many other open source programs) is done by adding new features to the source code stored in the „Concurrent Version System“ (CVS) at sourceforge.

    When there are several changes available and have been tested o.k., we do a new ngspice release (the current release is ngspice-24 as of Jan. 31st) by making a tarball out of the CVS source code and offer it on our web site.

    The two commands mdump and mrdump exist only since yesterday, so they cannot yet be part of a release, but they are stored in the actual source code at CVS

    Please have a look at the actual manual from http://ngspice.sourceforge.net/docs/ngspice-manual.pdf, chapters 16.2 and 31, for instructions how to obtain the most recent source code from CVS and how to compile it.

    Regards

    Holger

     
  • Mansour. RD.
    Mansour. RD.
    2012-02-20

    Dear Holger,

    Again, many thanks for all the help.

    I will look at the manual.

    Cheers,
    M. R. Darabad

     
  • Mansour. RD.
    Mansour. RD.
    2012-02-20

    Dear Holger,

    I followed the instructions in the manual and could access "A" and RHS matrices using "mdump" and "mrdump".

    Best regards,
    M. R. Darabad