1 Introduction

The trapped-ion system has been proven to be a promising candidate for quantum computing [1,2,3]. In the implementation of trapped-ion quantum computing, qubits can be encoded in a two-level system formed by the electronic ground and the long-lived excited state of an ion. The encoded states should have long enough relaxation and coherence time to complete the required quantum gate operations [4,5,6,7,8]. However, experimentally, magnetic field fluctuation greatly limits the coherence time of ion qubits, especially for those optical qubits [9, 10]. This is because the ambient magnetic field will lead to shift of the qubit energy levels via Zeeman effect.

The fluctuation of ambient magnetic field is mainly caused by ac power system. Although one can synchronize the experimental cycles with the power line to reduce the influence and prolong the coherence time of ion qubits [9], this well-known line trigger method will limit the duration of each experimental cycle to an integer multiple of the mains cycle time, i.e. 20 ms in our case, and lead to reduction of experimental efficiency. In addition, line trigger does not really eliminate the magnetic field jitter, and energy level of the qubit will still shift during the quantum operation stage, which will become a serious problem when long operation time is needed.

Magnetic shielding is usually used to solve this problem. However, it is less efficient for the low frequency noise [11] and often reduces optical access [12, 13]. In addition to passive methods, a common approach is using magnetometers to monitor the magnetic field fluctuation and then actively compensate it. But since the magnetometer can not be installed at the location of ion qubit, the compensation effect is usually imperfect [14,15,16]. Moreover, feedback and feedforward circuits are employed to suppress the magnetic field fluctuation, and the circuit design is complicated [17].

In this paper, a simple scheme of compensating the deterministic low-frequency magnetic field interference in the center of ion trap is demonstrated. This scheme utilizes a single \(^{40}\) \(\hbox {Ca}^+\) ion qubit as probe to detect the periodic magnetic field fluctuation. Then a programmable signal source is used to compensate the ac field. As a demonstration, we use an arbitrary waveform generator (AWG) for compensation, which can generate signal composed of 50 Hz sine wave and its harmonic components. By measuring the variation of atomic transition frequency over one cycle of the power supply, it is observed that magnetic field fluctuation is reduced by 86\(\%\). By measuring the coherence time \(T_2^*\) with standard Ramsey experiments [18], a 35-fold extension of the coherence time is observed from 70 to 2500 \(\upmu\)s without line trigger.

2 Compensation scheme and experimental setup

Mains electricity in the laboratory is usually transmitted through a three-phase alternating current system. Different loads generate the third (and higher) harmonic current in the neutral conductor, yielding not only 50 Hz but also a strong component of 150 Hz [17, 19]. In our experiment, the main magnetic field of the trapped-ion system is produced by permanent magnets, which, therefore, is not the source of magnetic field fluctuation. We deduce it is the magnetic field emitted by the power line that leads to the time varying Zeeman shift of the energy levels, which results in the loss of coherence. We measured the variation of atomic transition frequency over one cycle of power line and verified that the magnetic field fluctuates in a periodic manner. Note that in trapped-ion system, only the magnetic field at the trap center is concerned. Therefore, we can use the trapped ion itself as a probe and compensate the magnetic field fluctuation at its position by an intuitive active compensation method.

The Zeeman splitting gap of a atomic energy level is determined by the magnitude of overall magnetic field. Since the principal component of the magnetic field (\(B_z\) for example), is usually several hundred times stronger than the component in other directions (i.e. \(B_x\) and \(B_y\)), the quantum polarization axis is almost coincide with z axis. The overall magnetic field, expressed as \(B=\sqrt{B_x^2+B_y^2+B_z^2}\), is therefore, much more sensitive to the disturbance along the principal direction than along other directions, since \(\frac{\partial {B}}{\partial {B_x}}:\frac{\partial {B}}{\partial {B_y}}:\frac{\partial {B}}{\partial {B_z}} = B_x:B_y:B_z\). Therefore, the effects of disturbances along other axes are negligible before one can suppress the one along principal axis to approximately \(1\%\), and only magnetic fluctuation alone the main field direction is concerned in our work.

