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

Add a direct n-body solver #1571

Open
namurphy opened this issue May 23, 2022 · 1 comment
Open

Add a direct n-body solver #1571

namurphy opened this issue May 23, 2022 · 1 comment
Labels
Plasma Lv1 | Beginner Issues appropriate for someone who has some knowledge of physics plasmapy.simulation Related to the plasmapy.simulation subpackage Python Lv2 | Intermediate Issues that require a medium amount of knowledge of Python

Comments

@namurphy
Copy link
Member

namurphy commented May 23, 2022

An idea that came up while working on the Coulomb collision notebook in #1569 was that it would be useful to have a direct n-body solver. Having such a solver would let us launch a charged particle towards another at some impact parameter and then calculate and visualize the trajectories, which would be a really helpful thing to do when teaching Coulomb collisions. My guess is that we'd be able to implement a direct n-body solver in $∼100$ lines of code (plus tests & docstrings) so the maintenance burden would probably be low.

The solver would need to be compatible with astropy.units, though it should work with NumPy arrays under the hood for performance reasons, and so that we could make better use of Numba. It'd also need to be compatible with plasmapy.particles. The governing forces could be either the Coulomb force or gravitation.

We should also consider alternatives to writing our own n-body solver, such as using one that already exists elsewhere in the pythoniverse and writing a wrapper to make it compatible with astropy.units and plasmapy.particles if it isn't already. We could use then use that solver in the Coulomb collision notebook.

@namurphy
Copy link
Member Author

There are also more complicated algorithms that would offer better scaling, but with the tradeoff of increased code complexity. The scaling of a direct n-body simulator is $𝒪(n^2)$, which would be enough for educational use cases. One example would be the Barnes-Hut method which is $𝒪(n~\log~n)$. The increased code complexity makes me wonder if that would be more appropriate in its own package, which we could import and then make use of. In any case, that's beyond the scope of this issue.

@namurphy namurphy added simulations Plasma Lv1 | Beginner Issues appropriate for someone who has some knowledge of physics Python Lv2 | Intermediate Issues that require a medium amount of knowledge of Python labels May 24, 2022
@github-actions github-actions bot added the Stale Dormant issues & PRs which will be automatically closed if the label is not removed. label Jul 24, 2022
@namurphy namurphy removed the Stale Dormant issues & PRs which will be automatically closed if the label is not removed. label May 12, 2023
@namurphy namurphy added plasmapy.simulation Related to the plasmapy.simulation subpackage and removed plasmapy.simulations labels May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Plasma Lv1 | Beginner Issues appropriate for someone who has some knowledge of physics plasmapy.simulation Related to the plasmapy.simulation subpackage Python Lv2 | Intermediate Issues that require a medium amount of knowledge of Python
Projects
None yet
Development

No branches or pull requests

1 participant