[eispice] General Questions.

  • From: Cyril Giraudon <cyril.giraudon@xxxxxxx>
  • To: eispice@xxxxxxxxxxxxx
  • Date: Sat, 18 Nov 2006 13:59:10 +0100

Hi,

I like the idea I can simulate electrical circuits from a python shell. 
I think you start a very useful job.

I work on scientific platforms for electromagnetism simulation and 
python becomes my preferred language.
I have also began two wrappers around gnucap / ngspice with pyrex, but 
by lack of time, those projects sleep :-( ....

I'd like to ask some questions about eispice :

1 -
Have you ever think of writing eispice entirely in python ? It could 
seem ridiculous, but ...
I think there are several python packages very important in the python 
scientific world :
- numpy (scientific array handling, http://numpy.scipy.org/);
- matplotlib (2D scientific plotting capabilities, 
http://matplotlib.sourceforge.net/);
- scipy (general scientific tools based on numpy, 
http://www.scipy.org/SciPy);
- pytables (hdf5 wrapper, hdf5 is a general file format for large data 
writing, http://www.pytables.org/moin);

scipy (end perhaps numpy) comes with blas/lapack libraries (standard 
c/fortran library for matrices).
You can invert matrices with scipy as if you work with matlab 
(http://www.scipy.org/NumPy_for_Matlab_Users).
At the end of the linked page, you can read :

[V,D]=eig(a)

        

linalg.eig(a)

        

linalg.eig(a)

        

eigenvalues and eigenvectors of a

[V,D]=eigs(a,k)

        


        


        

find the k largest eigenvalues and eigenvectors of a

[Q,R,P]=qr(a,0)

        

(Q,R)=Sci.linalg.qr(a)

        

mat(...)

        

QR decomposition

[L,U,P]=lu(a)

        

(L,U)=Sci.linalg.lu(a) or
(LU,P)=Sci.linalg.lu_factor(a)

        

mat(...)

        

LU decomposition

conjgrad

        

Sci.linalg.cg

        

mat(...)

        

Conjugate gradients solver

fft(a)

        

fft(a)

        

mat(...)

        

Fourier transform of a

I haven't benchmarked the LU decomposition, but it's fortran behind the 
stage.
Apparently, you can use sparseLU from scipy : 
http://svn.scipy.org/svn/scipy/tags/0.4.2/Lib/sandbox/pysparse/tests/test_superlu.py

Where does a circuit simulator need to be fast except for matrices 
operations ?

The consequences are :
- development easier (scripting language);
- No compiled code;
- Cross platform;
- All devices models are written in python;
- no plug-in mechanism (only a good interface);
- Add a models on the fly;
- Perfect integration with python shells, development environments;
...

You probably know already a lot of what i've just said, but what are 
your motivations for using C language ?
Does Eispice  must be very fast, flexible, modular ?

2-
I have taken a look at the following example

from eispice import *
d = deck("Tline Test")
d.Vs = V('vs', gnd, 0, pulse(0, 1, 15*nano, 1*nano))
d.Rs = R('vs', 'vi', 30)
d.Tg = T('vi', gnd, "vo", "0", 50, 5*nano, 0.5)
d.Rl = R('vo', gnd, 10*kilo)
d.Cl = C('vo', gnd, 5*pico)
d.tran(0.1*nano, 100*nano)
plot(d)
taken from http://www.thedigitalmachine.net/eispice.manual.html.

and I have read the sentence :
"Added a Tk based plotter that should run a lot faster than the old 
gnuplot interface."

Do you really think Eispice must provide graphics capabilities ?
I have already discussed this point with al davis, gnucap developer, 
(http://archives.seul.org/geda/dev/May-2006/msg00011.html).

I think, the circuit simulator itself, must do the minimum amount of the 
task, furthermore in a python environment.
When the example demands a d.tran(0.1*nano, 100*nano), are you sure 
Eispice must control the step of returned values ?
Has Eispice have to plot results ?

Imagine Eispice knows only simulate a [start, end] transient analysis 
and return the last calculated value (it doesn't stock result in 
memory). The python user would write the following code snippet :

import numpy

from pylab import *

import eispice

d = eispice.deck("Tline Test");
d.Vs = V('vs', gnd, 0, pulse(0, 1, 15*nano, 1*nano))
d.Rs = R('vs', 'vi', 30)
d.Tg = T('vi', gnd, "vo", "0", 50, 5*nano, 0.5)
d.Rl = R('vo', gnd, 10*kilo)
d.Cl = C('vo', gnd, 5*pico)

step = 0.1*nano
voArray = numpy.array(1000)
tArray = numpy.array(1000)
i = 0
# Run the simulation
for t in numpy.arange(0.1*nano, 100*nano, step):
  d.tran(t, t+step)
  tArray[i] = t
  voArray[i] = d.getValue("vo")
  # Why not change Rs value in function of vo values (linked elements) ?
  i = i +1

# Plot the result
# http://matplotlib.sourceforge.net/screenshots.html
matplotlib.plot(tArray, voArray)
xlabel('time')
ylabel('Voltage (mV)')
grid('True')
show()

Yes, It's much longer, but Eispice code is "simpler" and the interaction 
with the user is strong.

The questions are :
What does the core of the simulator have to perform ?
How the user can interact with a running simulation ?
How implement circuit linked elements (linked sources)?
External module : wave form creation, Eispice would accept only 
discretized curves (array) ... ?

I wish I ask useful questions.

regards,

Cyril.




------------------------------------------------------------------
To unsubscribe from the eispice list send an email to:
eispice-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field

Other related posts: