예제 #1
0
    def __init__(self, ham_filename, **kwargs):
        ham_opts, param_opts, misc_opts = self.set_defaults(kwargs)

        # Read in the Hamiltonian integrals from file
        self.sys_ham = det_ops.HAM(filename=ham_filename, **ham_opts)
        ref_energy = self.sys_ham.slater_condon(self.sys_ham.ref_det,
                                                self.sys_ham.ref_det, None,
                                                None)

        # Setup simulation parameters. See system.py for details.
        self.sim_params = system.PARAMS(**param_opts)

        # Setup a statistics object, which accumulates various run-time variables.
        # See system.py for more details.
        self.sim_stats = system.STATS(self.sim_params,
                                      filename='fciqmc_stats',
                                      ref_energy=ref_energy)

        # Set up walker object as a dictionary.
        # Label determinants by the string representation of the list of occupied orbitals
        self.walkers = {repr(self.sys_ham.ref_det): self.sim_params.nwalk_init}
        self.sim_stats.nw = self.sim_params.nwalk_init
예제 #2
0
e, v = np.linalg.eigh(full_h)
print('Ground state energy of full hamiltonian is {}'.format(e[0]))

# Find the reference energy from the first element of the Hamiltonian.
# Define h_sim, which is where the reference energy has been removed from the diagonal of the hamiltonian
ref_energy = full_h[0,0]
h_sim = full_h - np.eye(full_h.shape[0])*ref_energy
print('Removing reference energy from simulated hamiltonian')

# Setup simulation parameters. See system.py for details.  
sim_params = system.PARAMS(totwalkers=2000, initwalkers=10, init_shift=0.0, 
        shift_damp=0.1, timestep=1.e-2, det_thresh=0.25, eqm_iters=250, 
        max_iter=15000, stats_cycle=10, seed=7)
# Setup a statistics object, which accumulates various run-time variables.
# See system.py for more details.
sim_stats = system.STATS(sim_params, filename='fciqmc_stats', ref_energy=ref_energy)

# Set up walker object as a dictionary.
# Initially, label determinants by their index in the hamiltonian array.
walkers = {0: sim_params.nwalk_init}
sim_stats.nw = sim_params.nwalk_init

for sim_stats.iter_curr in range(sim_params.max_iter):

    spawned_walkers = {}    # Dictionary to hold the spawned walkers of each iteration
    sim_stats.nw = 0.0      # Recompute number of walkers each iteration
    sim_stats.ref_weight = 0.0
    sim_stats.nocc_dets = 0

    # Iterate over occupied (not all) determinants (keys) in the dictionary
    # Note that this is python3 format