In this paper, we propose a PDE-based optimization motivated by the problem of microfluidic heat transfer to finding the optimal incompressible velocity fields in 2D domain. To solve this optimization model, we use spectral method to discretize the model to obtain an ODE based optimization. This way significantly reduces the complexity of the discretization optimization model, and gives a more accurate approximation of the original PDE based optimization. Some theoretical results are obtained.