Module utils

class utils.EmptySphere(*args, **kwargs)[source]

Bases: ase.atom.Atom

utils.center_cluster(atoms, invert=False)[source]

Centers an Atoms object by translating it so the origin is roughly at the center of the cluster. The function supposes that the cluster is wrapped inside the unit cell, with the origin being at the corner of the cell. It is used in combination with the cut functions, which work only if the origin is at the center of the cluster :param ase.Atoms atoms: an ASE Atoms object :param bool invert: if True, performs the opposite translation

(uncentering the cluster)

utils.cut_cone(atoms, radius, z=0)[source]

Shapes the cluster as a cone.

Keeps all the atoms of the input Atoms object inside a cone of based radius radius and of height z.

Parameters
  • atoms (ase.Atoms) – The cluster to modify.

  • radius (float) – The base cone radius in \(\mathring{A}\). # noqa: W605

  • z (float) – The height of the cone in \(\mathring{A}\). # noqa: W605

Returns

A new cluster.

Return type

ase.Atoms

utils.cut_cylinder(atoms, axis='z', radius=None)[source]

Removes all the atoms of an Atoms object outside a cylinder with a given axis and radius

Parameters
  • atoms (ase.Atoms) – an ASE Atoms object

  • axis (str) – string “x”, “y”, or “z”. The axis of the cylinder, “z” by default

  • radius (float) – the radius of the cylinder

Returns

The modified atom cluster

Return type

ase.Atoms

utils.cut_plane(atoms, x=None, y=None, z=None)[source]

Removes the atoms whose coordinates are higher (or lower, for a negative cutoff value) than the coordinates given for every dimension.

For example,

cut_plane(atoms, x=[-5,5], y=3.6, z=0)
# every atom whose x-coordinate is higher than 5 or lower than -5,
# and/or y-coordinate is higher than 3.6, and/or z-coordinate is higher
# than 0 is deleted.
Parameters
  • atoms (ase.Atoms) – an ASE Atoms object

  • x (int) – x cutoff value

  • y (int) – y cutoff value

  • z (int) – z cutoff value

Returns

The modified atom cluster

Return type

ase.Atoms

utils.cut_sphere(atoms, radius, center=(0, 0, 0))[source]

Removes all the atoms of an Atoms object outside a sphere with a given radius

Parameters
  • atoms (ase.Atoms) – an ASE Atoms object

  • radius (float) – the radius of the sphere

Returns

The modified atom cluster

Return type

ase.Atoms

utils.get_atom_index(atoms, x, y, z, scaled=False)[source]

Return the index of the atom that is the closest to the coordiantes given as parameters.

Parameters
  • atoms (ase.Atoms) – an ASE Atoms object

  • x (float) – the x position in angstroms

  • y (float) – the y position in angstroms

  • z (float) – the z position in angstroms

  • scaled (bool) – whether the x,y,z coordinates are scaled

Returns

the index of the atom as an integer

Return type

int

utils.hemispherical_cluster(cluster, emitter_tag=0, emitter_plane=0, diameter=0, planes=0, shape='spherical')[source]

Creates and returns a cluster based on an Atoms object and some parameters.

Parameters
  • cluster (Atoms object) – the Atoms object used to create the cluster

  • emitter_tag (integer) – the tag of your emitter

  • diameter (float) – the diameter of your cluster in Angströms

  • planes (integer) – the number of planes of your cluster

  • emitter_plane (integer) – the plane where your emitter will be starting by 0 for the first plane

See The hemispherical_cluster function for more informations.