For the users

Note

If you encounter an issue during installation, see our troubleshooting section. If that doesn’t resolve your issue, please create a bug report on our Github issue tracker.

Strict Requirements

mrsimulator has the following strict requirements:

See Package dependencies for a full list of requirements.

Make sure you have the required version of Python by typing the following in the terminal,

$ python --version

For MacOS users, Python version 3 is installed under the name python3. You may replace python for python3 in the above command and all subsequent Python statements.

For Windows users, Python is not usually installed by default. See Python.org for a list of official Python downloads and Windows installation instructions.

See also

If you do not have Python or have an older version of Python, you may visit the Python downloads or Anaconda websites and follow their instructions on installing Python.

Installing mrsimulator

Colaboratory is a Google research project. It is a Jupyter notebook environment that runs entirely in the cloud. Launch a new notebook on Colab. We recommend going through the Welcome to Colab! tutorial if you are new to Notebooks.

To install the mrsimulator package, type

!pip install mrsimulator

in a new cell, execute, and finally restart the runtime. All done! You may now start using the library, or proceed to Getting Started to continue the tutorial.

Updating mrsimulator

If you are upgrading to a newer version of mrsimulator, you should have all the prerequisites already installed on your system. In this case, type the following in the terminal/Prompt

$ pip install mrsimulator -U

All done! You may now start using the library or proceed to Getting Started to continue the tutorial.

Testing your build

Note

For Windows users using anaconda Python 3.8 and higher, you need to set the following environment variable in the Anaconda Prompt before running mrsimulator scripts.

$ set CONDA_DLL_SEARCH_MODIFICATION_ENABLE='1'

If the installation is successful, you should be able to run the following test file in your terminal. Download the test file here or copy and paste the following code into a Python file and run the code.

from mrsimulator import Simulator, SpinSystem, Site
from mrsimulator.method.lib import BlochDecaySpectrum
import matplotlib.pyplot as plt

# Make Site and SpinSystem objects
H_site = Site(isotope="1H", shielding_symmetric={"zeta": 13.89, "eta": 0.25})
spin_system = SpinSystem(sites=[H_site])

# Make static and MAS one-pulse acquire Method objects
static = BlochDecaySpectrum(channels=["1H"])
mas = BlochDecaySpectrum(channels=["1H"], rotor_frequency=1000)  # in Hz

# Setup and run the Simulation object
sim = Simulator(spin_systems=[spin_system], methods=[static, mas])
sim.run()

# Plot the spectra
fig, ax = plt.subplots(1, 2, figsize=(6, 3), subplot_kw={"projection": "csdm"})
ax[0].plot(sim.methods[0].simulation.real)
ax[0].set_title("Static")
ax[1].plot(sim.methods[1].simulation.real)
ax[1].set_title("MAS")
plt.tight_layout()
plt.show()

(png, hires.png, pdf)

../_images/users-1.png

Figure 3 Simulation of static and MAS solid-state NMR spectra

Note

If you encounter the following error

ValueError: numpy.ndarray size changed, may indicate binary incompatibility.
Expected 88 from C header, got 80 from PyObject

update numpy by running

$ pip install -U numpy