From a76e49f3b112be80c8e5dbbb496e80a084a82c44 Mon Sep 17 00:00:00 2001 From: Caleb Johnson Date: Wed, 4 Dec 2024 10:27:53 -0600 Subject: [PATCH 1/2] Support open shell --- qiskit_addon_dice_solver/dice_solver.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qiskit_addon_dice_solver/dice_solver.py b/qiskit_addon_dice_solver/dice_solver.py index 1f3cd1e..95510a6 100644 --- a/qiskit_addon_dice_solver/dice_solver.py +++ b/qiskit_addon_dice_solver/dice_solver.py @@ -174,6 +174,7 @@ def solve_fermion( hcore: np.ndarray, eri: np.ndarray, *, + open_shell: bool = False, mpirun_options: Sequence[str] | str | None = None, temp_dir: str | Path | None = None, clean_temp_dir: bool = True, @@ -199,11 +200,6 @@ def solve_fermion( For more information on the ``mpirun`` command line options, refer to the `man page `_. - .. note:: - - Only closed-shell systems are supported. The particle number for both - spin-up and spin-down determinants is expected to be equal. - .. note:: Determinants are interpreted by the ``Dice`` command line application as 5-byte unsigned integers; therefore, only systems @@ -218,6 +214,10 @@ def solve_fermion( is the number of qubits. hcore: Core Hamiltonian matrix representing single-electron integrals eri: Electronic repulsion integrals representing two-electron integrals + open_shell: A flag specifying whether configurations from the left and right + halves of the bitstrings should be kept separate. If ``False``, CI strings + from the left and right halves of the bitstrings are combined into a single + set of unique configurations and used for both the alpha and beta subspaces. mpirun_options: Options controlling the CPU resource allocation for the ``Dice`` command line application. These command-line options will be passed directly to the ``mpirun`` command line application during invocation of ``Dice``. These may be formatted as a ``Sequence`` of strings or a single string. If a ``Sequence``, @@ -236,7 +236,7 @@ def solve_fermion( - Approximate ground state from SCI - Average orbital occupancy """ - ci_strs = bitstring_matrix_to_ci_strs(bitstring_matrix) + ci_strs = bitstring_matrix_to_ci_strs(bitstring_matrix, open_shell=open_shell) num_up = format(ci_strs[0][0], "b").count("1") num_dn = format(ci_strs[1][0], "b").count("1") e_dice, sci_state, avg_occupancies = solve_hci( From 81bfd2e094ed755868d34a36371476856efb7c42 Mon Sep 17 00:00:00 2001 From: Caleb Johnson Date: Wed, 4 Dec 2024 10:33:38 -0600 Subject: [PATCH 2/2] reno --- releasenotes/notes/open-shell-7ce25a8ae730f144.yaml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 releasenotes/notes/open-shell-7ce25a8ae730f144.yaml diff --git a/releasenotes/notes/open-shell-7ce25a8ae730f144.yaml b/releasenotes/notes/open-shell-7ce25a8ae730f144.yaml new file mode 100644 index 0000000..0d88b8e --- /dev/null +++ b/releasenotes/notes/open-shell-7ce25a8ae730f144.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Open shell systems are now supported in :func:`qiskit_addon_dice_solver.solve_fermion` by setting the ``open_shell`` keyword argument to ``True``. If set to ``True``, the left and right halves of the input bitstrings may contain different hamming weights.