SBParticleSystem#

This class describes a particle system in SAMSON, i.e. a dynamical system composed of particles. A particle system has two buffers - a position buffer and a momentum buffer - which may be used to write adaptive simulation algorithms.

You can get a number of changed momentums and a momentum of a particle in the particle system:

print(particleSystem.numberOfChangedMomentums)
print(particleSystem.getMomentum(i))

# the same can be done for positions
print(particleSystem.numberOfChangedPositions)
print(particleSystem.getPosition(i))

You can get the index of i-th changed momentum. Assume for example that particle 17, 32, and 529 have had their momentum changed since the last flush of the momentum buffer. Then the following code:

for i in range(particleSystem.numberOfChangedMomentums):
        # changedMomentumIndex is the index of the i-th changed momentum
        changedMomentumIndex = particleSystem.getChangedMomentumIndex(i)
        print(changedMomentumIndex)

This will result in the following output:

17
32
529

You can use these indices in adaptive simulation algorithms for example together with samson.SBParticleSystem.

See also

SAMSON SDK: SBMDynamicalModelParticleSystem

class samson.SBParticleSystem(*args, **kwargs)#

Bases: SBDynamicalModel

This class describes a dynamical particle system.

Overloaded function.

  1. __init__(self: samson.SBParticleSystem) -> None

Constructs a dynamical particle system

  1. __init__(self: samson.SBParticleSystem, nodeIndexer: samson.SBNodeIndexer) -> None

Constructs a dynamical particle system based on a node indexer.

Parameters:

nodeIndexer (samson.SBNodeIndexer) – A node indexer with atoms.

addAtom(self: samson.SBParticleSystem, atom: samson.SBAtom) int#

Adds a atom to the particle system

correctDistanceWithPBC(self: samson.SBParticleSystem, distance: samson.SBPhysicalVector3) None#
flushMomentumBuffer(self: samson.SBParticleSystem) None#

Flushes the momentum buffer

getActivityFlag(*args, **kwargs)#

Overloaded function.

  1. getActivityFlag(self: samson.SBParticleSystem, atom: samson.SBAtom) -> bool

Returns activity flag of an atom

  1. getActivityFlag(self: samson.SBParticleSystem, atomIndex: int) -> bool

Returns activity flag of an atom

getAtomIndexer(self: samson.SBParticleSystem) samson.SBNodeIndexer#

Returns an indexer with the atoms associated to the particle system.

Returns:

A node indexer with the associated atoms.

Return type:

samson.SBNodeIndexer

getChangedMomentumIndex(self: samson.SBParticleSystem, i: int) int#

Returns the index of a changed momentum

getInverseMass(*args, **kwargs)#

Overloaded function.

  1. getInverseMass(self: samson.SBParticleSystem, atom: samson.SBAtom) -> samson.SBQuantity.unitsSI

Returns inverse mass of an atom

  1. getInverseMass(self: samson.SBParticleSystem, atomIndex: int) -> samson.SBQuantity.unitsSI

Returns inverse mass of an atom

getMass(*args, **kwargs)#

Overloaded function.

  1. getMass(self: samson.SBParticleSystem, atom: samson.SBAtom) -> samson.SBQuantity.unitsSI

Returns mass of an atom

  1. getMass(self: samson.SBParticleSystem, atomIndex: int) -> samson.SBQuantity.unitsSI

Returns mass of an atom

getMomentum(self: samson.SBParticleSystem, i: int) samson.SBPhysicalVector3#

Returns the momentum of an atom

getPosition(self: samson.SBParticleSystem, i: int) samson.SBPhysicalVector3#

Returns the position of an atom

getPositionChanged(self: samson.SBParticleSystem, i: int) bool#

Returns whether momentum i has been changed since the last flush

removeAtom(*args, **kwargs)#

Overloaded function.

  1. removeAtom(self: samson.SBParticleSystem, atom: samson.SBAtom) -> None

Removes an atom from the particle system

  1. removeAtom(self: samson.SBParticleSystem, atomIndex: int) -> None

Removes an atom from the particle system

removeAtoms(self: samson.SBParticleSystem, nodeIndexer: samson.SBNodeIndexer) None#

Removes atoms of a node indexer

roundForPBC(self: samson.SBParticleSystem, length: samson.SBQuantity.unitsSI) int#
setActivityFlag(*args, **kwargs)#

Overloaded function.

  1. setActivityFlag(self: samson.SBParticleSystem, atom: samson.SBAtom, flag: bool) -> None

Sets activity flag of an atom

  1. setActivityFlag(self: samson.SBParticleSystem, atomIndex: int, flag: bool) -> None

Sets activity flag of an atom

setMass(*args, **kwargs)#

Overloaded function.

  1. setMass(self: samson.SBParticleSystem, atom: samson.SBAtom, flag: samson.SBQuantity.unitsSI) -> None

Sets mass of an atom

  1. setMass(self: samson.SBParticleSystem, atomIndex: int, flag: samson.SBQuantity.unitsSI) -> None

Sets mass of an atom

setMomentum(self: samson.SBParticleSystem, i: int, newMomentum: samson.SBPhysicalVector3) None#

Updates the momentum of an atom

setPosition(self: samson.SBParticleSystem, i: int, newPosition: samson.SBPhysicalVector3) None#

Updates the position of an atom

property numberOfChangedMomentums#

Returns the number of changed momentum