Skip to content

Commit

Permalink
n body tools in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sambit-giri committed Aug 28, 2024
1 parent de7ff27 commit 3cb4964
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions docs/contents.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ Lightcone
.. automodule:: tools21cm.lightcone
:members:

N-Body Tools
------------
.. automodule:: tools21cm.nbody_tools
:members:

.. automodule:: tools21cm.nbody_file
:members:

Point statistics
----------------
.. automodule:: tools21cm.statistics
Expand Down
8 changes: 4 additions & 4 deletions src/tools21cm/nbody_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ def ParticleMass_to_ParticleNumber(Lbox, particle_mass, cosmo='Planck18'):
print('Particles | along each direction = {} | total = {}'.format(particle_number,particle_number**3))
return particle_number.value

def HaloMass_to_ParticleNumber(Lbox, halo_mass, particles_in_halo, cosmo='Planck18'):
def halo_mass_to_particle_number(Lbox, halo_mass, particles_in_halo, cosmo='Planck18'):
particle_mass = halo_mass/particles_in_halo
return ParticleMass_to_ParticleNumber(Lbox, particle_mass, cosmo=cosmo)
return particle_number_to_particle_mass(Lbox, particle_mass, cosmo=cosmo)

def ParticleNumber_to_ParticleMass(Lbox, particle_each_direction=None, particle_total=None, cosmo='Planck18'):
def particle_number_to_particle_mass(Lbox, particle_each_direction=None, particle_total=None, cosmo='Planck18'):
particle_number = particle_each_direction if particle_each_direction is not None else np.cbrt(particle_total)
cosmo = _set_cosmo(cosmo)
if not isinstance(Lbox, units.Quantity):
Lbox *= units.Mpc
print('As the box length provided is not using Astropy units, Mpc is assumed here.')
particle_mass = cosmo.critical_density0*cosmo.Om0*(Lbox/particle_number)**3
return particle_mass.to('Msun')
return particle_mass.to('Msun')

0 comments on commit 3cb4964

Please sign in to comment.