Design of a compact photonic crystal sensor