data Module

This module contains high level arrays and matrices.

Scalar Array

The class ScalarArray is a generic one dimensional array that should be used to store data within simulations that is not associated with any particular particles. For example the kinetic energy of the system or the array used to bin values when calculating a radial distribution.

class data.ScalarArray(initial_value=None, name=None, ncomp=1, dtype=<class 'ctypes.c_double'>)

Bases: host.Array

Class to hold an array of scalar values.

Parameters:
  • initial_value – Value to initialise array with, default 0.0.
  • name (str) – Collective name of stored vars eg positions.
  • ncomp (int) – Number of components.
  • dtype – Data type. Should be a ctypes C data type.
ctypes_value
Returns:first value in correct type.
max
Returns:The maximum value in the array.
mean
Returns:The mean value in the array.
min
Returns:The minimum in the array.
name = None

Name of ScalarArray instance.

resize(new_length)

Increase the size of the array. :param int new_length: New array length.

scale(val)

Scale data array by given value.

Parameters:val – Coefficient to scale all elements by.
sum
Returns:The array sum.

Particle Dat

This classes should be considered as a two dimensional matrix with each row storing the properties of a particle. The order of rows in relation to which particle they correspond to should always be conserved. This is the default behaviour of any sorting methods implemented in this framework.

class data.ParticleDat(npart=0, ncomp=1, initial_value=None, name=None, dtype=<class 'ctypes.c_double'>)

Bases: host.Matrix

Base class to hold properties of particles. This could be considered as a two dimensional matrix with each row representing the stored properties of a particle.

Parameters:
  • npart (int) – Number of particles (Number of row in matrix).
  • ncol (int) – Dimension of property to store per particle (Number of columns in matrix).
  • initial_value – Value to initialise array with, default zeros.
  • name (str) – Collective name of stored vars eg positions.
broadcast_data_from(rank=0, _resize_callback=True)
copy()
ctypes_data_access(mode=Read and write., pair=True)
Parameters:mode (access) – Access type required by the calling method.
Returns:The pointer to the data.
ctypes_data_post(mode=Read and write.)

Call after excuting a method on the data. :arg access mode: Access type required by the calling method.

data
gather_data_on(rank=0, _resize_callback=False)
halo_exchange()

Perform a halo exchange for the particle dat. WIP currently only functional for positions.

halo_start = None
Returns:The starting index of the halo region of the particle dat.
halo_start_reset()
Reset the starting postion of the halo region in the particle dat to
the end of the local particles.
halo_start_set(index)
Set the start of the halo region in the particle dat to the specified
index.
halo_start_shift(shift)

Shift the starting point of the halo in the particle dat by the specified shift. :param int shift: Offset to shift by.

max()
Returns:Maximum of local particles
max_npart = None
Returns:The maximum number of particles which can be stored within

this particle dat.

name = None
Returns:The name of the ParticleDat instance.
ncomp = None
Returns:The number of components stored for each particle.
norm_linf()

return the L1 norm of the array

npart_local = None
Returns:The number of particles with properties stored in the

particle dat.

npart_local_halo = None
Returns:The number of particles currently stored within the halo region of the particle dat.
npart_total

Get the total number of particles in the dat including halo particles.

Returns:
remove_particles(index=None)

Remove particles based on host.Array index :param index: host.Array with indices to remove :return:

resize(n, _callback=True)

Resize particle dat to be at least a certain size, does not resize if already large enough. :arg int n: New minimum size.

set_val(val)

Set all the entries in the particle dat to the same specified value.

Parameters:val – Value to set all entries to.
zero(n=None)

Typed Dat

Instances of this class should be used to store properties of particles which are common to multiple particles e.g. mass.

class data.TypedDat(nrow=1, ncol=1, initial_value=None, name=None, dtype=<class 'ctypes.c_double'>, key=None)

Bases: host.Matrix

Base class to hold floating point properties in matrix form of particles based on particle type.

Parameters:
  • nrow (int) – First dimension extent.
  • ncol (int) – Second dimension extent.
  • initial_value (double) – Value to initialise array with, default 0.0.
  • name (str) – Collective name of stored vars eg positions.
name = None
Returns:Name of TypedDat instance.

Table Of Contents

Previous topic

cell Module

Next topic

domain Module

This Page