ffsim 0.0.71__tar.gz → 0.0.72__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. {ffsim-0.0.71 → ffsim-0.0.72}/PKG-INFO +1 -1
  2. {ffsim-0.0.71/docs/how-to-guides → ffsim-0.0.72/docs/explanations}/fermion-operator.ipynb +1 -1
  3. {ffsim-0.0.71 → ffsim-0.0.72}/docs/explanations/index.md +2 -0
  4. {ffsim-0.0.71 → ffsim-0.0.72}/docs/explanations/lucj.ipynb +1 -1
  5. {ffsim-0.0.71 → ffsim-0.0.72}/docs/explanations/protocols.ipynb +1 -1
  6. ffsim-0.0.72/docs/explanations/variational-ansatzes.ipynb +472 -0
  7. {ffsim-0.0.71 → ffsim-0.0.72}/docs/how-to-guides/compute-expectation-values.ipynb +1 -1
  8. {ffsim-0.0.71 → ffsim-0.0.72}/docs/how-to-guides/index.md +1 -2
  9. ffsim-0.0.71/docs/how-to-guides/simulate-lucj.ipynb → ffsim-0.0.72/docs/how-to-guides/simulate-vqe.ipynb +78 -88
  10. {ffsim-0.0.71 → ffsim-0.0.72}/pyproject.toml +1 -1
  11. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/__init__.py +2 -0
  12. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/linalg/givens.py +4 -1
  13. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/gates/slater_determinant.py +2 -1
  14. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/random/__init__.py +2 -0
  15. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/random/random.py +44 -0
  16. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/variational/__init__.py +2 -0
  17. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/variational/uccsd.py +295 -0
  18. {ffsim-0.0.71 → ffsim-0.0.72}/src/fermion_operator.rs +1 -1
  19. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/variational/uccsd_test.py +132 -0
  20. {ffsim-0.0.71 → ffsim-0.0.72}/uv.lock +1 -1
  21. {ffsim-0.0.71 → ffsim-0.0.72}/.dockerignore +0 -0
  22. {ffsim-0.0.71 → ffsim-0.0.72}/.github/workflows/build-and-release.yml +0 -0
  23. {ffsim-0.0.71 → ffsim-0.0.72}/.github/workflows/check.yml +0 -0
  24. {ffsim-0.0.71 → ffsim-0.0.72}/.github/workflows/docker.yml +0 -0
  25. {ffsim-0.0.71 → ffsim-0.0.72}/.github/workflows/docs-dev.yml +0 -0
  26. {ffsim-0.0.71 → ffsim-0.0.72}/.github/workflows/docs-release.yml +0 -0
  27. {ffsim-0.0.71 → ffsim-0.0.72}/.github/workflows/test-latest-versions.yml +0 -0
  28. {ffsim-0.0.71 → ffsim-0.0.72}/.github/workflows/test-minimum-versions.yml +0 -0
  29. {ffsim-0.0.71 → ffsim-0.0.72}/.gitignore +0 -0
  30. {ffsim-0.0.71 → ffsim-0.0.72}/.pre-commit-config.yaml +0 -0
  31. {ffsim-0.0.71 → ffsim-0.0.72}/CONTRIBUTING.md +0 -0
  32. {ffsim-0.0.71 → ffsim-0.0.72}/Cargo.lock +0 -0
  33. {ffsim-0.0.71 → ffsim-0.0.72}/Cargo.toml +0 -0
  34. {ffsim-0.0.71 → ffsim-0.0.72}/Dockerfile +0 -0
  35. {ffsim-0.0.71 → ffsim-0.0.72}/LICENSE +0 -0
  36. {ffsim-0.0.71 → ffsim-0.0.72}/README.md +0 -0
  37. {ffsim-0.0.71 → ffsim-0.0.72}/compose.yaml +0 -0
  38. {ffsim-0.0.71 → ffsim-0.0.72}/docs/api/ffsim.contract.rst +0 -0
  39. {ffsim-0.0.71 → ffsim-0.0.72}/docs/api/ffsim.linalg.rst +0 -0
  40. {ffsim-0.0.71 → ffsim-0.0.72}/docs/api/ffsim.optimize.rst +0 -0
  41. {ffsim-0.0.71 → ffsim-0.0.72}/docs/api/ffsim.qiskit.rst +0 -0
  42. {ffsim-0.0.71 → ffsim-0.0.72}/docs/api/ffsim.random.rst +0 -0
  43. {ffsim-0.0.71 → ffsim-0.0.72}/docs/api/ffsim.rst +0 -0
  44. {ffsim-0.0.71 → ffsim-0.0.72}/docs/api/ffsim.testing.rst +0 -0
  45. {ffsim-0.0.71 → ffsim-0.0.72}/docs/api/index.md +0 -0
  46. {ffsim-0.0.71 → ffsim-0.0.72}/docs/conf.py +0 -0
  47. {ffsim-0.0.71 → ffsim-0.0.72}/docs/explanations/diag-coulomb-hamiltonian.ipynb +0 -0
  48. {ffsim-0.0.71 → ffsim-0.0.72}/docs/explanations/double-factorized.ipynb +0 -0
  49. {ffsim-0.0.71 → ffsim-0.0.72}/docs/explanations/hamiltonians.ipynb +0 -0
  50. {ffsim-0.0.71 → ffsim-0.0.72}/docs/explanations/orbital-rotation.ipynb +0 -0
  51. {ffsim-0.0.71 → ffsim-0.0.72}/docs/explanations/qubit-gate-decompositions.ipynb +0 -0
  52. {ffsim-0.0.71 → ffsim-0.0.72}/docs/explanations/state-vectors-and-gates.ipynb +0 -0
  53. {ffsim-0.0.71 → ffsim-0.0.72}/docs/how-to-guides/entanglement-forging.ipynb +0 -0
  54. {ffsim-0.0.71 → ffsim-0.0.72}/docs/how-to-guides/qiskit-circuits-sim.ipynb +0 -0
  55. {ffsim-0.0.71 → ffsim-0.0.72}/docs/how-to-guides/qiskit-lucj.ipynb +0 -0
  56. {ffsim-0.0.71 → ffsim-0.0.72}/docs/how-to-guides/qiskit-merge-orbital-rotations.ipynb +0 -0
  57. {ffsim-0.0.71 → ffsim-0.0.72}/docs/how-to-guides/qiskit-trotter.ipynb +0 -0
  58. {ffsim-0.0.71 → ffsim-0.0.72}/docs/how-to-guides/sample-from-state-vectors.ipynb +0 -0
  59. {ffsim-0.0.71 → ffsim-0.0.72}/docs/how-to-guides/sample-slater.ipynb +0 -0
  60. {ffsim-0.0.71 → ffsim-0.0.72}/docs/how-to-guides/simulate-trotter-hubbard.ipynb +0 -0
  61. {ffsim-0.0.71 → ffsim-0.0.72}/docs/how-to-guides/simulate-trotter-mol-ham.ipynb +0 -0
  62. {ffsim-0.0.71 → ffsim-0.0.72}/docs/index.md +0 -0
  63. {ffsim-0.0.71 → ffsim-0.0.72}/docs/install.md +0 -0
  64. {ffsim-0.0.71 → ffsim-0.0.72}/docs/tutorials/double-factorized-trotter.ipynb +0 -0
  65. {ffsim-0.0.71 → ffsim-0.0.72}/docs/tutorials/index.md +0 -0
  66. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/_lib.pyi +0 -0
  67. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/_slow/__init__.py +0 -0
  68. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/_slow/contract/__init__.py +0 -0
  69. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/_slow/contract/diag_coulomb.py +0 -0
  70. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/_slow/contract/num_op_sum.py +0 -0
  71. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/_slow/fermion_operator.py +0 -0
  72. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/_slow/gates/__init__.py +0 -0
  73. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/_slow/gates/diag_coulomb.py +0 -0
  74. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/_slow/gates/num_op_sum.py +0 -0
  75. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/_slow/gates/orbital_rotation.py +0 -0
  76. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/cistring.py +0 -0
  77. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/contract/__init__.py +0 -0
  78. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/contract/diag_coulomb.py +0 -0
  79. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/contract/num_op_sum.py +0 -0
  80. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/contract/one_body.py +0 -0
  81. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/contract/two_body.py +0 -0
  82. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/dimensions.py +0 -0
  83. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/gates/__init__.py +0 -0
  84. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/gates/basic_gates.py +0 -0
  85. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/gates/diag_coulomb.py +0 -0
  86. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/gates/num_op_sum.py +0 -0
  87. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/gates/orbital_rotation.py +0 -0
  88. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/gates/quad_ham.py +0 -0
  89. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/hamiltonians/__init__.py +0 -0
  90. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/hamiltonians/diagonal_coulomb_hamiltonian.py +0 -0
  91. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/hamiltonians/double_factorized_hamiltonian.py +0 -0
  92. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/hamiltonians/molecular_hamiltonian.py +0 -0
  93. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/hamiltonians/single_factorized_hamiltonian.py +0 -0
  94. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/linalg/__init__.py +0 -0
  95. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/linalg/double_factorized_decomposition.py +0 -0
  96. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/linalg/linalg.py +0 -0
  97. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/linalg/predicates.py +0 -0
  98. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/linalg/util.py +0 -0
  99. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/molecular_data.py +0 -0
  100. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/operators/__init__.py +0 -0
  101. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/operators/common_operators.py +0 -0
  102. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/operators/coupled_cluster.py +0 -0
  103. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/operators/fermi_hubbard.py +0 -0
  104. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/operators/fermion_action.py +0 -0
  105. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/operators/fermion_operator.py +0 -0
  106. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/optimize/__init__.py +0 -0
  107. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/optimize/_util.py +0 -0
  108. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/optimize/linear_method.py +0 -0
  109. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/protocols/__init__.py +0 -0
  110. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/protocols/apply_unitary_protocol.py +0 -0
  111. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/protocols/approximate_equality_protocol.py +0 -0
  112. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/protocols/diagonal_protocol.py +0 -0
  113. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/protocols/fermion_operator_protocol.py +0 -0
  114. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/protocols/linear_operator_protocol.py +0 -0
  115. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/protocols/trace_protocol.py +0 -0
  116. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/py.typed +0 -0
  117. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/__init__.py +0 -0
  118. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/gates/__init__.py +0 -0
  119. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/gates/diag_coulomb.py +0 -0
  120. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/gates/diag_coulomb_trotter_split_op.py +0 -0
  121. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/gates/double_factorized_trotter.py +0 -0
  122. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/gates/givens_ansatz.py +0 -0
  123. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/gates/num_num_ansatz.py +0 -0
  124. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/gates/num_op_sum.py +0 -0
  125. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/gates/orbital_rotation.py +0 -0
  126. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/gates/ucj.py +0 -0
  127. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/jordan_wigner.py +0 -0
  128. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/sampler.py +0 -0
  129. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/sim.py +0 -0
  130. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/transpiler_passes/__init__.py +0 -0
  131. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/transpiler_passes/drop_negligible.py +0 -0
  132. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/transpiler_passes/merge_orbital_rotations.py +0 -0
  133. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/transpiler_stages.py +0 -0
  134. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/qiskit/util.py +0 -0
  135. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/spin.py +0 -0
  136. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/states/__init__.py +0 -0
  137. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/states/bitstring.py +0 -0
  138. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/states/product_state_sum.py +0 -0
  139. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/states/rdm.py +0 -0
  140. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/states/sample_slater.py +0 -0
  141. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/states/slater.py +0 -0
  142. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/states/states.py +0 -0
  143. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/states/wick.py +0 -0
  144. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/testing/__init__.py +0 -0
  145. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/testing/testing.py +0 -0
  146. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/trotter/__init__.py +0 -0
  147. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/trotter/_util.py +0 -0
  148. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/trotter/diagonal_coulomb_split_op.py +0 -0
  149. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/trotter/double_factorized.py +0 -0
  150. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/trotter/qdrift.py +0 -0
  151. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/variational/givens.py +0 -0
  152. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/variational/hopgate.py +0 -0
  153. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/variational/multireference.py +0 -0
  154. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/variational/num_num.py +0 -0
  155. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/variational/orbital_optimization.py +0 -0
  156. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/variational/ucj_angles_spin_balanced.py +0 -0
  157. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/variational/ucj_spin_balanced.py +0 -0
  158. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/variational/ucj_spin_unbalanced.py +0 -0
  159. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/variational/ucj_spinless.py +0 -0
  160. {ffsim-0.0.71 → ffsim-0.0.72}/python/ffsim/variational/util.py +0 -0
  161. {ffsim-0.0.71 → ffsim-0.0.72}/src/contract/diag_coulomb.rs +0 -0
  162. {ffsim-0.0.71 → ffsim-0.0.72}/src/contract/mod.rs +0 -0
  163. {ffsim-0.0.71 → ffsim-0.0.72}/src/contract/num_op_sum.rs +0 -0
  164. {ffsim-0.0.71 → ffsim-0.0.72}/src/gates/diag_coulomb.rs +0 -0
  165. {ffsim-0.0.71 → ffsim-0.0.72}/src/gates/mod.rs +0 -0
  166. {ffsim-0.0.71 → ffsim-0.0.72}/src/gates/num_op_sum.rs +0 -0
  167. {ffsim-0.0.71 → ffsim-0.0.72}/src/gates/orbital_rotation.rs +0 -0
  168. {ffsim-0.0.71 → ffsim-0.0.72}/src/gates/phase_shift.rs +0 -0
  169. {ffsim-0.0.71 → ffsim-0.0.72}/src/jordan_wigner.rs +0 -0
  170. {ffsim-0.0.71 → ffsim-0.0.72}/src/lib.rs +0 -0
  171. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/__init__.py +0 -0
  172. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/_slow/__init__.py +0 -0
  173. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/_slow/contract/__init__.py +0 -0
  174. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/_slow/contract/diag_coulomb_test.py +0 -0
  175. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/_slow/contract/num_op_sum_test.py +0 -0
  176. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/_slow/gates/__init__.py +0 -0
  177. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/_slow/gates/diag_coulomb_test.py +0 -0
  178. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/_slow/gates/num_op_sum_test.py +0 -0
  179. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/_slow/gates/orbital_rotation_test.py +0 -0
  180. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/contract/__init__.py +0 -0
  181. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/contract/diag_coulomb_test.py +0 -0
  182. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/contract/num_op_sum_test.py +0 -0
  183. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/contract/two_body_test.py +0 -0
  184. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/gates/__init__.py +0 -0
  185. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/gates/basic_gates_test.py +0 -0
  186. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/gates/diag_coulomb_test.py +0 -0
  187. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/gates/num_op_sum_test.py +0 -0
  188. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/gates/orbital_rotation_test.py +0 -0
  189. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/gates/quad_ham_test.py +0 -0
  190. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/hamiltonians/__init__.py +0 -0
  191. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/hamiltonians/diagonal_coulomb_hamiltonian_test.py +0 -0
  192. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/hamiltonians/double_factorized_hamiltonian_test.py +0 -0
  193. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/hamiltonians/molecular_hamiltonian_test.py +0 -0
  194. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/hamiltonians/single_factorized_hamiltonian_test.py +0 -0
  195. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/linalg/__init__.py +0 -0
  196. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/linalg/double_factorized_decomposition_test.py +0 -0
  197. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/linalg/givens_test.py +0 -0
  198. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/linalg/linalg_test.py +0 -0
  199. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/linalg/util_test.py +0 -0
  200. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/molecular_data_test.py +0 -0
  201. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/operators/__init__.py +0 -0
  202. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/operators/common_operators_test.py +0 -0
  203. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/operators/coupled_cluster_test.py +0 -0
  204. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/operators/fermi_hubbard_test.py +0 -0
  205. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/operators/fermion_action_test.py +0 -0
  206. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/operators/fermion_operator_test.py +0 -0
  207. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/optimize/__init__.py +0 -0
  208. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/optimize/linear_method_test.py +0 -0
  209. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/protocols/__init__.py +0 -0
  210. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/protocols/trace_protocol_test.py +0 -0
  211. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/__init__.py +0 -0
  212. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/gates/__init__.py +0 -0
  213. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/gates/diag_coulomb_test.py +0 -0
  214. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/gates/diag_coulomb_trotter_split_op_test.py +0 -0
  215. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/gates/double_factorized_trotter_test.py +0 -0
  216. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/gates/givens_ansatz_test.py +0 -0
  217. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/gates/num_num_ansatz_test.py +0 -0
  218. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/gates/num_op_sum_test.py +0 -0
  219. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/gates/orbital_rotation_test.py +0 -0
  220. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/gates/slater_determinant_test.py +0 -0
  221. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/gates/ucj_test.py +0 -0
  222. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/jordan_wigner_test.py +0 -0
  223. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/sampler_test.py +0 -0
  224. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/sim_test.py +0 -0
  225. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/transpiler_passes/__init__.py +0 -0
  226. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/transpiler_passes/drop_negligible_test.py +0 -0
  227. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/transpiler_passes/merge_orbital_rotations_test.py +0 -0
  228. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/qiskit/util_test.py +0 -0
  229. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/random_test.py +0 -0
  230. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/states/__init__.py +0 -0
  231. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/states/bitstring_test.py +0 -0
  232. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/states/rdm_test.py +0 -0
  233. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/states/sample_slater_test.py +0 -0
  234. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/states/slater_test.py +0 -0
  235. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/states/states_test.py +0 -0
  236. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/states/wick_test.py +0 -0
  237. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/test_data/orbital_rotation-0.npy +0 -0
  238. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/test_no_warnings.py +0 -0
  239. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/testing_test.py +0 -0
  240. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/trotter/__init__.py +0 -0
  241. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/trotter/diag_coulomb_split_op_test.py +0 -0
  242. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/trotter/double_factorized_test.py +0 -0
  243. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/trotter/qdrift_test.py +0 -0
  244. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/variational/__init__.py +0 -0
  245. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/variational/givens_test.py +0 -0
  246. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/variational/hopgate_test.py +0 -0
  247. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/variational/multireference_test.py +0 -0
  248. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/variational/num_num_test.py +0 -0
  249. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/variational/orbital_optimization_test.py +0 -0
  250. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/variational/ucj_angles_spin_balanced_test.py +0 -0
  251. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/variational/ucj_spin_balanced_test.py +0 -0
  252. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/variational/ucj_spin_unbalanced_test.py +0 -0
  253. {ffsim-0.0.71 → ffsim-0.0.72}/tests/python/variational/ucj_spinless_test.py +0 -0
  254. {ffsim-0.0.71 → ffsim-0.0.72}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ffsim
