Factors.PyChemLib#

PyChemLib.py

functions borrowed from https://pythoninchemistry.org/sim_and_scat/intro

Copyright (c) 2023, SAXS Team, KEK-PF

demo_accel()#
demo_lj_force()#
demo_lj_force2()#
demo_run_md()#
get_accelerations(positions, mass)#

Calculate the acceleration on each particle as a result of each other particle. N.B. We use the Python convention of numbering from 0.

Parameters:

positions (ndarray of floats) – The positions, in a single dimension, for all of the particles (Å)

Returns:

The acceleration on each particle (eV/Åamu)

Return type:

ndarray of floats

init_velocity(T, number_of_particles, mass)#

Initialise the velocities for a series of particles.

Parameters:
  • T (float) – Temperature of the system at initialisation (K)

  • number_of_particles (int) – Number of particles in the system

Returns:

Initial velocities for a series of particles (eVs/Åamu)

Return type:

ndarray of floats

lj_force(r, epsilon, sigma)#

Implementation of the Lennard-Jones potential to calculate the force of the interaction.

Parameters:
  • r (float) – Distance between two particles (Å)

  • epsilon (float) – Potential energy at the equilibrium bond length (eV)

  • sigma (float) – Distance at which the potential energy is zero (Å)

Returns:

Force of the van der Waals interaction (eV/Å)

Return type:

float

run_md(dt, number_of_steps, initial_temp, x, mass)#

Run a MD simulation.

Parameters:
  • dt (float) – The timestep length (s)

  • number_of_steps (int) – Number of iterations in the simulation

  • initial_temp (float) – Temperature of the system at initialisation (K)

  • x (ndarray of floats) – The initial positions of the particles in a single dimension (Å)

Returns:

The positions for all of the particles throughout the simulation (Å)

Return type:

ndarray of floats

update_pos(x, v, a, dt)#

Update the particle positions.

Parameters:
  • x (ndarray of floats) – The positions of the particles in a single dimension

  • v (ndarray of floats) – The velocities of the particles in a single dimension

  • a (ndarray of floats) – The accelerations of the particles in a single dimension

  • dt (float) – The timestep length

Returns:

New positions of the particles in a single dimension

Return type:

ndarray of floats

update_velo(v, a, a1, dt)#

Update the particle velocities.

Parameters:
  • v (ndarray of floats) – The velocities of the particles in a single dimension (eVs/Åamu)

  • a (ndarray of floats) – The accelerations of the particles in a single dimension at the previous timestep (eV/Åamu)

  • a1 (ndarray of floats) – The accelerations of the particles in a single dimension at the current timestep (eV/Åamu)

  • dt (float) – The timestep length

Returns:

New velocities of the particles in a single dimension (eVs/Åamu)

Return type:

ndarray of floats