Particle-related classes¶
A simulation particle. |
|
A bond between two particles. |
|
A bond involving three particles. |
|
A bond involving four particles. |
|
A set of particles. |
|
A single configuration. |
-
class
baggianalysis.core.
Particle
(*args, **kwargs)¶ Bases:
pybind11_builtins.pybind11_object
A simulation particle.
Overloaded function.
__init__(self: baggianalysis.core.Particle, index: int) -> None
Build a new particle by specifying its index.
- Parameters
index (int) – The index of the particle. Note that this value cannot be changed later on.
__init__(self: baggianalysis.core.Particle, index: int, type: str) -> None
Build a new particle by specifying its index and type.
- Parameters
__init__(self: baggianalysis.core.Particle, index: int, type: str, position: glm::tvec3<scalar, P>) -> None
Build a new particle by specifying its index, type and position.
- Parameters
index (int) – The index of the particle. Note that this value cannot be changed later on.
type (str) – The type of the particle.
position (numpy.ndarray) – The position of the particle
__init__(self: baggianalysis.core.Particle, index: int, type: str, position: glm::tvec3<scalar, P>, velocity: glm::tvec3<scalar, P>) -> None
Build a new particle by specifying its index, type, position and velocity.
- Parameters
index (int) – The index of the particle. Note that this value cannot be changed later on.
type (str) – The type of the particle.
position (numpy.ndarray) – The position of the particle.
velocity (numpy.ndarray) – The velocity of the particle.
-
add_bonded_angle
(*args, **kwargs)¶ Overloaded function.
add_bonded_angle(self: baggianalysis.core.Particle, type: str, p1: baggianalysis.core.Particle, p2: baggianalysis.core.Particle, p3: baggianalysis.core.Particle) -> None
Add an angle of the given type (defined by three particles) this particle is involved in. Note that the current particle must be one of the three particles given as parameters.
- Parameters
add_bonded_angle(self: baggianalysis.core.Particle, p1: baggianalysis.core.Particle, p2: baggianalysis.core.Particle, p3: baggianalysis.core.Particle) -> None
Add an angle of the default type (defined by three particles) this particle is involved in. Note that the current particle must be one of the three particles given as parameters.
-
add_bonded_dihedral
(*args, **kwargs)¶ Overloaded function.
add_bonded_dihedral(self: baggianalysis.core.Particle, type: str, p1: baggianalysis.core.Particle, p2: baggianalysis.core.Particle, p3: baggianalysis.core.Particle, p4: baggianalysis.core.Particle) -> None
Add a dihedral of the given type (defined by four particles) this particle is involved in. Note that the current particle must be one of the four particles given as parameters.
- Parameters
type (str) – The type of the dihedral.
p1 (
Particle
) – The first particle participating in the dihedral.p2 (
Particle
) – The second particle participating in the dihedral.p3 (
Particle
) – The third particle participating in the dihedral.p4 (
Particle
) – The fourth particle participating in the dihedral.
add_bonded_dihedral(self: baggianalysis.core.Particle, p1: baggianalysis.core.Particle, p2: baggianalysis.core.Particle, p3: baggianalysis.core.Particle, p4: baggianalysis.core.Particle) -> None
Add a dihedral of the default type (defined by four particles) this particle is involved in. Note that the current particle must be one of the four particles given as parameters.
-
add_bonded_neighbour
(*args, **kwargs)¶ Overloaded function.
add_bonded_neighbour(self: baggianalysis.core.Particle, type: str, q: baggianalysis.core.Particle) -> None
Add a bond of the given type between the current particle and
q
.- Parameters
add_bonded_neighbour(self: baggianalysis.core.Particle, q: baggianalysis.core.Particle) -> None
Add a bond of the default type between the current particle and
q
.- Parameters
q (
Particle
) – The new bonded neighbour.
-
add_neighbour
(*args, **kwargs)¶ Overloaded function.
add_neighbour(self: baggianalysis.core.Particle, type: str, q: baggianalysis.core.Particle) -> None
Add particle
q
as a bond of the given type to the list of this particle’s neighbours. Contrary toadd_bonded_neighbour()
, the current particle is not added to the list ofq
’s neighbours.- Parameters
add_neighbour(self: baggianalysis.core.Particle, q: baggianalysis.core.Particle) -> None
Add particle
q
as a bond of the default type to the list of this particle’s neighbours. Contrary toadd_bonded_neighbour()
, the current particle is not added to the list ofq
’s neighbours.- Parameters
q (
Particle
) – The new neighbour.
-
add_orientation_vector
(self: baggianalysis.core.Particle, v: glm::tvec3<scalar, P>) → None¶ The molecule to which this particle belongs.
- Parameters
v (numpy.ndarray) – The new orientation vector.
-
property
angular_velocity
¶ The particle’s angular velocity.
- Type
-
property
bonded_angles
¶ A list of
ParticleAngle
s storing the angles (i.e. triplets of particles) this particle is involved in.- Type
Set(
ParticleAngle
)
-
property
bonded_dihedrals
¶ A list of
ParticleDihedral
s storing the dihedrals (i.e. list of four particles) this particle is involved in.- Type
Set(
ParticleDihedral
)
-
property
bonded_neighbours
¶ A list of this particle’s bonded neighbours.
- Type
Set(
ParticleBond
)
-
has_bonded_neighbour
(self: baggianalysis.core.Particle, q: baggianalysis.core.Particle) → bool¶ Check whether
q
is a bonded neighbour.
-
has_neighbour
(self: baggianalysis.core.Particle, q: baggianalysis.core.Particle) → bool¶ Check whether
q
is a neighbour.
-
property
index
¶ The particle’s index. This is a read-only property because changing the index of the particle should be done with the methods provided by
ParticleSet
andSystem
only.- type
int
-
make_copy
(self: baggianalysis.core.Particle, index: int) → baggianalysis.core.Particle¶ Return a copy of this particle with the given index. Note that neighbours and bonded neighbours, angles and dihedrals are not copied.
- Parameters
index (int) – The index of the new particle.
-
property
molecule
¶ The molecule to which this particle belongs.
- Type
-
property
neighbours
¶ A list of this particle’s neighbours.
- Type
Set(
ParticleBond
)
-
property
orientation_vectors
¶ A list of vectors related to the particle’s orientation. Depending on the specific model it may contain the list of interaction centres or the components of the orientation matrix.
- type
List(numpy.ndarray)
-
property
position
¶ The particle’s position.
- Type
-
remove_bonded_neighbour
(*args, **kwargs)¶ Overloaded function.
remove_bonded_neighbour(self: baggianalysis.core.Particle, link: baggianalysis.core.ParticleBond) -> None
Remove the given
ParticleBond
from the list of current particle’s bonds.- Parameters
link (
ParticleBond
) – The bond that should be removed.
remove_bonded_neighbour(self: baggianalysis.core.Particle, q: baggianalysis.core.Particle) -> None
Remove
q
from the list of current particle’s bonded neighbours.- Parameters
q (
Particle
) – The particle whose bond with the current particle should be removed.
-
remove_neighbour
(*args, **kwargs)¶ Overloaded function.
remove_neighbour(self: baggianalysis.core.Particle, link: baggianalysis.core.ParticleBond) -> None
Remove the given
ParticleBond
from the list of this particle’s neighbours.- Parameters
link (
ParticleBond
) – The link that should be removed.
remove_neighbour(self: baggianalysis.core.Particle, q: baggianalysis.core.Particle) -> None
Remove
q
from the list of this particle’s neighbours.- Parameters
q (
Particle
) – The particle that should be removed from the list of neighbous.
-
shift
(self: baggianalysis.core.Particle, delta: glm::tvec3<scalar, P>) → None¶ Add
delta
to the particle coordinates.- Parameters
delta (numpy.ndarray) – The shift to be added to the particle’s coordinates.
-
property
type
¶ The particle’s type.
- Type
string
-
property
velocity
¶ The particle’s velocity.
- Type
-
class
baggianalysis.core.
ParticleBond
¶ Bases:
pybind11_builtins.pybind11_object
A bond between two particles.
-
other
(self: baggianalysis.core.ParticleBond) → ba::Particle¶ The other particle involved in the bond.
-
-
class
baggianalysis.core.
ParticleAngle
¶ Bases:
pybind11_builtins.pybind11_object
A bond involving three particles.
-
class
baggianalysis.core.
ParticleDihedral
¶ Bases:
pybind11_builtins.pybind11_object
A bond involving four particles.
-
class
baggianalysis.core.
ParticleSet
(self: baggianalysis.core.ParticleSet) → None¶ Bases:
pybind11_builtins.pybind11_object
A set of particles.
The constructor takes no parameters.
-
N
(self: baggianalysis.core.ParticleSet) → int¶ The number of particles stored in the set.
-
add_particle
(self: baggianalysis.core.ParticleSet, p: baggianalysis.core.Particle) → None¶ Add
p
to the set.- Parameters
p (
Particle
) – The particle to be added to the set.
-
charge
(self: baggianalysis.core.ParticleSet) → float¶ The total charge stored in the set
-
charges
(self: baggianalysis.core.ParticleSet) → List[float]¶ Return a vector containing the charge of all the particles.
The vector is created ex novo every time this method is called. Do not use in performance-critical scenarios (or cache the result).
-
com
(self: baggianalysis.core.ParticleSet) → glm::tvec3<scalar, P>¶ The centre of mass of the set
-
id_exists
(self: baggianalysis.core.ParticleSet, p_idx: int) → bool¶ Check whether a particle with the given index is stored in the set.
-
indexes
(self: baggianalysis.core.ParticleSet) → List[int]¶ Return a vector containing the index of all the particles.
The vector is created ex novo every time this method is called. Do not use in performance-critical scenarios (or cache the result).
-
make_copy
(self: baggianalysis.core.ParticleSet, indexes_shift: int) → baggianalysis.core.ParticleSet¶ Make a copy of the set and of the particles therein, shifting all the particle indexes by the given value.
- Parameters
indexes_shift (int) – The shift to be added to the index of each particle.
-
mass
(self: baggianalysis.core.ParticleSet) → float¶ The total mass stored in the set
-
masses
(self: baggianalysis.core.ParticleSet) → List[float]¶ Return a vector containing the mass of all the particles.
The vector is created ex novo every time this method is called. Do not use in performance-critical scenarios (or cache the result).
-
property
name
¶ The name of the object. This can be used to keep track of particular particle sets (e.g. when dealing with
System.molecules()
).
-
particle_by_id
(self: baggianalysis.core.ParticleSet, p_idx: int) → baggianalysis.core.Particle¶ Retrieve the particle with the given index.
-
particles
(self: baggianalysis.core.ParticleSet) → List[baggianalysis.core.Particle]¶ The list of particles stored in the set
-
positions
(self: baggianalysis.core.ParticleSet) → List[glm::tvec3<scalar, P>]¶ Return a vector containing the position of all the particles.
The vector is created ex novo every time this method is called. Do not use in performance-critical scenarios (or cache the result).
-
remove_particle
(self: baggianalysis.core.ParticleSet, p: baggianalysis.core.Particle) → None¶ Remove
p
from the set.- Parameters
p (
Particle
) – The particle to be removed from the set.
-
remove_particle_by_id
(self: baggianalysis.core.ParticleSet, p_id: int) → None¶ Remove the particle with given index from the set.
- Parameters
p_idx (int) – The index of the particle to be removed from the set.
-
select
(self: baggianalysis.core.ParticleSet, predicate: Callable[[baggianalysis.core.Particle], bool]) → List[baggianalysis.core.Particle]¶ Return all those particles for which the given predicate evaluates to True.
Here is an example that creates a list of particles having a non-negative position along the x axis:
selected = system.select(lambda p: p.position[0] > 0)
Note that the returned list contains references to and not copies of the particles stored in this set.
- Parameters
predicate (callable) – A callable that takes a particle and returns True if the particle should be returned, False otherwise.
- Returns
The list of particles for which the predicate evaluates to True.
- Return type
List(
Particle
)
-
set_com
(self: baggianalysis.core.ParticleSet, new_com: glm::tvec3<scalar, P>) → None¶ Set the centre of mass of the set to a new value.
- Parameters
new_com (numpy.ndarray) – The new centre of mass of the set.
-
sort_particles_by_id
(self: baggianalysis.core.ParticleSet) → None¶ Sort the particles according to their index
-
types
(self: baggianalysis.core.ParticleSet) → List[str]¶ Return a vector containing the type of all the particles.
The vector is created ex novo every time this method is called. Do not use in performance-critical scenarios (or cache the result).
-
velocities
(self: baggianalysis.core.ParticleSet) → List[glm::tvec3<scalar, P>]¶ Return a vector containing the velocity of all the particles.
The vector is created ex novo every time this method is called. Do not use in performance-critical scenarios (or cache the result).
-
velocity
(self: baggianalysis.core.ParticleSet) → glm::tvec3<scalar, P>¶ The total velocity of the set
-
-
class
baggianalysis.core.
System
(*args, **kwargs)¶ Bases:
baggianalysis.core.ParticleSet
A single configuration.
Overloaded function.
__init__(self: baggianalysis.core.System) -> None
The default constructor, which takes no arguments.
__init__(self: baggianalysis.core.System, arg0: baggianalysis.core.System) -> None
The copy constructor.
-
available_index
(self: baggianalysis.core.System) → int¶ Return a particle index that can be used in the context of this system (that is, that is not used by any of the particles already present in the system).
- Returns
A number that can be used as a valid index for a new particle.
- Return type
-
property
box
¶
-
bring_particles_in_box
(self: baggianalysis.core.System, shift_by_half_box: bool = False) → None¶ Bring the particles back into the box.
- Parameters
shift_by_half_box (bool) – If False (the default value) particles will have coordinates ranging from 0 to the length of the box side. If True, the coordinates will range between -box/2 and +box/2.
-
copy_topology_from
(self: baggianalysis.core.System, other: baggianalysis.core.System) → None¶ Copy the topology details (bonds, angles, dihedrals) from another system.
- Parameters
other (
System
) – The system whence the topology should be copied.
-
empty_copy
(self: baggianalysis.core.System) → baggianalysis.core.System¶ Return a copy of this system (same time and box, no particles).
-
molecules
(self: baggianalysis.core.System) → List[baggianalysis.core.ParticleSet]¶ Return all the molecules contained in the system in the form of a list of
ParticleSet
.- Returns
The list of molecules contained in the system.
- Return type
list(
ParticleSet
)
-
normalise_molecules
(self: baggianalysis.core.System) → None¶ Use periodic boundary conditions to shift particle positions so that bonded neighbours are always as close as possible to each other and not separated by distances that are multiple of box sides.
-
reindex_particles
(self: baggianalysis.core.System, base_idx: int) → None¶ Sort the particles by index and assign them new indexes so that the first and last ones are
base_index
andbase_index + N() - 1
, respectively.- Parameters
base_index (int) – The starting index that should be used.
-
rescale_lengths
(self: baggianalysis.core.System, factor: float) → None¶ Rescale all lengths (positions, velocities, box sides, etc.) by the given factor.
- Parameters
factor (float) – The rescaling factor.
-
property
time
¶