# Using Python for the Simulation of a Closed-Loop PI Controller for a Buck Converter
## 1 Introduction  
Power electronics is a branch of electronics whose purpose is to develop systems that convert power from one form (source) to another form (load), as efficiently as possible. The aforementioned systems can be designed to operate in the power range from few W to MW, and can be found in home appliances, electric drives, renewable energy applications, electric trains, electric and hybrid cars and buses, industrial drives, and wireless power charging (smartphones and cars) [1], among others.  
The aforementioned applications require different types of systems, which can be subdivided into four categories: AC/AC, AC/DC, DC/DC and DC/AC. In turn, each of these systems may have multiple circuits which can be used for a particular application. Usually, an application is composed of several stages which may contain different categories of power converters.  
This paper focuses on the DC/DC converters, which are widely used in computer power supplies (ATX power supply) and servers, as well as in different types of charges and adapters (smartphones, tablet, laptops, etc.) that are used in our daily life.  
The design of power converters requires the understanding of the working principle of the circuits and their analysis, but also the use of simulation tools.  
One of the most commonly used tools to simulate power converters [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], as well as its components [12], is MATLAB/Simulink. The simplicity of the design of power converters, the high level of precision and user-friendly graphical interface makes this software very appealing [13, 14], especially with regard to Simulink as it allows for Model-Based Design (MBD). MATLAB/Simulink plays a key role in carrying out research tasks [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14].  
One of the major disadvantages of MATLAB is the fact that it is a proprietary programming language unlike Python. As the algorithms implemented in MATLAB are proprietary, it is not possible to access their code. This particularity can significantly limit the implementation of control methods, as well as the development of fault diagnosis techniques [15].  
Although Python does not allow MBD as MATLAB does, it has computational power and tools that make it possible to simulate DC/DC converters, as will be demonstrated in this paper.  
On the other hand, the use of Python is clearly advantageous when applying machine-learning algorithms. Python has many libraries and packages for old and new machine-learning models, being widely used in this context in both industry and academia [16; 17]. MATLAB has also some machine-learning algorithms that can provide immediate visual feedback, however these algorithms are proprietary.  
The use of machine-learning algorithms can be very useful in converter design, in particular with regard to the control methods [7; 8; 9], and in the development of fault diagnosis techniques [18; 19; 20; 21], making the proposed technique particularly suitable in these contexts.  
The rest of this article is organized as follows. Section 2 describes the application of the proposed technique to a converter operating in open loop. Section 3 presents the converter design process and Section 4 shows how to apply the proposed technique to a converter operating in closed loop. Section 5 shows the feasibility of the proposed technique through its comparison with LISpice. Finally, Section 6 presents the conclusions.