Anisotropic systems¶
In this tutorial, the H-NMR relaxation rates \(R_1\) and \(R_2\) are measured for water confined within a nanoslit composed of silica. This system illustrates an anisotropic case, where all three correlation functions, \(G^{(1)}\), \(G^{(2)}\), and \(G^{(3)}\), must be evaluated, and the rates must be calculated from Eq. (1). The hydrogen atoms of interest include those in the water molecules and those in the surface hydroxyl (-OH) groups of the silica. The individual contributions to \(R_1\) and \(R_2\) – namely, intra-molecular, inter-molecular, and water-hydroxyl interactions – are computed separately.
Note
If you are new to NMRDfromMD, it is recommended to begin with the simpler tutorial on Isotropic system.
MD system¶


The system consists of 602 \(\text{TIP4P}-\epsilon\) water molecules confined within a silica slit nanopore. The trajectory was recorded during a \(10\,\text{ns}\) production run performed using the open-source GROMACS software, in the anisotropic \(NP_zT\) ensemble, with a timestep of \(1\,\text{fs}\). To balance the surface charge, 20 sodium ions were added to the slit. The system was maintained at a temperature of \(T = 300\,\text{K}\) and a pressure of \(p = 1\,\text{bar}\). Atomic positions were saved to the prod.xtc file every \(2\,\text{ps}\).
Note
If you are interested in learning GROMACS and generating your own trajectories, beginner tutorials are available here.
File preparation¶
To access the GROMACS input files and pre-computed trajectory data, download the zip archive, or clone the water-in-silica dataset repository using:
git clone https://github.com/NMRDfromMD/dataset-water-in-silica.git
The necessary trajectory files for this tutorial are located in the data/
directory.
Create a MDAnalysis universe¶
Open a new Python script or a new notebook, and define the path to the data files:
datapath = "mypath/water-in-silica/raw-data/N50/"
Then, import NumPy, MDAnalysis, and NMRforMD:
import numpy as np
import MDAnalysis as mda
import nmrformd as nmrmd
From the trajectory files, create a MDAnalysis universe by loading the configuration file and the trajectory:
u = mda.Universe(datapath + "prod.tpr", datapath + "prod.xtc")
Next, extract some basic information from the universe, such as the number of molecules, the timestep, and the total duration:
n_molecules = u.atoms.n_residues
print(f"The number of molecules is {n_molecules}")
timestep = np.int32(u.trajectory.dt)
print(f"The timestep is {timestep} ps")
total_time = np.int32(u.trajectory.totaltime)
print(f"The total simulation time is {total_time} ps")
Running this will return:
>> The number of molecules is 623
>> The timestep is 2 ps
>> The total simulation time is 10000 ps
Launch the NMR analysis¶
Let us create three atom groups corresponding to: the hydrogen atoms of the silica, the hydrogen atoms of the water, and all the hydrogen atoms combined:
H_H2O = u.select_atoms("name HW1 HW2")
H_SIL = u.select_atoms("name H")
H_ALL = H_H2O + H_SIL
Then, let us run three separate NMR analyses: one for the water-silica interaction only, one for the intra-molecular interaction of water, and one for the inter-molecular interaction of water:
nmr_H2O_SIL = nmrmd.NMR(u, atom_group = H_H2O,
neighbor_group = H_SIL, number_i=40, isotropic=False)
nmr_H2O_INTRA = nmrmd.NMR(u, atom_group = H_H2O, neighbor_group = H_H2O, number_i=40,
type_analysis = 'intra_molecular', isotropic=False)
nmr_H2O_INTER = nmrmd.NMR(u, atom_group = H_H2O, neighbor_group = H_H2O, number_i=40,
type_analysis = 'inter_molecular', isotropic=False)
Note the use of isotropic=False
, which is required here because the system is anisotropic.
Extract the NMR spectra¶
Let us access the NMR relaxation rate \(R_1\):
R1_spectrum_H2O_SIL = nmr_H2O_SIL.R1
R1_spectrum_H2O_INTRA = nmr_H2O_INTRA.R1
R1_spectrum_H2O_INTER = nmr_H2O_INTER.R1
f = nmr_H2O_SIL.f


Figure: NMR relaxation rates \(R_1\) for the water confined in a silica slit.
Note that the \(\text{H}_2\text{O}-\text{silica}\) contribution is much smaller than the intra- and intermolecular contributions from the water. This is due to the relatively small number of hydrogen atoms from the silica (92), compared to the 1204 hydrogen atoms from the water.