pylj.mc¶
Functions related to the Monte-Carlo components of pylj.
- pylj.mc.accept(new_energy)[source]¶
Accept the move.
- Parameters:
new_energy (float) – A new total energy for the system.
- Returns:
A new total energy for the system.
- Return type:
float
- pylj.mc.get_new_particle(particles, random_particle, box_length)[source]¶
Generates a new position for the particle.
- Parameters:
particles (util.particle.dt, array_like) – Information about the particles.
random_particle (int) – Index of the random particle that is selected.
box_length (float) – Length of a single dimension of the simulation square.
- Returns:
Information about the particles, updated to account for the change of selected particle position.
- Return type:
util.particle.dt, array_like
- pylj.mc.initialise(number_of_particles, temperature, box_length, init_conf, mass=39.948, constants=[[1.363e-134, 9.273e-78]], forcefield=<class 'pylj.forcefields.lennard_jones'>)[source]¶
Initialise the particle positions (this can be either as a square or random arrangement), velocities (based on the temperature defined, and # calculate the initial forces/accelerations.
- Parameters:
number_of_particles (int) – Number of particles to simulate.
temperature (float) – Initial temperature of the particles, in Kelvin.
box_length (float) – Length of a single dimension of the simulation square, in Angstrom.
init_conf (string, optional) – The way that the particles are initially positioned. Should be one of: - ‘square’ - ‘random’
mass (float (optional)) – The mass of the particles being simulated.
constants (float, array_like (optional)) – The values of the constants for the forcefield used.
forcefield (function (optional)) – The particular forcefield to be used to find the energy and forces.
- Returns:
System information.
- Return type:
- pylj.mc.initialize(number_particles, temperature, box_length, init_conf)[source]¶
Maps to the mc.initialise function to account for US english spelling.
- pylj.mc.metropolis(temperature, old_energy, new_energy, n=0.7236883483313941)[source]¶
Determines if the move is accepted or rejected based on the metropolis condition.
- Parameters:
temperature (float) – Simulation temperature.
old_energy (float) – The total energy of the simulation in the previous configuration.
new_energy (float) – The total energy of the simulation in the current configuration.
n (float, optional) – The random number against which the Metropolis condition is tested. The default is from a numpy uniform distribution.
- Returns:
True if the move should be accepted.
- Return type:
bool
- pylj.mc.reject(position_store, particles, random_particle)[source]¶
Reject the move and return the particle to the original place.
- Parameters:
position_store (float, array_like) – The x and y positions previously held by the particle that has moved.
particles (util.particle.dt, array_like) – Information about the particles.
random_particle (int) – Index of the random particle that is selected.
- Returns:
Information about the particles, with the particle returned to the original position
- Return type:
util.particle.dt, array_like
- pylj.mc.select_random_particle(particles)[source]¶
Selects a random particle from the system and return its index and current position.
- Parameters:
particles (util.particle.dt, array_like) – Information about the particles.
- Returns:
int – Index of the random particle that is selected.
float, array_like – The current position of the chosen particle.