Skip to content

Commit 96473a6

Browse files
committed
Cleaned up the docs a bit
1 parent 92d6beb commit 96473a6

4 files changed

Lines changed: 61 additions & 45 deletions

File tree

compressible/problems/kh.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
def init_data(my_data, rp):
1010
""" initialize the Kelvin-Helmholtz problem """
1111

12-
msg.bold("initializing the sedov problem...")
12+
msg.bold("initializing the Kelvin-Helmholtz problem...")
1313

1414
# make sure that we are passed a valid patch object
1515
if not isinstance(my_data, patch.CellCenterData2d):
1616
print(my_data.__class__)
17-
msg.fail("ERROR: patch invalid in sedov.py")
17+
msg.fail("ERROR: patch invalid in kh.py")
1818

1919
# get the density, momenta, and energy as separate variables
2020
dens = my_data.get_var("density")

compressible/problems/logo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99

1010
def init_data(my_data, rp):
11-
""" initialize the sedov problem """
11+
""" initialize the logo problem """
1212

1313
msg.bold("initializing the logo problem...")
1414

1515
# make sure that we are passed a valid patch object
1616
if not isinstance(my_data, patch.CellCenterData2d):
17-
print("ERROR: patch invalid in sedov.py")
17+
print("ERROR: patch invalid in logo.py")
1818
print(my_data.__class__)
1919
sys.exit()
2020

docs/source/particles_basics.rst

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
Particles overview
2-
==================
1+
Particles
2+
=========
33

44
A solver for modelling particles.
55

66
``particles.particles`` implementation and use
77
----------------------------------------------
88

9-
We import the basic particles functionality as:
9+
We import the basic particles module functionality as:
1010

1111
.. code-block:: python
1212
@@ -20,28 +20,48 @@ The particles solver is made up of two classes:
2020
about a collection of particles.
2121

2222
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).
23+
based on the velocity on the grid. The keys are tuples of the particles'
24+
initial positions (however the values of the keys themselves are never used
25+
in the module, so this could be altered using e.g. a custom ``particle_generator``
26+
function without otherwise affecting the behaviour of the module).
2627