3
- Version: 0.0.71
3
+ Version: 0.0.72
4
4
  Classifier: License :: OSI Approved :: Apache Software License
5
5
  Classifier: Programming Language :: Python
6
6
  Classifier: Programming Language :: Python :: 3 :: Only
@@ -6,7 +6,7 @@
6
6
  "source": [
7
7
  "# The FermionOperator class\n",
8
8
  "\n",
9
- "This guide shows how to use the [FermionOperator](https://qiskit-community.github.io/ffsim/api/ffsim.html#ffsim.FermionOperator) class to represent arbitrary fermionic operators.\n",
9
+ "This page describes the [FermionOperator](https://qiskit-community.github.io/ffsim/api/ffsim.html#ffsim.FermionOperator) class, which is used to represent arbitrary fermionic operators.\n",
10
10
  "\n",
11
11
  "## Data representation\n",
12
12
  "\n",
@@ -5,10 +5,12 @@
5
5
 
6
6
  state-vectors-and-gates
7
7
  hamiltonians
8
+ variational-ansatzes
8
9
  orbital-rotation
9
10
  double-factorized
10
11
  diag-coulomb-hamiltonian
11
12
  lucj
13
+ fermion-operator
12
14
  protocols
13
15
  qubit-gate-decompositions
14
16
  ```
@@ -11,7 +11,7 @@
11
11
  "source": [
12
12
  "# The local unitary cluster Jastrow (LUCJ) ansatz\n",
13
13
  "\n",
14
- "This page explains the local unitary cluster Jastrow (LUCJ) ansatz, which was originally introduced in [Motta et al. (2023)](https://pubs.rsc.org/en/content/articlelanding/2023/sc/d3sc02516k). For a guide on simulating the LUCJ ansatz using ffsim, see [How to simulate the local unitary cluster Jastrow (LUCJ) ansatz](../how-to-guides/simulate-lucj.ipynb).\n",
14
+ "This page explains the local unitary cluster Jastrow (LUCJ) ansatz, which was originally introduced in [Motta et al. (2023)](https://pubs.rsc.org/en/content/articlelanding/2023/sc/d3sc02516k). For a guide on variationally optimizing the LUCJ ansatz using ffsim, see [Simulate the variational quantum eigensolver (VQE)](../how-to-guides/simulate-vqe.ipynb).\n",
15
15
  "\n",
16
16
  "## The general unitary cluster Jastrow (UCJ) ansatz\n",
17
17
  "\n",
@@ -167,7 +167,7 @@
167
167
  "source": [
168
168
  "## SupportsFermionOperator\n",
169
169
  "\n",
170
- "The `SupportsFermionOperator` protocol is for objects that can be converted to a [FermionOperator](../api/ffsim.rst#ffsim.FermionOperator), which is ffsim's symbolic representation of a [fermionic operator](../how-to-guides/fermion-operator.ipynb) as a linear combination of products of creation and annihilation operators. A class implements this protocol by defining the `_fermion_operator_` method, which has the signature\n",
170
+ "The `SupportsFermionOperator` protocol is for objects that can be converted to a [FermionOperator](../api/ffsim.rst#ffsim.FermionOperator), which is ffsim's symbolic representation of a [fermionic operator](../explanations/fermion-operator.ipynb) as a linear combination of products of creation and annihilation operators. A class implements this protocol by defining the `_fermion_operator_` method, which has the signature\n",
171
171
  "\n",
172
172
  "```python\n",
173
173
  "def _fermion_operator_(self) -> FermionOperator:\n",
@@ -0,0 +1,472 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "0a07a2ad",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Variational ansatzes\n",
9
+ "\n",
10
+ "This page explains how ffsim represents variational ansatzes.\n",
11
+ "\n",
12
+ "## Design\n",
13
+ "\n",
14
+ "In ffsim, a variational ansatz is a parameterized unitary operator. ffsim includes several classes for representing variational ansatzes. Each ansatz class stores the parameters of the ansatz in NumPy arrays, and implements the `SupportsApplyUnitary` [protocol](../explanations/protocols.ipynb) so that it can be passed to [ffsim.apply_unitary](../api/ffsim.rst#ffsim.apply_unitary) to apply the ansatz operator to a state vector.\n",
15
+ "\n",
16
+ "To facilitate variational optimization, each ansatz class implements:\n",
17
+ "\n",
18
+ "- `n_params`: a static method that returns the number of real-valued parameters\n",
19
+ " for a given set of ansatz settings.\n",
20
+ "- `from_parameters`: a static method that constructs the ansatz from a flat NumPy array of real-valued parameters.\n",
21
+ "- `to_parameters`: an instance method that converts the ansatz back to a flat NumPy array of real-valued parameters.\n",
22
+ "\n",
23
+ "These methods make it straightforward to use the ansatzes with standard numerical optimizers. For a guide on variational optimization, see [Simulate the variational quantum eigensolver (VQE)](../how-to-guides/simulate-vqe.ipynb).\n",
24
+ "\n",
25
+ "## Ansatz classes\n",
26
+ "\n",
27
+ "The rest of this page gives an overview of the variational ansatz classes in ffsim."
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "code",
32
+ "execution_count": 1,
33
+ "id": "89bbc9d6",
34
+ "metadata": {},
35
+ "outputs": [],
36
+ "source": [
37
+ "import numpy as np\n",
38
+ "\n",
39
+ "import ffsim\n",
40
+ "\n",
41
+ "# Use 4 spatial orbitals and 2 alpha + 2 beta electrons, as an example.\n",
42
+ "norb = 4\n",
43
+ "nocc = 2\n",
44
+ "nvrt = norb - nocc\n",
45
+ "nelec = (nocc, nocc)\n",
46
+ "\n",
47
+ "rng = np.random.default_rng(12345)\n",
48
+ "\n",
49
+ "# Reference state: Hartree-Fock state\n",
50
+ "reference_state = ffsim.hartree_fock_state(norb, nelec)\n",
51
+ "reference_state_spinless = ffsim.hartree_fock_state(norb, nocc)"
52
+ ]
53
+ },
54
+ {
55
+ "cell_type": "markdown",
56
+ "id": "926dfe98",
57
+ "metadata": {},
58
+ "source": [
59
+ "### UCJ ansatzes\n",
60
+ "\n",
61
+ "The unitary cluster Jastrow (UCJ) ansatz has the form\n",
62
+ "\n",
63
+ "$$\n",
64
+ " \\lvert \\Psi \\rangle = \\prod_{k = 1}^{L} \\mathcal{U}_k e^{i \\mathcal{J}_k} \\mathcal{U}_k^\\dagger \\lvert \\Phi_0 \\rangle\n",
65
+ "$$\n",
66
+ "\n",
67
+ "where $\\lvert \\Phi_0 \\rangle$ is a reference state, each $\\mathcal{U}_k$ is an\n",
68
+ "[orbital rotation](orbital-rotation.ipynb), and each $\\mathcal{J}_k$ is a diagonal\n",
69
+ "Coulomb operator of the form\n",
70
+ "\n",
71
+ "$$\n",
72
+ " \\mathcal{J} = \\frac{1}{2}\\sum_{\\sigma \\tau, ij} \\mathbf{J}^{\\sigma \\tau}_{ij} n_{\\sigma, i} n_{\\tau, j}.\n",
73
+ "$$\n",
74
+ "\n",
75
+ "The number of terms $L$ is referred to as the number of ansatz repetitions. An optional final orbital rotation can be appended at the end to support variational optimization of the orbital basis.\n",
76
+ "\n",
77
+ "The local UCJ (LUCJ) ansatz is implemented using the same classes as UCJ, by specifying additional arguments. For more detail on the UCJ ansatz, including its connection to CCSD and LUCJ, see [The local unitary cluster Jastrow (LUCJ) ansatz](lucj.ipynb).\n",
78
+ "\n",
79
+ "ffsim provides three UCJ classes that differ in their spin symmetry assumptions. The diagonal Coulomb matrices and orbital rotations are stored as NumPy arrays. The parameter vector encodes the independent entries of the diagonal Coulomb matrices (upper-triangular entries, since the matrices are symmetric) and the entries of the logarithms of the orbital rotations.\n",
80
+ "\n",
81
+ "#### UCJOpSpinBalanced\n",
82
+ "\n",
83
+ "The [UCJOpSpinBalanced](../api/ffsim.rst#ffsim.UCJOpSpinBalanced) class represents the spin-balanced UCJ operator, appropriate for closed-shell systems. It imposes the constraints $\\mathbf{J}^{\\alpha\\alpha} = \\mathbf{J}^{\\beta\\beta}$ and $\\mathbf{J}^{\\alpha\\beta} = \\mathbf{J}^{\\beta\\alpha}$, so each diagonal Coulomb operator is described by two symmetric matrices: $\\mathbf{J}^{\\alpha\\alpha}$ and $\\mathbf{J}^{\\alpha\\beta}$. The same orbital rotation is applied to both spin sectors.\n",
84
+ "\n",
85
+ "The data stored by this class consists of:\n",
86
+ "\n",
87
+ "- `diag_coulomb_mats`: An array of shape `(n_reps, 2, norb, norb)` containing the $\\mathbf{J}^{\\alpha\\alpha}$ and $\\mathbf{J}^{\\alpha\\beta}$ matrices for each repetition.\n",
88
+ "- `orbital_rotations`: An array of shape `(n_reps, norb, norb)` containing the orbital rotation for each repetition.\n",
89
+ "- `final_orbital_rotation`: An optional array of shape `(norb, norb)` containing a final orbital rotation."
90
+ ]
91
+ },
92
+ {
93
+ "cell_type": "code",
94
+ "execution_count": 2,
95
+ "id": "0c8e7890",
96
+ "metadata": {},
97
+ "outputs": [
98
+ {
99
+ "name": "stdout",
100
+ "output_type": "stream",
101
+ "text": [
102
+ "diag_coulomb_mats shape: (2, 2, 4, 4)\n",
103
+ "orbital_rotations shape: (2, 4, 4)\n"
104
+ ]
105
+ }
106
+ ],
107
+ "source": [
108
+ "n_reps = 2\n",
109
+ "\n",
110
+ "# Construct from a random parameter vector\n",
111
+ "n_params = ffsim.UCJOpSpinBalanced.n_params(norb, n_reps)\n",
112
+ "params = rng.standard_normal(n_params)\n",
113
+ "ucj_op = ffsim.UCJOpSpinBalanced.from_parameters(params, norb=norb, n_reps=n_reps)\n",
114
+ "\n",
115
+ "print(\"diag_coulomb_mats shape:\", ucj_op.diag_coulomb_mats.shape)\n",
116
+ "print(\"orbital_rotations shape:\", ucj_op.orbital_rotations.shape)\n",
117
+ "\n",
118
+ "# Apply the ansatz to the reference state\n",
119
+ "final_state = ffsim.apply_unitary(reference_state, ucj_op, norb=norb, nelec=nelec)"
120
+ ]
121
+ },
122
+ {
123
+ "cell_type": "markdown",
124
+ "id": "f15e6315",
125
+ "metadata": {},
126
+ "source": [
127
+ "The `interaction_pairs` argument can be used to restrict the orbital interactions in the diagonal Coulomb operators (setting the remaining entries to zero), which yields the local UCJ (LUCJ) variant:"
128
+ ]
129
+ },
130
+ {
131
+ "cell_type": "code",
132
+ "execution_count": 3,
133
+ "id": "86e1ab37",
134
+ "metadata": {},
135
+ "outputs": [],
136
+ "source": [
137
+ "# Restrict to interactions implementable on a square lattice\n",
138
+ "pairs_aa = [(p, p + 1) for p in range(norb - 1)]\n",
139
+ "pairs_ab = [(p, p) for p in range(norb)]\n",
140
+ "interaction_pairs = (pairs_aa, pairs_ab)\n",
141
+ "\n",
142
+ "n_params = ffsim.UCJOpSpinBalanced.n_params(\n",
143
+ " norb, n_reps, interaction_pairs=interaction_pairs\n",
144
+ ")\n",
145
+ "params = rng.standard_normal(n_params)\n",
146
+ "lucj_op = ffsim.UCJOpSpinBalanced.from_parameters(\n",
147
+ " params, norb=norb, n_reps=n_reps, interaction_pairs=interaction_pairs\n",
148
+ ")\n",
149
+ "\n",
150
+ "final_state = ffsim.apply_unitary(reference_state, lucj_op, norb=norb, nelec=nelec)"
151
+ ]
152
+ },
153
+ {
154
+ "cell_type": "markdown",
155
+ "id": "529c60a3",
156
+ "metadata": {},
157
+ "source": [
158
+ "#### UCJOpSpinUnbalanced\n",
159
+ "\n",
160
+ "The [UCJOpSpinUnbalanced](../api/ffsim.rst#ffsim.UCJOpSpinUnbalanced) class represents the spin-unbalanced UCJ operator, appropriate for open-shell systems. It allows $\\mathbf{J}^{\\alpha\\alpha}$ and $\\mathbf{J}^{\\beta\\beta}$ to differ and does not require $\\mathbf{J}^{\\alpha\\beta}$ to be symmetric (since $\\mathbf{J}^{\\alpha\\beta}_{ij} = \\mathbf{J}^{\\beta\\alpha}_{ji}$, the $\\mathbf{J}^{\\beta\\alpha}$ matrix need not be stored separately). Each diagonal Coulomb operator is therefore described by three matrices: $\\mathbf{J}^{\\alpha\\alpha}$, $\\mathbf{J}^{\\alpha\\beta}$, and $\\mathbf{J}^{\\beta\\beta}$. Separate orbital rotations are applied to the alpha and beta spin sectors.\n",
161
+ "\n",
162
+ "The data stored by this class consists of:\n",
163
+ "\n",
164
+ "- `diag_coulomb_mats`: An array of shape `(n_reps, 3, norb, norb)` containing the $\\mathbf{J}^{\\alpha\\alpha}$, $\\mathbf{J}^{\\alpha\\beta}$, and $\\mathbf{J}^{\\beta\\beta}$ matrices for each repetition.\n",
165
+ "- `orbital_rotations`: An array of shape `(n_reps, 2, norb, norb)` containing the alpha and beta orbital rotations for each repetition.\n",
166
+ "- `final_orbital_rotation`: An optional array of shape `(2, norb, norb)` containing a final orbital rotation for each spin sector."
167
+ ]
168
+ },
169
+ {
170
+ "cell_type": "code",
171
+ "execution_count": 4,
172
+ "id": "fee1f1cd",
173
+ "metadata": {},
174
+ "outputs": [
175
+ {
176
+ "name": "stdout",
177
+ "output_type": "stream",
178
+ "text": [
179
+ "diag_coulomb_mats shape: (2, 3, 4, 4)\n",
180
+ "orbital_rotations shape: (2, 2, 4, 4)\n"
181
+ ]
182
+ }
183
+ ],
184
+ "source": [
185
+ "n_params = ffsim.UCJOpSpinUnbalanced.n_params(norb, n_reps)\n",
186
+ "params = rng.standard_normal(n_params)\n",
187
+ "ucj_op_unbalanced = ffsim.UCJOpSpinUnbalanced.from_parameters(\n",
188
+ " params, norb=norb, n_reps=n_reps\n",
189
+ ")\n",
190
+ "\n",
191
+ "print(\"diag_coulomb_mats shape:\", ucj_op_unbalanced.diag_coulomb_mats.shape)\n",
192
+ "print(\"orbital_rotations shape:\", ucj_op_unbalanced.orbital_rotations.shape)\n",
193
+ "\n",
194
+ "final_state = ffsim.apply_unitary(\n",
195
+ " reference_state, ucj_op_unbalanced, norb=norb, nelec=nelec\n",
196
+ ")"
197
+ ]
198
+ },
199
+ {
200
+ "cell_type": "markdown",
201
+ "id": "6c3f4b23",
202
+ "metadata": {},
203
+ "source": [
204
+ "#### UCJOpSpinless\n",
205
+ "\n",
206
+ "The [UCJOpSpinless](../api/ffsim.rst#ffsim.UCJOpSpinless) class represents the spinless UCJ operator, for systems without a spin degree of freedom. The diagonal Coulomb operator takes the form\n",
207
+ "\n",
208
+ "$$\n",
209
+ " \\mathcal{J} = \\frac{1}{2}\\sum_{ij} \\mathbf{J}_{ij} n_i n_j\n",
210
+ "$$\n",
211
+ "\n",
212
+ "where $\\mathbf{J}$ is a single real symmetric matrix.\n",
213
+ "\n",
214
+ "The data stored by this class consists of:\n",
215
+ "\n",
216
+ "- `diag_coulomb_mats`: An array of shape `(n_reps, norb, norb)` containing the diagonal Coulomb matrix for each repetition.\n",
217
+ "- `orbital_rotations`: An array of shape `(n_reps, norb, norb)` containing the orbital rotation for each repetition.\n",
218
+ "- `final_orbital_rotation`: An optional array of shape `(norb, norb)` containing a final orbital rotation."
219
+ ]
220
+ },
221
+ {
222
+ "cell_type": "code",
223
+ "execution_count": 5,
224
+ "id": "9ecae377",
225
+ "metadata": {},
226
+ "outputs": [
227
+ {
228
+ "name": "stdout",
229
+ "output_type": "stream",
230
+ "text": [
231
+ "diag_coulomb_mats shape: (2, 4, 4)\n",
232
+ "orbital_rotations shape: (2, 4, 4)\n"
233
+ ]
234
+ }
235
+ ],
236
+ "source": [
237
+ "n_params = ffsim.UCJOpSpinless.n_params(norb, n_reps)\n",
238
+ "params = rng.standard_normal(n_params)\n",
239
+ "ucj_op_spinless = ffsim.UCJOpSpinless.from_parameters(params, norb=norb, n_reps=n_reps)\n",
240
+ "\n",
241
+ "print(\"diag_coulomb_mats shape:\", ucj_op_spinless.diag_coulomb_mats.shape)\n",
242
+ "print(\"orbital_rotations shape:\", ucj_op_spinless.orbital_rotations.shape)\n",
243
+ "\n",
244
+ "final_state_spinless = ffsim.apply_unitary(\n",
245
+ " reference_state_spinless, ucj_op_spinless, norb=norb, nelec=nocc\n",
246
+ ")"
247
+ ]
248
+ },
249
+ {
250
+ "cell_type": "markdown",
251
+ "id": "c4e0e300",
252
+ "metadata": {},
253
+ "source": [
254
+ "### UCCSD ansatzes\n",
255
+ "\n",
256
+ "The unitary coupled cluster singles and doubles (UCCSD) ansatz has the form\n",
257
+ "\n",
258
+ "$$\n",
259
+ " \\lvert \\Psi \\rangle = e^{T - T^\\dagger} \\lvert \\Phi_0 \\rangle\n",
260
+ "$$\n",
261
+ "\n",
262
+ "where\n",
263
+ "\n",
264
+ "$$\n",
265
+ " T = T_1 + T_2, \\quad\n",
266
+ " T_1 = \\sum_{ia} t_{ia} a^\\dagger_a a_i, \\quad\n",
267
+ " T_2 = \\sum_{ijab} t_{ijab} a^\\dagger_a a^\\dagger_b a_j a_i.\n",
268
+ "$$\n",
269
+ "\n",
270
+ "Here $i, j$ index occupied orbitals, $a, b$ index virtual orbitals, and the $t$-amplitudes $t_{ia}$ (singles) and $t_{ijab}$ (doubles) are the variational parameters.\n",
271
+ "\n",
272
+ "#### UCCSDOpRestrictedReal\n",
273
+ "\n",
274
+ "The [UCCSDOpRestrictedReal](../api/ffsim.rst#ffsim.UCCSDOpRestrictedReal) class represents the restricted UCCSD operator with real-valued $t$-amplitudes. \"Restricted\" means that the same spatial orbitals are used for both spin sectors, and the same $t$-amplitudes apply to both. This is the most common case when starting from a restricted Hartree-Fock (RHF) reference.\n",
275
+ "\n",
276
+ "The data stored by this class consists of:\n",
277
+ "\n",
278
+ "- `t1`: The real-valued $t_1$-amplitudes, an array of shape `(nocc, nvrt)`.\n",
279
+ "- `t2`: The real-valued $t_2$-amplitudes, an array of shape `(nocc, nocc, nvrt, nvrt)`.\n",
280
+ "- `final_orbital_rotation`: An optional array of shape `(norb, norb)` (may be complex-valued)."
281
+ ]
282
+ },
283
+ {
284
+ "cell_type": "code",
285
+ "execution_count": 6,
286
+ "id": "8ab56a0c",
287
+ "metadata": {},
288
+ "outputs": [
289
+ {
290
+ "name": "stdout",
291
+ "output_type": "stream",
292
+ "text": [
293
+ "t1 shape: (2, 2)\n",
294
+ "t2 shape: (2, 2, 2, 2)\n"
295
+ ]
296
+ }
297
+ ],
298
+ "source": [
299
+ "n_params = ffsim.UCCSDOpRestrictedReal.n_params(norb, nocc)\n",
300
+ "params = rng.standard_normal(n_params)\n",
301
+ "uccsd_op = ffsim.UCCSDOpRestrictedReal.from_parameters(params, norb=norb, nocc=nocc)\n",
302
+ "\n",
303
+ "print(\"t1 shape:\", uccsd_op.t1.shape)\n",
304
+ "print(\"t2 shape:\", uccsd_op.t2.shape)\n",
305
+ "\n",
306
+ "final_state = ffsim.apply_unitary(reference_state, uccsd_op, norb=norb, nelec=nelec)"
307
+ ]
308
+ },
309
+ {
310
+ "cell_type": "markdown",
311
+ "id": "3f47e5d1",
312
+ "metadata": {},
313
+ "source": [
314
+ "#### UCCSDOpRestricted\n",
315
+ "\n",
316
+ "The [UCCSDOpRestricted](../api/ffsim.rst#ffsim.UCCSDOpRestricted) class is just like `UCCSDOpRestrictedReal` except its $t$-amplitudes are allowed to take complex values, which doubles the number of real parameters."
317
+ ]
318
+ },
319
+ {
320
+ "cell_type": "code",
321
+ "execution_count": 7,
322
+ "id": "1438584f",
323
+ "metadata": {},
324
+ "outputs": [
325
+ {
326
+ "name": "stdout",
327
+ "output_type": "stream",
328
+ "text": [
329
+ "t1 shape: (2, 2)\n",
330
+ "t2 shape: (2, 2, 2, 2)\n"
331
+ ]
332
+ }
333
+ ],
334
+ "source": [
335
+ "n_params = ffsim.UCCSDOpRestricted.n_params(norb, nocc)\n",
336
+ "params = rng.standard_normal(n_params)\n",
337
+ "uccsd_op = ffsim.UCCSDOpRestricted.from_parameters(params, norb=norb, nocc=nocc)\n",
338
+ "\n",
339
+ "print(\"t1 shape:\", uccsd_op.t1.shape)\n",
340
+ "print(\"t2 shape:\", uccsd_op.t2.shape)\n",
341
+ "\n",
342
+ "final_state = ffsim.apply_unitary(reference_state, uccsd_op, norb=norb, nelec=nelec)"
343
+ ]
344
+ },
345
+ {
346
+ "cell_type": "markdown",
347
+ "id": "5d8f1747",
348
+ "metadata": {},
349
+ "source": [
350
+ "#### UCCSDOpUnrestrictedReal\n",
351
+ "\n",
352
+ "The [UCCSDOpUnrestrictedReal](../api/ffsim.rst#ffsim.UCCSDOpUnrestrictedReal) class represents the unrestricted UCCSD operator with real-valued $t$-amplitudes. \"Unrestricted\" means that separate $t$-amplitudes are used for different spin combinations, suitable for open-shell systems described by an unrestricted Hartree-Fock (UHF) reference.\n",
353
+ "\n",
354
+ "The data stored by this class consists of:\n",
355
+ "\n",
356
+ "- `t1`: A tuple `(t1_a, t1_b)` of real-valued arrays with shapes `(nocc_a, nvrt_a)` and `(nocc_b, nvrt_b)`.\n",
357
+ "- `t2`: A tuple `(t2_aa, t2_ab, t2_bb)` of real-valued arrays with shapes `(nocc_a, nocc_a, nvrt_a, nvrt_a)`, `(nocc_a, nocc_b, nvrt_a, nvrt_b)`, and `(nocc_b, nocc_b, nvrt_b, nvrt_b)`.\n",
358
+ "- `final_orbital_rotation`: An optional array of shape `(2, norb, norb)` containing a final orbital rotation for each spin sector."
359
+ ]
360
+ },
361
+ {
362
+ "cell_type": "code",
363
+ "execution_count": 8,
364
+ "id": "c7248787",
365
+ "metadata": {},
366
+ "outputs": [
367
+ {
368
+ "name": "stdout",
369
+ "output_type": "stream",
370
+ "text": [
371
+ "t1_a shape: (3, 1)\n",
372
+ "t1_b shape: (1, 3)\n",
373
+ "t2_aa shape: (3, 3, 1, 1)\n",
374
+ "t2_ab shape: (3, 1, 1, 3)\n",
375
+ "t2_bb shape: (1, 1, 3, 3)\n"
376
+ ]
377
+ }
378
+ ],
379
+ "source": [
380
+ "# Use an open-shell example: 3 alpha electrons and 1 beta electron\n",
381
+ "nelec_open = (3, 1)\n",
382
+ "nocc_a, nocc_b = nelec_open\n",
383
+ "nvrt_a = norb - nocc_a\n",
384
+ "nvrt_b = norb - nocc_b\n",
385
+ "\n",
386
+ "n_params = ffsim.UCCSDOpUnrestrictedReal.n_params(norb, nelec_open)\n",
387
+ "params = rng.standard_normal(n_params)\n",
388
+ "uccsd_op = ffsim.UCCSDOpUnrestrictedReal.from_parameters(\n",
389
+ " params, norb=norb, nelec=nelec_open\n",
390
+ ")\n",
391
+ "\n",
392
+ "print(\"t1_a shape:\", uccsd_op.t1[0].shape)\n",
393
+ "print(\"t1_b shape:\", uccsd_op.t1[1].shape)\n",
394
+ "print(\"t2_aa shape:\", uccsd_op.t2[0].shape)\n",
395
+ "print(\"t2_ab shape:\", uccsd_op.t2[1].shape)\n",
396
+ "print(\"t2_bb shape:\", uccsd_op.t2[2].shape)\n",
397
+ "\n",
398
+ "reference_state_open = ffsim.hartree_fock_state(norb, nelec_open)\n",
399
+ "final_state = ffsim.apply_unitary(\n",
400
+ " reference_state_open, uccsd_op, norb=norb, nelec=nelec_open\n",
401
+ ")"
402
+ ]
403
+ },
404
+ {
405
+ "cell_type": "markdown",
406
+ "id": "eti2tfrmpwn",
407
+ "metadata": {},
408
+ "source": [
409
+ "#### UCCSDOpUnrestricted\n",
410
+ "\n",
411
+ "The [UCCSDOpUnrestricted](../api/ffsim.rst#ffsim.UCCSDOpUnrestricted) class is just like `UCCSDOpUnrestrictedReal` except its $t$-amplitudes are allowed to take complex values, which doubles the number of real parameters."
412
+ ]
413
+ },
414
+ {
415
+ "cell_type": "code",
416
+ "execution_count": 9,
417
+ "id": "o9y5tcop3c",
418
+ "metadata": {},
419
+ "outputs": [
420
+ {
421
+ "name": "stdout",
422
+ "output_type": "stream",
423
+ "text": [
424
+ "t1_a shape: (3, 1)\n",
425
+ "t1_b shape: (1, 3)\n",
426
+ "t2_aa shape: (3, 3, 1, 1)\n",
427
+ "t2_ab shape: (3, 1, 1, 3)\n",
428
+ "t2_bb shape: (1, 1, 3, 3)\n"
429
+ ]
430
+ }
431
+ ],
432
+ "source": [
433
+ "n_params = ffsim.UCCSDOpUnrestricted.n_params(norb, nelec_open)\n",
434
+ "params = rng.standard_normal(n_params)\n",
435
+ "uccsd_op = ffsim.UCCSDOpUnrestricted.from_parameters(\n",
436
+ " params, norb=norb, nelec=nelec_open\n",
437
+ ")\n",
438
+ "\n",
439
+ "print(\"t1_a shape:\", uccsd_op.t1[0].shape)\n",
440
+ "print(\"t1_b shape:\", uccsd_op.t1[1].shape)\n",
441
+ "print(\"t2_aa shape:\", uccsd_op.t2[0].shape)\n",
442
+ "print(\"t2_ab shape:\", uccsd_op.t2[1].shape)\n",
443
+ "print(\"t2_bb shape:\", uccsd_op.t2[2].shape)\n",
444
+ "\n",
445
+ "final_state = ffsim.apply_unitary(\n",
446
+ " reference_state_open, uccsd_op, norb=norb, nelec=nelec_open\n",
447
+ ")"
448
+ ]
449
+ }
450
+ ],
451
+ "metadata": {
452
+ "kernelspec": {
453
+ "display_name": ".venv",
454
+ "language": "python",
455
+ "name": "python3"
456
+ },
457
+ "language_info": {
458
+ "codemirror_mode": {
459
+ "name": "ipython",
460
+ "version": 3
461
+ },
462
+ "file_extension": ".py",
463
+ "mimetype": "text/x-python",
464
+ "name": "python",
465
+ "nbconvert_exporter": "python",
466
+ "pygments_lexer": "ipython3",
467
+ "version": "3.12.11"
468
+ }
469
+ },
470
+ "nbformat": 4,
471
+ "nbformat_minor": 5
472
+ }
@@ -12,7 +12,7 @@
12
12
  "1. Convert your operator to a [SciPy LinearOperator](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.LinearOperator.html) using the `ffsim.linear_operator` [protocol](../explanations/protocols.ipynb).\n",
