Inverse Design of Photonic Crystals through Automatic Differentiation