Python tool for plotting the Root Locus (LGR) of control systems given their open-loop transfer functions
Consider a high-performance missile 💥 designed for satellite launch, which operates under a unity feedback system characterized by the following transfer function:
To plot the Root Locus for this system, we need to determine the dominant poles when
The characteristic equation can be expressed as:
where:
Factoring the polynomial
-
Poles:
${(0, 0), (-2, 0), (-2 + j1), (-2 - j1)}$ -
Zeros:
$\emptyset$
From this information, we can mark the poles and zeros of the open-loop system in the
The number of separate loci can be determined by:
Where:
$n_p = \text{Number of finite poles}$ $n_z = \text{Number of finite zeros}$
Thus,
The Root Locus is symmetric with respect to the real axis. Observing the previous sketch, we can see that the segment above the real axis is a mirror image of that below.
The
and
Calculating these values yields:
The angles of the asymptotes are calculated as follows:
- For
$q = 0$ :
- For
$q = 1$ :
- For
$q = 2$ :
- For
$q = 3$ :
Now we can refine our sketch by plotting the asymptotes and their corresponding angles.
Next, we determine the points where poles intersect the real axis, if any. To find these points, we set the derivative
Expanding this gives us:
Taking the derivative:
We find the roots of the equation:
The roots are:
We consider only the real root:
Now, we need to determine the points where the imaginary axis is crossed, if any. We apply the Routh-Hurwitz criterion on
Simplifying leads to:
Now, we check stability using the Routh-Hurwitz criterion on the characteristic polynomial
Calculating the intermediate coefficients gives:
- For
$a$ :
- For
$b$ :
For the system to be critically stable (or unstable), we set
Applying this value of
Solving for
These points indicate where the system crosses the imaginary axis.
With all points determined, we can use the angle condition to find the departure angle
Noting the symmetry, we calculate:
- For
$P(-2,1)$ :
This gives us:
Consequently, the sketch of the Root Locus appears as follows:
To validate our sketch, we can utilize software for plotting, such as the
LGR - Desmos version created by the talented @Lucas-Morais-Freire:
Alternatively, we can use our simple Python tool available in this repository to generate the plot. Executing the code will yield the following output:
python ./main.py
# Poles of the open-loop system: [-2.+1.j -2.-1.j -2.+0.j 0.+0.j]
# Zeros of the open-loop system: []
# Root Locus Analysis:
# Number of poles: 4
# Number of zeros: 0
# Pole angles (in degrees): [ 153.43494882 -153.43494882 180. 0. ]
To conclude, when
Leading to:
This results in:
Adding these points to the Root Locus results in the following plot:
The dominant poles for
These dominant poles significantly influence the system's dynamics since they are nearest to the imaginary axis.
To execute the script, use the following command:
python ./main.py
To run the project in a virtual environment:
python3 -m venv venv
# deactivate # -> if necessary
source venv/bin/activate
pip install -r requirements.txt
python ./main.py
To update the requirements.txt
file with the current dependencies, run:
: > requirements.txt && pip freeze > requirements.txt