Atoms

class atomman.Atoms(natoms: Optional[int] = None, atype: Optional[Union[int, Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype]]]]], bool, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]]] = None, pos: Optional[Union[int, Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype]]]]], bool, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]]] = None, prop: Optional[dict] = None, model: Optional[Union[str, io.IOBase, DataModelDict.DataModelDict.DataModelDict]] = None, safecopy: bool = False, **kwargs)

Bases: object

Class for representing a collection of atoms.

class PropertyDict(host: atomman.core.Atoms.Atoms)

Bases: collections.OrderedDict

Extends OrderedDict to work with Atoms

property atypes: tuple

List of int atom types.

Type

tuple

df() pandas.core.frame.DataFrame

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

extend(value: Union[atomman.core.Atoms.Atoms, int]) atomman.core.Atoms.Atoms

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: Optional[list] = None, unit: Optional[list] = None, prop_unit: Optional[dict] = None) DataModelDict.DataModelDict.DataModelDict

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: int

The number of atoms in the Atoms class.

Type

int

property natypes: int

The number of atom types in the Atoms class.

Type

int

prop(key: Optional[str] = None, index: Optional[Union[int, list, slice]] = None, value: Optional[Any] = None, a_id: Optional[int] = None) Optional[Union[list, atomman.core.Atoms.Atoms, numpy.ndarray]]

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: str, value: Any, atype: Optional[int] = 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: PropertyDict

All assigned per-atom properties.

Type

PropertyDict