pylj.comp¶
These are the COMPutationally intensive, COMPiled (by cython) functions. Generally these are functions required by pylj which involve a pair-wise comparison of particles. These are written in C++, the source of which can be found in the src/comp.cpp file.
-
pylj.comp.calculate_pressure()¶ Calculates the instantaneous pressure of the simulation cell, found with the following relationship:
\[p = \langle \rho k_b T \rangle + \bigg\langle \frac{1}{3V}\sum_{i}\sum_{j<i} \mathbf{r}_{ij}\mathbf{f}_{ij} \bigg\rangle\]Parameters: - particles (util.particle_dt, array_like) – Information about the particles.
- box_length (float) – Length of a single dimension of the simulation square, in Angstrom.
- temperature (float) – Instantaneous temperature of the simulation.
- cut_off (float) – The distance greater than which the forces between particles is taken as zero.
- constants (float, array_like (optional)) – The constants associated with the particular forcefield used, e.g. for the function forcefields.lennard_jones, theses are [A, B].
Returns: Instantaneous pressure of the simulation.
Return type: float
-
pylj.comp.compute_energy()¶ Calculates the total energy of the simulation. This uses a 12-6 Lennard-Jones potential model for Argon with values:
- A = 1.363e-134 J m \(^{12}\)
- B = 9.273e-78 J m \(^6\)
Parameters: - particles (util.particle_dt, array_like) – Information about the particles.
- box_length (float) – Length of a single dimension of the simulation square, in Angstrom.
- cut_off (float) – The distance greater than which the energies between particles is taken as zero.
- constants (float, array_like (optional)) – The constants associated with the particular forcefield used, e.g. for the function forcefields.lennard_jones, theses are [A, B].
Returns: - util.particle_dt, array_like – Information about particles, with updated accelerations and forces.
- float, array_like – Current distances between pairs of particles in the simulation.
- float, array_like – Current energies between pairs of particles in the simulation.
-
pylj.comp.compute_force()¶ Calculates the forces and therefore the accelerations on each of the particles in the simulation. This uses a 12-6 Lennard-Jones potential model for Argon with values:
- A = 1.363e-134 J m \(^{12}\)
- B = 9.273e-78 J m \(^6\)
Parameters: - particles (util.particle_dt, array_like) – Information about the particles.
- box_length (float) – Length of a single dimension of the simulation square, in Angstrom.
- cut_off (float) – The distance greater than which the forces between particles is taken as zero.
- constants (float, array_like (optional)) – The constants associated with the particular forcefield used, e.g. for the function forcefields.lennard_jones, theses are [A, B].
- mass (float (optional)) – The mass of the particle being simulated (units of atomic mass units).
Returns: - util.particle_dt, array_like – Information about particles, with updated accelerations and forces.
- float, array_like – Current distances between pairs of particles in the simulation.
- float, array_like – Current forces between pairs of particles in the simulation.
- float, array_like – Current energies between pairs of particles in the simulation.
-
pylj.comp.dist()¶ Returns the distance array for the set of particles.
Parameters: - xpos (float, array_like (N)) – Array of length N, where N is the number of particles, providing the x-dimension positions of the particles.
- ypos (float, array_like (N)) – Array of length N, where N is the number of particles, providing the y-dimension positions of the particles.
- box_length (float) – The box length of the simulation cell.
Returns: - distances float, array_like ((N - 1) * N / 2)) – The pairs of distances between the particles.
- xdistances float, array_like ((N - 1) * N / 2)) – The pairs of distances between the particles, in only the x-dimension.
- ydistances float, array_like ((N - 1) * N / 2)) – The pairs of distances between the particles, in only the y-dimension.
-
pylj.comp.heat_bath()¶ Rescales the velocities of the particles in the system to control the temperature of the simulation. Thereby allowing for an NVT ensemble. The velocities are rescaled according the following relationship,
\[v_{\text{new}} = v_{\text{old}} \times \sqrt{\frac{T_{\text{desired}}}{\bar{T}}}\]Parameters: - particles (util.particle_dt, array_like) – Information about the particles.
- temperature_sample (float, array_like) – The temperature at each timestep in the simulation.
- bath_temp (float) – The desired temperature of the simulation.
Returns: Information about the particles with new, rescaled velocities.
Return type: util.particle_dt, array_like