Nblobs = sum([x.Nblobs for x in bodies]) max_angle_shift = max_translation / max_body_length accepted_moves = 0 acceptance_ratio = 0.5 # Create blobs coordinates array sample_r_vectors = get_blobs_r_vectors(bodies, Nblobs) # begin MCMC # get energy of the current state before jumping into the loop start_time = time.time() current_state_energy = many_body_potential_pycuda.compute_total_energy( bodies, sample_r_vectors, periodic_length=periodic_length, debye_length_wall=read.debye_length_wall, repulsion_strength_wall=read.repulsion_strength_wall, debye_length=read.debye_length, repulsion_strength=read.repulsion_strength, weight=weight, blob_radius=blob_radius) # quaternion to be used for disturbing the orientation of each body quaternion_shift = Quaternion(np.array([1, 0, 0, 0])) # for each step in the Markov chain, disturb each body's location and orientation and obtain the new list of r_vectors # of each blob. Calculate the potential of the new state, and accept or reject it according to the Markov chain rules: # 1. if Ej < Ei, always accept the state 2. if Ej < Ei, accept the state according to the probability determined by # exp(-(Ej-Ei)/kT). Then record data. # Important: record data also when staying in the same state (i.e. when a sample state is rejected) for step in range(read.initial_step, read.n_steps): blob_index = 0
Nblobs = sum([x.Nblobs for x in bodies]) max_angle_shift = max_translation / max_body_length accepted_moves = 0 acceptance_ratio = 0.5 # Create blobs coordinates array sample_r_vectors = get_blobs_r_vectors(bodies, Nblobs) # begin MCMC # get energy of the current state before jumping into the loop start_time = time.time() current_state_energy = many_body_potential_pycuda.compute_total_energy(bodies, sample_r_vectors, periodic_length = periodic_length, debye_length_wall = read.debye_length_wall, repulsion_strength_wall = read.repulsion_strength_wall, debye_length = read.debye_length, repulsion_strength = read.repulsion_strength, weight = weight, blob_radius = blob_radius) # quaternion to be used for disturbing the orientation of each body quaternion_shift = Quaternion(np.array([1,0,0,0])) # for each step in the Markov chain, disturb each body's location and orientation and obtain the new list of r_vectors # of each blob. Calculate the potential of the new state, and accept or reject it according to the Markov chain rules: # 1. if Ej < Ei, always accept the state 2. if Ej < Ei, accept the state according to the probability determined by # exp(-(Ej-Ei)/kT). Then record data. # Important: record data also when staying in the same state (i.e. when a sample state is rejected) for step in range(read.initial_step, read.n_steps): blob_index = 0