An Optimal Power Flow with User-Defined Objective Functions and Constraints Zulmar S. Machado Jr, Glauco N. Taranto, Djalma M. Falc˜ ao Federal University of Rio de Janeiro Rio de Janeiro, Brazil zulmar@coep.ufrj.br, tarang@coep.ufrj.br, falcao@nacad.ufrj.br Abstract - This paper presents an optimal power flow (OPF) methodology with user-defined objective functions and constraints. First and second-order automatic differen- tiation techniques are applied, allowing flexibility to the pro- gram. The algorithm is based on an interior-point method with an embedded full Newton-Raphson solver. The com- putational framework is structured with advanced concepts of object oriented modeling (OOM) using the C++ language. This framework readily allows modeling generalizations, making it possible to incorporate detailed models of gener- ators and their controls. Numerical results are presented for a 45-bus equivalent of the Southern Brazilian power system. Keywords - Optimal Power Flow, User-defined OPF, Au- tomatic Differentiation, Object-Oriented Modeling 1 INTRODUCTION I N present day operation of electric power systems, where market-driven rules have led the systems to oper- ate with reduced security margins, it is of paramount im- portance the availability of robust and flexible computa- tional tools for system analysis. In this context, the object- oriented modeling encompasses these desirable features and puts itself as an alternative to becoming a framework for development of new power system tools. Generally, in conventional Optimal Power Flow (OPF) programs, models are pre-defined and cannot be modified by users, unless changing the source code. Some pro- grams allow users to choose objective functions and con- straints, among a pre-defined set. Although being able to fulfill most of the usual analysis needs, they limit, to some extent, the desires of users that would like to analyze un- usual objectives and constraints. This paper proposes an OPF able to have user-defined objective functions and constraints, without the need to change and recompile the program source code. The objective function and constraints are constructed from an user-defined format utilizing a structure called Model, which aggregates parameters, equations and in- formation flows of a given power system apparatus. This technique readily allows for generalizations in the formu- lations of objective functions and constraints. Further- more, it allows for example, the utilization of more de- tailed generator models, making it possible to have inter- nal generator variables as part of the objective function. Models for round-rotor and salient-pole synchronous ma- chines are options available in the program. The represen- tation is possible because the OPF formulation is based on augmented algebraic power system equations. The proposed OPF methodology utilizes automatic differentiation techniques, and calculates the first and second-order derivatives of the objective function and of the equality and inequality constraints, thus obtaining the Hessian and Jacobian matrices of the lagrangian func- tion. This capability of automatic differentiation aggre- gates new features to the program, making readily possi- ble the incorporation of any differentiable mathematical function in the OPF formulation. It is presented an OPF algorithm with the Karush- Kuhn-Tucker (KKT) optimality conditions solved via a full Newton-Raphson method. The algorithm is based on an interior-point method implemented with object- oriented modeling in C++. Numerical results are presented for a 45-bus equiva- lent of the Southern Brazilian power system. 2 MODELING For transient and steady-state stability analysis, a power system is represented by a set of nonlinear differ- ential and algebraic equations as given by (1) below. ˙ x = f (x, y) (1) 0 = g(x, y) where x is the vector of state variables, such as rotor speed and angle, y is the vector of algebraic variables, such as the complex nodal voltages, and f and g are vectors of non-linear functions describing, respectively, the differ- ential equations modeling the system dynamical elements (generators and their controllers, FACTS devices, induc- tion motors, etc.) and the algebraic equations modeling the network. Conventional OPF formulations are only based in the set of algebraic equations given in (1), which basically represents the load flow equations. Steady-state or small- signal stability analysis are based in the equilibrium point of (1) yielding the following representation: ˙ x = 0 = f (x, y) (2) 0 = g(x, y) The set of algebraic equations given by (2) is then used as a new set of equality constraints in an OPF formulation, similarly to the methodology used in the quasi steady-state simulation presented in [1] and originally introduced in [2]. The addition of the equation f (x, y)=0 to the set of equality constraints opens a whole range of opportunities 15th PSCC, Liege, 22-26 August 2005 Session 21, Paper 3, Page 1