This paper is focused on the mathematical modeling of unified power flow controller (UPFC), which is an advanced and versatile member of flexible ac transmission systems (FACTS). The proposed model is for the implementation of the device in conventional Newton-Raphson (NR) power flow algorithm and in power system analysis software package (PSASP). The model, derived from two-voltage source representation, is presented and analyzed in detail. The model represents a more robust and feasible alternative to others, because it is able to take operational losses of UPFC into account. A program in Fortran-77 language has been written in order to extend conventional NR algorithm based on proposed model. The model has also been adapted into PSASP by means of user-defined modeling technique. Different computer simulation studies performed on IEEE 14-bus and IEEE 30-bus test systems are presented in the paper to test and compare the two approaches. A robust and reliable convergence of the power flow studies is guaranteed by implementing the two approaches with high convergence speeds. UPFC can be theoretically located anywhere along a transmission line. In this respect, also the effects of UPFC allocation on power system operation have been investigated in detail. (c) 2007 Elsevier Ltd. All rights reserved.