Data#
- class up4.Data(filename)#
Bases:
object
Class that holds the particle data for processing.
If you have simulation data, you will probably want to use
Data.from_pdata()
to instantiate this class as this handles a large number of particles. For experimental data,Data.from_tdata()
is recommended. However, as the choice ultimately makes no difference to how you use this library, that choice is down to you!Methods
from_pdata:
Constructor for up4.Data using data that has large numbers of particles, typically from simulation.
from_tdata:
Constructor for up4.Data using data that has low numbers of particles, typically from experiment.
stats:
Calculate statistics of the dataset such as dimensions, mean velocity and number of particles.
set_time:
Select the dataset between two times.
vectorfield:
Return vector data as a vector field.
velocityfield:
Return the velocity data as a velocity field.
extract:
Return particle information over specified duration.
numberfield:
Return the number density field.
mean_velocity:
Return the mean velocity of all valid particles in the system.
dispersion:
Return the dispersion of all valid particles in the system for a given time
histogram:
Return the histogram of all valid particles in the system for a given time
granular_temperature:
Return the granular temperature of all valid particles in the system for a given time
lacey_mixing_index:
Return the lacey mixing index for the whole system over a given time
circulation_time:
Return the circulation time for the whole system, returns all times as one large array
circulation_time_two_boundary:
Return the circulation time for the whole system determined using two bounaries, returns all times as one large array
concentration_field:
Return the concentration field for the whole system
homogenity_index:
Return the homogenity index for the whole system, defiuned by two particle species
msd_field:
Return the mean square displacement field for the whole system
msd:
Return the mean square displacement for the whole system over time
- circulation_time(position, axis=0)#
Calculate the circulation time of a particle in a system. This algorithm works by setting a single boundary, which the particle has to cross 3 times.
- circulation_time_two_boundary(position, axis=0)#
Calculate the circulation time of a particle in a system. This algorithm works by setting two boundaries, which the particle has to cross 5 times in total.
- concentration_field(grid, type_a=1, type_b=2)#
Calculate the concentration field of the system The concentration field is calculated by counting the number of particles of type a and b in a region of the system. The concentration is calculated by n_a / (n_a + n_b).
- dimensions()#
Return the dimensions of the system as a dictionary. The dictionary contains the following keys: *
xmin
: Minimum x coordinate. *xmax
: Maximum x coordinate. *ymin
: Minimum y coordinate. *ymax
: Maximum y coordinate. *zmin
: Minimum z coordinate. *zmax
: Maximum z coordinate.
- dispersion(grid, time_for_dispersion)#
Return the dispersion of the particles in the system.
See [1] for further details.
- Parameters:
- Returns:
References
[1]Martin, T. W., J. P. K. Seville, and D. J. Parker. “A general method for quantifying dispersion in multiscale systems using trajectory analysis.”
- extract(particle_id, timestep)#
Return particle information over specified duration.
- Parameters:
- Returns:
numpy.ndarray
2D numpy array with shape (timestep[1] - timestep[0]) X 7. Where in each row is the current time, particle position and its velocity components.
- static from_pdata(filename)#
Create new instance of the up4.Data class. This method assumes a particle oriented hdf5 file.
- static from_tdata(filename)#
Create new instance of the Data class. This method assumes a time oriented hdf5 file.
- granular_temperature(grid, mode='xyz')#
Calculate the granular temperature of the system. The granular temperature is defined as the mean fluctuating velocity of the particles.
- Parameters:
- grid
PyGrid
The grid that defines the region of the system.
- mode
str
The mode in which the granular temperature is calculated. The following modes are available:
‘xyz’
‘x’
‘y’
‘z’
, by default ‘xyz’
- grid
- Returns:
PyGrid
The granular temperature of the system.
- histogram(grid, property='velocity', bins=100, limit=0.0)#
Calculate a histogram of a specific property in a region of the system.
The histogram is calculated for all particles that are valid according to the particleselector. The histogram is calculated for the region defined by the grid.
- Parameters:
- Returns:
- histogram
numpy.ndarray
The histogram.
- bin_edges
numpy.ndarray
The bin edges.
- histogram
- homogenity_index(grid, min_vel=0.0)#
Calculate the homogenity index.
- Parameters:
- grid
PyGrid
The grid that defines the region of the system.
- grid
- lacey_mixing_index(grid, type_a=0, type_b=1, threshold=10)#
Calculate the Lacey mixing index for two particle types in a region of the system for a time period.
- Parameters:
- Returns:
- time
numpy.ndarray
The time of the mixing index.
- mixing_index
numpy.ndarray
The mixing index.
- time
- max_position()#
Return the max position of the system as a array The array contains the following values at positions: *
0
: Maximum x coordinate. *1
: Maximum y coordinate. *2
: Maximum z coordinate.
- mean_velocity()#
Return the mean velocity of all valid particles in the system.
- Returns:
float
Mean particle velocity
- min_position()#
Return the min position of the system as a array The array contains the following values at positions: *
0
: Minimum x coordinate. *1
: Minimum y coordinate. *2
: Minimum z coordinate.
- msd(grid, min_time=0.0, max_time=0.0, steps=100)#
Calculate the mean squared displacement of a particle in a system.
- Parameters:
- Returns:
- msd_field(grid, time)#
Calculate the mean squared displacement field of the system. The mean squared displacement field is calculated by calculating the mean squared displacement of a particle in a region of the system. Each cell element represents the mean squared displacement of all particles in that cell.
- Parameters:
- grid
PyGrid
The grid that defines the region of the system.
- grid
- Returns:
- msd_field
PyGrid
The mean squared displacement field of the system.
- msd_field
- nparticles()#
Number of particles in the system.
- numberfield(grid)#
Return the number density field.
- occupancyfield(grid, min_vel=0.0)#
Return the occupancy field.
- set_time(min_time, max_time)#
Select the dataset between two different times.
- stats()#
Calculate statistics of the dataset and print to terminal. Currently these are: * System dimensions. * Maximum time. * Number of particles. * Mean velocity. * Minimum and maximum velocity.