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 helper method for running a simulation with grids of particles #270

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

asross
Copy link
Contributor

@asross asross commented Oct 15, 2021

While using particle classes to help visualize the results of pyqg simulations, I ended up writing some helper methods for running simulations with particles together, that seemed like they might be a useful feature for the main library. Here's an initial pass at how this might be incorporated, let me know what you think!

@rabernat
Copy link
Member

rabernat commented Nov 1, 2021

@hscannell maybe you could have a look at this since you are doing particles with pyqg?

@asross
Copy link
Contributor Author

asross commented Mar 25, 2022

Let me know if this looks good to merge @hscannell!

I also added a quick animated demo of this feature to docs/examples.

Copy link
Member

@rabernat rabernat left a comment

Choose a reason for hiding this comment

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

This looks awesome. One minor API suggestion which can also be ignored for now.

@@ -233,6 +237,35 @@ def __init__(
self._initialize_inversion_matrix()
self._initialize_diagnostics(diagnostics_list)

def add_particles(self, initial_coords=None, order=1):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def add_particles(self, initial_coords=None, order=1):
def add_particles(self, density=0.125, initial_coords=None, order=1):


Parameters
----------

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
density : float
How many particles to put per grid cell. Mutually exclusive with ``initial_coords``.

"""

if initial_coords is None:
n = self.nx // 8
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
n = self.nx // 8
n = int(self.nx * density)

or maybe something even better (non-discretized, using linspace)

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.

None yet

2 participants