27-
The particles can be initialised in a number of ways:
28+
The particles can be initialized in a number of ways:
2829

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>`,
30+
* :func:`randomly_generate_particles <particles.particles.Particles.randomly_generate_particles>`,
31+
which randomly generates ``n_particles`` within the domain.
32+
* :func:`grid_generate_particles <particles.particles.Particles.grid_generate_particles>`,
3233
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+
x-direction and y-direction (note that it uses the same number of particles in
3435
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-
* :func:`array_generate_particles <particles.particles.Particle.array_generate_particles>`,
38-
generates particles based on array of particle positions passed to the constructor;
39-
* the user can define their own ``particle_generator`` and pass this into the
40-
Particles constructor. This function takes the number of particles to be
36+
domain is not square). The number of particles will be increased/decreased
37+
in order to fill the whole domain.
38+
* :func:`array_generate_particles <particles.particles.Particles.array_generate_particles>`,
39+
which generates particles based on array of particle positions passed to the
40+
constructor.
41+
* The user can define their own ``particle_generator`` function and pass this into the
42+
``Particles`` constructor. This function takes the number of particles to be
4143
generated and returns a dictionary of ``Particle`` objects.
4244

43-
We can initialize particles in a problem using the following code in the
44-
solver's ``Simulation.initialize`` function:
45+
We can turn on/off the particles solver using the following runtime paramters:
46+
47+
+--------------------------------------------------------------------------------+
48+
|``[particles]`` |
49+
+=======================+========================================================+
50+
|``do_particles`` | do we want to model particles? (0=no, 1=yes) |
51+
+-----------------------+--------------------------------------------------------+
52+
|``n_particles`` | number of particles to be modelled |
53+
+-----------------------+--------------------------------------------------------+
54+
|``particle_generator`` | how do we initialize the particles? "random" |
55+
| | randomly generates particles throughout the domain, |
56+
| | "grid" generates equally spaced particles, "array" |
57+
| | generates particles at positions given in an array |
58+
| | passed to the constructor. This option can be |
59+
| | overridden by passing a custom generator function to |
60+
| | the ``Particles`` constructor. |
61+
+-----------------------+--------------------------------------------------------+
62+
63+
Using these runtime parameters, we can initialize particles in a problem using
64+
the following code in the solver's ``Simulation.initialize`` function:
4565

4666
.. code-block:: python
4767
@@ -58,38 +78,34 @@ update of the other variables in the solver's ``Simulation.evolve`` function:
5878
if self.particles is not None:
5979
self.particles.update_particles(self.dt)
6080
81+
This will both update the positions of the particles and enforce the boundary
82+
conditions.
83+
6184
For some problems (e.g. advection), the x- and y- velocities must also be passed
6285
in as arguments to this function as they cannot be accessed using the standard
63-
``get_var("velocity")`` command.
86+
``get_var("velocity")`` command. In this case, we would instead use
87+
88+
.. code-block:: python
89+
90+
if self.particles is not None:
91+
self.particles.update_particles(self.dt, u, v)
6492
65-
We can turn on/off the particles solver using the following runtime paramters:
6693
67-
+--------------------------------------------------------------------------------+
68-
|``[particles]`` |
69-
+=======================+========================================================+
70-
|``do_particles`` | do we want to model particles? (0=no, 1=yes) |
71-
+-----------------------+--------------------------------------------------------+
72-
|``n_particles`` | number of particles to be modelled |
73-
+-----------------------+--------------------------------------------------------+
74-
|``particle_generator`` | how do we initialize the particles? "random" |
75-
| | randomly generates particles throughout the domain, |
76-
| | "grid" generates equally spaced particles. This |
77-
| | option can be overridden by passing a custom generator |
78-
| | function to the ``Particles`` constructor. |
79-
+-----------------------+--------------------------------------------------------+
8094
8195
Plotting particles
8296
------------------
8397

84-
Particles can be plotted by getting their positions using
98+
Given the ``Particles`` object ``particles``, we can plot the particles by getting
99+
their positions using
85100

86101
.. code-block:: python
87102
88103
particle_positions = particles.get_positions()
89104
90105
In order to track the movement of particles over time, it's useful
91-
to 'dye' the particles based on their initial positions. This can
92-
be done by calling
106+
to 'dye' the particles based on their initial positions. Assuming that the
107+
keys of the particles dictionary were set as the particles' initial positions,
108+
this can be done by calling
93109

94110
.. code-block:: python
95111

particles/particles.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def enforce_particle_boundaries(self):
248248
# -x boundary
249249
if p.x < myg.xmin:
250250
if xlb in ["outflow", "neumann"]:
251-
del self.particles[k]
251+
del(self.particles[k])
252252
continue
253253
elif xlb == "periodic":
254254
p.x = myg.xmax + p.x - myg.xmin
@@ -260,7 +260,7 @@ def enforce_particle_boundaries(self):
260260
# +x boundary
261261
if p.x > myg.xmax:
262262
if xrb in ["outflow", "neumann"]:
263-
del self.particles[k]
263+
del(self.particles[k])
264264
continue
265265
elif xrb == "periodic":
266266
p.x = myg.xmin + p.x - myg.xmax
@@ -272,7 +272,7 @@ def enforce_particle_boundaries(self):
272272
# -y boundary
273273
if p.y < myg.ymin:
274274
if ylb in ["outflow", "neumann"]:
275-
del self.particles[k]
275+
del(self.particles[k])
276276
continue
277277
elif ylb == "periodic":
278278
p.y = myg.ymax + p.y - myg.ymin
@@ -284,7 +284,7 @@ def enforce_particle_boundaries(self):
284284
# +y boundary
285285
if p.y > myg.ymax:
286286
if yrb in ["outflow", "neumann"]:
287-
del self.particles[k]
287+
del(self.particles[k])
288288
continue
289289
elif yrb == "periodic":
290290
p.y = myg.ymin + p.y - myg.ymax

0 commit comments

Comments
 (0)