octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octave - Ngspice interface


From: Kozma, Endre
Subject: Re: Octave - Ngspice interface
Date: Sat, 06 Sep 2014 11:36:44 +0200

Hello,

I met the similar problem last year, but I wanted full control over ngspice (wanted to control a buck-boost converter modeled in ngspice with a control algorithm developed in octave). I tried out some possibilities. They all were based on popen2, but because ngspice doesn't flush its outputs, thus I wasn't happy with that. Then I improved this popen2 method with using pseudo terminal. This latter worked quite well already, but parsing the received data was always a pain and the bloated octave code I had to write for that was far from what I liked. Fortunately as of release 26 ngspice delivers a shared dynamic library through which you can do practically anything with ngspice from octave. Probably you will have to compile it (I've never seen yet a binary package of the shared library), but hopefully it won't mean any problem for you. I built it without any problems in linux and cygwin. When the library is installed you can write the necessary oct-files (for interfacing octave and the library) to get and send data in an elegant and simple way. The library is independent from the ngspice application package, but it can do whatever the application can do except the user interface.
If you're interested in this I attached my oct-files as examples. Of course they are far from being perfect.

Just to wet your appetite here is an octave code snippet I can now deploy with this solution.

ngspice_init();
ngspice_command(["source simu.cir"; "tran 0.1us 6us uic"]);
[v6, v77] = ngspice_get_vector(["v(6)"; "v(77)"]);

You can see that the functions are quite general, so it might be be worth to create a nice octave package.

Regards,
Endre


On Wed, 2014-09-03 at 10:18 -0700, CdeMills wrote:
Hello,

I have students developping simulations, and they needed to read into Octave
results produced by Ngspice.

We used the set of file developped by Werner Hoch in 2005. Due to my
students needs, I made two changes:
1) new function do_ngspice, which is a simple wrapper around ngspice call
2) spice_readfile: add the alility to read multiple "plots" present in the
raw file. F.i., performing an AC sweep and requesting a ".OP" (operating
point) computation lead to a file with two "plots"; one for the sweep, one
for the DC components

Should I diffuse an update through ngspice maitainers, or should I create
some package in octave-forge ?

Regards

Pascal



--
View this message in context: http://octave.1599824.n4.nabble.com/Octave-Ngspice-interface-tp4666332.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.



Attachment: ngspice_oct.tar.gz
Description: application/compressed-tar


reply via email to

[Prev in Thread] Current Thread [Next in Thread]