forgive my ignorance ...

14 views
Skip to first unread message

aapje

unread,
Aug 16, 2009, 9:28:41 PM8/16/09
to pycircuit
hello,

I was just playing a little with PyCircuit, to get both the numerical
and symbolic output of the RC-filter, when my eye felt on the
redundancy in the declarations and I wonder if this redundancy can't
be reduced (without sacrifying the enormuous flexibility, probably
available in PyCircuit).

Especially the following declarations:
cir['R1'] = R(1, 2, r=1e3)
cir2['R1'] = R(1, 2, r=Symbol('R1'))
the first one contains 3 times "R" and the second one even 4 times.

As an experiment I wrote a little wrapper-class,
and with this wrapper-class you can write
all 3 examples with the code given below.

What am I throwing away, by using this wrapper-class ?

Another point (maybe a buggy),
I suppose that the circuit.default_toolkit is only used when you don't
specify a toolkit explicty in a class initialisation or function call.
This works well for symbolic definitions of components (if the circuit
is explictly generated with the symbolic toolkit), but calling
TwoPortAnalysis (with an explict parameter toolkit = symbolic, on a
symbolic circuit ) doesn't work. To get it working you have to specify
circuit.default_toolkit = symbolic).

thanks,
Stef Mientki

"""Combination of all 3 examples, using a wrapper-class"""
from Circuits import *

# Create the RC circuit
cir = SubCircuit2 ()
cir.add ( 'VS', 1, gnd, 1 )
cir.add ( 'R1', 1, 2, 1e3 )
cir.add ( 'C1', 2, gnd, 1e-12 )

# example 1, plot output as function of the frequency :
cir.Hw ( 2, gnd, 6, 9 )

# example 2, print symbolic transfer function :
print 'H(s) =', cir.Hs_Symbolic ( 2, 1 )

# example 3, print symbolic State-Space representation :
print 'ABCD =', str ( cir.SS_Symbolic ( 1, gnd, 2, gnd ) ) .replace
('\n', '\n ')

henrik johansson

unread,
Aug 24, 2009, 4:31:18 PM8/24/09
to pyci...@googlegroups.com
Hi Stef,

I'm back from vacation, sorry about the late reply.

I haven't yet tried PyLab Works but there is great potential to
improve usability of pycircuit.

How is pycircuit integrated with PyLab Work? Does it allow you to
create pycircuit object by drawing a circuit schematics interactively?

Do you think it would be possible to use the post-processing
capabilities of pycircuit together with Pylab Works? I could imagine
that the waveform objects can be useful.
The plots on the screenshots look great and currently there is no
waveform viewer for pycircuit.

> I was just playing a little with PyCircuit, to get both the numerical
> and symbolic output of the RC-filter, when my eye felt on the
> redundancy in the declarations and I wonder if this redundancy can't
> be reduced (without sacrifying the enormuous flexibility, probably
> available in PyCircuit).
>
> Especially the following declarations:
>  cir['R1'] = R(1, 2, r=1e3)
>  cir2['R1'] = R(1, 2, r=Symbol('R1'))
> the first one contains 3 times "R" and the second one even 4 times.
>
> As an experiment I wrote a little wrapper-class,
> and with this wrapper-class you can write
> all 3 examples with the code given below.
>
> What am I throwing away, by using this wrapper-class ?

I agree that this way is much simpler syntax and should be included as
an alternative to the more flexible present way. The obvious
difference is the flexibility of adding custom names and custom models
like:
cir['Lseries'] = myL(1, 2, l=1e-9)

To make your solution even shorter one could set the parameters of
basic circuit elements to Symbol(instancename) when the symbolic
toolkit is used.

> Another point (maybe a buggy),
> I suppose that the circuit.default_toolkit is only used when you don't
> specify a toolkit explicty in a class initialisation or function call.
> This works well for symbolic definitions of components (if the circuit
> is explictly generated with the symbolic toolkit), but calling
> TwoPortAnalysis (with an explict parameter toolkit = symbolic, on a
> symbolic circuit ) doesn't work. To get it working you have to specify
> circuit.default_toolkit = symbolic).

This must be a bug, I will have look at it. Thanks for reporting it.

I would like to try your circuit wrapper and the latest version of
PyLab works. Is there a git or svn repo with the development version?

Best regards,

Henrik

Stef Mientki

unread,
Aug 25, 2009, 9:55:26 AM8/25/09
to pyci...@googlegroups.com
hi Henrik,

henrik johansson wrote:
> Hi Stef,
>
> I'm back from vacation, sorry about the late reply.
>
> I haven't yet tried PyLab Works but there is great potential to
> improve usability of pycircuit.
>
> How is pycircuit integrated with PyLab Work? Does it allow you to
> create pycircuit object by drawing a circuit schematics interactively?
>
> Do you think it would be possible to use the post-processing
> capabilities of pycircuit together with Pylab Works? I could imagine
> that the waveform objects can be useful.
> The plots on the screenshots look great and currently there is no
> waveform viewer for pycircuit.
>
>
Great that you're interested.
I just build a circuit editor, based on OGL-like-drawing capabilities
already available in PyLab_Works.
I need to fix some bugs, implement rectangle connection lines (OGl now
only has zig-zag lines), and generate netlists (or cicuit defintions for
PyCircuit).
You can get a first impression here:
http://mientki.ruhosting.nl/data_www/pylab_works/pw_circuit_editor.html

I don't have a svn storage (yet, I don't like them, long story ),
but I''ll inform you, when a new version with circuit design is
available ( 1 or 2 weeks expected).

btw. I have one question:
what type of components are available within PyCircuit ( normal and
symbolic ) ?

cheers,
Stef

henrik johansson

unread,
Aug 27, 2009, 3:07:08 PM8/27/09
to pyci...@googlegroups.com
> btw. I have one question:
> what type of components are available within PyCircuit ( normal and
> symbolic ) ?

Right now it's not many models except for the basic linear components.
There is a linear MOS transistor and a very simple diode model. But
there will be more models in the future. We also have a long term goal
of supporting verilog-a models.

Cheers,

Henrik

Reply all
Reply to author
Forward
0 new messages