13
13
  "2. Use matrix multiplication and `np.vdot` to compute the expectation value.\n",
14
14
  "\n",
15
- "If you already have a SciPy LinearOperator, you can skip Step 1. Otherwise, you can get a LinearOperator from any object that implements ffsim's `SupportsLinearOperator` [protocol](../explanations/protocols.ipynb). Such objects include the [Hamiltonian classes](../explanations/hamiltonians.ipynb) as well as the [FermionOperator class](../how-to-guides/fermion-operator.ipynb).\n",
15
+ "If you already have a SciPy LinearOperator, you can skip Step 1. Otherwise, you can get a LinearOperator from any object that implements ffsim's `SupportsLinearOperator` [protocol](../explanations/protocols.ipynb). Such objects include the [Hamiltonian classes](../explanations/hamiltonians.ipynb) as well as the [FermionOperator class](../explanations/fermion-operator.ipynb).\n",
16
16
  "\n",
17
17
  "\n",
18
18
  "The following code cell demonstrates these steps for a molecular Hamiltonian with randomly generated one- and two-body tensors."
@@ -5,11 +5,10 @@
5
5
 
6
6
  sample-from-state-vectors
7
7
  compute-expectation-values
8
- simulate-lucj
8
+ simulate-vqe
9
9
  simulate-trotter-mol-ham
10
10
  simulate-trotter-hubbard
11
11
  entanglement-forging
12
- fermion-operator
13
12
  sample-slater
14
13
  qiskit-lucj
15
14
  qiskit-trotter