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

Update tutorials and improve tutorial testing framework #3408

Merged
merged 18 commits into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@
"metadata": {},
"outputs": [],
"source": [
"Efield = np.array((0.1, 0, 0)) # an electric field of 0.1 is the upper limit of the linear response regime for this model\n",
"E = 0.1 # an electric field of 0.1 is the upper limit of the linear response regime for this model\n",
"Efield = np.array([E, 0, 0])\n",
"for p in system.part:\n",
" p.ext_force = p.q * Efield"
]
Expand Down
13 changes: 12 additions & 1 deletion testsuite/scripts/tutorials/test_05-raspberry_electrophoresis.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,26 @@

import unittest as ut
import importlib_wrapper
import numpy as np

tutorial, skipIfMissingFeatures = importlib_wrapper.configure_and_import(
"@TUTORIALS_DIR@/05-raspberry_electrophoresis/05-raspberry_electrophoresis.py",
gpu=True, num_iterations=10, num_steps_per_iteration=10)
gpu=True, box_l=20., E=0.2, num_iterations=150, num_steps_per_iteration=400)
KaiSzuttor marked this conversation as resolved.
Show resolved Hide resolved


@skipIfMissingFeatures
class Tutorial(ut.TestCase):
system = tutorial.system
def test_trajectory(self):
trajectory = np.loadtxt('posVsTime.dat')[:,1:4]
# the raspberry should have traveled mostly on the x-axis
dist = np.abs(trajectory[-1, :] - trajectory[0, :])
self.assertGreater(dist[0], 2 * dist[1])
self.assertGreater(dist[0], 2 * dist[2])
# the velocity should be highest on the x-axis
vel = np.abs(np.mean(trajectory[1:, :] - trajectory[:-1, :], axis=0))
self.assertGreater(vel[0], 2 * vel[1])
self.assertGreater(vel[0], 2 * vel[2])


if __name__ == "__main__":
Expand Down