Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added optional subspace to diagonalization #146

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

joannaqw
Copy link

@joannaqw joannaqw commented Feb 14, 2025

Fixes #137

subspace = True allows one to always have configurations spanning a user-defined smaller subspace (norbsmall, nelecsmall) in the diagonalization, regardless of samples collected from experiments. Optional arguments include subspace_norb, subspace_alpha, and subspace beta.

  • Write release note

@CLAassistant
Copy link

CLAassistant commented Feb 14, 2025

CLA assistant check
All committers have signed the CLA.

@@ -79,6 +82,10 @@ def solve_fermion(
spin_sq: float | None = None,
max_davidson: int = 100,
verbose: int | None = None,
subspace: bool = False,
subspace_orb: Optional[int] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
subspace_orb: Optional[int] = None,
subspace_orb: int | None = None,

and similarly elsewhere

@@ -79,6 +82,10 @@ def solve_fermion(
spin_sq: float | None = None,
max_davidson: int = 100,
verbose: int | None = None,
subspace: bool = False,
subspace_orb: Optional[int] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to document these arguments in the docstring.

@@ -593,3 +610,17 @@ def _transition_str_to_bool(string_rep: np.ndarray) -> tuple[np.ndarray, np.ndar
annihilate = np.logical_or(string_rep == "-", string_rep == "n")

return diag, create, annihilate

def generate_bitstrings(norb, neleca,nelecb, n_orb, n_alpha, n_beta):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write a docstring for this function. If it's meant to be a private function, prefix it with an underscore _. Also, please add type annotations to the function arguments.

alpha_strings = get_strings(n_orb, n_alpha)
beta_strings = get_strings(n_orb, n_beta)
d_orb = neleca+nelecb - n_alpha - n_beta
doubly_occ = [''.join(seq) for seq in itertools.product('1', repeat=int(d_orb/2))]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is equivalent to

double_occ = ['1' * int(d_orb / 2)]

Is this what you meant to write? I'm having a bit of trouble following the logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to always include certain bitstrings in diagonalization subspace
3 participants