As shown in Fig. 1, the main equipment used in our scheme includes a three-turn magnetic field compensation coil and a programmable AWG (Keysight 33600A). The compensation coil is installed in the direction of quantum polarization axis (along the main field) and driven by an AWG.The AWG can generate multi-tone signal with adjustable phases. It then drives the coil to produce an alternating magnetic field to compensate the fluctuation along the main field direction at position of the ion. In the experiment, magnetic field fluctuation is probed by a single \(^{40}\) \(\hbox {Ca}^+\) ion, which is loaded into the blade-shaped linear Paul trap by three-step photoionization method with 732 nm and 423 nm laser beams [20]. The 397 nm linear beam is used for Doppler cooling and fluorescence detection. The 397 nm \(\sigma\) laser beam is used to initialize the ion state to \(S_{1/2}(m_J=-1/2)\). The 729 nm axial beam is used to shelve the \(S_{1/2}(m_J=-1/2)\) state to \(D_{5/2}\) state for fluorescence dependent state detection. For \(^{40}\) \(\hbox {Ca}^+\) ions, qubit is usually encoded in the Zeeman sublevels of ground state \(S_{1/2}\) and metastable state \(D_{5/2}\). But since the electric quadrupole transition is driving by a narrow linewidth 729 nm laser beam, the phase noise of this laser will also be a problem that affects the coherence time [21]. In our experiment, the spin qubit is encoded in the Zeeman sublevels \(S_{1/2}(m_J =-1/2)\) and \(S_{1/2}(m_J=1/2)\), with a frequency gap about 10 MHz, which can be manipulated by Raman transitions [22, 23]. As shown in Fig. 2, the two-photon stimulated Raman transition is driven by two 397 nm laser beams with detuning of \(\Delta =-180\) GHz [24, 25]. Since both Raman beams are generated from the same laser and propagate through the same optical fiber, linewidth of this transition is insensitive to the laser frequency jitter [23, 26]. Besides, the effective wave-vector of copropagating Raman beams is zero, the transition is insensitive to ion’s motion [23]. The motional decoherence is not involved in our experiment. Therefore, the magnetic field fluctuation becomes the primary factor that restricts the coherence time of ion qubits.

Fig. 1
figure 1

Schematic view of the experimental setup. The black dots represent permanent magnets used to generate the main magnetic field. The wave lines indicate the low-frequency magnetic field fluctuation induced by power line

Fig. 2
figure 2

Scheme of the stimulated Raman transitions for a \(^{40}\) \(\hbox {Ca}^+\) ion. The Zeeman sublevels of the ground state are split by 10.057 MHz. The effective detuning \(\delta\) from the transition \(S_{1/2}(m_J =-1/2) \leftrightarrow S_{1/2}(m_J=1/2)\) is given by \(\omega _{1}-\omega _{2} = \omega _0 +\delta\). Both beams are detuned to the two-level resonance frequency by \(\Delta = -180\) GHz

The typical experimental sequence in our scheme starts with Doppler cooling of a single \(^{40}\) \(\hbox {Ca}^{+}\) ion. Subsequently, by applying 397 nm \(\sigma ^-\) laser pulse, the ion can be initialized to \(S_{1/2}(m_J =-1/2)\). Then, the spin qubit is manipulated by two red-detuned 397 nm laser beams. To distinguish the qubit states (\(S_{1/2}(m_J =-1/2)\) and \(S_{1/2}(m_J=1/2)\)), electron shelving technique [27] is employed, where a frequency-selective laser pulse near 729 nm is used to transfer \(S_{1/2}(m_J =-1/2)\) to the metastable \(D_{5/2}\) before applying the fluorescence detection beams.

