Skip to content

Commit

Permalink
adding new line character and removing space
Browse files Browse the repository at this point in the history
  • Loading branch information
sacpis committed Aug 8, 2024
1 parent fdfc01d commit a3df618
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions docs/sphinx/examples/python/tutorials/afqmc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Quantum Enhanced Auxiliary Field Quantum Monte Carlo \n",
"# Quantum Enhanced Auxiliary Field Quantum Monte Carlo\n",
"\n",
"This work was done in collaboration with the Next Generation Computing team at [BASF](https://www.basf.com/global/en.html). \n",
"This work was done in collaboration with the Next Generation Computing team at [BASF](https://www.basf.com/global/en.html).\n",
"\n",
"In this tutorial we implement a quantum-classical hybrid workflow for computing the ground state energies of a strongly interacting molecular system. The algorithm consists of two parts: \n",
"In this tutorial we implement a quantum-classical hybrid workflow for computing the ground state energies of a strongly interacting molecular system. The algorithm consists of two parts:\n",
"\n",
"\n",
"1. A variational quantum eigensolver that uses the quantum-number-preserving ansatz proposed by [Anselmetti et al. (2021)](https://doi.org/10.1088/1367-2630/ac2cb3) to generate a quantum trial wave function $|\\Psi_T\\rangle$ using CUDA Quantum. \n",
"1. A variational quantum eigensolver that uses the quantum-number-preserving ansatz proposed by [Anselmetti et al. (2021)](https://doi.org/10.1088/1367-2630/ac2cb3) to generate a quantum trial wave function $|\\Psi_T\\rangle$ using CUDA Quantum.\n",
"\n",
"2. An Auxiliary-Field Quantum Monte Carlo simulation that realizes a classical imaginary time evolution and collects the ground state energy estimates.\n",
"\n"
"2. An Auxiliary-Field Quantum Monte Carlo simulation that realizes a classical imaginary time evolution and collects the ground state energy estimates.\n"
]
},
{
Expand Down Expand Up @@ -77,7 +76,7 @@
"Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.0->plum-dispatch->ipie==0.7.1) (2.18.0)\n",
"Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich>=10.0->plum-dispatch->ipie==0.7.1) (0.1.2)\n",
"\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
"\u001b[0m"
"\u001b[0m\n"
]
}
],
Expand Down Expand Up @@ -116,7 +115,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We start by defining the structure of the molecule, the basis set, and its spin. We build the molecule object with PySCF and run a preliminary Hartree-Fock computation. Here we choose as an example a [chelating agent](https://doi.org/10.1021/acs.jctc.3c01375) representing a relevant class of substances industrially produced at large scales. Their use ranges, among the others, from water softeners in cleaning applications, modulators of redox behaviour in oxidative bleaching, scale suppressants, soil remediation and ligands for catalysts. In particular we focus here in a Fe(III)-NTA complex whose structure is given in the file imported below. "
"We start by defining the structure of the molecule, the basis set, and its spin. We build the molecule object with PySCF and run a preliminary Hartree-Fock computation. Here we choose as an example a [chelating agent](https://doi.org/10.1021/acs.jctc.3c01375) representing a relevant class of substances industrially produced at large scales. Their use ranges, among the others, from water softeners in cleaning applications, modulators of redox behaviour in oxidative bleaching, scale suppressants, soil remediation and ligands for catalysts. In particular we focus here in a Fe(III)-NTA complex whose structure is given in the file imported below.\n"
]
},
{
Expand All @@ -133,7 +132,7 @@
"num_active_orbitals = 5\n",
"num_active_electrons = 5\n",
"\n",
"# You can swap to O3 which is a smaller system and takes less computational resources and time to run. \n",
"# You can swap to O3 which is a smaller system and takes less computational resources and time to run.\n",
"\n",
"atom = \"src/geo_o3.xyz\"\n",
"basis = \"cc-pVTZ\"\n",
Expand Down Expand Up @@ -165,8 +164,8 @@
"molecule = gto.M(atom=atom, spin=spin, basis=basis, verbose=0)\n",
"\n",
"# Restriced open shell HF.\n",
"hartee_fock = scf.ROHF(molecule) \n",
"hartee_fock.chkfile = \"src/output.chk\" \n",
"hartee_fock = scf.ROHF(molecule)\n",
"hartee_fock.chkfile = \"src/output.chk\"\n",
"\n",
"# Run Hartree-Fock.\n",
"hartee_fock.kernel()\n"
Expand All @@ -182,7 +181,7 @@
"Since this molecule contains of around 600 orbitals (which would correspond to 1200 qubits) and 143 total electrons, it is impossible to perform a full VQE with full statevector simulation. Therefore, we need to identify an active space with fewer orbitals and electrons that contribute to the strongly interacting part of the whole molecule. We then run a post Hartree-Fock computation with the PySCF's built-in CASCI method in order to obtain the one-body ($t_{pq}$) and two-body \n",
"($V_{prqs}$) integrals that define the molecular Hamiltonian in the active space:\n",
"\n",
"$$ H= \\sum_{pq}t_{pq}\\hat{a}_{p}^\\dagger \\hat {a}_{q}+\\sum_{pqrs} V_{prqs}\\hat a_{p}^\\dagger \\hat a_{q}^\\dagger \\hat a_{s}\\hat a_{r} \\tag{1}$$"
"$$ H= \\sum_{pq}t_{pq}\\hat{a}_{p}^\\dagger \\hat {a}_{q}+\\sum_{pqrs} V_{prqs}\\hat a_{p}^\\dagger \\hat a_{q}^\\dagger \\hat a_{s}\\hat a_{r} \\tag{1}$$\n"
]
},
{
Expand Down Expand Up @@ -218,15 +217,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Run VQE with CUDA-Q"
"### Run VQE with CUDA-Q\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"We can now execute the VQE algorithm using the quantum number preserving ansatz. At the end of the VQE, we store the final statevector that will be used in the classical AFQMC computation as an initial guess. "
"We can now execute the VQE algorithm using the quantum number preserving ansatz. At the end of the VQE, we store the final statevector that will be used in the classical AFQMC computation as an initial guess.\n"
]
},
{
Expand Down Expand Up @@ -280,15 +279,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Auxiliary Field Quantum Monte Carlo (AFQMC)"
"### Auxiliary Field Quantum Monte Carlo (AFQMC)\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"AFQMC is a numerical method for computing relevant properties of strongly interacting molecules. AFQMC is a type of Quantum Monte Carlo method that combines the use of random walks with an auxiliary field to simulate the imaginary-time evolution of a quantum system and drive it to the lowest energy state. This method can provide accurate results for ground-state properties of a wide range of physical systems, including atoms, molecules, and solids. Here we summarize the main features of AFQMC while a detailed introduction to can be found [here](https://www.cond-mat.de/events/correl13/manuscripts/zhang.pdf). "
"AFQMC is a numerical method for computing relevant properties of strongly interacting molecules. AFQMC is a type of Quantum Monte Carlo method that combines the use of random walks with an auxiliary field to simulate the imaginary-time evolution of a quantum system and drive it to the lowest energy state. This method can provide accurate results for ground-state properties of a wide range of physical systems, including atoms, molecules, and solids. Here we summarize the main features of AFQMC while a detailed introduction to can be found [here](https://www.cond-mat.de/events/correl13/manuscripts/zhang.pdf).\n"
]
},
{
Expand All @@ -302,7 +301,7 @@
"=\\sum_{pq} h_{pq} {a}_{p}^{\\dagger} {a}_{q} + \\frac{1}{2} \\sum_{pqrs} v_{pqrs}{a}_{p}^{\\dagger} {a}_r {a}^{\\dagger}_{q} {a}_s \\tag{2}\n",
"\\end{equation}\n",
"where ${a}_{p}^{\\dagger}$ and ${a}_{q}$ are fermionic creation and annihilation operators of orbitals $p$ and $q$, respectively. The terms $h_{pq} $ and \n",
"$v_{pqrs}$ are the matrix elements of the one-body, $H_1$, and two-body, $H_2$, interactions of $H$, respectively. Here, we omit the spin indices for simplicity. \n",
"$v_{pqrs}$ are the matrix elements of the one-body, $H_1$, and two-body, $H_2$, interactions of $H$, respectively. Here, we omit the spin indices for simplicity.\n",
"\n",
"AFQMC realizes an imaginary time propagation of an initial state (chosen as a Slater determinant) $\\ket{\\Psi_{I}}$ towards the ground state $\\ket{\\Psi_0}$ of a given hamiltonian, $H$, with\n",
"\\begin{equation}\n",
Expand Down Expand Up @@ -353,7 +352,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Preparation of the molecular Hamiltonian"
"### Preparation of the molecular Hamiltonian\n"
]
},
{
Expand Down Expand Up @@ -391,15 +390,15 @@
"afqmc_hamiltonian = HamGeneric(\n",
" np.array([h1e, h1e]),\n",
" cholesky_vectors.transpose((1, 2, 0)).reshape((num_basis * num_basis, num_chol)),\n",
" e0,\n",
" e0\n",
")\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Preparation of the trial wave function"
"### Preparation of the trial wave function\n"
]
},
{
Expand Down Expand Up @@ -433,14 +432,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Setup of the AFQMC parameters"
"### Setup of the AFQMC parameters\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here we can choose the input options like the timestep $\\Delta\\tau$, the total number of walkers `num_walkers` and the total number of AFQMC iterations `num_blocks`."
"Here we can choose the input options like the timestep $\\Delta\\tau$, the total number of walkers `num_walkers` and the total number of AFQMC iterations `num_blocks`.\n"
]
},
{
Expand Down Expand Up @@ -501,7 +500,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7a9769507370>"
"<matplotlib.legend.Legend at 0x7a9769507370>\n"
]
},
"execution_count": 9,
Expand Down Expand Up @@ -549,7 +548,7 @@
}
],
"source": [
"print(cudaq.__version__)"
"print(cudaq.__version__)\n"
]
}
],
Expand Down

0 comments on commit a3df618

Please sign in to comment.