# An Improved Mixed AC/DC Power Flow Algorithm in Hybrid AC/DC Grids with MT-HVDC Systems
## 3 Mixed AC/DC Power Flow Algorithm  
The mixed AC/DC PF algorithm, which is an improved sequential AC/DC PF algorithm [19], can be used to obtain the initial operating points to analyze the dynamics of the hybrid AC/DC grids by solving the AC and DC PF sequentially and keeping both the converter station power and voltage at each node constant.  
In order to implement the mixed AC/DC PF algorithm, the per-unit conversion should be performed for the entire system. Each converter station is connected to both AC and DC grids. The AC side of the converter station is modeled by a voltage source connected to the AC bus through a phase reactor (\(Z_{C}=R_{C}+j\omega L_{C}\)), a capacitor (\(Z_{F}=\frac{-j}{\omega c}\)), and a transformer (\(Z_{TR}=R_{TR}+j\omega L_{TR}\)). Also, the DC side of the converter station is connected to the DC grid. The power losses at the converter station are considered as a quadratic function of the converter station Root Mean Square (RMS) AC current as follows [23]:  
\[P_{Loss}=a+bI+cI^{2} \tag{30}\]  
where \(a\), \(b\), and \(c\) are the loss coefficients.  
It should be noted that,  
\[P_{gi}+P_{DCi}+P_{Lossi}=0 \tag{31}\]  
Assume an MT-HVDC system with \(n\) converter stations and \(n_{DC}\) DC lines. For AC/DC PF analysis, at least one converter station should be capable of controlling \(V_{DC}\) (DC-slack bus) in the entire DC grids, and the rest of the converter stations control the active power. The detailed explanations of the mixed AC/DC PF are given as follows:  
1. Start by an initial guess of the active power injected to the AC grid by the DC-slack converter station at the \(l\)th iteration (\(P_{gs_{n}}^{(l)}\)), where \(n_{s}\) represents the index of the DC-slack bus.
2. Transform all converter stations which are connected to the \(j\)th bus to PV or PQ buses based on their control modes (including droop-based control strategies) and solve the AC PF. At the \(l\)th iteration, the active power injected by all the non-slack converter stations is constant, while \(P_{gs_{n}}^{(l)}\) changes.
3. Calculate the converter station losses using Equation (30) considering the active power injected by the \(i\)th converter to the AC grid (\(P_{gi}^{(l)}\)) and the active power injected by the \(i\)th converter station to the DC grid (\(P_{DCi}^{(l)}\)). In this step, the AC/DC connections and the converter stations' limits should be considered.
4. Solve the DC PF for the DC grid using the Newton-Raphson method. In this step, the DC-slack bus regulates the DC voltage (\(V_{DCn_{s}}^{(0)}\)) initially, and the DC buses determine the active power injection (\(P_{DCi}^{(l)}\)). Therefore, the DC voltage at each bus and also \(P_{DCn_{s}}^{(l)}\) are calculated.
5. Compute DC-slack and droop buses iteration (\(k\)). As a new value of \(P_{gs_{n}}^{(l+1)}\) is calculated, considering the converter station losses, 1. Initialization: \(P_{gn_{s}}^{(k=0)}=P_{gn_{s}}^{(l)}\).
2. Solve the branch \(j\), \(n_{s}-g\), \(n_{s}\) considering \(V_{jns}\), \(\theta_{jns}\), \(Q_{jns}\), and \(P_{gs_{n_{s}}}^{(k)}\) using the Newton-Raphson method.
3. Obtain the new value of \(P_{gs_{n}}^{(k+1)}\) with \(P_{DCn_{s}}\) and \(P_{Lossns}\) using Equations (30) and (31).
4. If \(\left|P_{gs_{n}}^{(k+1)}-P_{gs_{n_{s}}}^{(k)}\right|<\varepsilon\), stop the calculations. Otherwise, \(k=k+1\) and return to step II. The output is \(P_{gn_{s}}^{(k+1)}\).
6. Check the convergence criterion. If \(\left|P_{gs_{n}}^{(k+1)}-P_{gs_{n}}^{(k)}\right|<\varepsilon\), stop the calculations. Otherwise, \(k=k+1\) and return to step 1.  
It should be noted that all linear and nonlinear variables are considered in the mixed AC/DC PF algorithm. Based on the topology of the hybrid AC/DC grids, the rating and length of each transmission line are determined. Also, the droop parameters and reference voltage have a direct impact on the reference power.