Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
fa062207
Commit
fa062207
authored
Sep 17, 2019
by
Mccaskey, Alex
Browse files
updating cmakelists licenses
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
44c40c7f
Pipeline
#71496
passed with stage
in 4 minutes and 25 seconds
Changes
78
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
cmake/Modules/FindClang.cmake
deleted
100644 → 0
View file @
44c40c7f
# Detect Clang libraries
#
# Defines the following variables:
# CLANG_FOUND - True if Clang was found
# CLANG_INCLUDE_DIRS - Where to find Clang includes
# CLANG_LIBRARY_DIRS - Where to find Clang libraries
#
# CLANG_LIBCLANG_LIB - Libclang C library
#
# CLANG_CLANGFRONTEND_LIB - Clang Frontend (C++) Library
# CLANG_CLANGDRIVER_LIB - Clang Driver (C++) Library
# ...
#
# CLANG_LIBS - All the Clang C++ libraries
#
# Uses the same include and library paths detected by FindLLVM.cmake
#
# See http://clang.llvm.org/docs/InternalsManual.html for full list of libraries
#=============================================================================
# Copyright 2014-2015 Kevin Funk <kfunk@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
if
(
${
Clang_FIND_REQUIRED
}
)
find_package
(
LLVM
${
Clang_FIND_VERSION
}
REQUIRED
)
else
()
find_package
(
LLVM
${
Clang_FIND_VERSION
}
)
endif
()
set
(
CLANG_FOUND FALSE
)
if
(
LLVM_FOUND AND LLVM_LIBRARY_DIRS
)
macro
(
FIND_AND_ADD_CLANG_LIB _libname_
)
string
(
TOUPPER
${
_libname_
}
_prettylibname_
)
find_library
(
CLANG_
${
_prettylibname_
}
_LIB NAMES
${
_libname_
}
HINTS
${
LLVM_LIBRARY_DIRS
}
)
if
(
CLANG_
${
_prettylibname_
}
_LIB
)
set
(
CLANG_LIBS
${
CLANG_LIBS
}
${
CLANG_
${
_prettylibname_
}
_LIB
}
)
endif
()
endmacro
(
FIND_AND_ADD_CLANG_LIB
)
# note: On Windows there's 'libclang.dll' instead of 'clang.dll' -> search for 'libclang', too
find_library
(
CLANG_LIBCLANG_LIB NAMES clang libclang HINTS
${
LLVM_LIBRARY_DIRS
}
)
# LibClang: high-level C interface
FIND_AND_ADD_CLANG_LIB
(
clangFrontend
)
FIND_AND_ADD_CLANG_LIB
(
clangDriver
)
FIND_AND_ADD_CLANG_LIB
(
clangCodeGen
)
FIND_AND_ADD_CLANG_LIB
(
clangSema
)
FIND_AND_ADD_CLANG_LIB
(
clangChecker
)
FIND_AND_ADD_CLANG_LIB
(
clangAnalysis
)
FIND_AND_ADD_CLANG_LIB
(
clangRewriteFrontend
)
FIND_AND_ADD_CLANG_LIB
(
clangRewrite
)
FIND_AND_ADD_CLANG_LIB
(
clangAST
)
FIND_AND_ADD_CLANG_LIB
(
clangASTMatchers
)
FIND_AND_ADD_CLANG_LIB
(
clangParse
)
FIND_AND_ADD_CLANG_LIB
(
clangLex
)
FIND_AND_ADD_CLANG_LIB
(
clangBasic
)
FIND_AND_ADD_CLANG_LIB
(
clangARCMigrate
)
FIND_AND_ADD_CLANG_LIB
(
clangEdit
)
FIND_AND_ADD_CLANG_LIB
(
clangFrontendTool
)
FIND_AND_ADD_CLANG_LIB
(
clangRewrite
)
FIND_AND_ADD_CLANG_LIB
(
clangSerialization
)
FIND_AND_ADD_CLANG_LIB
(
clangTooling
)
FIND_AND_ADD_CLANG_LIB
(
clangStaticAnalyzerCheckers
)
FIND_AND_ADD_CLANG_LIB
(
clangStaticAnalyzerCore
)
FIND_AND_ADD_CLANG_LIB
(
clangStaticAnalyzerFrontend
)
FIND_AND_ADD_CLANG_LIB
(
clangSema
)
FIND_AND_ADD_CLANG_LIB
(
clangRewriteCore
)
endif
()
if
(
CLANG_LIBS OR CLANG_LIBCLANG_LIB
)
set
(
CLANG_FOUND TRUE
)
else
()
message
(
STATUS
"Could not find any Clang libraries in
${
LLVM_LIBRARY_DIRS
}
"
)
endif
()
if
(
CLANG_FOUND
)
set
(
CLANG_LIBRARY_DIRS
${
LLVM_LIBRARY_DIRS
}
)
set
(
CLANG_INCLUDE_DIRS
${
LLVM_INCLUDE_DIRS
}
)
# check whether llvm-config comes from an install prefix
execute_process
(
COMMAND
${
LLVM_CONFIG_EXECUTABLE
}
--src-root
OUTPUT_VARIABLE _llvmSourceRoot
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string
(
FIND
"
${
LLVM_INCLUDE_DIRS
}
"
"
${
_llvmSourceRoot
}
"
_llvmIsInstalled
)
if
(
NOT _llvmIsInstalled
)
message
(
STATUS
"Detected that llvm-config comes from a build-tree, adding more include directories for Clang"
)
list
(
APPEND CLANG_INCLUDE_DIRS
"
${
LLVM_INSTALL_PREFIX
}
/tools/clang/include"
# build dir
"
${
_llvmSourceRoot
}
/tools/clang/include"
# source dir
)
endif
()
message
(
STATUS
"Found Clang (LLVM version:
${
LLVM_VERSION
}
)"
)
message
(
STATUS
" Include dirs:
${
CLANG_INCLUDE_DIRS
}
"
)
message
(
STATUS
" Clang libraries:
${
CLANG_LIBS
}
"
)
message
(
STATUS
" Libclang C library:
${
CLANG_LIBCLANG_LIB
}
"
)
else
()
if
(
Clang_FIND_REQUIRED
)
message
(
FATAL_ERROR
"Could NOT find Clang"
)
endif
()
endif
()
cmake/Modules/FindLLVM.cmake
deleted
100644 → 0
View file @
44c40c7f
# Find the native LLVM includes and libraries
#
# Defines the following variables
# LLVM_INCLUDE_DIRS - where to find llvm include files
# LLVM_LIBRARY_DIRS - where to find llvm libs
# LLVM_CFLAGS - llvm compiler flags
# LLVM_LFLAGS - llvm linker flags
# LLVM_MODULE_LIBS - list of llvm libs for working with modules.
# LLVM_INSTALL_PREFIX - LLVM installation prefix
# LLVM_FOUND - True if llvm found.
# LLVM_VERSION - Version string ("llvm-config --version")
#
# This module reads hints about search locations from variables
# LLVM_ROOT - Preferred LLVM installation prefix (containing bin/, lib/, ...)
#
# Note: One may specify these as environment variables if they are not specified as
# CMake variables or cache entries.
#=============================================================================
# Copyright 2014 Kevin Funk <kfunk@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
if
(
NOT LLVM_ROOT AND DEFINED ENV{LLVM_ROOT}
)
file
(
TO_CMAKE_PATH
"$ENV{LLVM_ROOT}"
LLVM_ROOT
)
endif
()
# if the user specified LLVM_ROOT, use that and fail otherwise
if
(
LLVM_ROOT
)
find_program
(
LLVM_CONFIG_EXECUTABLE NAMES llvm-config HINTS
${
LLVM_ROOT
}
/bin DOC
"llvm-config executable"
NO_DEFAULT_PATH
)
else
()
# find llvm-config, prefer the one with a version suffix, e.g. llvm-config-3.5
# note: FreeBSD installs llvm-config as llvm-config35 and so on
# note: on some distributions, only 'llvm-config' is shipped, so let's always try to fallback on that
string
(
REPLACE
"."
""
LLVM_FIND_VERSION_CONCAT
${
LLVM_FIND_VERSION
}
)
find_program
(
LLVM_CONFIG_EXECUTABLE NAMES llvm-config-
${
LLVM_FIND_VERSION
}
llvm-config
${
LLVM_FIND_VERSION_CONCAT
}
llvm-config DOC
"llvm-config executable"
)
# other distributions don't ship llvm-config, but only some llvm-config-VERSION binary
# try to deduce installed LLVM version by looking up llvm-nm in PATH and *then* find llvm-config-VERSION via that
if
(
NOT LLVM_CONFIG_EXECUTABLE
)
find_program
(
_llvmNmExecutable llvm-nm
)
if
(
_llvmNmExecutable
)
execute_process
(
COMMAND
${
_llvmNmExecutable
}
--version OUTPUT_VARIABLE _out
)
string
(
REGEX REPLACE
".*LLVM version ([^
\n
]+).*"
"
\\
1"
_versionString
"
${
_out
}
"
)
find_program
(
LLVM_CONFIG_EXECUTABLE NAMES llvm-config-
${
_versionString
}
DOC
"llvm-config executable"
)
endif
()
endif
()
endif
()
set
(
LLVM_FOUND FALSE
)
if
(
LLVM_CONFIG_EXECUTABLE
)
# verify that we've found the correct version of llvm-config
execute_process
(
COMMAND
${
LLVM_CONFIG_EXECUTABLE
}
--version
OUTPUT_VARIABLE LLVM_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if
(
NOT LLVM_VERSION
)
set
(
_LLVM_ERROR_MESSAGE
"Failed to parse version from llvm-config"
)
elseif
(
LLVM_FIND_VERSION VERSION_GREATER LLVM_VERSION
)
set
(
_LLVM_ERROR_MESSAGE
"LLVM version too old:
${
LLVM_VERSION
}
"
)
else
()
set
(
LLVM_FOUND TRUE
)
endif
()
else
()
set
(
_LLVM_ERROR_MESSAGE
"Could NOT find 'llvm-config' executable"
)
endif
()
if
(
LLVM_FOUND
)
execute_process
(
COMMAND
${
LLVM_CONFIG_EXECUTABLE
}
--includedir
OUTPUT_VARIABLE LLVM_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process
(
COMMAND
${
LLVM_CONFIG_EXECUTABLE
}
--libdir
OUTPUT_VARIABLE LLVM_LIBRARY_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process
(
COMMAND
${
LLVM_CONFIG_EXECUTABLE
}
--cppflags
OUTPUT_VARIABLE LLVM_CFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process
(
COMMAND
${
LLVM_CONFIG_EXECUTABLE
}
--ldflags
OUTPUT_VARIABLE LLVM_LFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process
(
COMMAND
${
LLVM_CONFIG_EXECUTABLE
}
--libs core bitreader asmparser analysis
OUTPUT_VARIABLE LLVM_MODULE_LIBS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process
(
COMMAND
${
LLVM_CONFIG_EXECUTABLE
}
--libfiles
OUTPUT_VARIABLE LLVM_LIBS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string
(
REPLACE
" "
";"
LLVM_LIBS
${
LLVM_LIBS
}
)
# Make it consistent with --libs
execute_process
(
COMMAND
${
LLVM_CONFIG_EXECUTABLE
}
--system-libs
OUTPUT_VARIABLE LLVM_SYSTEM_LIBS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process
(
COMMAND
${
LLVM_CONFIG_EXECUTABLE
}
--prefix
OUTPUT_VARIABLE LLVM_INSTALL_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# potentially add include dir from binary dir for non-installed LLVM
execute_process
(
COMMAND
${
LLVM_CONFIG_EXECUTABLE
}
--src-root
OUTPUT_VARIABLE _llvmSourceRoot
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string
(
FIND
"
${
LLVM_INCLUDE_DIRS
}
"
"
${
_llvmSourceRoot
}
"
_llvmIsInstalled
)
if
(
NOT _llvmIsInstalled
)
list
(
APPEND LLVM_INCLUDE_DIRS
"
${
LLVM_INSTALL_PREFIX
}
/include"
)
endif
()
endif
()
if
(
LLVM_FIND_REQUIRED AND NOT LLVM_FOUND
)
message
(
FATAL_ERROR
"Could not find LLVM:
${
_LLVM_ERROR_MESSAGE
}
"
)
elseif
(
_LLVM_ERROR_MESSAGE
)
message
(
STATUS
"Could not find LLVM:
${
_LLVM_ERROR_MESSAGE
}
"
)
endif
()
if
(
LLVM_FOUND
)
message
(
STATUS
"Found LLVM (version:
${
LLVM_VERSION
}
): (using
${
LLVM_CONFIG_EXECUTABLE
}
)"
)
message
(
STATUS
" Include dirs:
${
LLVM_INCLUDE_DIRS
}
"
)
message
(
STATUS
" LLVM libraries:
${
LLVM_LIBS
}
"
)
message
(
STATUS
" LLVM System libraries:
${
LLVM_SYSTEM_LIBS
}
"
)
endif
()
cmake/Modules/FindLibunwind.cmake
View file @
fa062207
# *******************************************************************************
# Copyright (c) 2019 UT-Battelle, LLC.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# and Eclipse Distribution License v.10 which accompany this distribution.
# The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
# and the Eclipse Distribution License is available at
# https://eclipse.org/org/documents/edl-v10.php
#
# Contributors:
# Alexander J. McCaskey - initial API and implementation
# *******************************************************************************/
# - Try to find Libunwind
# Input variables:
# LIBUNWIND_ROOT_DIR - The libunwind install directory;
...
...
cmake/Modules/format.cmake
View file @
fa062207
# *******************************************************************************
# Copyright (c) 2019 UT-Battelle, LLC.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# and Eclipse Distribution License v.10 which accompany this distribution.
# The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
# and the Eclipse Distribution License is available at
# https://eclipse.org/org/documents/edl-v10.php
#
# Contributors:
# Alexander J. McCaskey - initial API and implementation
# *******************************************************************************/
find_program
(
CLANG_FORMAT_EXECUTABLE
NAMES
clang-format-7.0
...
...
docker/dev/Dockerfile
deleted
100644 → 0
View file @
44c40c7f
from
xacc/base
run
git clone
--recursive
https://github.com/eclipse/xacc
&&
cd
xacc
\
&& mkdir build && cd build && cmake .. -DPYTHON_INCLUDE_DIR=$(python3 -c "import sysconfig; print(sysconfig.get_paths()['platinclude'])") -DCMAKE_EXPORT_COMPILE_COMMANDS=ON && cp compile_commands.json .. \
&& cd /projects && git clone https://github.com/ornl-qci/xacc-rigetti \
&& git clone https://github.com/ornl-qci/xacc-ibm \
&& git clone https://github.com/ornl-qci/xacc-vqe \
&& git clone https://github.com/ornl-qci/tnqvm
docker/dev/docker-compose.yml
deleted
100644 → 0
View file @
44c40c7f
version
:
'
2'
services
:
xacc-dev
:
image
:
xacc/devel
command
:
tail -f /dev/null
environment
:
-
TERM=xterm
security_opt
:
-
seccomp:unconfined
network_mode
:
host
docker/dev/theia/Dockerfile
deleted
100644 → 0
View file @
44c40c7f
from
theiaide/theia-full:next
run
apt-get
-y
update
\
&& unlink /usr/bin/clangd \
&& wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \
&& echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial main" > \
/etc/apt/sources.list.d/llvm.list \
&& apt-get -y update && apt-get install -y clang-tools-7 cmake libssl-dev \
python3 libpython3-dev python3-pip vim gdb gfortran libblas-dev \
liblapack-dev pkg-config \
&& ln -s /usr/bin/clangd-7 /usr/bin/clangd \
&& ln -s /usr/bin/clang++-7 /usr/bin/clang++ \
&& ln -s /usr/bin/clang-7 /usr/bin/clang \
&& git clone --recursive https://github.com/eclipse/xacc \
&& cd xacc && mkdir build && cd build \
&& CC=clang CXX=clang++ cmake .. -DPYTHON_INCLUDE_DIR=/usr/include/python3.5 -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE \
&& make -j4 install
add
settings.json /home/.theia/
docker/dev/theia/README.md
deleted
100644 → 0
View file @
44c40c7f
# Develop with Theia
To develop XACC using the Eclipse Theia IDE and Docker
```
bash
$
git clone
--recursive
https://github.com/eclipse/xacc
$
cd
xacc/docker/dev/theia
$
docker-compose up
-d
```
Navigate to
`http://localhost:3000`
in your web browser. For an application look and feel in Google Chrome, you can run
```
bash
$
/Applications/Google
\
Chrome.app/Contents/MacOS/Google
\
Chrome
--app
=
http://localhost:3000
(
On a Mac
)
$
google-chrome
--app
=
http://localhost:3000
(
On Linux
)
```
To delete this development workspace
```
bash
$
docker-compose down
```
docker/dev/theia/docker-compose.yml
deleted
100644 → 0
View file @
44c40c7f
version
:
'
2'
services
:
xacc-dev
:
image
:
xacc/theia-dev
volumes
:
-
../../../../:/home/project
ports
:
-
3000:3000
docker/dev/theia/settings.json
deleted
100644 → 0
View file @
44c40c7f
{
"cpp.buildConfigurations"
:
[{
"name"
:
"xacc"
,
"directory"
:
"/home/project/xacc/build"
}
]
}
docker/expo_tutorial/Dockerfile
deleted
100644 → 0
View file @
44c40c7f
from
xacc/base
label
maintainer="Alex McCaskey <mccaskeyaj@ornl.gov>"
run
rm
/bin/sh
&&
ln
-s
/bin/bash /bin/sh
&&
apt-get
-y
update
&&
apt-get
-y
install
vim gfortran libblas-dev liblapack-dev pkg-config libhdf5-dev
\
&&
python3
-m
pip
install
--upgrade
pip xacc
&&
python3
-m
pip
install
jupyterlab pyquil mpmath deepdiff
\
numpy scipy openfermion xacc-rigetti xacc-vqe tnqvm xacc-ibm
--no-cache-dir
&&
ipython3 kernel
install
\
&&
python3
-m
pip uninstall
-y
h5py
&&
python3
-m
pip
install
h5py
==
2.8.0rc1
\
&&
git clone https://github.com/amccaskey/OpenFermion-Psi4
&&
cd
OpenFermion-Psi4
&&
python3
-m
pip
install
--user
.
\
&&
cd
/
&&
git clone
--recursive
https://github.com/ornl-qci/xacc-vqe-bayesopt
\
&&
cd
xacc-vqe-bayesopt
&&
mkdir
build
&&
cd
build
&&
cmake ..
-DXACC_DIR
=
$(
python3
-m
pyxacc
-L
)
\
&&
apt-get
install
-y
apt-transport-https ca-certificates curl software-properties-common
\
&&
curl
-fsSL
https://download.docker.com/linux/ubuntu/gpg | apt-key add -
\
&&
add-apt-repository
"deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic test"
\
&&
apt-get update
-y
&&
apt-get
install
-y
docker-ce
\
&&
sed
-i
's/os.rename/shutil.move/g'
/usr/local/lib/python3.6/dist-packages/openfermion/hamiltonians/_molecular_data.py
\
&&
sed
-i
's/import os/import os, shutil/g'
/usr/local/lib/python3.6/dist-packages/openfermion/hamiltonians/_molecular_data.py
run
cd
/
&&
git clone https://github.com/psi4/psi4
&&
cd
psi4
&&
mkdir
build
&&
cd
build
\
&&
cmake ..
-DPYTHON_EXECUTABLE
=
$(
which python3
)
-DCMAKE_INSTALL_PREFIX
=
$(
python3
-m
site
--user-site
)
/psi4
\
&&
make
-j8
install
\
&&
echo
"./psi4"
>>
/root/.local/lib/python3.6/site-packages/psi4.pth
\
&&
echo
"export PATH=
$PATH
:
$(
python3
-m
site
--user-site
)
/psi4/bin"
>>
~/.bashrc
run
echo
"alias python=python3"
>>
~/.bashrc
\
&&
echo
"function xacc-logs() { docker logs -f
\$
(docker ps -aqf name=expo) ; }"
>>
~/.bashrc
docker/expo_tutorial/README.md
deleted
100644 → 0
View file @
44c40c7f
Tutorial instructions
```
bash
$
docker-compose pull
$
docker-compose up
-d
```
Open localhost:9000 in web browser
docker/expo_tutorial/deuteron/Deuteron_H2.ipynb
deleted
100644 → 0
View file @
44c40c7f
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Simulating Deuteron $N=2$ Hamiltonian with XACC-VQE"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from openfermionpsi4 import run_psi4\n",
"from openfermion.hamiltonians import MolecularData\n",
"import numpy as np\n",
"import xacc\n",
"from xacc import InstructionParameter\n",
"import xaccvqe as vqe\n",
"from xaccvqe import PauliOperator\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Import necessary libraries, create the Hamiltonian and Ansatz Circuits"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"xacc.Initialize(['--compiler','quil'])\n",
"\n",
"# Specify the Accelerator to run on, \n",
"# default to TNQVM MPS simulator\n",
"qpuName = 'tnqvm'\n",
"qpu = xacc.getAccelerator(qpuName)\n",
"\n",
"# Construct the H2 Hamiltonian (see Eq 4 of paper)\n",
"H2 = PauliOperator(5.906709445) + \\\n",
" PauliOperator({0:'X',1:'X'}, -2.1433) + \\\n",
" PauliOperator({0:'Y',1:'Y'}, -2.1433) + \\\n",
" PauliOperator({0:'Z'}, .21829) + \\\n",
" PauliOperator({1:'Z'}, -6.125)\n",
"\n",
"# Code up and compile the H2 ansatz in Quil\n",
"srcH2 = \"\"\"__qpu__ ansatz(AcceleratorBuffer, double t0) {\n",
"X 0\n",
"RY(t0) 1\n",
"CNOT 1 0\n",
"}\"\"\"\n",
"ansatzH2 = xacc.compileKernel(qpu, srcH2) \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Parameter Sweep"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Sweep over the given angle range for H2 and plot\n",
"angle_range = np.linspace(-np.pi,np.pi,50)\n",
"energiesH2 = [vqe.execute(H2, **{'task':'compute-energy', \n",
" 'vqe-params':str(t), \n",
" 'ansatz':ansatzH2}).energy\n",
" for t in angle_range]\n",
"import matplotlib.pyplot as plt\n",
"plt.figure(figsize=(9,5))\n",
"plt.xlabel(r'$\\theta$')\n",
"plt.ylabel(r'$\\langle H\\rangle$')\n",
"plt.plot(angle_range, energiesH2, '-', color='k', label=r'tnqvm')\n",
"plt.legend()\n",
"plt.show()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## VQE routine"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Execute H2 VQE routine\n",
"vqeResultH2 = vqe.execute(H2, **{'task':'vqe', 'ansatz':ansatzH2})\n",
"print('H2 (Optimal Angle, Energy) = (', vqeResultH2.angles, ',', vqeResultH2.energy, ')')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise - Run the Parameter Sweep on IBM simulator"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
%% Cell type:markdown id: tags:
# Simulating Deuteron $N=2$ Hamiltonian with XACC-VQE
%% Cell type:code id: tags:
```
python
from
openfermionpsi4
import
run_psi4
from
openfermion.hamiltonians
import
MolecularData
import
numpy
as
np
import
xacc
from
xacc
import
InstructionParameter
import
xaccvqe
as
vqe
from
xaccvqe
import
PauliOperator
%
matplotlib
inline
```
%% Cell type:markdown id: tags:
## Import necessary libraries, create the Hamiltonian and Ansatz Circuits
%% Cell type:code id: tags:
```
python
xacc
.
Initialize
([
'--compiler'
,
'quil'
])
# Specify the Accelerator to run on,
# default to TNQVM MPS simulator
qpuName
=
'tnqvm'
qpu
=
xacc
.
getAccelerator
(
qpuName
)
# Construct the H2 Hamiltonian (see Eq 4 of paper)
H2
=
PauliOperator
(
5.906709445
)
+
\
PauliOperator
({
0
:
'X'
,
1
:
'X'
},
-
2.1433
)
+
\
PauliOperator
({
0
:
'Y'
,
1
:
'Y'
},
-
2.1433
)
+
\
PauliOperator
({
0
:
'Z'
},
.
21829
)
+
\
PauliOperator
({
1
:
'Z'
},
-
6.125
)
# Code up and compile the H2 ansatz in Quil
srcH2
=
"""__qpu__ ansatz(AcceleratorBuffer, double t0) {
X 0
RY(t0) 1
CNOT 1 0
}"""
ansatzH2
=
xacc
.
compileKernel
(
qpu
,
srcH2
)
```