Forum Navigation
You need to log in to create posts and topics.

Topology of create bonds

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.


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