Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions src/tequila/quantumchemistry/qc_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def orthonormalize_basis_orbitals(self):
# backward compatibility
return self.use_native_orbitals()

def use_native_orbitals(self, inplace=False, core: list = None, *args, **kwargs):
def use_native_orbitals(self, inplace=False, core: list = [], *args, **kwargs):
"""
Parameters
----------
Expand Down Expand Up @@ -786,23 +786,39 @@ def get_core(active):
co.sort()
return co

def active_to_active(active):
'''
translates active indices from canonical/the original basis to the native coeffs
'''
ov = numpy.zeros(shape=(len(self.integral_manager.orbitals)))
for i in active:
for j in range(len(d)):
ov[j] += numpy.abs(inner(c.T[i], d.T[j], s))
act = []
for i in range(len(active)):
idx = numpy.argmax(ov)
act.append(idx)
ov[idx] = 0.
act.sort()
return act

active = None
if not self.integral_manager.active_space_is_trivial() and core is None:
core = [i.idx_total for i in self.integral_manager.orbitals if i.idx is None]
if "active" in kwargs:
active = kwargs["active"]
kwargs.pop("active")
if core is None:
if not len(core):
core = get_core(active)
else:
if active is None:
if core is None:
if not len(core):
if not self.integral_manager.active_space_is_trivial():
active = [i.idx_total for i in self.integral_manager.orbitals if i.idx is not None]
active = active_to_active(active)
core = [i.idx_total for i in self.integral_manager.orbitals if i.idx is None]
else:
core = []
active = [i for i in range(len(self.integral_manager.orbitals))]
else:
if isinstance(core, int):
core = [core]
active = get_active(core)
else:
active = get_active(core)
assert len(active) + len(core) == len(self.integral_manager.orbitals)
to_active = [i for i in range(len(self.integral_manager.orbitals)) if i not in core]
to_active = {active[i]: to_active[i] for i in range(len(active))}
Expand Down
Loading