📜 ⬆️ ⬇️

Simulation of transients during electrical circuit switching by means of Python



Why take into account transients


In general, transients can occur in an electrical circuit if there are inductive and capacitive elements in the circuit that have the ability to accumulate or release energy from a magnetic or electric field. At the moment of switching, when the transition process begins, there is a redistribution of energy between the inductive, capacitive elements of the circuit and external sources of energy, if they are connected to the circuit. In this case, large overvoltages, overcurrents, electromagnetic oscillations may occur, which can disrupt the operation of automation systems and other devices, up to their failure.

On the other hand, transients find practical application, for example, in various kinds of electronic generators, in electronic and automation circuits.
')
There are many publications on this topic [1,2,3], but most of them contain descriptions of transients, based on the methods of analytical solution of the corresponding equations. Numerical methods are used much less frequently, and most of these publications are devoted to the description of the method of numerical solution of a differential equation.

Given the numerical methods that are well developed in the SciPy library, I give an example of mathematical modeling of transients when switching in electric circuits by means of this library.

How can we build graphs of transients when switching electrical circuits


Generalized electrical circuit diagram.


Consider a circuit containing a current source - E, an inductor - L, two resistances - R1, R2, a capacitor - C, and a switch.

We present the parameters of the electrical circuit for the state after switching.

In the open state, the circuit shown in the figure corresponds to the conditions:



Listing of the program for constructing graphs of transient processes in a circuit upon opening
#!/usr/bin/python # -*- coding: utf-8 -*- import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt R1=10;R2=20;L=0.02;C=0.00005;E=100;tm=0.02; #   def f(y, t):#    . y1,y2 = y return [y2,-(R1/L)*y2-(1/(L*C))*y1+E/(L*C)] t = np.linspace(0,tm,1000) y0 = [E*R2/(R1+R2),0]#  z = odeint(f, y0, t)#   y1=z[:,0] #    y2=100*C*z[:,1] #    plt.title('       ', size=12) plt.plot(t*1000,y1,linewidth=2, label=' U(t)') plt.plot(t*1000,y2,linewidth=2, label=' i3(t)=100*C*dUc(t)/dt') plt.ylabel("Uc(t), i3(t)") plt.xlabel("t*1000") plt.legend(loc='best') plt.grid(True) plt.show() 

The result of the program




In the open circuit, i2 = 0, and i3 = i1, so only the current and voltage are shown in the graph. The nature of transient processes is damped oscillations.

In the closed state, the circuit shown in the figure corresponds to the conditions:



Listing of the program for constructing graphs of transient processes in a circuit upon closure.
 #!/usr/bin/python # -*- coding: utf-8 -*- import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt R1=10;R2=20;L=0.02;C=0.00005;E=100;tm=0.02; #    def f(y, t):#    . y1,y2 = y return [y2,-((L+R1*R2*C)/(R2*L*C))*y2-((R1+R2)/(R2*L*C))*y1+E/(L*C)] t = np.linspace(0,tm,1000) y0 = [E,0]#  z = odeint(f, y0, t)#   y1=z[:,0] #    y2=100*(C*z[:,1]+y1/R2) y3=100*C*z[:,1] y4=100*y1/R2 plt.title('       ', size=12) plt.plot(t*1000,y1,linewidth=2, label=' Uc(t)') plt.plot(t*1000,y2,linewidth=2, label=' i1(t)*100') plt.plot(t*1000,y3,linewidth=2, label='i3(t)*100') plt.plot(t*1000,y4,linewidth=2, label=' i2*100') plt.ylabel("Uc(t),i1(t),i2(t),i3(t)") plt.xlabel("t*1000") plt.legend(loc='best') plt.grid(True) plt.show() 

The result of the program




In a closed circuit for currents, the relation i1 = i2 + i3 is satisfied. Transients aperiodic. In the steady state, i3 = 0, i1 = i2, which follows from the graph.

Conclusion


Numerical solutions of differential equations using Python tools simplify the analysis of transients in electrical circuits, make it vivid and allow you to focus on the results without analyzing the methods for solving equations.

Links


  1. torus.pp.ua/manuals/lessons/matusko/perechodn.html
  2. electricalschool.info/spravochnik/electroteh/747-perekhodnye-processy-v-jelektricheskojj.html
  3. ru.wikipedia.org/wiki/Transitional_processes_in_electric_chains

Source: https://habr.com/ru/post/330990/


All Articles