adsorpy.molecule_lib module

Contains all the molecules that can be used in this simulation.

Also includes molecule loader scripts, for which the molecule data is not included in this lib. You need to supply your own .xyz files, or you can use preconfigured simple shapes.

adsorpy.molecule_lib.discorectangle(params, offx=0.0, offy=0.0)[source]

Create a discorectangle using the union of two circles and a rectangle.

The circles are automatically approximated using linear segments (error of 1% or less).

Parameters:
  • params (list[float]) – Radius of the two circles and distance between the two halves in Angstrom.

  • offx (float) – X offset.

  • offy (float) – Y offset.

Return type:

Polygon

Returns:

The molecule shape as a polygon.

adsorpy.molecule_lib.circulium(radius, x_offset=0.0, y_offset=0.0, quad_segs=8)[source]

Create a simple circular polygon.

The circles are automatically approximated using linear segments (error of 1% or less).

Parameters:
  • radius (float) – Radius of the circle.

  • x_offset (float) – The x-offset in angstrom.

  • y_offset (float) – The y-offset in angstrom.

  • quad_segs (int) – The amount of linear segments in a quarter circle.

Return type:

Polygon

Returns:

The molecule shape as a polygon.

adsorpy.molecule_lib.dogbonium(scale=1)[source]

Make a molecule shaped like a bone. Used as a pathological case.

Parameters:

scale (float) – scale of the shape.

Return type:

Polygon

Returns:

The molecule shape as a polygon.

adsorpy.molecule_lib.polygonium(verts=3, scale=1.0, roundedness=0.0)[source]

Create a simple regular polygon with optional rounding.

Parameters:
  • verts (int) – The vertex count.

  • scale (float) – The scale factor of the polygon.

  • roundedness (float) – The roundedness.

Return type:

Polygon

Returns:

The regular (rounded) polygon.

adsorpy.molecule_lib.xyz_reader(file_name, ignore_atoms=None, x_offset=0.0, y_offset=0.0, roll=0.0, pitch=0.0, yaw=0.0, z_trim=None)[source]

Read files in the xyz format of VASP.

Parameters:
  • file_name (str | Path) – The name of the file, including the .xyz extension. Include the path.

  • ignore_atoms (str | list[str] | None) – Atoms to ignore when making the molecule. Useful if the slab is empty.

  • x_offset (float) – The offset in the x direction.

  • y_offset (float) – The offset in the x direction.

  • yaw (float) – Rotation along the x-axis.

  • pitch (float) – Rotation along the y-axis.

  • roll (float) – Rotation along the z-axis.

  • z_trim (float | None) – The z value below which all molecules are removed.

Return type:

Polygon

Returns:

The molecule polygon read from the xyz file.

adsorpy.molecule_lib.first_time_loader(file_name, ignore_atoms=None, x_offset=None, y_offset=None, roll=None, pitch=None, yaw=None, z_trim=None, reference_lattice_spacing=4.74)[source]

Script to run when you first load the molecule. Shows the molecule in xy, zy, and xz perspective, and vdwaals.

Can be used to rotate the molecule until satisfied, and will print a string that can be used for the xyz reader.

Parameters:
  • file_name (str | Path) – File name. Include the path.

  • ignore_atoms (str | list[str] | None) – Atoms to be ignored, optional. Either a string or an iterable of strings.

  • x_offset (float | None) – The x offset.

  • y_offset (float | None) – The y offset.

  • roll (float | None) – Rotation along the x-axis.

  • pitch (float | None) – Rotation along the y-axis.

  • yaw (float | None) – Rotation along the z axis.

  • z_trim (float | None) – Value below which all molecules are ignored.

  • reference_lattice_spacing (float) – The lattice spacing of the reference grid.

Return type:

dict[str, str | float | list[str] | Path | None]

Returns:

The updated dict of parameters after rotation and translation.

adsorpy.molecule_lib._update(val, ang_x, ang_y, ang_z, translate_x, translate_y, box_x, box_y, box_z, box_xoff, box_yoff, atompos, axs, fig, atomcolours, atomkeys, reference_lattice_spacing)[source]
Return type:

None

adsorpy.molecule_lib._initialise_reader(file_name, ignore_atoms=None, z_trim=None)[source]

Initialise the xyz_reader and first_time_loader.

Parameters:
  • file_name (str | Path) – name of the file to read.

  • ignore_atoms (str | list[str] | None) – list of atoms to ignore.

  • z_trim (float | None) – z value under which to remove the atoms.

Return type:

tuple[ndarray[tuple[int], dtype[str_]], ndarray[tuple[int, Literal[3]], dtype[double]]]

Returns:

a tuple of the atom keys and atom positions in 3D. Filtered.

Raises:

ValueError

  1. if the file type is not .xyz or 2) if the used settings would return an empty molecule.