Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testsuite: VS relative without EXTERNAL_FORCES #2350

Merged
merged 1 commit into from
Oct 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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