Atoms

class atomman.Atoms(natoms=None, atype=None, pos=None, prop=None, model=None, safecopy=False, **kwargs)

Bases: object

Class for representing a collection of atoms.

class PropertyDict(host)

Bases: collections.OrderedDict

Extends OrderedDict to work with Atoms

property atypes

List of int atom types.

Type

tuple

df()

Returns a pandas.DataFrame of all atomic properties. Multi-dimensional per-atom data will be converted into multiple table columns.

extend(value)

Allows additional atoms to be added to the end of the atoms list.

Parameters

value (atomman.Atoms or int) – An int value will result in the atoms object being extended by that number of atoms, with all per-atom properties having default values (atype = 1, everything else = 0). For an Atoms value, the current atoms list will be extended by the correct number of atoms and all per-atom properties in value will be copied over. Any properties defined in one Atoms object and not the other will be set to default values.

Returns

A new Atoms object containing all atoms and properties of the current object plus the additional atoms.

Return type

atomman.Atoms

model(prop_name=None, unit=None, prop_unit=None)

Generates a data model for the Atoms object.

Parameters
  • prop_name (list, optional) – The Atoms properties to include. If neither prop_name nor prop_unit are given, all system properties will be included.

  • unit (list, optional) – Lists the units for each prop_name as stored in the table. For a value of None, no conversion will be performed for that property. If neither unit nor prop_units given, pos will be given in Angstroms and all other values will not be converted.

  • prop_unit (dict, optional) – dictionary where the keys are the property keys to include, and the values are units to use. If neither unit nor prop_units given, pos will be given in Angstroms and all other values will not be converted.

Returns

A JSON/XML data model for the current Atoms object.

Return type

DataModelDict.DataModelDict

property natoms

The number of atoms in the Atoms class.

Type

int

property natypes

The number of atom types in the Atoms class.

Type

int

prop(key=None, index=None, value=None, a_id=None)

Accesses the per-atom properties for controlled getting and setting. For getting values, prop() always returns a copy of the underlying data as opposed to the data itself.

Parameters
  • key (str, optional) – Per-atom property name.

  • index (int, list, slice, optional) – Index of atoms.

  • value (any, optional) – Property values to assign.

  • a_id (int, optional) – Integer atom index. Left in for backwards compatibility.

Returns

  • list – If no parameters given, returns a list of all assigned property keys.

  • atomman.Atoms – If index or a_id is given without value or key, returns a new Atoms instance for the specified atom indices.

  • numpy.ndarray – If key (and index/a_id) is given without value, returns a copy of the data associated with that property key.

Raises

ValueError – If a_id and index are both given, or only value is given.

prop_atype(key, value, atype=None)

Allows for per-atom properties to be assigned according to Atoms.atypes.

Parameters
  • key (str) – Per-atom property name.

  • value (list, any) – Property value(s) to assign. If atype is not given, this should be an object of length Atoms.natypes. Otherwise, should be a single per-atom value.

  • atype (int, optional) – A specific atype to assign value to.

Raises

ValueError – If length of value does not match Atoms.natypes or atype is not in Atoms.atypes.

property view

All assigned per-atom properties.

Type

PropertyDict