## 2 Problem Formulation
### DSTATCOM-Integrated Load Flow Steps  
The goal of load flow in a power system is to determine the steady-state voltages, currents, and power flows in all branches and nodes of the system under a given set of load and generation conditions. The classical load flow techniques, such as the Newton-Raphson and Gauss-Seidel methods, are not well-suited for solving load flow problems in radial distribution systems (RDS), due to the high R/X ratios inherent in these systems. In contrast, the forward-backward sweep algorithm [16], which is based on the fundamental principles of Kirchhoff's laws, can be employed to determine the system's power flow. From Figure 1, the current flowing in the branch between nodes \(i\) and \(i+1\) is given by:  
\[I_{i,i+1}=\frac{P_{i}-jQ_{i}}{V_{i}\angle-\delta_{i}} \tag{13}\]  
Active and reactive losses within the branch are given by:  
\[\left\{ \begin{array}{ll}P_{l(i,i+1)}=r_{i,i+1}\frac{\left(P_{i}^{2}+Q_{i}^{2} \right)}{V_{i}^{2}}\\ Q_{l(i,i+1)}=x_{i,i+1}\frac{\left(P_{i}^{2}+Q_{i}^{2}\right)}{V_{i}^{2}}\end{array} \right. \tag{14}\]  
The active and reactive powers at the beginning of the branch are given by:  
\[\left\{ \begin{array}{ll}P_{i}=P_{i+1}+P_{l(i,i+1)}\\ Q_{i}=Q_{i+1}+Q_{l(i,i+1)}\end{array} \right. \tag{15}\]  
Considering Equations (14) and (15):  
\[I_{i,i+1}=\frac{V_{i}\angle\delta_{i}-V_{i+1}\angle\delta_{i+1}}{r_{i,i+1}+jx_ {i,i+1}}=\frac{P_{i}-jQ_{i}}{V_{i}\angle-\delta_{i}} \tag{16}\]  
Separating the real and imaginary parts:  
\[\left\{ \begin{array}{ll}V_{i}V_{i+1}\cos(\delta_{i+1}-\delta_{i})=V_{i}^{2} -\left(P_{i}r_{i-1,i}+Q_{i}x_{i-1,i}\right)\\ V_{i}V_{i+1}\sin(\delta_{i+1}-\delta_{i})=Q_{i}r_{i-1,i}-P_{i}x_{i-1,i}\end{array} \right. \tag{17}\]  
From Equation (17):  
\[V_{i+1}=\left\{V_{i}^{2}-2(P_{i}r_{i+1}+Q_{i}x_{i+1})\right.+\left(r_{i,i+1}^{ 2}+x_{i,i+1}^{2}\right)\frac{\left(P_{i}^{2}+Q_{i}^{2}\right)}{V_{i}^{2}} \right\}^{1/2} \tag{18}\]\[\delta_{i+1}=\delta_{i}+\tan^{-1}\Bigg{\{}\frac{Q_{i}r_{i,i+1}-P_{i}x_{i,i+1}}{V_{i ^{2}}^{2}-(P_{i}r_{i,i+1}+Q_{i}x_{i,i+1})}\Bigg{\}} \tag{19}\]  
The forward-backward sweep algorithm operates through the following steps:  
**Step 1:** Preparation--Read system data, including the system's topology, bus characteristics, branch parameters, load consumption values, and DSTATCOM data, along with its operating constraints. **Step 2:** Initialization--Assume a flat voltage profile as the starting point for the initial voltages and set the first iteration, denoted as \(k\), to 0. **Step 3:** Nodal Current Calculation--Calculate the injected current at each load bus \(i\) using the assumed known voltage, with the following equation:  
\[I_{i}^{(k)}=conj\Bigg{(}\frac{P_{L,i}+jQ_{L,i}}{V_{i}^{(k-1)}}\Bigg{)}+\left( \frac{jB_{i}}{2}V_{i}^{(k-1)}\right) \tag{20}\]  
\(B_{i}\) is the susceptance, where \(P_{L,i}\) and \(Q_{L,i}\) are the active and reactive load demands, and \(V_{i}^{(k-1)}\) is the bus voltage at the \((k-1)^{th}\) iteration. **Step 4:** Adding Current Injected by the DSTATCOM--For each bus where the DSTATCOM is connected, calculate the current it injects using Equation (4). Then, add this calculated current to the previously injected current on the same bus. \[I_{i}^{(k)}=I_{i}^{(k)}+I_{DSTAT} \tag{21}\]  
**Step 5:** Backward Sweep--Starting with the last-ordered branch, the current \(J_{i+1}^{(k)}\) flowing between the node \(i\) and its preceding node \(i-1\) is determined using the BIBC (branch-current to bus-current) matrix [16], as follows:  
\[J_{i,i-1}^{(k)}=[BIBC]\times\left[I_{i}^{(k)}\right] \tag{22}\]  
**Step 6:** Forward Sweep--The node voltages are updated iteratively, starting from the root bus, in accordance with the following equation:  
\[V_{i+1}^{(k)}=V_{i}^{(k)}-Z_{i,i+1}J_{i,i-1}^{(k)} \tag{23}\]  
where \(Z_{i,j+1}\) is the series impedance of branch \(i\), \(i+1\).