particles package¶
Particles routines
Submodules¶
particles.particles module¶
Stores and manages particles and updates their positions based on the velocity on the grid.
-
class
particles.particles.
Particle
(x, y, u=0, v=0)[source]¶ Bases:
object
Class to hold properties of a single (massless) particle.
This class could be extended (i.e. inherited from) to model e.g. massive/charged particles.
-
class
particles.particles.
Particles
(sim_data, bc, n_particles, particle_generator='grid', pos_array=None, init_array=None)[source]¶ Bases:
object
Class to hold multiple particles.
-
array_generate_particles
(pos_array, init_array=None)[source]¶ Generate particles based on array of their positions. This is used when reading particle data from file.
Parameters: - pos_array : float array
Array of particle positions.
- init_array : float array
Array of initial particle positions.
-
enforce_particle_boundaries
()[source]¶ Enforce the particle boundaries
TODO: copying the dict and adding everything back again is messy - think of a better way to do this? Did it this way so don’t have to remove items from a dictionary while iterating it for outflow boundaries.
-
get_init_positions
()[source]¶ Return initial positions of the particles as an array.
We defined the particles as a dictionary with their initial positions as the keys, so this just becomes a restructuring operation.
-
grid_generate_particles
(n_particles)[source]¶ Generate particles equally spaced across the grid. Currently has the same number of particles in the x and y directions (so dx != dy unless the domain is square) - may be better to scale this.
If necessary, shall increase/decrease n_particles in order to fill grid.
-
update_particles
(dt, u=None, v=None)[source]¶ Update the particles on the grid. This is based off the
AdvectWithUcc
function in AMReX, which used the midpoint method to advance particles using the cell-centered velocity.We will explicitly pass in u and v if they cannot be accessed from the
sim_data
usingget_var("velocity")
.Parameters: - dt : float
timestep
- u : ArrayIndexer object
x-velocity
- v : ArrayIndexer object
y-velocity
-