Topology of create bonds

Quote from xiaoqian Lu on December 17, 2020, 2:27 pmhello !
I have a problem using the function CreateBondsModifier of ovito.
The topology of bonds is new , it is different from the ParticleIdentifier, and in the track file, the same ID has a different topology.
So, how do I get the ParticleIdentifier through the Topology?
Thank you for your reply in advance.
hello !
I have a problem using the function CreateBondsModifier of ovito.
The topology of bonds is new , it is different from the ParticleIdentifier, and in the track file, the same ID has a different topology.
So, how do I get the ParticleIdentifier through the Topology?
Thank you for your reply in advance.

Quote from Constanze Kalcher on December 17, 2020, 3:09 pmHi,
please note that the topology bond property defines the connectivity between particles in the form of a N x 2 array of indices into the Particles array. As opposed to the particle identifier property, the particle indices are 0-based.
You can use the particle indices from the topology property to look up any corresponding particle property, e.g.
def modify(frame, data): bond_topology = data.particles.bonds.topology # array with bond topology # Create bonds enumerator object. bonds_enum = BondsEnumerator(data.particles.bonds) # Loop over atoms. for particle_index in range(data.particles.count): # Loop over bonds of current atom. for bond_index in bonds_enum.bonds_of_particle(particle_index): # Obtain the indices of the two particles connected by the bond: a,b = bond_topology[bond_index] print(f"Particle Identifiers:{ data.particles['Particle Identifier'][[a,b]] }")also see https://www.ovito.org/docs/current/scene_objects.bonds.php.
Hi,
please note that the topology bond property defines the connectivity between particles in the form of a N x 2 array of indices into the Particles array. As opposed to the particle identifier property, the particle indices are 0-based.
You can use the particle indices from the topology property to look up any corresponding particle property, e.g.
def modify(frame, data): bond_topology = data.particles.bonds.topology # array with bond topology # Create bonds enumerator object. bonds_enum = BondsEnumerator(data.particles.bonds) # Loop over atoms. for particle_index in range(data.particles.count): # Loop over bonds of current atom. for bond_index in bonds_enum.bonds_of_particle(particle_index): # Obtain the indices of the two particles connected by the bond: a,b = bond_topology[bond_index] print(f"Particle Identifiers:{ data.particles['Particle Identifier'][[a,b]] }")
also see https://www.ovito.org/docs/current/scene_objects.bonds.php.