NMR spectra calculations
calculate_spectrum
For most use cases the calculate_spectrum
function should be sufficient to perform NMR spectra calculations. By default, it uses the clustering approach discussed in the solver chapter. This approach is exact for molecules smaller than the specified maximum cluster size (set by default to 12) and for larger systems still accurate and efficient.
For a quick introduction to this method you can just read on, however, for a proper walkthrough of all the customization options check out the example notebooks.
The calculate_spectrum
function takes as input an object with the molecular data of the system of interest which can be of type MolecularData
or NMRParameters
. The latter is derived from the former using the spin_system
method and only stores the isotopes, chemical shifts and J-coupling values. The second input argument of calculate_spectrum
is of type NMRCalculationParameters
and stores all parameters necessary to specify a NMR spectrum calculation. For more details on these objects check out the corresponding sections Molecule input and Data types.
As part of HQS NMR Tool
a module containing example molecules is provided. You can calculate the spectrum for one of the example molecules simply as follows:
from hqs_nmr.calculate import calculate_spectrum
from hqs_nmr.datatypes import NMRCalculationParameters
from hqs_nmr_parameters.examples import molecules
# Obtain example molecule of datatype NMRParameters.
molecule_parameters = molecules["C3H8"].spin_system()
# Define the calculation parameters. The only required parameter is the
# magnetic field in Tesla.
calculation_parameters = NMRCalculationParameters(field_T=11.7433)
# Calculate the spectrum.
nmr_result = calculate_spectrum(
molecule_parameters,
calculation_parameters
)
nmr_result
is now an object of datatype NMRResultSpectrum1D
and stores the calculated spectrum as well as the input to the calculation. The spectrum can now be plotted as follows:
import numpy as np
import matplotlib.pyplot as plt
summed_spectrum = np.sum(nmr_result.spectrum.spin_contributions, axis=0)
plt.plot(nmr_result.spectrum.omegas_ppm, summed_spectrum, linewidth=0.3, label="spectrum")
plt.title("500 MHz, Propane")
plt.xlabel("$\\delta$ [ppm]")
plt.ylabel("$Intensity \\, [a. u.]$")
plt.savefig("propane_500MHz_NMR_spectrum.png", dpi=2000)
plt.show()
Note that we store the individual spin contributions rather than the summed spectrum in nmr_result.spectrum.spin_contributions
. Hence we have to sum them before plotting the spectrum.
The result should look as follows:
