# Optimal Power Flow Solutions for Power System Considering Electric Market and Renewable Energy
## 2 Formulation of the Studied Problem
### Constraints  
Power balance: The balance of power between the source (i.e., power generated by thermal units, wind power plants, and capacitors) and consumption (i.e., demands of all loads and losses on all transmission lines) is a common restriction. The constraint is for active power and reactive power as follows:  
\[\sum_{k=1}^{N_{TUs}}PT_{k}+\sum_{m=1}^{N_{Wp_{k}}}PW_{m}\ -\ \sum_{l=1}^{N_{Loads}} PLoad_{l}-\sum_{b=1}^{N_{Bus}}P_{Loss,b}=0 \tag{4}\]  
\[\sum_{k=1}^{N_{TUs}}QT_{k}+\sum_{c=1}^{N_{Caps}}QC_{c}+\sum_{m=1}^{N_{Wp_{k}}} QW_{m}\ -\ \sum_{l=1}^{N_{Loads}}QLoad_{l}-\sum_{b=1}^{N_{Bus}}Q_{Loss,b}=0 \tag{5}\]  
However, the constraints (4) and (5) cannot be reached directly by power flow method, Newton-Raphson. The Matpower program [49] is used in the study to reach power flows, and the program uses the Newton-Raphson method [50]. The two general constraints are converted into the balance power constraint at each node as follows:  
\[PT_{i}\ +\ PW_{i}\ -PLoad_{i}=Vol_{i}\ \sum_{j}^{N_{nodes}}Vol_{j}\big{[} GC_{ij}\cos\big{(}\theta_{i}-\theta_{j}\big{)}+BS_{ij}\sin\big{(}\theta_{i}- \theta_{j}\big{)}\ \big{]};\ i=1,\ldots,\ N_{nodes} \tag{6}\]  
\[QT_{i}+QC_{i}\ -QLoad_{i}=Vol_{i}\ \sum_{j}^{N_{nodes}}Vol_{j}\big{[} GC_{ij}\cos\big{(}\theta_{i}-\theta_{j}\big{)}\ -\ BS_{ij}\sin\big{(}\theta_{i}-\theta_{j}\big{)}\ \big{]};\ i=1,\ldots,\ N_{nodes} \tag{7}\]  
where \(QC_{i}\) is the reactive power generation of the capacitors at the \(i\)th node and \(QC_{i}\) must be constrained by:  
\[QC_{i}^{Min}\ \leq QC_{i}\leq\ QC_{i}^{Max};i=1,\ldots,\ N_{nodes} \tag{8}\]  
Limitation on active and reactive power generation: As operating, thermal units and wind power plants must satisfy the limitation of active and reactive generation capacity as follows:  
\[PT_{k}^{Min}\leq\ PT_{k}\ \leq\ PT_{k}^{Max} \tag{9}\]  
\[PW_{m}^{Min}\leq\ PW_{m}\ \leq\ PW_{m}^{Max} \tag{10}\]  
\[QT_{k}^{Min}\leq\ QT_{k}\ \leq\ QT_{k}^{Max} \tag{11}\]  
\[QW_{m}^{Min}\leq\ QW_{m}\ \leq\ QW_{m}^{Max} \tag{12}\]  
Limitation on voltage: All loads and generators at the \(i\)th node must be kept within an acceptable operating range, as follows:  
\[Vol_{i}^{Min}\leq Vol_{i}\leq\ Vol_{i}^{Max};\ i=1,\ldots,\ N_{nodes} \tag{13}\]  
\[Vol_{k}^{Min}\leq Vol_{k}\leq\ Vol_{k}^{Max};\ k=1,\ldots,\ N_{TUs} \tag{14}\]  
where \(Vol_{i}^{Min}\) and \(Vol_{i}^{Max}\), and \(Vol_{k}^{Min}\) and \(Vol_{k}^{Max}\) are the smallest and highest voltage values of load at the node \(i\) and of the thermal unit \(k\). In the study, the two values are selected to be 0.95 and 1.1 pu, respectively [4].  
Transformer constraints: The transformer's tap setting must fall within the lower and upper limits indicated by the inequality below:  
\[Tp^{Min}\leq\ Tp_{n}\ \leq\ Tp^{Max}\ ;\ n=1,\ldots,\ N_{TF} \tag{15}\]  
Limitation of transmission lines: Transmission lines are conductors connecting each two nodes. The transmission limit of the lines is also the limit of the conductors. However,parameter of transmission lines is apparent power, while that of conductors is current. So, the current limit must be converted into apparent power limit as follows:  
\[S_{b}\ \leq\ S_{b}^{Max}\ ;\ b=1,\ldots,\ N_{Brs} \tag{16}\]  
where \(\ S_{b}\) and \(\ S_{b}^{Max}\) are the operating apparent power and the maximum capacity of the \(b\)th transmission line.