The 2H lock of an NMR spectrometer continuously monitors the frequency of the 2H resonance of a deuterated solvent used to prepare the NMR sample. If the frequency of the 2H resonance changes due to an environmental instability while the lock is engaged, a feedback mechanism is used to correct the magnetic field via a Bo shim coil, returning the 2H resonance to its original position. It is very effective at reducing (if not eliminating) environmental instability from NMR data collected over periods of time spanning minutes or hours. The effect of the lock is illustrated in the figure below.
Bruker Fourier 300 NMR spectrometer. Each panel represents 2048 single-scan 1D 1H NMR spectra collected over 1.5 hours. The data in the left-hand panel were collected during the day without the 2H lock. The data in the center panel were collected in the middle of the night without the 2H lock. The data in the right-hand panel were collected during the day using the 2H lock. The 2H lock clearly compensates for environmental instability. There was no student traffic in the lab during the collection of any of the data. Outside of the lab are two construction sites which are busiest during the day and quieter at night. This is reflected in a comparison between the left-hand and center panels of the figure. The data collected in the middle of the night without the 2H lock show somewhat less instability compared to similar data collected during the day.