-
Notifications
You must be signed in to change notification settings - Fork 35
[Docs] update gen_ham with UHF #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marwafar
wants to merge
4
commits into
NVIDIA:main
Choose a base branch
from
marwafar:gen_ham_doc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+122
−19
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,16 +2,16 @@ Generating Molecular Hamiltonians | |
| ---------------------------------- | ||
|
|
||
| The CUDA-Q Solvers library accelerates a wide range of applications in the domain of quantum chemistry. | ||
| To facilitate these calculations, CUDA-Q Solvers provides the `solver.create_molecule` function to allow users to generate basis sets and Hamiltonians for many systems of interest. | ||
| The molecule class contains basis set informations, and the Hamiltonian (`molecule.hamiltonian`) for the target systems. | ||
| To facilitate these calculations, CUDA-Q Solvers provides the `solver.create_molecule` function to allow users to generate the electronic Hamiltonians for many systems of interest. | ||
| The molecule class contains informations about the Hamiltonian (`molecule.hamiltonian`) for the target systems. | ||
| These Hamiltonians can then be used as input into the hybrid quantum-classical solvers that the CUDA-Q Solvers API provides. | ||
|
|
||
|
|
||
| Molecular Orbitals and Hamiltonians | ||
| +++++++++++++++++++++++++++++++++++ | ||
|
|
||
| First we define the atomic geometry of the molecule by specifying a array of atomic symbols as strings, and coordinates in 3D space. We then get a molecule object from the `solvers.create_molecule` call. | ||
| Here we create "default" Hamiltonian for the N2 system using complete active space molecular orbitals constructed from Hartree-Fock atomic orbitals. | ||
| First, we define the atomic geometry of the molecule by specifying an array of atomic symbols as strings, and coordinates in 3D space. We then get a molecule object from the `solvers.create_molecule` call. | ||
| Here, we create "default" Hamiltonian for the N2 system using complete active space molecular orbitals constructed from Restricted Hartree-Fock molecular orbitals. | ||
|
|
||
| .. tab:: Python | ||
|
|
||
|
|
@@ -27,15 +27,32 @@ Here we create "default" Hamiltonian for the N2 system using complete active spa | |
| verbose=True) | ||
|
|
||
| We specify: | ||
| - The geometry previously created | ||
| - The single particle basis set (here STO-3G) | ||
| - The total spin | ||
| - The geometry previously created. User can also provide geometry through the path to the XYZ file. For example, `geometry='path/to/xyz/file.xyz'`. | ||
| - The basis set (here STO-3G) | ||
| - The total spin (2 * S) | ||
| - The total charge | ||
| - The number of electrons in the complete active space | ||
| - The number of orbitals in the complete activate space | ||
| - The number of orbitals in the complete active space | ||
| - A verbosity flag to help introspect on the data what was generated. | ||
|
|
||
| Along with the orbitals and Hamiltonian, we can also view various properties like the Hartree-Fock energy, and the energy of the frozen core orbitals by printing `molecule.energies`. | ||
| Along with the Hamiltonian, we can also view various properties like the Hartree-Fock energy, and the energy of the frozen core orbitals by printing `molecule.energies`. | ||
|
|
||
| For using Unrestricted Hartree-Fock (UHF) orbitals, user can set the `UR` parameter to `True` in the `create_molecule` function. Here's an example: | ||
|
|
||
| .. tab:: Python | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| geometry = [('N', (0.0, 0.0, 0.5600)), ('N', (0.0, 0.0, -0.5600))] | ||
| molecule = solvers.create_molecule(geometry, | ||
| 'sto-3g', | ||
| 0, | ||
| 0, | ||
| nele_cas=2, | ||
| norb_cas=3, | ||
| UR=True, | ||
| verbose=True) | ||
|
|
||
|
|
||
| Natural Orbitals from MP2 | ||
| ++++++++++++++++++++++++++ | ||
|
|
@@ -56,12 +73,15 @@ Now we take our same N2 molecule, but generate natural orbitals from second orde | |
| integrals_natorb=True, | ||
| verbose=True) | ||
|
|
||
| Note that we use the same API but,toggle `MP2=True` and `integrals_natorb=True`. | ||
| Note that we use the same API but,toggle `MP2=True` and `integrals_natorb=True`. This will generate the molecular orbitals from MP2 natural orbitals, and compute the Hamiltonian integrals in this basis. | ||
| This option is unallowed yet when using `UR=True`. When using `UR=True`, only UHF molecular orbitals are employed to generate the electronic Hamiltonian. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "not yet available for" |
||
|
|
||
| CASSCF Orbitals | ||
| +++++++++++++++ | ||
|
|
||
| Next, we can start from either Hartree-Fock or perturbation theory atomic orbitals and build complete active space self-consistent field (CASSCF) molecular orbitals. | ||
| Next, we can start from either Hartree-Fock or perturbation theory natural orbitals and build complete active space self-consistent field (CASSCF) molecular orbitals. | ||
|
|
||
| In the example below, we employ the CASSCF procedure starting from RHF molecular orbitals to generate the spin molecular Hamiltonian. | ||
|
|
||
| .. tab:: Python | ||
|
|
||
|
|
@@ -78,7 +98,8 @@ Next, we can start from either Hartree-Fock or perturbation theory atomic orbita | |
| integrals_casscf=True, | ||
| verbose=True) | ||
|
|
||
| For Hartree-Fock, or | ||
| Alternatively, we can also start from RHF, then MP2 natural orbitals and then perform CASSCF to generate the spin molecular Hamiltonian. | ||
| In this case, natural orbitals from MP2 are used to set the active space for the CASSCF procedure. | ||
|
|
||
| .. tab:: Python | ||
|
|
||
|
|
@@ -97,7 +118,42 @@ For Hartree-Fock, or | |
| integrals_casscf=True, | ||
| verbose=True) | ||
|
|
||
| for MP2. In these cases, printing the `molecule.energies` also shows the `R-CASSCF` energy for the system. | ||
| In these cases, printing the `molecule.energies` also shows the `R-CASSCF` energy for the system. | ||
|
|
||
| Now that we have seen how to generate basis sets and Hamiltonians for quantum chemistry systems, we can use these as inputs to hybrid quantum-classical methods like VQE or adapt VQE via the CUDA-Q Solvers API. | ||
|
|
||
| For open-shell systems | ||
| ++++++++++++++++++++++++++ | ||
|
|
||
| For Restricted Open-shell Hartree-Fock (ROHF) orbitals, user can set the `spin` parameter to a non-zero value while keeping the `charge` parameter as needed. For example, for a molecule with one unpaired electron, you can set `spin=1` and `charge=1`. Here's an example: | ||
|
|
||
| .. tab:: Python | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| geometry = [('N', (0.0, 0.0, 0.5600)), ('N', (0.0, 0.0, -0.5600))] | ||
| molecule = solvers.create_molecule(geometry, | ||
| 'sto-3g', | ||
| 1, | ||
| 1, | ||
| nele_cas=3, | ||
| norb_cas=3, | ||
| verbose=True) | ||
|
|
||
|
|
||
| For Unrestricted Hartree-Fock (UHF) orbitals, user can set `UR=True` and the `spin` parameter to a non-zero value while keeping the `charge` parameter as needed. Here's an example: | ||
|
|
||
| .. tab:: Python | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| geometry = [('N', (0.0, 0.0, 0.5600)), ('N', (0.0, 0.0, -0.5600))] | ||
| molecule = solvers.create_molecule(geometry, | ||
| 'sto-3g', | ||
| 1, | ||
| 1, | ||
| nele_cas=3, | ||
| norb_cas=3, | ||
| UR=True, | ||
| verbose=True) | ||
|
|
||
| Now that we have seen how to generate the spin molecular Hamiltonians for quantum chemistry systems, we can use these as inputs to hybrid quantum-classical methods like VQE or adapt VQE via the CUDA-Q Solvers API. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any merit to just calling this option "UHF" rather than "UR"? May just be easier to remember.