def test_transformer(self): import os from PySpice.Spice.Netlist import Circuit circuit = Circuit('Diode Characteristic Curve') circuit.L('primary', 'Vlp', 'Vdrain', '{l_trf}') circuit.C('resonance', 'Vlv', 'Vdrain', '{cap_r}') circuit.L('secondary', 'Vls', 'ghv', '{Ls}') circuit.R('secondary', 'Vls', 1, 5.15) circuit.K('flyback', 'Lprimary', 'Lsecondary', 1)
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 skidl_K = K(ind1=skidl_L1, ind2=skidl_L2, coupling=5) skidl_circ = generate_netlist() print(skidl_circ) # In[28]: 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) # In[29]: netlist_comp_check(skidl_circ, pyspice_circ) # ## L | Inductor # # PySpice/PySpice/Spice/BasicElement.py; class Inductor(DipoleElement) # # skidl/skidl/libs/pyspice_sklib.py; name="L" # # ngspice 3.2.9 Inductors: # # LYYYYYYY n| n- <value > <mname > <nt=val> <m=val> <scale=val> <temp=val> <dtemp=val> <tc1=val> <tc2=val> <ic=init_condition >
frequency = 1e3 period = 1 / frequency omega = 2 * np.pi * frequency I_P1 = 100 L_P1 = 1e-6 L_S1 = 10e-6 K_P1S1 = 0.1 circuit = Circuit('2CoupledInductors') #Primary Side circuit.I('I2', circuit.gnd, 'N1', 'AC ' + str(I_P1) + '') circuit.L('L_P1', circuit.gnd, 'N1', str(L_P1)) # Secondary Side circuit.L('L_S1', circuit.gnd, 'N2', str(L_S1)) circuit.K('K_P1S1', 'LL_P1', 'LL_S1', K_P1S1) # NB, it adds an L to the name of the inductor ... print(circuit) # # Do the simulation # simulator = circuit.simulator(temperature=25, nominal_temperature=25) # analysis = simulator.ac(variation='lin', number_of_points=1, start_frequency=frequency, stop_frequency=frequency) # # Print the results # print('--- Results ---') # for node in analysis.nodes.values(): # print('Node {}: {:5.2f} V'.format(str(node), float(abs(node))))