mpacts.core. particle

In order to be able to use this module import it like this:

import mpacts.core.particle
#or assign it to a shorter name
import mpacts.core.particle as par

Particle

class mpacts.core.particle.Particle

Bases: mpacts.core.baseobject.BaseObject

Class that represents a single particle (element) in a particle container.
Has no default location.
  • Optional keywords:
    • g_parentIndex (default value = -1) — the translated to global version of the parentindex
    • index (default value = -1) — Index of this particle
    • pc (default value = None) — The particle container this particle is in
object __init__(tuple args, dict kwds) :
args: name, parent kwds: [index, g_parentIndex, pc]
Particle(name, parent, **kwargs)
get_arrayvalue((Particle)self, (str)arrayname) → object :

Returns the value for a specific array for this particle

get_global_index((Particle)arg1) → int :

Returns the global index of this particle.

get_pc((Particle)arg1) → ArrayManager :

Returns the underlying particle container datastructure.

local_to_global_index((Particle)self, (int)localindex) → int :

Returns the global index fo a single local index

remove_particle((Particle)self) → None :

Removes particle and all sub-particles.

set_arrayvalue()
object set_arrayvalue(tuple args, dict kwds) :
Sets individual values for this particle

ParticleCollection

class mpacts.core.particle.ParticleCollection

Bases: mpacts.core.baseobject.BaseObject

Class that represents all particles with the same parent.

Raises an exception This class cannot be instantiated from Python

ParticleCollection(name, parent, **kwargs)
create_particle((ParticleCollection)self) → Particle :

Creates and returns a new particle that is part of this collection.

get_collection((ParticleCollection)self, (str)arrayname) → object :

Returns the content of the given array belonging to this particle collection only (ie. with the same parent particle).

get_particle((ParticleCollection)self, (int)index) → Particle :

Returns a new particle that specifically points to a single particle. Can be used to create subparticles below this particle. Same as using [idx] operator.

local_to_global_index((ParticleCollection)self, (int)localindex) → int :

Returns the global index fo a single local index

set_collection()
object set_collection(tuple args, dict kwds) :
Allows to set all direct child arrays with kwargs that are either lists or single values. In case the collection is still empty, the list will be used to create new sub-particles.Single values work as long as there is at least one list present to infer the length. Different length lists are not allowed. In case there are elements in the collection, the single value will set all values belonging to this particle collection, the list will set the elements with the list provided the list is the same size as the collection.
size((ParticleCollection)self) → int :

Returns the number of particles in this collection with the same parent.

translate_connectivity((ParticleCollection)self, (ParticleCollection)other_particle, (list)connectivity list) → list :

Returns a translated list of the connections between this particle_collection and another one. If connections need to be translated between the same particle, just explicitly pass ‘self’ as other particle.

mpacts.core.particle.create_particle((BaseObject)arg1) → Particle :

Create new particle in the given particlecontainer

mpacts.core.particle.get_particle((BaseObject)arg1, (int)arg2) → Particle :

Get a particle starting from the particlecontainer and the index of the particle.

mpacts.core.particle.get_particle_from_global((BaseObject)arg1, (int)arg2) → Particle :

Get a particle starting from the particlecontainer and the GLOBAL index of the particle.

mpacts.core.particle.get_particlecollection((BaseObject)arg1) → ParticleCollection :

Create new particlecollection. Typically used for ‘flat’ particles with no hierachy such as spheres.