def run_test_circuit_6(name): I1 = CurrentSource('I1', [0, 1], 2, (2, 0.002)) # 2 Ampere R2 = Resistor('R2', [1, 0], 3) # 1 Ohm L3 = Inductor('L3', [1, 0], 0.001, 0) # 0.01 H # I_start = 0.1 test_circuit = Circuit(gpu=True) test_circuit.add_components([I1, R2, L3]) res = test_circuit.solve_AC(0, 0.1, 0.001) # test_circuit.print_results() test_circuit.draw_plot(name, I1, res, 'I') test_circuit.draw_plot(name, R2, res, 'V') test_circuit.draw_plot(name, L3, res, 'V')
def run_test_circuit_4(name): G2 = Conductor('G2', [1, 0], 0.25) # 0.5 1/Ohm R1 = Resistor('R1', [1, 2], 1) # 2 Ohm R3 = Resistor('R3', [2, 0], 5) # 4 Ohm I4 = CurrentSource('I4', [0, 1], 2) # 0.5 Ampere test_circuit = Circuit() test_circuit.add_components([R1, G2, R3, I4]) test_circuit.solve_DC() # DC test_circuit.print_matrix() test_circuit.print_results()
def run_test_circuit_4(name): R1 = Resistor('R1', [1, 2], 1) # 1 Ohm R2 = Resistor('R2', [2, 0], 1) # 1 Ohm I3 = CurrentSource('I3', [1, 0], 1) # 1 Ampere R4 = Resistor('R4', [3, 2], 1) # 1 Ohm R5 = Resistor('R5', [4, 1], 1) # 1 Ohm R6 = Resistor('R6', [4, 0], 1) # 1 Ohm R7 = Resistor('R7', [3, 1], 1) # 1 Ohm test_circuit = Circuit(gpu=True) test_circuit.add_components([R1, R2, I3, R4, R5, R6, R7]) test_circuit.solve_DC() # DC test_circuit.print_results()
def run_test_circuit_sweep(name): G2 = Conductor('G2', [0, 1], 0.25) # 0.5 1/Ohm # R2 = Resistor('R2', [0, 1], 0.25) # 0.5 1/Ohm R1 = Resistor('R1', [1, 2], 1) # 2 Ohm R3 = Resistor('R3', [2, 0], 5) # 4 Ohm I4 = CurrentSource('I4', [0, 1], 2) # 0.5 Ampere test_circuit = Circuit() test_circuit.add_components([R1, G2, R3, I4]) res = test_circuit.solve_DC_sweep(I4, 2, 8, 1) # DC print(res['result']) test_circuit.draw_VA_plot('VA', I4, res)
def run_test_circuit_7(name): I1 = CurrentSource('I1', [2, 0], 2, (2, 0.2, 0.1)) # 2 Ampere R2 = Resistor('R2', [1, 0], 1) # 1 Ohm L3 = Inductor('L3', [2, 0], 0.01, ) # 0.01 H # I_start = 0. C4 = Capacitor('C4', [1, 2], 0.00001) # 0.00001 F #U_start = 0. test_circuit = Circuit() test_circuit.add_components([I1, R2, L3, C4]) res = test_circuit.solve_AC(0, 0.001, 0.000002) test_circuit.print_results() test_circuit.draw_plot(name, I1, res, 'I') test_circuit.draw_plot(name, R2, res, 'V') test_circuit.draw_plot(name, L3, res, 'V') test_circuit.draw_plot(name, C4, res, 'I')
def run_test_circuit_5(name): I2 = CurrentSource('I1', [0, 1], 2, (2, 0.23, 0.1)) # 2 Ampere R1 = Resistor('R2', [1, 0], 10) # 1 Ohm C3 = Capacitor('C3', [1, 0], 1e-6, 0) # 1e-6 F # U_start = 0 argument test_circuit = Circuit() test_circuit.add_components([R1, I2, C3]) # test_circuit.solve_DC() # DC res = test_circuit.solve_AC(0, 1e-4, 0.5e-7) # AC # print(res['result']) test_circuit.print_results() test_circuit.print_matrix() test_circuit.draw_plot(name, I2, res, 'I') test_circuit.draw_plot(name, R1, res, 'V') test_circuit.draw_plot(name, C3, res, 'I')
# # # ########## # # # # # # #### ###### ###### # # I4 # # # # # # #### # R2 # # R3 # # # # # # # # # ###### ###### # # # # # # # # # ########## 0 ############################# # from resistor import Resistor from conductivity import Conductor from current_source import CurrentSource from circuit import Circuit if __name__ == '__main__': R1 = Resistor('R1', [1, 0], 2) # 2 Ohm R2 = Resistor('R2', [1, 2], 1) # 1 Ohm R3 = Resistor('R3', [2, 0], 1) # 1 Ohm I4 = CurrentSource('I4', [1, 0], 1) # 1 Ampere test_circuit = Circuit() test_circuit.add_components([R1, R2, R3, I4]) test_circuit.solve_DC('HM10') test_circuit.print_matrix() test_circuit.print_results('HM10') # test_circuit.print()