Skip to content

Commit 92912c5

Browse files
committed
Particle speeds now calculated based off interpolated grid speeds (as in AMReX). Added documentation for particle classes
1 parent da04206 commit 92912c5

9 files changed

Lines changed: 176 additions & 86 deletions

File tree

advection/simulation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ def evolve(self):
8686
u2d = myg.scratch_array() + u
8787
v2d = myg.scratch_array() + v
8888

89-
self.particles.update_particles(u2d, v2d, self.dt,
90-
self.rp.get_param("advection.limiter"))
89+
self.particles.update_particles(u2d, v2d, self.dt)
9190

9291
self.particles.enforce_particle_boundaries()
9392

compressible/simulation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,9 @@ def evolve(self):
226226
ener[:, :] += 0.5*self.dt*(ymom[:, :] + old_ymom[:, :])*grav
227227

228228
if self.particles is not None:
229-
limiter = self.rp.get_param("compressible.limiter")
230229
u, v = self.cc_data.get_var("velocity")
231230

232-
self.particles.update_particles(u, v, self.dt, limiter)
231+
self.particles.update_particles(u, v, self.dt)
233232
self.particles.enforce_particle_boundaries()
234233

235234
# increment the time

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pyro: a python hydro code
3737
diffusion_basics
3838
incompressible_basics
3939
lowmach_basics
40+
particles_basics
4041
swe_basics
4142

4243
.. toctree::

docs/source/modules.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pyro2
2020
lm_atm
2121
mesh
2222
multigrid
23+
particles
2324
plot
2425
pyro
2526
simulation_null

docs/source/particles.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
particles package
2+
=================
3+
4+
.. automodule:: particles
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
9+
Submodules
10+
----------
11+
12+
particles\.particles module
13+
--------------------
14+
15+
.. automodule:: particles.particles
16+
:members:
17+
:undoc-members:
18+
:show-inheritance:

docs/source/particles_basics.rst

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
Particles overview
2+
==================
3+
4+
A solver for modelling particles.
5+
6+
``particles.particles`` implementation and use
7+
----------------------------------------------
8+
9+
We import the basic particles functionality as:
10+
11+
.. code-block:: python
12+
13+
import particles.particles as particles
14+
15+
The particles solver is made up of two classes:
16+
17+
* :func:`Particle <particles.particles.Particle>`, which holds
18+
the data about a single particle (its position and velocity);
19+
* :func:`Particles <particles.particles.Particles>`, which holds the data
20+
about a collection of particles.
21+
22+
The particles are stored as a dictionary, and their positions are updated
23+
based on the velocity on the grid. The keys are assumed to be the initial
24+
positions of the particles (however this is only used for plotting purposes
25+
so any tuple would be fine).
26+
27+
The particles can be initialised in a number of ways:
28+
29+
* :func:`randomly_generate_particles <particles.particles.Particle.randomly_generate_particles>`,
30+
which randomly generates ``n_particles`` within the domain;
31+
* :func:`grid_generate_particles <particles.particles.Particle.grid_generate_particles>`,
32+
which will generate approximately ``n_particles`` equally spaced in the
33+
x-direction and y-direction (though the uses the same number of particles in
34+
each direction, so the spacing will be different in each direction if the
35+
domain is not square.) The number of particles will be increased/decreased
36+
in order to fill the whole domain;
37+
* the user can define their own ``particle_generator_func`` and pass this into the
38+
Particles constructor. This function takes the number of particles to be
39+
generated and returns a dictionary of ``Particle`` objects.
40+
41+
We can initialize particles in a problem using the following code in the
42+
solver's ``Simulation.initialize`` function:
43+
44+
.. code-block:: python
45+
46+
if self.rp.get_param("particles.do_particles") == 1:
47+
self.particles = particles.Particles(self.cc_data, bc, self.rp)
48+
49+
The particles can then be advanced by inserting the following code after the
50+
update of the other variables in the solver's ``Simulation.evolve`` function:
51+
52+
.. code-block:: python
53+
54+
if self.particles is not None:
55+
self.particles.update_particles(u, v, self.dt)
56+
self.particles.enforce_particle_boundaries()
57+
58+
where ``u`` and ``v`` are the ``ArrayIndexer`` objects holding the x-velocity and
59+
y-velocity on the grid.
60+
61+
We can turn on/off the particles solver using the following runtime paramters:
62+
63+
+--------------------------------------------------------------------------------+
64+
|``[particles]`` |
65+
+=======================+========================================================+
66+
|``do_particles`` | do we want to model particles? (0=no, 1=yes) |
67+
+-----------------------+--------------------------------------------------------+
68+
|``n_particles`` | number of particles to be modelled |
69+
+-----------------------+--------------------------------------------------------+
70+
|``particle_generator`` | how do we initialize the particles? "random" |
71+
| | randomly generates particles throughout the domain, |
72+
| | "grid" generates equally spaced particles. This |
73+
| | option can be overridden by passing a custom generator |
74+
| | function to the ``Particles`` constructor. |
75+
+-----------------------+--------------------------------------------------------+

incompressible/simulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def evolve(self):
393393
self.cc_data.fill_BC("y-velocity")
394394

395395
if self.particles is not None:
396-
self.particles.update_particles(u, v, self.dt, limiter)
396+
self.particles.update_particles(u, v, self.dt)
397397
self.particles.enforce_particle_boundaries()
398398

399399
# increment the time

0 commit comments

Comments
 (0)