Skip to content

Commit

Permalink
getting the examples running and ensuring backwords compatibiilty
Browse files Browse the repository at this point in the history
  • Loading branch information
arm61 committed Aug 26, 2018
1 parent 936f2ce commit 78234a7
Show file tree
Hide file tree
Showing 5 changed files with 694 additions and 660 deletions.
Binary file modified pylj/comp.cpython-36m-x86_64-linux-gnu.so
Binary file not shown.
21 changes: 13 additions & 8 deletions pylj/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def sample(particles, box_length, initial_particles, system):
temperature_new)
pressure_new = heavy.calculate_pressure(particles, box_length,
temperature_new, system.cut_off,
system.a, system.b)
system.constants)
msd_new = calculate_msd(particles, initial_particles, box_length)
system.pressure_sample = np.append(system.pressure_sample, pressure_new)
system.force_sample = np.append(system.force_sample,
Expand Down Expand Up @@ -272,18 +272,23 @@ def calculate_temperature(particles):
return k


def compute_force(particles, box_length, cut_off, a=1.363e-134, b=9.273e-78,
mass=39.948, forcefield=ff.lennard_jones):
def compute_force(particles, box_length, cut_off,
constants=[1.363e-134, 9.273e-78], mass=39.948,
forcefield=ff.lennard_jones):
part, dist, forces, energies = heavy.compute_force(particles, box_length,
cut_off, a=a, b=b,
mass=mass)
cut_off,
constants=constants,
mass=mass,
forcefield=forcefield)
return part, dist, forces, energies


def compute_energy(particles, box_length, cut_off, a=1.363e-134, b=9.273e-78,
def compute_energy(particles, box_length, cut_off,
constants=[1.363e-134, 9.273e-78],
forcefield=ff.lennard_jones):
dist, energies = heavy.compute_energy(particles, box_length, cut_off, a=a,
b=b)
dist, energies = heavy.compute_energy(particles, box_length, cut_off,
constants=constants,
forcefield=forcefield)
return dist, energies


Expand Down
18 changes: 8 additions & 10 deletions pylj/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ class System:
"""
def __init__(self, number_of_particles, temperature, box_length,
init_conf='square', timestep_length=1e-14,
cut_off=15, a=1.363e-134, b=9.273e-78, mass=39.948):
cut_off=15, constants=[1.363e-134, 9.273e-78], mass=39.948):
self.number_of_particles = number_of_particles
self.init_temp = temperature
self.a = a
self.b = b
self.constants = constants
self.mass = mass
if box_length <= 600:
self.box_length = box_length * 1e-10
Expand Down Expand Up @@ -119,12 +118,12 @@ def compute_force(self):
"""Maps to the compute_force function in either the comp (if Cython is
installed) or the pairwise module and allows for a cleaner interface.
"""
a = self.a
b = self.b
constants = self.constants
mass = self.mass
part, dist, forces, energies = md.compute_force(self.particles,
self.box_length,
self.cut_off, a=a, b=b,
self.cut_off,
constants = constants,
mass=mass)
self.particles = part
self.distances = dist
Expand All @@ -136,12 +135,11 @@ def compute_energy(self):
is installed) or the pairwise module and allows for a cleaner
interface.
"""
a = self.a
b = self.b
constants = self.constants
self.distances, self.energies = md.compute_energy(self.particles,
self.box_length,
self.cut_off, a=a,
b=b)
self.cut_off,
constants=constants)

def integrate(self, method):
"""Maps the chosen integration method.
Expand Down
Loading

0 comments on commit 78234a7

Please sign in to comment.