How to call MRChem#

There are two main strategies for performing an MRChem calculation: 1) the traditional approach using the terminal and terminal tools like vim or emacs; or 2) doing everything in the Jupyter notebook by writing simple functions to generate the input and submit the calculation.

Using the terminal#

Open a new Jupyter Lab terminal by from the Jupyter Launcher (blue button with white “+”). This works like any other linux terminal, and you can edit input files and look at output files here to complete the exercise.

MRChem with OpenMP parallelization should already be pre-installed from our conda distribution. In order to start an MRChem calculation, you just call the input parser (mrchem) from the command line like this:

OMP_NUM_THREADS=16 mrchem jobname.inp

This will parse the user input file (jobname.inp) and generate a program input file in JSON format (jobname.json), and then pass the program input to the binary MRChem executable and redirect stdout to the output file (jobname.out). The output is also stored in jobname.json in JSON format in a separate output section, and this file serves as a complete record of the calculation (including both the input and output). In the example above, MRChem will use 16 threads as defined in the OMP_NUM_THREADS environment variable.

Using the notebook#

Another way to call MRChem is to do everything in the notebook. This would mean that you write a function that generates the input file, and then a function which calls MRChem using the subprocess module. This strategy is the one used in the solution to these exercises, since everything then can be contained within the notebook environment, from input generation to doing the calculation, to data analysis and visualization.

We provide these scripts, and they should work in a black box manner. However, you are encouraged to look at how they are defined by checking out the file utils/functions.py to see how they work.