Skip to content

Commit

Permalink
Merge pull request #2350 from RudolfWeeber/vsr_test_guard
Browse files Browse the repository at this point in the history
Testsuite: VS relative without EXTERNAL_FORCES
  • Loading branch information
fweik authored Oct 29, 2018
2 parents a0fdfc6 + ce9afd0 commit b4e2b9a
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions testsuite/python/virtual_sites_relative.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,29 +176,30 @@ def test_pos_vel_forces(self):
for i in 2, 3, 4:
self.verify_vs(system.part[i])

# Test transfer of forces accumulating on virtual sites
# to central particle
f2 = np.array((3, 4, 5))
f3 = np.array((-4, 5, 6))
# Add forces to vs
system.part[2].ext_force = f2
system.part[3].ext_force = f3
system.integrator.run(0)
# get force/torques on non-vs
f = system.part[1].f
t = system.part[1].torque_lab

# Expected force = sum of the forces on the vs
self.assertLess(np.linalg.norm(f - f2 - f3), 1E-6)

# Expected torque
# Radial components of forces on a rigid body add to the torque
t_exp = np.cross(system.distance_vec(
system.part[1], system.part[2]), f2)
t_exp += np.cross(system.distance_vec(
system.part[1], system.part[3]), f3)
# Check
self.assertLessEqual(np.linalg.norm(t_exp - t), 1E-6)
if espressomd.has_features("EXTERNAL_FORCES"):
# Test transfer of forces accumulating on virtual sites
# to central particle
f2 = np.array((3, 4, 5))
f3 = np.array((-4, 5, 6))
# Add forces to vs
system.part[2].ext_force = f2
system.part[3].ext_force = f3
system.integrator.run(0)
# get force/torques on non-vs
f = system.part[1].f
t = system.part[1].torque_lab

# Expected force = sum of the forces on the vs
self.assertLess(np.linalg.norm(f - f2 - f3), 1E-6)

# Expected torque
# Radial components of forces on a rigid body add to the torque
t_exp = np.cross(system.distance_vec(
system.part[1], system.part[2]), f2)
t_exp += np.cross(system.distance_vec(
system.part[1], system.part[3]), f3)
# Check
self.assertLessEqual(np.linalg.norm(t_exp - t), 1E-6)

# Check virtual sites without velocity
system.virtual_sites.have_velocity = False
Expand Down Expand Up @@ -241,7 +242,7 @@ def run_test_lj(self):
# Type=1, i.e., no lj ia for the center of mass particles
system.part.add(
rotation=(1, 1, 1), id=3 * i, pos=random.random(3) * l, type=1,
omega_lab=0.3 * random.random(3), v=random.random(3))
omega_lab=0.3 * random.random(3), v=random.random(3))
# lj spheres
system.part.add(rotation=(1, 1, 1), id=3 * i + 1,
pos=system.part[3 * i].pos +
Expand Down Expand Up @@ -304,6 +305,7 @@ def test_lj(self):
system.cell_system.set_domain_decomposition(use_verlet_lists=False)
self.run_test_lj()

@ut.skipIf(not espressomd.has_features("EXTERNAL_FORCES"), "skipped due to missing external forces.")
def test_zz_stress_tensor(self):
system = self.system
system.time_step = 0.01
Expand Down

0 comments on commit b4e2b9a

Please sign in to comment.