Chemistry library installation

The quantum chemistry library for the Quantum Development Kit is designed to work well with computational chemistry packages, most notably the NWChem computational chemistry platform developed by the Environmental Molecular Sciences Laboratory (EMSL) at Pacific Northwest National Laboratory. In particular, the Microsoft.Quantum.Chemistry package provides tools for loading instances of quantum chemistry simulation problems represented in the Broombridge schema, also supported for export by recent versions of NWChem.

The Quantum Development Kit chemistry library also provides a command-line tool, qdk-chem, for converting between legacy formats and Broombridge.

This section details how to use the Quantum Development Kit with either NWChem and Broombridge, or legacy formats and qdk-chem.

Using the Quantum Development Kit with NWChem

To get up and running using NWChem together with the Quantum Development Kit, use one of the following methods:

See End-to-end with NWChem for more information on how to work with NWChem to chemical models to analyze with the Quantum Development Kit chemistry library.

Getting started using Broombridge files provided with the samples

The IntegralData/YAML folder in the Quantum Development Kit Samples repository contains Broombridge-formatted molecule data files.

As a simple example, use the chemistry library sample, GetGateCount to load the Hamiltonian from one of Broombridge files and perform gate estimates of quantum simulation algorithms:

cd Quantum/Chemistry/GetGateCount
dotnet run -- --path=../IntegralData/YAML/h2.yaml --format=YAML

See Loading a Hamiltonian from file for more information on how to input molecules represented by the Broombridge schema.

See Obtaining resource counts for more information on resource estimation.

Getting started using the EMSL Arrows Builder

EMSL Arrows is a tool that uses NWChem and chemical computational databases to generate molecule data. EMSL Arrows Builder for the Quantum Development Kit allows you to enter your model using multiple molecular model builders and generate the Broombridge data file to be used by the Quantum Development Kit.

From the EMSL page, click the Instructions tab, and follow the Simple Examples instructions to generate Broombridge files. Then try running the GetGateCount to see the quantum resource estimates for these molecules.

Installing NWChem from source

Full instructions on how to install NWChem from source are provided by PNNL.

Tip

If you wish to use NWChem from Windows 10, the Windows Subsystem for Linux is a great option. Once you have installed Ubuntu 18.04 LTS for Windows, run ubuntu18.04 from your favorite terminal and follow the instructions above to install NWChem from source.

Once you have compiled NWChem from source, you can run the yaml_driver script provided with NWChem to quickly produce Broombridge instances from NWChem input decks:

$NWCHEM_TOP/contrib/quasar/yaml_driver input.nw

This command will create a new input.yaml file in the Broombridge format within your current directory.

Using NWChem with Docker

Pre-built images for using NWChem are available cross-platform via Docker Hub. To get started, follow the Docker installation instructions for your platform:

Tip

If you are using Docker for Windows, you will need to share the drive containing your temporary directory (usually this is the C:\ drive) with the Docker daemon. See the Docker documentation for more details.

Once you have Docker installed, you can either use the PowerShell module provided with the Quantum Development Kit samples to run the image, or you can run the image manually. We detail using PowerShell here; if you would like to use the Docker image manually, please see the documentation provided with the image.

Running NWChem through PowerShell Core

To use the NWChem Docker image with the Quantum Development Kit, we provide a small PowerShell module that handles moving files in and out of NWChem for you. If you don't already have PowerShell Core installed, you can download it cross-platform from the PowerShell repository on GitHub.

Note

PowerShell Core is also used for some samples to demonstrate interoperability with data science and business analytics workflows.

Once you have PowerShell Core installed, import InvokeNWChem.psm1 to make NWChem commands available in your current session:

cd Quantum/utilities/
Import-Module ./InvokeNWChem.psm1

This will make the Convert-NWChemToBroombridge command available in your current PowerShell session. To download any needed images from Docker and use them to run NWChem input decks and capture output to Broombridge, run the following:

Convert-NWChemToBroombridge ./input.nw

This will create a Broombridge file by running NWChem on input.nw. By default, the Broombridge output will have the same name and path as the input deck, with the .nw extension replaced by .yaml. This can be overridden by using the -DestinationPath parameter to Convert-NWChemToBroombridge. More information can be obtained by using PowerShell's built-in help functionality:

Convert-NWChemToBroombridge -?
Get-Help Convert-NWChemToBroombridge -Full

Using the Quantum Development Kit with the qdk-chem tool

To install qdk-chem, you can use the .NET Core SDK at the command line:

dotnet tool install --global Microsoft.Quantum.Chemistry.Tools

Once you have installed qdk-chem, you can use the --help option to get more details about the functionality offered by the qdk-chem tool.

To convert to and from Broombridge, you can use the qdk-chem convert command:

qdk-chem convert --from fcidump --to broombridge data.fcidump --out data.yml

The qdk-chem convert command can also accept its data from standard input, and can write to standard output; this is especially useful within scripts and for integrating with tools that export to legacy formats. For example, in Bash:

cat data.fcidump | qdk-convert --from fcidump --to broombridge - > data.yml