def construct_state(up_orbs, dn_orbs): res = Vec.zero() for i, j in np.ndindex(len(up_orbs), len(dn_orbs)): up_coef, up_occ = up_orbs[i] dn_coef, dn_occ = dn_orbs[j] res += Vec({Det(up_occ, dn_occ): up_coef*dn_coef}) return res
def main(): mol = gto.Mole() mol.unit = 'bohr' mol.atom = 'C 0 0 0' mol.spin = 0 mol.symmetry = 'dooh' mol.basis = 'ccpvdz' mol.output = 'pyscf.txt' mol.verbose = 4 mol.build() mol.is_atomic_system = mol.natm == 1 mf = sym_rhf.RHF(mol) mf.max_cycle = 1000 mf.run() p = L2Projector(mol, mf) print('Is atomic: ', mol.is_atomic_system) print('Type: ', type(mf)) print('mo_coeffs: ') for row in mf.mo_coeff: print(''.join(["%8.4f"%c for c in row])) print('mo energy: ') print(mf.mo_energy) d1 = Det([2, 3, 4, 7, 10], [1, 2, 3, 4, 8]) d2 = Det([1, 4], [1]) d3 = Det([1, 3], [1]) d4 = Det([1, 5], [1]) csf1 = Vec({d1 : 1}) csf2 = Vec({d2: 1}) csf3 = Vec({d3: 1, d4: 1}) #v = Vec({d1: 0.707, d2: 0.707}) targ = 1 p1 = p.project(targ, csf1) p2 = p.project(targ, csf2) p3 = p.project(targ, csf3) # p4 = p.project(targ, csf4) # p5 = (0.516/0.266) * p.project(targ, csf5) print("p1: ") for det, coef in sorted(p1.dets.items(), key = lambda det_coef: -abs(det_coef[1])): print(det, ": ", coef/p1.norm()) # print("p2: ") # for det, coef in sorted(p2.dets.items(), key = lambda det_coef: -abs(det_coef[1])): # print(det, ": ", coef) # print("p3: ") # for det, coef in sorted(p3.dets.items(), key = lambda det_coef: -abs(det_coef[1])): # print(det, ": ", coef) # print("p4: ") # for det, coef in sorted(p4.dets.items(), key = lambda det_coef: -abs(det_coef[1])): # print(det, ": ", coef) # print("p5: ") # for det, coef in sorted(p5.dets.items(), key = lambda det_coef: -abs(det_coef[1])): # print(det, ": ", coef) print('Error: ', p.eigen_error(targ, p1))
def dets_from_new_orbs(new_up_orbs, new_dn_orbs, up_orbs, dn_orbs): res = Vec.zero() for up_coef, up_occ in new_up_orbs: res += Vec({Det(up_occ, dn_orbs): up_coef}) # p = rel_parity(up_occ) # res += up_coef*p*Det(up_occ, dn_orbs) for dn_coef, dn_occ in new_dn_orbs: res += Vec({Det(up_orbs, dn_occ): dn_coef}) # p = rel_parity(dn_occ) # res += dn_coef*p*Det(up_orbs, dn_occ) return res
def proj_det(self, targ, state): #TODO: Change proj to iterate over every det in state and add results assert(isinstance(state, Det)) projected_out_ls = [l for l in self.possible_ang_mom(state) if l != targ] res = Vec.zero() res += state #OP IN COMPLEX BAS #res = change_basis(self.complex_bas, res) for l in projected_out_ls: # print("Projecting l = ", l, " with ", len(res.dets), " dets.") l2_state = self.apply_l2(res) res *= -l*(l+1) res += l2_state res /= (targ*(targ+1) - l*(l+1)) #Prune res s.t. some percentage of total magnitude is present # print("Ndets before prune: ", len(res.dets)) # res = self.prune(targ, res, 1e-8) # print("Ndets after prune: ", len(res.dets)) remove = [] for det, coef in res.dets.items(): if abs(coef) < 1e-8: remove.append(det) for det in remove: del res.dets[det] #OP IN COMPLEX BAS #res = change_basis(self.mol_bas, res) return res
def apply_1body(op, state): if isinstance(state, Det): #returns a Vec/CSF after applying operator up_orbs, dn_orbs = state.up_occ, state.dn_occ # new_up_orbs, new_dn_orbs = [], [] # for n, orb in enumerate(up_orbs): # expanded = expand_orbs(up_orbs[:n] + [op[orb]] + up_orbs[n+1:]) # new_up_orbs += expanded # for n, orb in enumerate(dn_orbs): # expanded = expand_orbs(dn_orbs[:n] + [op[orb]] + dn_orbs[n+1:]) # new_dn_orbs += expanded new_up_orbs, new_dn_orbs = get_new_orbs(op, up_orbs, dn_orbs) return dets_from_new_orbs(new_up_orbs, new_dn_orbs, up_orbs, dn_orbs) # res = Vec.zero() # for up_coef, up_occ in new_up_orbs: # p = rel_parity(up_occ) # res += up_coef*p*Det(up_occ, dn_orbs) # for dn_coef, dn_occ in new_dn_orbs: # p = rel_parity(dn_occ) # res += dn_coef*p*Det(up_orbs, dn_occ) # return res elif isinstance(state, Vec): res = Vec.zero() for det, coef in state.dets.items(): res += coef*apply_1body(op, det) return res
def csf_string_to_det(self, csf_string): str_pairs = [s.split('|') for s in csf_string.split('i') if s != ""] coef_det_pairs = [(float(c), *self.parse_det_str(det_str)) for [c, det_str] in str_pairs] csf = Vec.zero() for coef, sign, det in coef_det_pairs: csf += sign * coef * det return csf
def real_coeffs(self, state): real = Vec.zero() err = 0 for det, coef in state.dets.items(): err += abs(coef.imag) real += det*(coef.real) if (err > 1e-2): print('\n', 'Warning: imag. part of complex coef discarded in L2 projection') return real
def project(self, targ, state): if isinstance(state, Det): return self.proj_det(targ, state) res = Vec.zero() for det, coef in state.dets.items(): res += coef*self.proj_det(targ, det) #res = self.prune(targ, res, 1e-8) res = self.real_coeffs(res) return res
def apply_l2(self, state): lz_state = self.apply_lz(state) lz2_state = self.apply_lz(lz_state) lup_state = self.apply_lup(state) ldn_lup_state = self.apply_ldn(lup_state) res = Vec.zero() res += ldn_lup_state res += lz2_state res += lz_state return res
def apply_l2(lup, ldn, lz, csf): res = Vec.zero() lz_csf = apply_1body(lz, csf) lz2_csf = apply_1body(lz, lz_csf) lup_csf = apply_1body(lup, csf) ldn_lup_csf = apply_1body(ldn, lup_csf) res += ldn_lup_csf res += lz2_csf res += lz_csf return res
def L2(self, state): lz_state = apply_1body(self.lz_tot, state) lz2_state = apply_1body(self.lz_tot, lz_state) lup_state = apply_1body(self.lup_tot, state) ldn_lup_state = apply_1body(self.ldn_tot, lup_state) res = Vec.zero() res += ldn_lup_state res += lz2_state res += lz_state return res
def change_basis(U, state): if isinstance(state, Det): up_orbs, dn_orbs = state.up_occ, state.dn_occ new_up_orbs = expand_orbs([U[orb] for orb in up_orbs]) new_dn_orbs = expand_orbs([U[orb] for orb in dn_orbs]) return construct_state(new_up_orbs, new_dn_orbs) elif isinstance(state, Vec): res = Vec.zero() for det, coef in state.dets.items(): res += coef*change_basis(U, det) return res
def prune(self, targ, state, err): assert(0 < err and err < 1) tol = (1 - err)*state.norm() res = Vec.zero() for det, coef in sorted(state.dets.items(), key = lambda item: -abs(item[1])): if res.norm() > tol: break res += det*(coef.real) #if self.eigen_error(targ, res) < err: # break return res
def write_csfs(qmc_file, config_csfs, config_labels, csf_tol, reduce_csfs): det_indices, accepted_csfs = {}, [] output_lines = [] for config, csfs in config_csfs.items(): config_sum = add_csfs([coef for coef, csf in csfs], [csf for coef, csf in csfs]) n_dets = len(config_sum.dets) #n_dets = 1 if (config_sum.norm()/np.sqrt(n_dets) < csf_tol): continue for coef, csf in csfs: # for det in csf.dets: # if det not in det_indices: # det_indices[det] = len(det_indices) accepted_csfs.append((coef, csf)) decreasing_coefs = lambda coef_and_csf: -abs(coef_and_csf[0]) sorted_csfs = sorted([(coef, csf) for coef, csf in accepted_csfs], key = decreasing_coefs) sorted_dets, reindex, det_indices = [], {}, {} for coef, csf in sorted_csfs: for det in csf.dets: if det not in det_indices: sorted_dets.append(det) det_indices[det] = len(det_indices) if config_labels[det] not in reindex: reindex[config_labels[det]] = len(reindex) # for det, index in det_indices.items(): # rep = config_rep(Config(det)) # if rep not in config_labels: # config_labels[rep] = len(config_labels) # sorted_dets[index] = det dets_str = '\n'.join( [det_row_str(det, n, reindex[config_labels[det]]) for n, det in enumerate(sorted_dets)]) output_lines.append(dets_str + ' (iworbd(iel,idet), iel=1, nelec)\n') csf_coeffs_str = '\t'.join(['%.10f' % coeff for coeff, csf in sorted_csfs]) ndets_str = '\t'.join([str(len(csf.dets)) for coef, csf in sorted_csfs]) output_lines.append(str(len(sorted_csfs)) + ' ncsf\n') output_lines.append(csf_coeffs_str + ' (csf_coef(icsf), icsf=1, ncsf)\n') output_lines.append(ndets_str + ' (ndet_in_csf(icsf), icsf=1, ncsf)\n') wf = Vec.zero() for coef, csf in sorted_csfs: index_str = (' '.join([str(det_indices[det] + 1) for det, coef in csf.dets.items()]) + ' (iwdet_in_csf(idet_in_csf,icsf),idet_in_csf=1,ndet_in_csf(icsf))\n') coeff_str = (' '.join(['%.8f'%coef for det, coef in csf.dets.items()]) + ' (cdet_in_csf(idet_in_csf,icsf),idet_in_csf=1,ndet_in_csf(icsf))\n') output_lines.append(index_str) output_lines.append(coeff_str) wf += coef*csf wf_energy = Ham("FCIDUMP_real_orbs").expectation(wf) return wf_energy, len(sorted_csfs), len(sorted_dets), output_lines
def convert_vec(self, state): if isinstance(state, DeterminantLinearCombination): res = Vec.zero() for det, coef in state.det_coeffs.items(): p, converted_det = self.convert_vec(det) res += coef * p * converted_det return res elif isinstance(state, Determinant): up_orbs, dn_orbs = [], [] for orbital in state.orbitals: name = orbital.labels['name'] orbs = up_orbs if name[8:10] == 'up' else dn_orbs orbs.append(int(name[11:])) p = rel_parity(up_orbs)*rel_parity(dn_orbs) return p, Det(up_orbs, dn_orbs)
def debug_proj(self, state): float_format = "%12.8f" print('START DEBUG: ') state = change_basis(self.complex_bas, state) lz_state = self.apply_lz(state) lz2_state = self.apply_lz(lz_state) lup_state = self.apply_lup(state) ldn_lup_state = self.apply_ldn(lup_state) print('input state: ') # for det, coef in change_basis(self.complex_bas, state).dets.items(): for det, coef in state.dets.items(): print(det, (float_format + float_format + "i")%(coef.real, coef.imag)) print('input state (orig basis): ') # for det, coef in change_basis(self.mol_bas, change_basis(self.complex_bas, state)).dets.items(): for det, coef in state.dets.items(): print(det, (float_format + float_format + "i")%(coef.real, coef.imag)) print('lz * state: ') # for det, coef in change_basis(self.complex_bas, lz_state).dets.items(): for det, coef in lz_state.dets.items(): print(det, (float_format + float_format + "i")%(coef.real, coef.imag)) print('lz * lz * state: ') # for det, coef in change_basis(self.complex_bas, lz2_state).dets.items(): for det, coef in lz2_state.dets.items(): print(det, (float_format + float_format + "i")%(coef.real, coef.imag)) print('lup * state: ') # for det, coef in change_basis(self.complex_bas, lup_state).dets.items(): for det, coef in lup_state.dets.items(): print(det, (float_format + float_format + "i")%(coef.real, coef.imag)) print('ldn * lup * state: ') # for det, coef in change_basis(self.complex_bas, ldn_lup_state).dets.items(): for det, coef in ldn_lup_state.dets.items(): print(det, (float_format + float_format + "i")%(coef.real, coef.imag)) res = Vec.zero() res += ldn_lup_state res += lz2_state res += lz_state print('L2 * state: ') # for det, coef in change_basis(self.complex_bas, res).dets.items(): for det, coef in ldn_lup_state.dets.items(): print(det, (float_format + float_format + "i")%(coef.real, coef.imag)) print('END DEBUG: ')
parser = CsfParser(mol, mf) csf_str1 = "1.00000000 |2s+; 2py+; 2pz+; 2px+; 2s−i" csf1 = parser.csf_string_to_det(csf_str1) print(csf1) print(p.project(0, csf1)) csf_str2 = "0.57735027 |2s+; 2pz+; 2px+; 3py+; 2s−i-0.57735027 |2s+; 2py+; 2px+; 3pz+; 2s−i0.57735027 |2s+; 2py+; 2pz+; 3px+; 2s−i" csf2 = parser.csf_string_to_det(csf_str2) print(csf2) print(p.project(0, csf2)) csf_str3 = "-0.05773503 |2py+; 3dxy+; 3dyz+; 3dr2−z2+; 2s−i-0.05773503 |2px+; 3dxy+; 3dr2−z2+; 3dxz+; 2s−i-0.11547005 |2pz+; 3dyz+; 3dr2−z2+; 3dxz+; 2s−i-0.10000000 |2py+; 3dxy+; 3dyz+; 3dx2−y2+; 2s−i-0.05773503 |2pz+; 3dxy+; 3dr2−z2+; 3dx2−y2+; 2s−i-0.05773503 |2px+; 3dyz+; 3dr2−z2+; 3dx2−y2+; 2s−i-0.10000000 |2px+; 3dxy+; 3dxz+; 3dx2−y2+; 2s−i0.05773503 |2py+; 3dr2−z2+; 3dxz+; 3dx2−y2+; 2s−i-0.23094011 |2s+; 3dxy+; 3dyz+; 3dr2−z2+; 2py−i-0.40000000 |2s+; 3dxy+; 3dyz+; 3dx2−y2+; 2py−i0.23094011 |2s+; 3dr2−z2+; 3dxz+; 3dx2−y2+; 2py−i-0.46188022 |2s+; 3dyz+; 3dr2−z2+; 3dxz+; 2pz−i-0.23094011 |2s+; 3dxy+; 3dr2−z2+; 3dx2−y2+; 2pz−i-0.23094011 |2s+; 3dxy+; 3dr2−z2+; 3dxz+; 2px−i-0.23094011 |2s+; 3dyz+; 3dr2−z2+; 3dx2−y2+; 2px−i-0.40000000 |2s+; 3dxy+; 3dxz+; 3dx2−y2+; 2px−i-0.05773503 |2s+; 2py+; 3dyz+; 3dr2−z2+; 3dxy−i-0.05773503 |2s+; 2px+; 3dr2−z2+; 3dxz+; 3dxy−i-0.10000000 |2s+; 2py+; 3dyz+; 3dx2−y2+; 3dxy−i-0.05773503 |2s+; 2pz+; 3dr2−z2+; 3dx2−y2+; 3dxy−i-0.10000000 |2s+; 2px+; 3dxz+; 3dx2−y2+; 3dxy−i0.05773503 |2s+; 2py+; 3dxy+; 3dr2−z2+; 3dyz−i-0.11547005 |2s+; 2pz+; 3dr2−z2+; 3dxz+; 3dyz−i0.10000000 |2s+; 2py+; 3dxy+; 3dx2−y2+; 3dyz−i-0.05773503 |2s+; 2px+; 3dr2−z2+; 3dx2−y2+; 3dyz−i-0.05773503 |2s+; 2py+; 3dxy+; 3dyz+; 3dr2−z2−i0.05773503 |2s+; 2px+; 3dxy+; 3dxz+; 3dr2−z2−i0.11547005 |2s+; 2pz+; 3dyz+; 3dxz+; 3dr2−z2−i0.05773503 |2s+; 2pz+; 3dxy+; 3dx2−y2+; 3dr2−z2−i0.05773503 |2s+; 2px+; 3dyz+; 3dx2−y2+; 3dr2−z2−i0.05773503 |2s+; 2py+; 3dxz+; 3dx2−y2+; 3dr2−z2−i-0.05773503 |2s+; 2px+; 3dxy+; 3dr2−z2+; 3dxz−i-0.11547005 |2s+; 2pz+; 3dyz+; 3dr2−z2+; 3dxz−i0.10000000 |2s+; 2px+; 3dxy+; 3dx2−y2+; 3dxz−i-0.05773503 |2s+; 2py+; 3dr2−z2+; 3dx2−y2+; 3dxz−i-0.10000000 |2s+; 2py+; 3dxy+; 3dyz+; 3dx2−y2−i-0.05773503 |2s+; 2pz+; 3dxy+; 3dr2−z2+; 3dx2−y2−i-0.05773503 |2s+; 2px+; 3dyz+; 3dr2−z2+; 3dx2−y2−i-0.10000000 |2s+; 2px+; 3dxy+; 3dxz+; 3dx2−y2−i0.05773503 |2s+; 2py+; 3dr2−z2+; 3dxz+; 3dx2−y2−i" csf3 = parser.csf_string_to_det(csf_str3) prj3 = p.project(0, csf3) diff = Vec.zero() diff += csf3 diff += -1 * prj3 print(diff.norm()) csf_str4 = "0.19720266 |2py+; 3dxy+; 3dyz+; 3dr2−z2+; 2s−i0.19720266 |2px+; 3dxy+; 3dr2−z2+; 3dxz+; 2s−i0.39440532 |2pz+; 3dyz+; 3dr2−z2+; 3dxz+; 2s−i0.34156503 |2py+; 3dxy+; 3dyz+; 3dx2−y2+; 2s−i0.19720266 |2pz+; 3dxy+; 3dr2−z2+; 3dx2−y2+; 2s−i0.19720266 |2px+; 3dyz+; 3dr2−z2+; 3dx2−y2+; 2s−i0.34156503 |2px+; 3dxy+; 3dxz+; 3dx2−y2+; 2s−i-0.19720266 |2py+; 3dr2−z2+; 3dxz+; 3dx2−y2+; 2s−i-0.09759001 |2s+; 2px+; 3dxy+; 3dyz+; 3dxy−i0.02817181 |2s+; 2py+; 3dyz+; 3dr2−z2+; 3dxy−i0.09759001 |2s+; 2py+; 3dxy+; 3dxz+; 3dxy−i0.02817181 |2s+; 2px+; 3dr2−z2+; 3dxz+; 3dxy−i-0.14638501 |2s+; 2py+; 3dyz+; 3dx2−y2+; 3dxy−i-0.14085904 |2s+; 2pz+; 3dr2−z2+; 3dx2−y2+; 3dxy−i-0.14638501 |2s+; 2px+; 3dxz+; 3dx2−y2+; 3dxy−i-0.09759001 |2s+; 2pz+; 3dxy+; 3dyz+; 3dyz−i0.14085904 |2s+; 2py+; 3dxy+; 3dr2−z2+; 3dyz−i-0.09759001 |2s+; 2py+; 3dyz+; 3dxz+; 3dyz−i-0.11268723 |2s+; 2pz+; 3dr2−z2+; 3dxz+; 3dyz−i0.04879500 |2s+; 2py+; 3dxy+; 3dx2−y2+; 3dyz−i-0.14085904 |2s+; 2px+; 3dr2−z2+; 3dx2−y2+; 3dyz−i0.09759001 |2s+; 2pz+; 3dxz+; 3dx2−y2+; 3dyz−i-0.08451543 |2s+; 2py+; 3dxy+; 3dyz+; 3dr2−z2−i-0.09759001 |2s+; 2px+; 3dyz+; 3dr2−z2+; 3dr2−z2−i0.08451543 |2s+; 2px+; 3dxy+; 3dxz+; 3dr2−z2−i0.16903085 |2s+; 2pz+; 3dyz+; 3dxz+; 3dr2−z2−i-0.09759001 |2s+; 2py+; 3dr2−z2+; 3dxz+; 3dr2−z2−i-0.08451543 |2s+; 2pz+; 3dxy+; 3dx2−y2+; 3dr2−z2−i0.08451543 |2s+; 2px+; 3dyz+; 3dx2−y2+; 3dr2−z2−i0.08451543 |2s+; 2py+; 3dxz+; 3dx2−y2+; 3dr2−z2−i-0.14085904 |2s+; 2px+; 3dxy+; 3dr2−z2+; 3dxz−i-0.11268723 |2s+; 2pz+; 3dyz+; 3dr2−z2+; 3dxz−i0.09759001 |2s+; 2pz+; 3dxy+; 3dxz+; 3dxz−i-0.09759001 |2s+; 2px+; 3dyz+; 3dxz+; 3dxz−i0.04879500 |2s+; 2px+; 3dxy+; 3dx2−y2+; 3dxz−i0.09759001 |2s+; 2pz+; 3dyz+; 3dx2−y2+; 3dxz−i-0.14085904 |2s+; 2py+; 3dr2−z2+; 3dx2−y2+; 3dxz−i-0.14638501 |2s+; 2py+; 3dxy+; 3dyz+; 3dx2−y2−i-0.14085904 |2s+; 2pz+; 3dxy+; 3dr2−z2+; 3dx2−y2−i0.02817181 |2s+; 2px+; 3dyz+; 3dr2−z2+; 3dx2−y2−i-0.14638501 |2s+; 2px+; 3dxy+; 3dxz+; 3dx2−y2−i-0.02817181 |2s+; 2py+; 3dr2−z2+; 3dxz+; 3dx2−y2−i0.09759001 |2s+; 2px+; 3dyz+; 3dx2−y2+; 3dx2−y2−i-0.09759001 |2s+; 2py+; 3dxz+; 3dx2−y2+; 3dx2−y2−i" csf4 = parser.csf_string_to_det(csf_str4) prj4 = p.project(0, csf4) diff = Vec.zero() diff += csf4 diff += -1 * prj4 print(diff.norm()) csf_str5 = "0.10540926 |2py+; 3dxy+; 3dyz+; 3dr2−z2+; 2s−i0.10540926 |2px+; 3dxy+; 3dr2−z2+; 3dxz+; 2s−i0.21081851 |2pz+; 3dyz+; 3dr2−z2+; 3dxz+; 2s−i0.18257419 |2py+; 3dxy+; 3dyz+; 3dx2−y2+; 2s−i0.10540926 |2pz+; 3dxy+; 3dr2−z2+; 3dx2−y2+; 2s−i0.10540926 |2px+; 3dyz+; 3dr2−z2+; 3dx2−y2+; 2s−i0.18257419 |2px+; 3dxy+; 3dxz+; 3dx2−y2+; 2s−i-0.10540926 |2py+; 3dr2−z2+; 3dxz+; 3dx2−y2+; 2s−i0.18257419 |2s+; 2px+; 3dxy+; 3dyz+; 3dxy−i-0.21081851 |2s+; 2py+; 3dyz+; 3dr2−z2+; 3dxy−i-0.18257419 |2s+; 2py+; 3dxy+; 3dxz+; 3dxy−i-0.21081851 |2s+; 2px+; 3dr2−z2+; 3dxz+; 3dxy−i0.10540926 |2s+; 2pz+; 3dr2−z2+; 3dx2−y2+; 3dxy−i0.18257419 |2s+; 2pz+; 3dxy+; 3dyz+; 3dyz−i-0.10540926 |2s+; 2py+; 3dxy+; 3dr2−z2+; 3dyz−i0.18257419 |2s+; 2py+; 3dyz+; 3dxz+; 3dyz−i-0.10540926 |2s+; 2pz+; 3dr2−z2+; 3dxz+; 3dyz−i0.18257419 |2s+; 2py+; 3dxy+; 3dx2−y2+; 3dyz−i0.10540926 |2s+; 2px+; 3dr2−z2+; 3dx2−y2+; 3dyz−i-0.18257419 |2s+; 2pz+; 3dxz+; 3dx2−y2+; 3dyz−i0.18257419 |2s+; 2px+; 3dyz+; 3dr2−z2+; 3dr2−z2−i0.18257419 |2s+; 2py+; 3dr2−z2+; 3dxz+; 3dr2−z2−i0.31622777 |2s+; 2pz+; 3dxy+; 3dx2−y2+; 3dr2−z2−i0.10540926 |2s+; 2px+; 3dxy+; 3dr2−z2+; 3dxz−i-0.10540926 |2s+; 2pz+; 3dyz+; 3dr2−z2+; 3dxz−i-0.18257419 |2s+; 2pz+; 3dxy+; 3dxz+; 3dxz−i0.18257419 |2s+; 2px+; 3dyz+; 3dxz+; 3dxz−i0.18257419 |2s+; 2px+; 3dxy+; 3dx2−y2+; 3dxz−i-0.18257419 |2s+; 2pz+; 3dyz+; 3dx2−y2+; 3dxz−i0.10540926 |2s+; 2py+; 3dr2−z2+; 3dx2−y2+; 3dxz−i0.10540926 |2s+; 2pz+; 3dxy+; 3dr2−z2+; 3dx2−y2−i-0.21081851 |2s+; 2px+; 3dyz+; 3dr2−z2+; 3dx2−y2−i0.21081851 |2s+; 2py+; 3dr2−z2+; 3dxz+; 3dx2−y2−i-0.18257419 |2s+; 2px+; 3dyz+; 3dx2−y2+; 3dx2−y2−i0.18257419 |2s+; 2py+; 3dxz+; 3dx2−y2+; 3dx2−y2−i" csf5 = parser.csf_string_to_det(csf_str5) prj5 = p.project(0, csf5)
def make_state(coef, up_occ, dn_occ): return Vec({Det(up_occ, dn_occ): coef})
def real_part(csf): res = Vec.zero() for det, coef in csf.dets.items(): res += coef.real*det return res
def add_csfs(coefs, csfs): res = Vec.zero() for coef, csf in zip(coefs, csfs): res += coef*csf return res