diff --git a/my_dmet/fragments.py b/my_dmet/fragments.py index ef45e36d..c172ceae 100644 --- a/my_dmet/fragments.py +++ b/my_dmet/fragments.py @@ -346,7 +346,6 @@ def do_Schmidt_ofc_embedding (self, oneRDM_loc, all_frags): # Reorder impurity orbitals so that fragments are at the top, as much as possible proj = np.dot (loc2imp[self.frag_orb_list,:].conjugate ().T, loc2imp[self.frag_orb_list,:]) evals, u_imp = matrix_eigen_control_options (proj, sort_vecs=-1, only_nonzero_vals=False) - assert (np.logical_and (np.allclose (evals[:self.norbs_frag], 1), np.allclose (evals[self.norbs_frag:], 0))), evals loc2imp = np.dot (loc2imp, u_imp) self.loc2emb = get_complete_basis (loc2imp) diff --git a/my_dmet/main_object.py b/my_dmet/main_object.py index 4327f1c4..42fce64f 100644 --- a/my_dmet/main_object.py +++ b/my_dmet/main_object.py @@ -34,7 +34,7 @@ class dmet: def __init__( self, theInts, fragments, isTranslationInvariant=False, SCmethod='BFGS', incl_bath_errvec=True, use_constrained_opt=False, doDET=False, doDET_NO=False, CC_E_TYPE='LAMBDA', minFunc='FOCK_INIT', wma_options=False, print_u=True, - print_rdm=True, ofc_embedding=False, debug_energy=False, noselfconsistent=False): + print_rdm=True, ofc_embedding=False, debug_energy=False, noselfconsistent=False, do_constrCASSCF=False): if isTranslationInvariant: raise RuntimeError ("The translational invariance option doesn't work! It needs to be completely rebuilt!") @@ -63,6 +63,7 @@ def __init__( self, theInts, fragments, isTranslationInvariant=False, SCmethod=' self.ofc_embedding = ofc_embedding self.debug_energy = debug_energy self.noselfconsistent = noselfconsistent + self.do_constrCASSCF = do_constrCASSCF if self.noselfconsistent: SCmethod = 'NONE' for frag in self.fragments: @@ -520,7 +521,8 @@ def doselfconsistent_orbs (self, iters): else: self.mu_imp = optimize.newton( self.numeleccostfunction, self.mu_imp, tol=1e-6 ) print (" Chemical potential =", self.mu_imp) - self.doexact (self.mu_imp, frag_constrained_casscf=True) + if self.do_constrCASSCF: + self.doexact (self.mu_imp, frag_constrained_casscf=True) loc2wmas_new = np.concatenate ([frag.loc2amo for frag in self.fragments], axis=1) try: diff --git a/my_drudge/PartActvHoleDrudge.py b/my_drudge/PartActvHoleDrudge.py index 619bb0f4..a2dd6eee 100755 --- a/my_drudge/PartActvHoleDrudge.py +++ b/my_drudge/PartActvHoleDrudge.py @@ -262,8 +262,8 @@ def _subst_actv_vec_rdm (term: Term, rdm: IndexedBase, actv_range, op_parser, re actv_parsed = [p for r, p in zip (ranges, parsed) if r==actv_range] amp = term.amp if len (actv_parsed) > 0: - actv_cr_idxs = sum([list(p[2]) for p in actv_parsed if p[1]==CR], []) - actv_an_idxs = sum([list(p[2]) for p in reversed (actv_parsed) if p[1]==AN], []) + actv_cr_idxs = sum([[p[2][0]] for p in actv_parsed if p[1]==CR], []) + actv_an_idxs = sum([[p[2][0]] for p in reversed (actv_parsed) if p[1]==AN], []) actv_idxs = actv_cr_idxs + actv_an_idxs amp = amp * rdm[actv_idxs] return Term (term.sums, amp, inac_vecs) diff --git a/my_pyscf/mcscf/mc1step_constrained.py b/my_pyscf/mcscf/mc1step_constrained.py index 30011a35..72a8d1a8 100644 --- a/my_pyscf/mcscf/mc1step_constrained.py +++ b/my_pyscf/mcscf/mc1step_constrained.py @@ -300,13 +300,13 @@ def uniq_var_indices (self): mask[ncas:ncasrot,:ncas] = True # Can I add others to get occ-vir rotation without spoiling it? # Yes I can, but this ~slows it down~ somehow! (At least it doesn't break it, but I'm not sure it's doing anything?) - idx_unocc1 = np.isclose (self._crocc, 0) - idx_occ1 = ~idx_unocc1 - idx_occ2, idx_unocc2 = np.copy (idx_occ1), np.copy (idx_unocc1) - idx_occ1[ncasrot:] = idx_unocc1[ncasrot:] = False - idx_occ2[:ncasrot] = idx_unocc2[:ncasrot] = False - mask[np.ix_(idx_occ1,idx_unocc1)] = True - mask[np.ix_(idx_occ2,idx_unocc2)] = True + #idx_unocc1 = np.isclose (self._crocc, 0) + #idx_occ1 = ~idx_unocc1 + #idx_occ2, idx_unocc2 = np.copy (idx_occ1), np.copy (idx_unocc1) + #idx_occ1[ncasrot:] = idx_unocc1[ncasrot:] = False + #idx_occ2[:ncasrot] = idx_unocc2[:ncasrot] = False + #mask[np.ix_(idx_occ1,idx_unocc1)] = True + #mask[np.ix_(idx_occ2,idx_unocc2)] = True return mask def pack_uniq_var (self, rot):