lammpsio.Bonds

class lammpsio.Bonds(N, num_types=None)

Bond connections between particles.

All values of indexes follow the LAMMPS 1-indexed convention, but the arrays themselves are 0-indexed.

Parameters:
  • N (int) – Number of bonds.

  • num_types (int) – Number of bond types. Default of None means the number of types is determined from the unique typeids.

Example

Create bonds:

bonds = lammpsio.topology.Bonds(N=3, num_types=1)
bonds.id = [1, 2, 3]
bonds.typeid = [1, 1, 1]
bonds.members = [[1, 2], [2, 3], [1, 3]]

This creates a molecule with three bonds of the same type. The bonds are defined between particle IDs 1-2, 2-3, and 1-3 to form a triangle structure.

Methods:

has_id()

Check if configuration has connection IDs.

has_members()

Check if configuration has connection members.

has_typeid()

Check if configuration has connection typeids.

reorder(order[, check_order])

Reorder the connections in place.

Attributes:

N

Number of connections.

id

Unique identifiers (IDs).

members

Connection members.

num_types

Number of connection types.

type_label

Labels of connection type IDs.

typeid

Connection type IDs.

property N

Number of connections.

Type:

int

has_id()

Check if configuration has connection IDs.

Returns:

True if connection IDs have been initialized.

Return type:

bool

has_members()

Check if configuration has connection members.

Returns:

True if particle members have been initialized.

Return type:

bool

has_typeid()

Check if configuration has connection typeids.

Returns:

True if connection typeids have been initialized.

Return type:

bool

property id

Unique identifiers (IDs).

The default value on initialization runs from 1 to N.

Type:

(N,) numpy.ndarray of int

property members

Connection members.

The default value on initialization is 1 for all entries. M is the number of members in the connection.

Type:

(N, M) numpy.ndarray of int

property num_types

Number of connection types.

Type:

int

reorder(order, check_order=True)

Reorder the connections in place.

Parameters:
  • order (list) – New order of indexes.

  • check_order (bool) – If True, validate the new order before applying it.

property type_label

Labels of connection type IDs.

Type:

LabelMap

property typeid

Connection type IDs.

The default value on initialization is 1 for all entries.

Type:

(N,) numpy.ndarray of int