In order to quantitatively measure the power-line-relevant low-frequency magnetic fluctuation, we use line trigger method to synchronize experimental sequence with the phase of power line. The shift of Raman transition frequency is measured at different delay times relative to the power signal, which characterizes the magnetic field fluctuation. To check whether the magnetic field fluctuation is suppressed by our method, the variation of resonance frequency during one cycle of the power line signal is recorded before and after compensation. In addition, the dephasing time of ion qubit is also measured in both cases by scanning the free evolution time in the Ramsey experiment.

3 Results and analysis

Using above setup, the resonance frequency shift induced by background magnetic field at different delay times is quantitatively measured. The result is shown in Fig. 3a, frequency shift caused by the power line is about 7 kHz, indicating a peak–peak amplitude of 2.5 mGauss for the magnetic fluctuation. To extract the amplitude and phase of the main component of magnetic fluctuation, nonlinear fitting was carried out, including frequency components of 50 Hz, 100 Hz, 150 Hz and 200 Hz. The fitting function is

$$\begin{aligned} \begin{aligned} f = A +\sum _{i=1}^4B_i \cos (2 \pi \times 50i \times t +\phi _i), \end{aligned} \end{aligned}$$
(1)

where f is the shifted resonance frequency, t is the phase delay time with respect to power line, \(B_i\) and \(\phi _i\) \((i=1,2,3,4)\) denote the amplitude and initial phase of the i-th order harmonic, respectively.

As shown in Table 1, we obtain the fluctuation amplitudes of the four strongest harmonics and find that 50 Hz and 150 Hz components are the most dominant. These components greatly affect the coherence time of ion qubits. Figure 3b shows the Ramsey fringe of transition \(S_{1/2}(m_J =-1/2) \leftrightarrow S_{1/2}(m_J=1/2)\). Each point is obtained by averaging over 100 experiments and the fitting function [28] is

$$\begin{aligned} P_S = \frac{1}{2} [\exp (-\tau ^2/T_{2}^{*2}) \cos (\omega \tau + \phi _j)+1 ], \end{aligned}$$
(2)

where \(P_S\) is the population of \(S_{1/2}(m_J=1/2)\) state, \(\omega\) is the oscillation frequency of the fringe, \(\tau\) is the free precession time, \(\phi _j\) is the phase offset and \(T_{2}^{*}\) denotes the coherence time. Without line trigger and reverse compensation, the coherence time \(T_2^*\) extracted is around 70 \(\upmu\)s.

Table 1 Dominant components of frequency variation induced by magnetic fluctuation
Fig. 3
figure 3

a Variation in resonant frequency within a power line cycle. Measured data is marked by solid square, and the red line indicates the fitted curve with empirical formula Eq. (1). b Ramsey interference fringe under the decoherence effect of power line. Each of the measured population is the average of 100 experiments and the solid red line is fitted curve using empirical function Eq. (2). The error is calculated using projection measurement noise model

To suppress the dominant components of the ac magnetic field, we implement reverse compensation for 50 Hz and 150 Hz interference in this work. An out-of-phase compensation signal is generated by applying proper driving signal to the compensation magnetic coil via an AWG. The driving signal is derived through an excitation–response process.

A line-triggered burst signal, which is slightly shorter than 20 ms containing a pre-defined frequency component of 50 Hz and 100 Hz, is periodically applied to the compensation coil for excitation. Then, the obtained fluctuation of resonance frequency shift is a compound signal contains the effect of background and excited magnetic field. So the response of the compensation coil to the excitation signal can be derived by subtracting the background from this compound signal. According to the relationship between background and excitation signal, the amplitude and phase of required compensating driving signal can be derived. In the experiment, we found that the magnetic field coil responds to input signal in a non-linear manner, and the driving signal could be modified more accurately. For this purpose, we modify the driving signal iteratively, in each iteration the dephasing time is measured and used as criterion for modification. This process is terminated until the coherence time is optimal. As shown in Fig. 4b, the optimal coherence time can reach about 2500 \(\upmu\)s, which is 35.7 times longer than that before applying the reverse modulation signal. After compensation, the residual fluctuation of resonance frequency is suppressed by 86\(\%\), as shown in Fig. 4a. It can be seen that the experimental data are in good agreement with the fitting curve, which implies that the spectrum of residual dephasing noise approximately obeys Gaussian distribution.

