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, shorten text in active matter tutorial #4585

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion doc/tutorials/active_matter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
configure_tutorial_target(
TARGET tutorial_am DEPENDS active_matter.ipynb figures/friction.svg
figures/pusher-puller.svg figures/geometry.svg figures/flow_field.svg)
figures/pusher-puller.svg figures/geometry.svg)

nb_export(TARGET tutorial_am FILE "active_matter.ipynb" HTML_RUN)
197 changes: 77 additions & 120 deletions doc/tutorials/active_matter/active_matter.ipynb

Large diffs are not rendered by default.

Binary file removed doc/tutorials/active_matter/figures/flow_field.pdf
Binary file not shown.
31 changes: 0 additions & 31 deletions doc/tutorials/active_matter/figures/flow_field.svg

This file was deleted.

Binary file removed doc/tutorials/active_matter/figures/rectify.jpg
Binary file not shown.
24 changes: 23 additions & 1 deletion testsuite/scripts/tutorials/test_active_matter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import unittest as ut
import importlib_wrapper

Expand All @@ -23,10 +24,17 @@
gpu=True,
ED_N_SAMPLING_STEPS=100000,
RECT_N_SAMPLES=150,
HYDRO_N_STEPS=100
HYDRO_N_STEPS=150
)


def curl2d(flow, spacing):
# curl_z = d(v_y) / dx - d(v_x) / dy
dvy_dx = np.gradient(flow[:, :, 1], spacing[0], axis=0)
dvx_dy = np.gradient(flow[:, :, 0], spacing[1], axis=1)
return dvy_dx - dvx_dy


@skipIfMissingFeatures
class TestActMat(ut.TestCase):
system = tutorial.system
Expand All @@ -52,6 +60,20 @@ def test_hydrodynamics(self):
tutorial.system.analysis.linear_momentum(
include_particles=False)[2], 0)

def test_flow_profile(self):
"""
Check the flow field curl is symmetric with 4 local extrema
centered around the particle.
"""
flow_field = tutorial.vels[:, :, (0, 2)]
curl = curl2d(flow_field, 2 * [tutorial.lbf.agrid])
curl_percent = curl * 100. / np.max(np.abs(curl))
threshold_percent = 85.
self.assertGreaterEqual(curl_percent[16, 20], threshold_percent)
self.assertGreaterEqual(curl_percent[18, 16], threshold_percent)
self.assertLessEqual(curl_percent[16, 16], -threshold_percent)
self.assertLessEqual(curl_percent[18, 20], -threshold_percent)


if __name__ == "__main__":
ut.main()