Getting general information on an N-body system¶
In this section, we describe several techniques to retrieve a variety of general information from an N-body model.
To run the examples proposed hereafter, you need first to follow the instructions given in the section Generate examples .
We also suppose that the following model has been loaded, i.e, in your python interpreter you typed:
>>> from pNbody import Nbody
>>> nb = Nbody("MW_galaxy.hdf5")
General info¶
General info on the model can always be obtained with the info()
method
>>> nb.info()
-----------------------------------
particle file : ['MW_galaxy.hdf5']
ftype : 'swift'
mxntpe : 6
nbody : 20235
nbody_tot : 20235
npart : [391, 17969, 0, 0, 1875, 0]
npart_tot : [391, 17969, 0, 0, 1875, 0]
mass_tot : 1.8421547
byteorder : 'little'
pio : 'no'
len pos : 20235
pos[0] : array([ 0.59459096, -6.849886 , 0.83441144], dtype=float32)
pos[-1] : array([-3.0051165, -5.1332235, 0.5773136], dtype=float32)
len vel : 20235
vel[0] : array([219.8732 , 9.581228, 11.225813], dtype=float32)
vel[-1] : array([ 187.3271 , -109.07539 , -16.536251], dtype=float32)
len mass : 20235
mass[0] : 1.9999294e-05
mass[-1] : 1.9999294e-05
len num : 20235
num[0] : 0
num[-1] : 1294976
len tpe : 20235
tpe[0] : 0
tpe[-1] : 4
atime : 0.0
redshift : 0.0
flag_sfr : 0
flag_feedback : 0
flag_cooling : 0
num_files : [1]
boxsize : [1500.32945615]
omega0 : 0.0
omegalambda : 0.0
hubbleparam : 0.0
flag_age : 0.0
flag_metals : 0.0
nallhw : [0 0 0 0 0 0]
critical_energy_spec: 0.0
Variables¶
The first part of the output illustrate the different variables attached to an Nbody
object:
variable name |
meaning |
---|---|
nb.p_name |
filename containing particles data |
nb.ftype |
file format |
nb.mxntpe |
max number of particle type |
nb.nbody |
number of particles in the file |
nb.nbody_tot |
total number of particles (if stored in multiple files) |
nb.npart |
the number of particles of each type |
nb.npart_tot |
total number of particles of each type (if stored in multiple files) |
nb.mass_tot |
total mass |
nb.byteorder |
byte order (“big” or “little”) |
nb.pio |
parallel io |
To get the full list of variables attached to an Nbody
object, type:
>>> nb.get_list_of_vars()
['ChimieNelements', 'Density', 'DesNumNgb', 'Hsml', 'MaxNumNgbDeviation', 'Tree',
'UnitLength_in_cm', 'UnitMass_in_g', 'UnitVelocity_in_cm_per_s', 'Unit_current_in_cgs',
'Unit_temp_in_cgs', 'Unit_time_in_cgs', '_AM', '_header', 'arrays', 'arrays_props',
'atime', 'boxsize', 'byteorder', 'command_line', 'comovingintegration', 'comovingtoproperconversion',
'critical_energy_spec', 'date', 'defaultparameters', 'empty', 'ext_methods',
'flag_age', 'flag_chimie_extraheader', 'flag_cooling', 'flag_entr_ics', 'flag_feedback',
'flag_metals', 'flag_sfr', 'ftype', 'gittag', 'hubblefactorcorrection', 'hubbleparam',
'kws', 'localsystem_of_units', 'mass_tot', 'massarr', 'nallhw', 'nbody', 'nbody_tot',
'npart', 'npart_tot', 'num_files', 'nzero', 'omega0', 'omegalambda', 'p_name',
'p_name_global', 'parameters', 'pio', 'ptypes', 'redshift', 'skipped_io_blocks',
'spec_vars', 'spec_vect', 'status', 'unitsfile', 'unitsparameters', 'username',
'utype', 'verbose']
Specific variables for a given format is obtained by:
>>> nb.get_default_spec_vars()
{'massarr': array([0, 0, 0, 0, 0, 0]), 'atime': 0.0, 'redshift': 0.0, 'flag_sfr': 0,
'flag_feedback': 0, 'npart_tot': array([ 0, 0, 20235, 0, 0, 0]),
'npart': array([ 0, 0, 20235, 0, 0, 0]), 'flag_cooling': 0,
'num_files': 1, 'boxsize': 0.0, 'omega0': 0.0, 'omegalambda': 0.0, 'hubbleparam': 0.0,
'flag_age': 0.0, 'flag_metals': 0.0, 'nallhw': array([0, 0, 0, 0, 0, 0]), 'flag_entr_ics': 0,
'flag_chimie_extraheader': 0, 'critical_energy_spec': 0.0, 'empty': '', 'comovingintegration': True,
'hubblefactorcorrection': False, 'comovingtoproperconversion': True, 'ChimieNelements': 0,
'utype': 'swift', 'command_line': 'none', 'gittag': 'none', 'date': 'none', 'username': 'username'}
Those variable are mandatory for a given format.
Arrays¶
The second part of the output gives a list of arrays, i.e., information attached to each particles.
The table below gives the minimal arrays required for an Nbody
object.
array name |
content |
---|---|
nb.pos |
Coordinates of particles in file unit |
nb.vel |
Velocities of particles in file unit |
nb.mass |
Masses of particles in file unit |
nb.num |
IDs of particles |
nb.tpe |
Types of particles |
Note that those arrays are brute arrays, i.e., with values precisely corresponding to what is stored in the file. They are thus is the units that should be specified in the file or in the format. Note that not all format gives this information.
To get the full list of arrays attached to an Nbody
object, type:
>>> nb.get_list_of_arrays()
['mass', 'num', 'pos', 'rsp_init', 'sp_type', 'tpe', 'tstar_init', 'u_init', 'vel']
They respective memory footprint can be obtained using:
>>> nb.get_arrays_memory_footprint()
Number of particles = 20235
variable name size bytes Gb
-------------------------------------------------------------------
mass 20235 80940 0.000
num 20235 161880 0.000
pos 60705 242820 0.000
rsp_init 20235 80940 0.000
sp_type 20235 80940 0.000
tpe 20235 161880 0.000
tstar_init 20235 80940 0.000
u_init 20235 80940 0.000
vel 60705 242820 0.000
Total 0 1214100 0.001
The list of specific array is obtained by:
>>> nb.get_default_spec_array()
{}
Those arrays are mandatory for a given format.
Methods¶
It may be very useful to get the list of all methods attached to a given Nbody
object.
The list is obtained via:
>>> nb.get_list_of_methods()
['A', 'AbRatio', 'Accel', 'Ba', 'BaFe',
...
'y', 'z', 'zmodes', 'zprof']
Methods obtained from an extention, i.e., defined outside the core of pNbody are obtained using:
>>> nb.get_ext_methods()
get_default_arrays_props : Nbody_gh5 : /local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py
load : Nbody_gh5 : /local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py
dump : Nbody_gh5 : /local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py
_init_spec : Nbody_gh5 : /local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py
get_excluded_extension : Nbody_gh5 : /local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py
getParticleMatchingDict : Nbody_gh5 : /local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py
check_spec_ftype : Nbody_gh5 : /local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py
...
foo : _NbodyMyArepo : /home/revaz/.pNbody/extensions/my_arepo.py
Cm : _NbodyMyGear : /home/revaz/.pNbody/extensions/my_gear.py
ccdalign : _NbodyMyGear : /home/revaz/.pNbody/extensions/my_gear.py
In addition to the name of the method, this method gives the name of the object that define it as well as the file where it is defined.