  NV center is one of the most promising platforms in the field of quantum
sensing. Magnetometry based on NV center, especially, has achieved a concrete
development in regions of biomedicine and medical diagnostics. Improving the
sensitivity of NV center sensor under wide inhomogeneous broadening and filed
amplitude drift is one crucial issue of continuous concern, which relies on the
coherent control of NV center with higher average fidelity. Quantum optimal
control (QOC) methods provide access to this target, nevertheless the high time
consumption of current methods due to the large number of needful sample points
as well as the complexity of the parameter space has hindered their usability.
In this paper we propose the Bayesian estimation phase-modulated (B-PM) method
to tackle this problem. In the case of state transforming of NV center
ensemble, the B-PM method reduces the time consumption by more than $90\%$
compared to the conventional standard Fourier base (SFB) method while
increasing the average fidelity from $0.894$ to $0.905$. In AC magnetometry
scenery, the optimized control pulse given by B-PM method achieves a eight-fold
extension of the coherence time $T_2$ compared to rectangular $\pi$ pulse.
Similar application can be made in other sensing situations. As a general
algorithm, the B-PM method can be further extended to open- and closed-loop
optimization of complex systems based on a variety of quantum platforms.
