PySpice icon indicating copy to clipboard operation
PySpice copied to clipboard

added circuit plotting with SchemDraw

Open chaffra opened this issue 7 years ago • 2 comments

Hello,

This PR allows the user to visualize to circuit with SchemDraw while building it. Example

circuit = Circuit('Diode Characteristic Curve')
circuit.include(spice_library['1N4148'])
circuit.schematic.add(schem.elements.GND)
V =circuit.V('input', 'Vin', circuit.gnd, 10@u_V,
            schematic_kwargs={'show_plus': True}
            )
R = circuit.R('1', 'Vin', 'Vout', 1@u_Ω,
              schematic_kwargs={'d':'right', 'show_minus': True}
             ) # not required for simulation
X = circuit.X('D1', '1N4148', 'Vout', circuit.gnd,
             schematic_kwargs={'schematic': schem.elements.DIODE, 'd':'down'},
             )
circuit.schematic.add(schem.elements.GND)
circuit.schematic.draw()

Not all electrical components diagrams are implemented yet but this is a start.

chaffra avatar Nov 26 '18 04:11 chaffra

Thanks I didn't know SchemDraw !

SchemDraw looks cool as an alternative to circuit_macros which is hard to use and require a lot of dependencies ...

Some references on SchemDraw:

  • https://pypi.org/project/SchemDraw
  • https://cdelker.bitbucket.io/SchemDraw/SchemDraw.html
  • https://pythonforundergradengineers.com/circuit-diagram-problem-with-schemdraw.html

I wonder how it compares ? I was thinking to such feature, even for basic circuits.

Now the question is on the API. We could give a look to Modelica annotation.

The approach using an optional kwarg seems interesting. Maybe we could improve a bit the syntax.

Note: I don't have so much time to work on PySpice actually ...

FabriceSalvaire avatar Nov 26 '18 23:11 FabriceSalvaire