Skip to content
New issue

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

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

Already on GitHub? # to your account

Interaction Pairs are overridden #310

Open
osamarais opened this issue Aug 22, 2024 · 1 comment
Open

Interaction Pairs are overridden #310

osamarais opened this issue Aug 22, 2024 · 1 comment

Comments

@osamarais
Copy link

osamarais commented Aug 22, 2024

When creating a UCJOpSpinBalanced operator from t_amplitudes, passing the interaction pairs does not result in a smaller number of parameters. It seems like the interaction pairs are overridden.

MWE to reproduce this:

import ffsim
from pyscf import gto, scf, cc

mol = gto.Mole()
mol.basis = 'sto6g'

atoms = [['C',(0, 0, 0)], ['C',(0, 0, 1.2)]]

mol.atom = atoms
mol.build()

mf = scf.RHF(mol)
scf = mf.run()

active_space = [i for i in range(mol.nelectron//2 - 4//2, mol.nelectron//2 + 4//2)]

ccsd = cc.CCSD(scf, frozen=[i for i in range(mol.nao_nr()) if i not in active_space]).run()

n_reps = 2
pairs_aa = [(0, 1), (1, 2), (2, 3)]
pairs_ab = [(0, 0)]

operator = ffsim.UCJOpSpinBalanced.from_t_amplitudes(ccsd.t2, n_reps=n_reps)
operator_local = ffsim.UCJOpSpinBalanced.from_t_amplitudes(ccsd.t2, n_reps=n_reps, interaction_pairs=(pairs_aa,pairs_ab))

print(f'Number of parameters in UCJ Spin Balanced:  {operator.to_parameters().size}')
print(f'Number of parameters in LUCJ Spin Balanced: {operator_local.to_parameters().size}')


print(f'Expected number of parameters in UCJ Spin Balanced:  {operator.n_params(4,2)}')
print(f'Expected number of parameters in LUCJ Spin Balanced: {operator.n_params(4,2, interaction_pairs=(pairs_aa,pairs_ab))}')

The relevant part of the output:

Number of parameters in UCJ Spin Balanced:  72
Number of parameters in LUCJ Spin Balanced: 72
Expected number of parameters in UCJ Spin Balanced:  72
Expected number of parameters in LUCJ Spin Balanced: 40
@kevinsung
Copy link
Collaborator

UCJOpSpinBalanced does not store the interaction pairs, so you need to pass them to to_parameters, like this:

operator_local.to_parameters(interaction_pairs=(pairs_aa, pairs_ab))

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

No branches or pull requests

2 participants