def corr_by_proj(dets_p, ref_key): """Calculates correlation energy by projection.""" # E_corr = sum_j!=o(<D_j|H|D_0>*(<N_j>/<N_0>)) # Returns numerator and denominator separately, such that they can both be averaged over iterations. ref_orbs = key_ops.key_2_orbs(ref_key) numer = 0 # Initializes numerator. for key in dets_p: if key != ref_key: orbs_gnd, sign_exc, orbs_diff = key_ops.difference(ref_key, key) if orbs_gnd != None: term = integrals.sandwich(orbs_gnd, orbs_diff) * dets_p[key].value if not sign_exc: term = -term numer += term denom = float(dets_p[ref_key].value) # Denominator. return numer, denom
def corr_by_proj(dets_p, ref_key): """Calculates correlation energy by projection.""" # E_corr = sum_j(<D_j|H|D_0>*(<N_j>/<N_0>)) - E_0 ref_orbs = key_ops.key_2_orbs(ref_key) numer = 0 for key in dets_p: if key != ref_key: orbs_gnd, sign_exc, orbs_diff = key_ops.difference(ref_key, key) if orbs_gnd != None: term = black_box.sandwich(orbs_gnd, orbs_diff) * dets_p[key].value if not sign_exc: term = -term numer += term denom = float(dets_p[ref_key].value) return numer, denom
def set_diag_entry(self, key): """Sets diagonal matrix element of this determinant.""" orbs = key_ops.key_2_orbs(key) self.diag_entry = black_box.sandwich(orbs, ())
def set_diag_entry(self, key): """Sets diagonal matrix element of this determinant.""" # Excludes the reference energy of D0. orbs = key_ops.key_2_orbs(key) self.diag_entry = integrals.sandwich(orbs, ()) - integrals.ref_energy
change_shift_crit_num = 5000 init_crit_w_num = 10 init_walker_num = 50 max_iter_num = 15000 wait_for_aver_num = 2500 damping = 0.05 init_shift = 0.05 ref_key = (1, 15, 1, 15) single_prob = 0.5 tau = 0.0025 change_shift_step = 5 update_plots_step = 20 # The exact correlation energy is found by directly diagonalizing the Hamiltonian on MATLAB. exact_corr = -0.1543290876 # The ranges of various plots. orb_num = integrals.para_list[2] e_num = integrals.para_list[3] y_axis_eig_vec_plot = [-1, 1] y_axis_energy_plot = [-0.3, 0.1] y_axis_log_w_num_plot = [3, 11] # Sets the reference energy. integrals.ref_energy = integrals.sandwich(key_ops.key_2_orbs(ref_key), ()) # Begins the simulation. import run_simu aver_shift, aver_proj, dets_p, vec = run_simu.run()