Skip to content

Conversation

@rykerfish
Copy link
Contributor

This PR is to address a comment left by a reviewer about testing the thermal drift. Mainly, it adds:

  • a test that verifies convergence of RFDs to the divergence term computed deterministically.
  • functionality to specify the RFD delta in the interface of NBody and DPStokes, as well as changes to specifying delta in units of hydrodynamicRadius

Here's a plot using DPStokes(single_wall) showing convergence of an RFD for a fixed particle configuration to the deterministic solution. It matches the expected $O(1/\sqrt{N})$ convergence:
rfd_error

I changed it to specify delta in terms of particle radius since it should have units of length and since we found delta needs to be small specifically compared to particle radius. Here's another plot showing an RFD for the same particle configuration using $a=0.1$ with DPStokes. If we just use $\delta=1e^{-3}$, the error plateaus early. Using $\delta=1e^{-3}a$ gives better convergence.
delta_comparison

I also deleted the tests test_divM_is_zero and test_divM_matches_rfd as I think this test should supersede those two tests. It implicitly checks (to numerical error) that periodic/open geometries return 0 for divM since the deterministic divergence in those cases is numerically 0 (very small).

Final notes: NBody single_wall can converge somewhat slowly but runs quickly so I cranked the number of iterations it was allowed to go up to. DPStokes can reach an error plateau sometimes slightly before 1e-3, presumably since DPStokes is only designed for 2-3 digits of accuracy. For this reason, I used a lower tolerance to test convergence for DPStokes.

Let me know what you think!

…. the RFD step size should be small with respect to the particle, so delta=1e-3*a gives better convergence for small particle radii instead of simply using delta=1e-3 always
…y high for NBody since it can sometimes take a long time to converge
@github-actions
Copy link

Linter reported no issues

All Python files are correctly formatted with Black.

@github-actions
Copy link

Linter reported no issues

All C/C++ files are correctly formatted with clang-format.

Copy link
Contributor

@RaulPPelaez RaulPPelaez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks Ryker

@RaulPPelaez RaulPPelaez merged commit 543c924 into main Nov 24, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants