gnucap-devel
[Top][All Lists]
Advanced

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

Re: [Gnucap-devel] python bindings update


From: Felix Salfelder
Subject: Re: [Gnucap-devel] python bindings update
Date: Thu, 27 Dec 2018 17:57:58 +0100
User-agent: NeoMutt/20170113 (1.7.2)

On Wed, Dec 26, 2018 at 05:08:09PM +0100, Patrick Mulder wrote:
> === pulse_ckt.sp
> spice
> v1 (1 0) pulse (0 1)
> 
> .print tran v(1)
> .tran 0 1 .1
> .tran trace all
> 
> .end
> ===

note that the spice behavioural models also take arguments by name. if
you can't avoid spice, a better representation would be

v1 1 0 pulse iv=0 pv=1

perhaps you should also set rise to a positive value.

not sure why you have two .tran commands in there. the second one simply
does another second (without something interesting happening). the
command ".tran 1" does one second, but with automatic steps.

> sim_pulse.py
[..]

the following might get you started.

===
import gnucap
from gnucap import command as cmd

cmd("get stuff.sp")
print("listing circuit")
cmd("list")
cmd("store tran v(nodes)")
cmd("transient 1 trace=none > /dev/null") # spice aliases don't work

# bug: does not throw if "v(1)" doesnt exist, (but returns None).
w = gnucap.CKT_BASE_find_wave("v(1)")

for i in w:
        print (i)
===

> 1) how to print/check what netlist was loaded, basically a kind of status
> command, where we could see what would be simulate

cmd("list") above. dumps the netlist to stdout.

> 2) where do I start the actual simulation (in the .sp file or from the
> python script)

i think, if you load a circuit with "get", commands are ignored.
preferred way to run them is through gnucap.command, as you did.

> 3) how to fetch the results from the simulation, and either wrap them in
> Numpy or maybe in Pandas

for now, it's probably most straightforward to access data through the
wave store, as shown above. waves are iterable and yield pairs of
double, perhaps you can pass it to a numpy array constructor or so.

alternatively, you could run the wave through a measurement command and
store the result in a parameter, then access the result (see inv.py from
line 31). either way, call "store" before the simulation command.

(there are better and more immediate ways on the way, ETA unknown.)

> When I have this working, I can try to share the results in a Jupyter
> notebook.

sounds useful, please do. i'd like to add it to the examples.

thanks
felix



reply via email to

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