Skip to content

Initialize UCJ from CISD#595

Open
davidomanovic wants to merge 7 commits intoqiskit-community:mainfrom
davidomanovic:feature/ucj_from_cisd
Open

Initialize UCJ from CISD#595
davidomanovic wants to merge 7 commits intoqiskit-community:mainfrom
davidomanovic:feature/ucj_from_cisd

Conversation

@davidomanovic
Copy link
Contributor

@davidomanovic davidomanovic commented Mar 16, 2026

Initialization of UCJ from CISD as described in https://arxiv.org/pdf/2511.22476

Added as a method from.cisd() in UCJOpSpinBalanced, and any necessary tests. Closes issue #592.

image

def from_cisd(
cisd,
*,
civec: np.ndarray | None = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of accepting cisd, only accept civec, and rename it to cisd_vec. Also, rename the method to from_cisd_vec.

"or use a converged PySCF CISD object with a `ci` attribute."
)

c0, c1, c2 = cisd.cisdvec_to_amplitudes(civec, copy=False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use pyscf.ci.cisd.cisdvec_to_amplitudes instead, since you won't have the cisd object anymore.

"UCJOpSpinBalanced.from_cisd requires amplitudes from a restricted "
"closed-shell CISD calculation."
)
if np.isclose(c0, 0.0):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a keyword-only argument c0_tol: float = 1e-8 to use for the absolute tolerance here. Also, this is a nit but prefer math.isclose to np.isclose when comparing numbers because it avoids numpy function dispatch overhead.


@staticmethod
def from_cisd_vec(
cisd_vec,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a type annotation.

def from_cisd_vec(
cisd_vec,
*,
nmo: int,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename this to norb to match with the rest of ffsim.

]
| None = None,
tol: float = 1e-8,
c0_tol: float = 1e-8,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's put c0_tol after nocc and before n_reps.

:meth:`from_t_amplitudes`.

Args:
civec: CISD coefficient vector.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to update this to cisd_vec and also add document norb, nocc, and c0_tol.

Comment on lines +614 to +616
if cisd_vec is None:
raise ValueError("CISD coefficient vector `cisd_vec` cannot be None.")

Copy link
Collaborator

Choose a reason for hiding this comment

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

This check is unnecessary.

cisd_vec, nmo, nocc, copy=False
)

if math.isclose(c0, 0.0, rel_tol=0.0, abs_tol=c0_tol):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we're comparing to zero, it's actually unnecessary to specify rel_tol.

Comment on lines +623 to +624
f"CISD reference coefficient c0={c0} is too close to zero "
f"(abs_tol={c0_tol})."
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
f"CISD reference coefficient c0={c0} is too close to zero "
f"(abs_tol={c0_tol})."
f"CISD reference coefficient c0={c0} is smaller than the specified threshold, c0_tol={c0_tol}."

t2 = c2 / c0 - 0.5 * np.einsum("ia,jb->ijab", t1, t1)

operator = ffsim.UCJOpSpinBalanced.from_cisd_vec(
cisd.ci, nmo=cisd.nmo, nocc=cisd.nocc
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should also test that cisd.ci was not modified, since you chose to pass copy=False in cisdvec_to_amplitudes.

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.

2 participants