Skip to content

Commit

Permalink
Merge pull request #72 from maximillian-dolan/master
Browse files Browse the repository at this point in the history
adjusting docstrings
  • Loading branch information
arm61 authored Aug 8, 2024
2 parents b5b0480 + 06519ee commit 12ff450
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
14 changes: 7 additions & 7 deletions pylj/forcefields.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def energy(self, dr):
.. math::
E = \frac{4e*a^{12}}{dr^{12}} - \frac{4e*a^{6}}{dr^6}
Attributes:
Parameters
----------
dr (float): The distance between particles.
Expand All @@ -47,7 +47,7 @@ def force(self, dr):
.. math::
f = \frac{48e*a^{12}}{dr^{13}} - \frac{24e*a^{6}}{dr^7}
Attributes:
Parameters
----------
dr (float): The distance between particles.
Expand Down Expand Up @@ -110,7 +110,7 @@ def mixing(self, constants_2):
a = 4*\epsilon*(\sigma^12)
b = 4*\epsilon*(\sigma^6)
Parameters:
Parameters
----------
constants_2: float, array_like
The second set of constantss
Expand Down Expand Up @@ -150,7 +150,7 @@ def energy(self, dr):
.. math::
E = Ae^{(-Bdr)} - \frac{C}{dr^6}
Attributes:
Parameters
----------
dr (float): The distance between particles.
Expand All @@ -175,7 +175,7 @@ def force(self, dr):
.. math::
f = ABe^{(-Bdr)} - \frac{6C}{dr^7}
Attributes:
Parameters
----------
dr (float): The distance between particles.
Expand All @@ -201,7 +201,7 @@ def mixing(self, constants2):
b_{12} = \sqrt{b_1 * b_2}
c_{12} = \sqrt{c_1 * c_2}
Attributes:
Parameters
----------
constants_2: float, array_like
The second set of constantss
Expand Down Expand Up @@ -247,7 +247,7 @@ def energy(self, dr):
E = 0
}
Attributes:
Parameters
----------
dr (float): The distance between particles.
Expand Down
16 changes: 16 additions & 0 deletions pylj/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def velocity_verlet(
Updates the particles positions and velocities in terms of the Velocity
Verlet algorithm. Also calculates the instanteous temperature, pressure,
and force and appends these to the appropriate system array.
Parameters
----------
particles: util.particle_dt, array_like
Expand All @@ -92,6 +93,7 @@ def velocity_verlet(
Length for each Velocity-Verlet integration step, in seconds.
box_length: float
Length of a single dimension of the simulation square, in Angstrom.
Returns
-------
util.particle_dt, array_like:
Expand Down Expand Up @@ -127,6 +129,7 @@ def velocity_verlet(

def sample(particles, box_length, initial_particles, system):
"""Sample parameters of interest in the simulation.
Parameters
----------
particles: util.particle_dt, array_like
Expand All @@ -137,6 +140,7 @@ def sample(particles, box_length, initial_particles, system):
Information about the initial particle conformation.
system: System
Details about the whole system
Returns
-------
System:
Expand Down Expand Up @@ -165,6 +169,7 @@ def sample(particles, box_length, initial_particles, system):

def calculate_msd(particles, initial_particles, box_length):
"""Determines the mean squared displacement of the particles in the system.
Parameters
----------
particles: util.particle_dt, array_like
Expand All @@ -173,6 +178,7 @@ def calculate_msd(particles, initial_particles, box_length):
Information about the initial state of the particles.
box_length: float
Size of the cell vector.
Returns
-------
float:
Expand Down Expand Up @@ -205,6 +211,7 @@ def update_positions(
positions, old_positions, velocities, accelerations, timestep_length, box_length
):
"""Update the particle positions using the Velocity-Verlet integrator.
Parameters
----------
positions: (2, N) array_like
Expand All @@ -224,6 +231,7 @@ def update_positions(
Length for each Velocity-Verlet integration step, in seconds.
box_length: float
Length of a single dimension of the simulation square, in Angstrom.
Returns
-------
(2, N) array_like:
Expand All @@ -246,6 +254,7 @@ def update_velocities(
velocities, accelerations_old, accelerations_new, timestep_length
):
"""Update the particle velocities using the Velocity-Verlet algoritm.
Parameters
----------
velocities: (2, N) array_like
Expand All @@ -257,6 +266,7 @@ def update_velocities(
accelerations.
timestep_length: float
Length for each Velocity-Verlet integration step, in seconds.
Returns
-------
(2, N) array_like:
Expand All @@ -273,10 +283,12 @@ def update_velocities(

def calculate_temperature(particles, mass):
"""Determine the instantaneous temperature of the system.
Parameters
----------
particles: util.particle_dt, array_like
Information about the particles.
Returns
-------
float:
Expand All @@ -297,6 +309,7 @@ def calculate_temperature(particles, mass):
def compute_force(particles, box_length, cut_off, constants, forcefield, mass):
r"""Calculates the forces and therefore the accelerations on each of the
particles in the simulation.
Parameters
----------
particles: util.particle_dt, array_like
Expand All @@ -313,6 +326,7 @@ def compute_force(particles, box_length, cut_off, constants, forcefield, mass):
The particular forcefield to be used to find the energy and forces.
mass: float (optional)
The mass of the particle being simulated (units of atomic mass units).
Returns
-------
util.particle_dt, array_like
Expand All @@ -337,6 +351,7 @@ def heat_bath(particles, temperature_sample, bath_temperature):
.. math::
v_{\text{new}} = v_{\text{old}} \times
\sqrt{\frac{T_{\text{desired}}}{\bar{T}}}
Parameters
----------
particles: util.particle_dt, array_like
Expand All @@ -345,6 +360,7 @@ def heat_bath(particles, temperature_sample, bath_temperature):
The temperature at each timestep in the simulation.
bath_temp: float
The desired temperature of the simulation.
Returns
-------
util.particle_dt, array_like
Expand Down
17 changes: 16 additions & 1 deletion pylj/pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
def compute_force(particles, box_length, cut_off, constants, forcefield, mass):
r"""Calculates the forces and therefore the accelerations on each of the
particles in the simulation.
Parameters
----------
particles: util.particle_dt, array_like
Expand All @@ -22,6 +23,7 @@ def compute_force(particles, box_length, cut_off, constants, forcefield, mass):
The particular forcefield to be used to find the energy and forces.
mass: float (optional)
The mass of the particle being simulated (units of atomic mass units).
Returns
-------
util.particle_dt, array_like
Expand Down Expand Up @@ -73,6 +75,7 @@ def compute_force(particles, box_length, cut_off, constants, forcefield, mass):
#Jit tag here had to be removed
def separation(dx, dy):
"""Calculate the distance in 2D space.
Parameters
----------
dx: float
Expand All @@ -88,6 +91,7 @@ def separation(dx, dy):

def update_accelerations(particles, f, m, dx, dy, dr):
"""Update the acceleration arrays of particles.
Parameters
----------
particles: util.particle_dt, array_like
Expand Down Expand Up @@ -124,6 +128,7 @@ def update_accelerations(particles, f, m, dx, dy, dr):
def second_law(f, m, d1, d2):
"""Newton's second law of motion to get the acceleration of the particle
in a given dimension.
Parameters
----------
f: float
Expand Down Expand Up @@ -204,6 +209,7 @@ def calculate_pressure(
.. math::
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
Expand All @@ -222,6 +228,7 @@ def calculate_pressure(
The particular forcefield to be used to find the energy and forces.
mass: float (optional)
The mass of the particle being simulated (units of atomic mass units).
Returns
-------
float:
Expand All @@ -248,6 +255,7 @@ def heat_bath(particles, temperature_sample, bath_temp):
.. math::
v_{\text{new}} = v_{\text{old}} \times
\sqrt{\frac{T_{\text{desired}}}{\bar{T}}}
Parameters
----------
particles: util.particle_dt, array_like
Expand All @@ -256,6 +264,7 @@ def heat_bath(particles, temperature_sample, bath_temp):
The temperature at each timestep in the simulation.
bath_temp: float
The desired temperature of the simulation.
Returns
-------
util.particle_dt, array_like
Expand All @@ -270,6 +279,7 @@ def heat_bath(particles, temperature_sample, bath_temp):
#Jit tag here had to be removed
def dist(xposition, yposition, box_length, types):
"""Returns the distance array for the set of particles.
Parameters
----------
xpos: float, array_like (N)
Expand All @@ -283,6 +293,7 @@ def dist(xposition, yposition, box_length, types):
types: str, array_like (N)
Array of length N, where N is the number of particles, providing the
type of each particle.
Returns
-------
drr: float, array_like ((N - 1) * N / 2))
Expand Down Expand Up @@ -318,12 +329,14 @@ def dist(xposition, yposition, box_length, types):
#Jit tag here had to be removed
def pbc_correction(position, cell):
"""Correct for the periodic boundary condition.
Parameters
----------
position: float
Particle position.
cell: float
Cell vector.
Returns
-------
float:
Expand All @@ -336,11 +349,13 @@ def create_dist_identifiers(type_identifier):
'''
Creates correct distance identifier matrix for particular type
of particle
Parameters
-------
----------
type identifiers:
the identifier array listing 1 for particles of that type
or 0 for particles of a different type
Returns
-------
distances: float, array_like
Expand Down
2 changes: 2 additions & 0 deletions pylj/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class System:
is being run. This includes the particles
object, as will as sampling objects such as the temperature, pressure, etc.
arrays.
Parameters
----------
number_of_particles: int
Expand Down Expand Up @@ -310,6 +311,7 @@ def __version__(): # pragma: no cover

def particle_dt():
"""Builds the data type for the particles, this consists of:
- xposition and yposition
- xvelocity and yvelocity
- xacceleration and yacceleration
Expand Down

0 comments on commit 12ff450

Please sign in to comment.