Skip to content

Particle Documentation

Dane Cross edited this page Feb 20, 2022 · 6 revisions

This is a class that keeps track of a particle's position and velocity along timesteps.

  • Source Code: /lib/Particle.py
  • Examples: /lib/tests/

Instance variables

(aka variables that each object has stored in it)

  • id (int): the particle ID from the rockstar output
  • mass (float): the mass of the particle in Solar Masses
  • x, y, z (list of float): particle positions at each timestep in Mpc/h
  • vx, vy, vz (list of float): particle velocities at each timestep in kpc/s
  • energy (list of float): the energy of the particle at each timestep in units of Msun * (kpc)^2/s^2. *
  • bound_rank (list of int): ranking of the boundedness of the particle wrt the other particles in the halo. *
  • parent_ids (list of int): list of the halo id of the parent halo

* neither the energy nor the ranking is immediately calculated. Energy defaults to -np.inf and boundedness defaults to -1. To calculate the energy and boundedness of the particle run get_energy (documentation below) and rank_particle_boundedness (documentation in the Halo class).

Constructors

Particle()

Default constructor.

arguments:

None

output:

a new, empty particle object

Particle(xi, yi, zi, vxi, vyi, vzi, this_index = i, num_timesteps = 1, mass = -inf, id=-1)

Full Constructor for a Particle.

arguments

  • xi, yi, zi, vxi, vyi, vzi (float): positions and velocities of the particle at time this_index
  • this_index (int, optional): time index for which the position and velocities occur
  • num_timesteps (int, optional): number of timesteps available for the particle
  • mass (float,optional): mass of the particle. If you want to calculate the energy of the particle, this must be set
  • id ( int, optional): id of the particle, defaults to -1

outputs

Fully initialized particle object.

Public Functions

get_energy(timestep, particle_field, halo_v=(0,0,0))

gets the energy of a particle at a certain timestep

arguments

  • timestep (int): the timestep at which to calculate the energy of the particle
  • particle_field (list of Particle): list of particles which are contained in the halo
  • halo_v (tuple): 3-velocity of the halo

insert_at_timestep(x, y, z, vx, vy, vz, timestep, parent_halo=-1)

inserts position and velocity information at a certain timestep

arguments

  • x, y, z (float): particle positions at timestep in Mpc/h
  • vx, vy, vz (float): particle velocities at timestep in kpc/s
  • timestep (int): timestep at which to input these positions and velocities
  • parent_halo (int, optional): the parent halo that the particle belongs to at this timestep (updates the member_of instance variable)

outputs

No return value, will update the x, y, z, vx, vy, vz instance variables appropriately

save(pdir="./")

saves the particle to a file which can be later opened

arguments

  • pdir (str, optional): desired output particle directory

outputs

saves a file of the name "p_{p.id}.npy" to the input directory

load_particle(name)

loads a saved particle

arguments

  • name (str): the path+name of the file you wish to load

outputs

Particle object with the same instance variables as the loaded object