def avg_hist_2(filename,filename2,num_files): for i in range(num_files): walk = np.load(f'{filename}/{filename2}_{i}.npy',allow_pickle=True) plt.figure(i) plt.xlabel('Walker Oxygen Bond Angle') plt.ylabel('Density') plt.title(f'Wave Function of Oxygen Angles at {i+1} million steps') plt.bar(align='edge', width=1.5, linewidth=0, **lib.avg_hist(walk),alpha=.6) plt.show()
def avg_hist(filename,filename2,num_files): walkers = [] for i in range(num_files): walk = np.load(f'{filename}/{filename2}_{i}.npy',allow_pickle=True) for j in range(len(walk)): walkers.append(walk[j]) plt.figure(i) plt.xlabel('Walker Oxygen Bond Angle') plt.ylabel('Density') plt.title(f'Wave Function of Oxygen Angles after {i+1} million steps') plt.bar(align='edge', width=1.5, **lib.avg_hist(walkers)) plt.show()
# Array axes are walkers, molecules, atoms, coordinates #walkers = (np.random.rand(n_walkers, num_molecules, lib.atomic_masses.shape[0],lib.coord_const) - .5) # Uncomment this line if loading in an already equliibrated walker array #walkers = np.load('5000_walker.npy') ####################################################################################### # Simulation start = time.time() # Equilibriate Walkers #walkers = lib.sim_loop(walkers,equilibriation_phase,dt)['w'] ref_energy = lib.sim_loop(walkers, sim_length, dt, wf_save=wave_func_interval, output_filename=output_filename)['r'] np.savetxt(f'{output_filename}_cr_ref', [np.mean(ref_energy[int(sim_length / 2):sim_length])]) #np.save(f'dt{dt}_sim{sim_length}_walk{n_walkers}',wave_func_out) sys.exit(0) # Simulation loop for descentdent weighting ''' sim_out = lib.sim_loop(walkers,sim_length,dt,dw_save=prop_interval) walkers, reference_energy, num_walkers, snapshots = [sim_out[k] for k in 'wrns'] '''
# Imports import numpy as np import itertools as it import DMC_rs_lib as lib import sys # Start of validation here, everything above is solely from copied files to keep the same PE functions # INPUT is filename, number of molecules for trimer/dimer/monomer filename = sys.argv[1] num_mol = int(sys.argv[2]) # load the walker array walk_array = np.load(filename + '.npy') # reshape the walker array walk_reshape = np.reshape(walk_array, (walk_array.shape[0], num_mol, 3, 3)) intra_PE = lib.intra_pe(walk_reshape) if num_mol > 1: inter_PE, _, _, = lib.inter_pe(walk_reshape) total_PE = lib.total_pe(walk_reshape) np.savetxt(filename + '_intra', intra_PE) if num_mol > 1: np.savetxt(filename + '_inter', inter_PE) np.savetxt(filename + '_total', total_PE)
prop_amount = .5 walkers, num_molecules = out.gen_walker_array(filename, n_walkers, prop_amount, num_molecules) # Uncomment the code below if doing an initialization within a random range # Initial 4D walker array # Returns a uniform distribution cenetered at the given bond length # Array axes are walkers, molecules, atoms, coordinates #walkers = (np.random.rand(n_walkers, num_molecules, lib.atomic_masses.shape[0],lib.coord_const) - .5) # Uncomment this line if loading in an already equliibrated walker array #walkers = np.load('5000_walker.npy') ####################################################################################### # Simulation ''' start = time.time() # Equilibriate Walkers walkers = lib.sim_loop(walkers,equilibriation_phase,dt)['w'] lib.sim_loop(walkers,sim_length,dt,wf_save=wave_func_interval,output_filename=output_filename) #np.save(f'dt{dt}_sim{sim_length}_walk{n_walkers}',wave_func_out) print(f'Total time: {time.time()-start:.1f}') sys.exit(0) ''' # Simulation loop for descentdent weighting ''' sim_out = lib.sim_loop(walkers,sim_length,dt,dw_save=prop_interval)
prop_period = 20 prop_steps = int(prop_period / dt) # Number of times we run DW simulation loop prop_reps = 5 #################################################################################### # Molecule Model Constants # Number of molecules in each walker # Used to initialize the walker array num_molecules = 1 # Initialize the walker array depending on the method inputted if method == 'one_atom_random': walkers = lib.init_one_atom_random(n_walkers, prop_range, num_molecules, input_file) elif method == 'one_atom_normal': walkers = lib.init_one_atom_normal(n_walkers, prop_range, num_molecules, input_file) elif method == 'equil_random': walkers = lib.init_equil_random(n_walkers, prop_range, num_molecules, input_file) elif method == 'equil_normal': walkers = lib.init_equil_normal(n_walkers, prop_range, num_molecules, input_file) elif method == 'normal': walkers = lib.init_normal(n_walkers, num_molecules, prop_range)