diff --git a/doc/source/code-examples/examples.rst b/doc/source/code-examples/examples.rst deleted file mode 100644 index 56daef8..0000000 --- a/doc/source/code-examples/examples.rst +++ /dev/null @@ -1,46 +0,0 @@ -Basic examples -============== - -Here are a few short basic `how to` examples. - -How to define a Molecule in Qibochem ------------------------------------- - -A ``Molecule`` can be defined either inline, or using an ``.xyz`` file. An example for a H2 molecule: - -.. code-block:: - - from qibochem.driver.molecule import Molecule - - # Inline definition - h2 = Molecule([('H', (0.0, 0.0, 0.0)), ('H', (0.0, 0.0, 0.74804))]) - - # From an .xyz file - # h2 = Molecule(xyz_file='h2.xyz') - -Interfacing with PSI4/PySCF to obtain the 1-/2- electron integrals ------------------------------------------------------------------- - -After defining a ``Molecule``, the next step is to obtain the molecular integrals. Qibochem has has functions that interface with either `PySCF`_ or `PSI4`_ to do so: - -.. _PySCF: https://pyscf.org/ -.. _PSI4: https://psicode.org/ - -.. code-block:: - - from qibochem.driver.molecule import Molecule - - # Inline definition of H2 - h2 = Molecule([('H', (0.0, 0.0, 0.0)), ('H', (0.0, 0.0, 0.74804))]) - - # Using PySCF - h2.run_pyscf() - # Using PSI4 - # h2.run_psi4() - -Next section ------------- - -hello world - - diff --git a/doc/source/code-examples/index.rst b/doc/source/code-examples/index.rst index ca5822e..1bb0728 100644 --- a/doc/source/code-examples/index.rst +++ b/doc/source/code-examples/index.rst @@ -8,4 +8,4 @@ This section provides examples of how to use Qibochem. .. toctree:: :maxdepth: 2 - examples + molecule diff --git a/doc/source/code-examples/molecule.rst b/doc/source/code-examples/molecule.rst new file mode 100644 index 0000000..226e560 --- /dev/null +++ b/doc/source/code-examples/molecule.rst @@ -0,0 +1,60 @@ +Building a Molecule +=================== + +To get started with Qibochem, the molecular system of interest is first defined: + +Molecular geometry input +------------------------ + +A ``Molecule`` can be defined either inline, or using an ``.xyz`` file. An example for a H2 molecule: + +.. code-block:: + + from qibochem.driver.molecule import Molecule + + # Inline definition + h2 = Molecule([('H', (0.0, 0.0, 0.0)), ('H', (0.0, 0.0, 0.74804))]) + + # From an .xyz file + # h2 = Molecule(xyz_file='h2.xyz') + +Note that the comment line in the ``.xyz`` file can be used to define the electronic charge and spin multiplicity of the molecule. +If it is not given, it defaults to 0 and 1, respectively. + + +Obtaining the molecular Hamiltonian +----------------------------------- + +After defining the molecular coordinates, the next step is to obtain the molecular integrals. +Qibochem offers the functionality to interface with either `PySCF`_ or `PSI4`_ towards that end: + +.. _PySCF: https://pyscf.org/ +.. _PSI4: https://psicode.org/ + +.. code-block:: + + from qibochem.driver.molecule import Molecule + + # Inline definition of H2 + h2 = Molecule([('H', (0.0, 0.0, 0.0)), ('H', (0.0, 0.0, 0.74804))]) + + # Using PySCF + h2.run_pyscf() + # Using PSI4 + # h2.run_psi4() + +After the molecular integrals have been calculated, molecular Hamiltonian can then be constructed in the form of a Qibo ``SymbolicHamiltonian``: + +.. code-block:: + + from qibochem.driver.molecule import Molecule + + # Inline definition of H2 + h2 = Molecule([('H', (0.0, 0.0, 0.0)), ('H', (0.0, 0.0, 0.74804))]) + + # Calculate molecular integrals + h2.run_pyscf() + + # Get molecular Hamiltonian + hamiltonian = h2.hamiltonian() +