Most of the fundamental optimization problems for power systems are highly non-convex and NP-hard (in the worst case), partially due to the nonlinearity of certain physical quantities, e.g. active power, reactive power and magnitude of voltage. The classical optimal power flow (OPF) problem is one of such problems, which has been studied for half a century. Recently, we obtained a condition under which the duality gap is zero for the classical OPF problem and hence a globally optimal solution to this problem can be found efficiently by solving a semidefinite program. This zero-duality-gap condition is satisfied for IEEE benchmark systems and holds widely in practice due to the physical properties of transmission lines. The present paper studies the case when there are other common sources of non-convexity, such as variable shunt elements, variable transformer ratios and contingency constraints. It is shown that zero duality gap for the classical OPF problem implies zero duality gap for a general OPF-based problem with these extra sources of non-convexity. This result makes it possible to find globally optimal solutions to several fundamental power problems in polynomial time.