Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdolan authored and maxdolan committed Jul 28, 2024
1 parent 974f23f commit fe87f9f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 8 additions & 4 deletions pylj/forcefields.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ def energy(self, dr):
"""
energy = self.a * np.exp(- np.multiply(self.b, dr)) - self.c / np.power(dr, 6)
# Cut out infinite values where r = 0
energy[energy > 10e300] = 0
energy[energy < -10e300] = 0
if type(dr) != float:
energy = np.array(energy)
energy[np.where(energy > 10e300)] = 0
energy[np.where(energy < -10e300)] = 0
self.energy = energy
return self.energy

Expand All @@ -177,8 +179,10 @@ def force(self, dr):
"""
force = self.a * self.b * np.exp(- np.multiply(self.b, dr)) - 6 * self.c / np.power(dr, 7)
# Cut out infinite values where r = 0
force[force > 10e300] = 0
force[force < -10e300] = 0
if type(dr) != float:
force = np.array(force)
force[np.where(force > 10e300)] = 0
force[np.where(force < -10e300)] = 0
self.force = force
return self.force

Expand Down
10 changes: 5 additions & 5 deletions pylj/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_system_square(self):
300,
8,
mass=39.948,
constants=[1.363e-134, 9.273e-78],
constants=[[1.363e-134, 9.273e-78]],
forcefield=ff.lennard_jones,
)
assert_equal(a.number_of_particles, 2)
Expand All @@ -34,7 +34,7 @@ def test_system_random(self):
8,
init_conf="random",
mass=39.948,
constants=[1.363e-134, 9.273e-78],
constants=[[1.363e-134, 9.273e-78]],
forcefield=ff.lennard_jones,
)
assert_equal(a.number_of_particles, 2)
Expand All @@ -57,7 +57,7 @@ def test_system_too_big(self):
300,
1000,
mass=39.948,
constants=[1.363e-134, 9.273e-78],
constants=[[1.363e-134, 9.273e-78]],
forcefield=ff.lennard_jones,
)
self.assertTrue(
Expand All @@ -73,7 +73,7 @@ def test_system_too_small(self):
300,
2,
mass=39.948,
constants=[1.363e-134, 9.273e-78],
constants=[[1.363e-134, 9.273e-78]],
forcefield=ff.lennard_jones,
)
self.assertTrue(
Expand All @@ -89,7 +89,7 @@ def test_system_init_conf(self):
100,
init_conf="horseradish",
mass=39.948,
constants=[1.363e-134, 9.273e-78],
constants=[[1.363e-134, 9.273e-78]],
forcefield=ff.lennard_jones,
)
self.assertTrue(
Expand Down

0 comments on commit fe87f9f

Please sign in to comment.