diff --git a/docs/tutorials/03-double-factorized.ipynb b/docs/tutorials/03-double-factorized.ipynb index f3c37be1d..2952eda8f 100644 --- a/docs/tutorials/03-double-factorized.ipynb +++ b/docs/tutorials/03-double-factorized.ipynb @@ -35,7 +35,7 @@ "\n", "where $n_{\\sigma, i} = a^\\dagger_{\\sigma, i} a_{\\sigma, i}$ is the occupation number operator and $\\mathbf{J}_{ij}$ is a real symmetric matrix.\n", "\n", - "In the cell below, we construct the Hamiltonian for a hydrogen molecule at a stretched bond length and then get the double-factorized representation of the Hamiltonian." + "In the cell below, we construct the Hamiltonian for an ethene molecule at a stretched bond length and then get the double-factorized representation of the Hamiltonian." ] }, { @@ -47,14 +47,34 @@ "import pyscf\n", "import ffsim\n", "\n", - "# Build an H2 molecule\n", + "# Build a stretched ethene molecule\n", + "bond_distance = 2.678\n", + "a = 0.5 * bond_distance\n", + "b = a + 0.5626\n", + "c = 0.9289\n", "mol = pyscf.gto.Mole()\n", - "mol.build(atom=[[\"H\", (0, 0, 0)], [\"H\", (0, 0, 1.8)]], basis=\"sto-6g\", symmetry=\"d2h\")\n", + "mol.build(\n", + " atom=[\n", + " [\"C\", (0, 0, a)],\n", + " [\"C\", (0, 0, -a)],\n", + " [\"H\", (0, c, b)],\n", + " [\"H\", (0, -c, b)],\n", + " [\"H\", (0, c, -b)],\n", + " [\"H\", (0, -c, -b)],\n", + " ],\n", + " basis=\"sto-6g\",\n", + " symmetry=\"d2h\",\n", + ")\n", "hartree_fock = pyscf.scf.RHF(mol)\n", "hartree_fock.kernel()\n", "\n", + "# Define active space\n", + "active_space = range(mol.nelectron // 2 - 2, mol.nelectron // 2 + 2)\n", + "\n", "# Get molecular data and molecular Hamiltonian (one- and two-body tensors)\n", - "mol_data = ffsim.MolecularData.from_hartree_fock(hartree_fock)\n", + "mol_data = ffsim.MolecularData.from_hartree_fock(\n", + " hartree_fock, active_space=active_space\n", + ")\n", "norb = mol_data.norb\n", "nelec = mol_data.nelec\n", "mol_hamiltonian = mol_data.hamiltonian\n", @@ -69,7 +89,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Here, `mol_hamiltonian` is an instance of `MolecularHamiltonian`, a dataclass that stores the one- and two-body tensors, and `df_hamiltonian` is an instance of `DoubleFactorizedHamiltonian`, a dataclass that stores the updated one-body-tensor, diagonal Coulomb matrices, and orbital rotations. In the cell below, we print out the tensors describing the original and double-factorized representations." + "Here, `mol_hamiltonian` is an instance of `MolecularHamiltonian`, a dataclass that stores the one- and two-body tensors, and `df_hamiltonian` is an instance of `DoubleFactorizedHamiltonian`, a dataclass that stores the updated one-body-tensor, diagonal Coulomb matrices, and orbital rotations. In the cell below, we print out the shapes of the tensors describing the original and double-factorized representations." ] }, { @@ -78,26 +98,25 @@ "metadata": {}, "outputs": [], "source": [ - "# Print some information\n", "print(\"Original representation\")\n", "print(\"-----------------------\")\n", - "print(\"One-body tensor:\")\n", - "print(mol_hamiltonian.one_body_tensor)\n", + "print(\"One-body tensor shape:\")\n", + "print(mol_hamiltonian.one_body_tensor.shape)\n", "print()\n", - "print(\"Two-body tensor:\")\n", - "print(mol_hamiltonian.two_body_tensor)\n", + "print(\"Two-body tensor shape:\")\n", + "print(mol_hamiltonian.two_body_tensor.shape)\n", "print()\n", "\n", "print(\"Double-factorized representation\")\n", "print(\"--------------------------------\")\n", - "print(\"One-body tensor:\")\n", - "print(df_hamiltonian.one_body_tensor)\n", + "print(\"One-body tensor shape:\")\n", + "print(df_hamiltonian.one_body_tensor.shape)\n", "print()\n", - "print(\"Diagonal Coulomb matrices:\")\n", - "print(df_hamiltonian.diag_coulomb_mats)\n", + "print(\"Diagonal Coulomb matrices shape:\")\n", + "print(df_hamiltonian.diag_coulomb_mats.shape)\n", "print()\n", - "print(\"Orbital rotations:\")\n", - "print(df_hamiltonian.orbital_rotations)" + "print(\"Orbital rotations shape:\")\n", + "print(df_hamiltonian.orbital_rotations.shape)" ] }, { @@ -263,7 +282,7 @@ "source": [ "import scipy.sparse.linalg\n", "\n", - "time = 1.0\n", + "time = 5.0\n", "\n", "exact_state = scipy.sparse.linalg.expm_multiply(\n", " -1j * time * hamiltonian,\n",