Optimal flow for general multi-carrier energy systems, including load flow equations