Fig. 4
figure 4

a Resonance frequency fluctuation within one power line cycle before (black squares) and after (red dots) compensation. b Ramsey interference fringes after compensation for transition \(S_{1/2}(m_J=-1/2) \leftrightarrow S_{1/2}(m_J = 1/2)\), without line trigger. The solid line is the fitting curve using function Eq. (2) and the extracted coherence time \(T_2^*\) is around 2.5 ms. The error is calculated by projection measurement noise model

Our method is based on the assumption that the magnetic field fluctuation is long-term stable. However, interference caused by the power supply could be unstable in the laboratory, since equipment is turned on and off at random moments, which changes the magnetic interference. Therefore, it is advisable to place electrical equipment away from the ion trap.

We also checked the long-term stability of the magnetic field compensation effect in our system. Thirty days after the optimal compensation, we measured the residual magnetic field fluctuation and the coherence time again. It is found that the coherence time has decreased to about 2000 \(\upmu\)s, as shown in Fig. 5. Also, the frequency fluctuation caused by residual field has increased, as shown in Fig. 6. Therefore, the compensation signal should be modified once the coherence time is significant deteriorated, which usually occurs within a few tens of days. Fortunately, it is quite easy to implement the iterative compensation routine again, which only takes around 10 min.

Fig. 5
figure 5

Ramsey interference fringes obtained one month after optimal compensation

Fig. 6
figure 6

Resonance frequency fluctuation after optimal compensation (red dots) and the one obtained one month later (black squares)

4 Discussion and conclusion

In this work, a method to suppress the magnetic field fluctuation induced by mains power is demonstrated. The method uses a trapped ion to detect the dominate components of magnetic field fluctuation and determine the excitation–response relationship of the compensation coil. For magnetic compensation, a line triggered programmable AWG is used to generate a multi-tone compensation signal. After iteratively optimizing the compensation signal, the coherence time of ion qubit is extended from 70 to 2500 \(\upmu\)s. The amplitude of magnetic field fluctuation is reduced by 86\(\%\) compared with the case without suppression. Due to the slow variation of mains interference, we found that the coherence time of the ion qubits will slowly decrease within a few tens of days. Therefore, it is necessary to periodically optimize the compensation parameters. This process, however, is quite simple and can be automated in principle.

Our compensation scheme does not require complex feedback circuits or additional magnetic field detection devices. The main device in our method is an AWG, whose sampling rate only needs to be greater than 100 kHz, since the interference is dominated by low frequency components.

It should to be mentioned that, if the measurement sequence is synchronized with the power line, the \(1/e^2\) decay time of the Ramsey fringe contrast can reach 8 ms when measured by phase sweeping Ramsey measurement method. It indicate that, once all the power-line-relevant magnetic fluctuation are suppressed, the coherence time should achieve 8 ms. However, it can not attained by traditional line trigger method, since the resonant frequency is changing during the quantum operation stage, and the coherence time is strongly depend on the relative phase to the power line. This can be verified by the fact that, the density of Ramsey fringes are not evenly distributed in a line triggered time sweeping Ramsey experiment.

That the theoretical limit of 8 ms coherence time is not reached in this work may be due to the deficiencies in our implementation: (i) We only compensated the magnetic fields components of 50 Hz and 150 Hz, while similarly, the other orders of harmonics can also be compensated if necessary. (ii) The data collection and fitting is not accurate enough when we measure the time varying magnetic field. Further afford could be made to improve the measurement accuracy of magnetic field fluctuation, and take more higher orders of interference into consideration.

Although the work reported here is also far from eliminating the periodic magnetic field, it can largely replace the line trigger method for the sake of higher experimental efficiency and comparable coherence time.