## 3 CPC-Based Reactive Power Compensation Optimization Model
### Constraint Condition  
The amplitude of the APF compensation current is limited to the peak current of the power electronic device. For a selected device, it is a fixed value and can be defined as \(l_{\text{cmax}}\).  
If this value is exceeded by the compensated current, the APF will stop working, and the device can even be damaged.  
The reactive power compensation current of the compensation device \(i_{cc}\) cannot exceed the difference between the limit current of the compensation device and the \(DC\)-side voltage-stabilizing current \(i_{cu}^{*}\). When the reactive power compensation device compensates for the reactive current, the amplitude current constraint in the reactive power optimization problem of the compensation device can be expressed as follows:  
\[s.t.1\;\text{max}(I_{Acc\text{max}}^{*},I_{Bcc\text{max}}^{*},I_{Ccc\text{max} }^{*})\leq l_{cc\text{max}} \tag{19}\]  
where \(I_{Acc\text{max}}^{*}\), \(I_{Bcc\text{max}}^{*}\), and \(I_{Ccc\text{max}}^{*}\) are the three-phase reference compensation current amplitudes of the compensation device. \(l_{cc\text{max}}\) is the amplitude of the reactive power compensation current of the compensation device.  
In order to prevent negative compensation or over-compensation of a phase reactive current, the upper and lower limits of the optimized compensation parameters are constrained to 1 and 0:  
\[s.t.2\left\{\begin{array}{l}0\leq w_{r}\leq 1\\ 0\leq w_{n}\leq 1\\ 0\leq w_{z}\leq 1\\ 0\leq w_{g}\leq 1\end{array}\right. \tag{20}\]  
Considering only the compensation fundamental current component, the method of calculating the three-phase output compensation current amplitude of the reactive power compensation device is analyzed below.  
When the initial phase angle of the phase \(A\) voltage is set to 0\({}^{\circ}\), and the three-phase voltage is symmetrical, the three-phase reference compensation current output by the reactive power compensation device is as follows:  
\[\left\{\begin{array}{l}i_{Acc1}^{*}(t)=w_{r}l_{\text{max}}\cos(\omega t-90^{ \circ})+w_{n}l_{\text{max}}\cos(\omega t+\varphi_{n})+w_{z}l_{\text{max}}\cos (\omega t+\varphi_{z})\\ i_{Bcc1}^{*}(t)=w_{r}l_{\text{max}}\cos(\omega t-210^{\circ})+w_{n}l_{\text{ max}}\cos(\omega t+120^{\circ}+\varphi_{n})+w_{z}l_{\text{max}}\cos(\omega t+ \varphi_{z})\\ i_{CC1}^{*}(t)=w_{r}l_{\text{max}}\cos(\omega t+30^{\circ})+w_{n}l_{\text{ max}}\cos(\omega t-120^{\circ}+\varphi_{n})+w_{z}l_{\text{max}}\cos(\omega t+ \varphi_{z})\end{array}\right. \tag{21}\]  
where \(\varphi_{n}\) and \(\varphi_{z}\) are the initial phases of negative-sequence current and zero-sequence current, respectively. If the initial phase angle of the phase \(A\) voltage is \(\varphi\), \(\varphi\) should be added to the initial phase angle of each component of the decomposition.  
Taking phase \(A\) as an example, the amplitude of the output current of the compensation device can be calculated based on orthogonal decomposition:  
\[\left\{\begin{array}{l}I_{Acc1x}^{*}=I_{\text{max}}w_{r}\cos(-90^{\circ})+I _{\text{max}}w_{n}\cos\varphi_{n}+I_{\text{max}}w_{z}\cos\varphi_{z}\\ I_{Acc1y}^{*}=I_{\text{max}}w_{r}\sin(-90^{\circ})+I_{\text{max}}w_{n}\sin\varphi _{n}+I_{\text{max}}w_{z}\sin\varphi_{z}\end{array}\right. \tag{22}\]  
In this way, the amplitude of the phase \(A\) current of the compensation device is as follows:  
\[I_{Acc1\text{max}}^{*}=\sqrt{I_{Acc1x}^{*}+I_{Acc1y}^{*}}^{2} \tag{23}\]  
When considering that the harmonic current component is compensated for, the phase \(A\) reference compensation current amplitude of the compensation device is as follows:  
\[I_{Acc\text{max}}^{*}=I_{Acc1\text{max}}^{*}+I_{Ag\text{max}}^{*} \tag{24}\]  
where \(I_{Ag\text{max}}^{*}\) is the amplitude of the reference generative current in phase \(A\) of the compensation device.  
Similarly, the amplitude of the \(B\) and \(C\) two-phase reference compensation currents can be obtained.