
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 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. 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
- torus.pp.ua/manuals/lessons/matusko/perechodn.html
- electricalschool.info/spravochnik/electroteh/747-perekhodnye-processy-v-jelektricheskojj.html
- ru.wikipedia.org/wiki/Transitional_processes_in_electric_chains