Abstract-Efficiency, comfort, and convenience are three major aspects in the design of control systems for residential Heating, Ventilation, and Air Conditioning (HVAC) units. In this paper we propose an optimization-based algorithm for HVAC control that minimizes energy consumption while maintaining a desired temperature in a room. Our algorithm uses a Computer Fluid Dynamics model, mathematically formulated using Partial Differential Equations (PDEs), to describe the interactions between temperature, pressure, and air flow. Our model allows us to naturally formulate problems such as controlling the temperature of a small region of interest within a room, or to control the speed of the air flow at the vents, which are hard to describe using finite-dimensional Ordinary Partial Differential (ODE) models. Our results show that our algorithm produces significant energy savings without a decrease in comfort.