Create coupled inductors

below is the exscript from https://github.com/GProtoZeroW/skidl/blob/master/skidl/libs/skidl_2_pyspice_check.ipynb where I tried to create coupled inductors in skidl but couldn’t figure it out. Was able to create them in pyspice.

K | Coupled (Mutual) Inductors

PySpice/PySpice/Spice/BasicElement.py; class CoupledInductor(AnyPinElement)

skidl/skidl/libs/pyspice_sklib.py; name=“K”

ngspice 3.2.11 Coupled (Mutual) Inductors:

KXXXXXXX LYYYYYYY LZZZZZZZ value

Notes

  • need to get Dave’s help on using K inside skidl
  • the inductors must already exist for pyspice to work
reset()
net_1=Net('N1'); net_2=Net('N2') 
skidl_L1=L(ref='1', value=5, m=5, temp=5, dtemp=5, ic=5); skidl_L1['p', 'n']+=net_1, net_2 
skidl_L2=L(ref='2', value=5, m=5, temp=5, dtemp=5, ic=5); skidl_L2['p', 'n']+=net_1, net_2 
#need to find out how to use this 
#skidl_K=K() 
skidl_circ=generate_netlist() 
print(skidl_circ)

No errors or warnings found during netlist generation.

.title L1 N1 N2 5 dtemp=5 ic=5 m=5 temp=5 L2 N1 N2 5 dtemp=5 ic=5 m=5 temp=5

pyspice_circ=Circuit('')
#inductors need to exsist to then be coupled 
pyspice_circ.L('1', 'N1', 'N2', 5, m=5, temp=5, dtemp=5, ic=5) 
pyspice_circ.L('2', 'N1', 'N2', 5, m=5, temp=5, dtemp=5, ic=5) 
pyspice_circ.K('1', 'L1', 'L2', coupling_factor=5) 
print(pyspice_circ)

.title L1 N1 N2 5 dtemp=5 ic=5 m=5 temp=5 L2 N1 N2 5 dtemp=5 ic=5 m=5 temp=5 K1 L1 L2 5

After more testing the following has been found.

  1. Any use of the kw defined in https://github.com/xesscorp/skidl/blob/master/skidl/libs/pyspice_sklib.py name=“K” kw’s: "kw": {"ind1": "ind1", "ind2": "ind2", "coupling": "coupling"} produces Value Error; ex K(coupling=2.5@u_H) yields ValueError: Unknown argument coupling=2.5

  2. using just a no argument (see issue from above) the generate_netlist yields a error; ex K(); generate_netlist() yields TypeError: can only concatenate str (not "NoneType") to str