Skip to content

Commit f7e7245

Browse files
committed
Fixed the bug in the build_minimal_csf_basis_singlet function and also updated the examples in the docstring of this function and the function build_minimal_csf_basis
1 parent 40c9f38 commit f7e7245

1 file changed

Lines changed: 11 additions & 22 deletions

File tree

src/libra_py/citools/interfaces.py

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from . import csf
2626
from . import slatdet as sd
2727

28-
from liblibra_core import *
28+
from liblibra_core import MATRIX, CMATRIX
2929

3030
def find_matches(
3131
config: List[int],
@@ -89,8 +89,6 @@ def find_matches(
8989
return matches
9090

9191

92-
from typing import List, Tuple, Any
93-
9492
def build_minimal_csf_basis(
9593
configs: List[Tuple[int, ...]],
9694
active_space: List[int],
@@ -131,8 +129,6 @@ def build_minimal_csf_basis(
131129
132130
Example
133131
-------
134-
>>> import numpy as np
135-
>>> # Example input from MOPAC/Libra
136132
>>> configs0_raw = [(6, -6, 7, -7, 9, -8)]
137133
>>> active_space = [6, 7, 8, 9, 10, 11]
138134
>>> nelec = 6
@@ -142,12 +138,9 @@ def build_minimal_csf_basis(
142138
... configs0_raw, active_space, nelec, max_unpaired
143139
... )
144140
>>>
145-
>>> print(len(min_basis))
146-
19
147-
>>> print(all_confs[0])
148-
(6, -6, 7, -7, 8, -8)
149-
>>> print(all_phases[0])
150-
1
141+
>>> print(min_basis)
142+
[((6, -6, 7, -7, 8, -9), 1),
143+
((6, -6, 7, -7, -8, 9), 1)]
151144
"""
152145

153146
# Generate all possible determinants (with parity) for the given active space
@@ -203,8 +196,6 @@ def build_minimal_csf_basis_singlet(
203196
204197
Example
205198
-------
206-
>>> import numpy as np
207-
>>> # Example input from MOPAC/Libra
208199
>>> configs0_raw = [(6, -6, 7, -7, 9, -8)]
209200
>>> active_space = [6, 7, 8, 9, 10, 11]
210201
>>> nelec = 6
@@ -214,20 +205,18 @@ def build_minimal_csf_basis_singlet(
214205
... configs0_raw, active_space, nelec, max_unpaired
215206
... )
216207
>>>
217-
>>> print(len(min_basis))
218-
19
219-
>>> print(all_confs[0])
220-
(6, -6, 7, -7, 8, -8)
221-
>>> print(all_phases[0])
222-
1
208+
>>> print(min_basis)
209+
[((6, -6, 7, -7, 8, -9), 1),
210+
((6, -6, 7, -7, -8, 9), 1)]
223211
"""
224212

225213
# Generate all possible determinants (with parity) for the given active space
226-
# dets: List[Tuple[Any, ...]] = list(sd.generate_determinants_with_parity(active_space, nelec))
214+
dets: List[Tuple[Any, ...]] = list(sd.generate_single_excitations(active_space, nelec))
227215

228216
min_basis: List[Tuple[Any, ...]] = []
229-
for det, phase in sd.generate_single_excitations(active_space, nelec):
230-
min_basis.append((det, phase))
217+
for config in configs:
218+
matches = find_matches(config, dets, max_unpaired)
219+
min_basis.extend(matches)
231220

232221
# Avoid error when basis is empty
233222
transposed_basis: List[Tuple[Any, ...]] = list(zip(*min_basis)) if min_basis else []

0 commit comments

Comments
 (0)