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.AtomKey¶
Atom key validator. String of length 1 or 2 denoting chemical symbols.
alias of
Annotated[str,StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=2, pattern=None, ascii_only=None)]
- adsorpy.molecule_lib._load_radii_from_json()[source]¶
Load the van der Waals radii from the vdw_radii.json file.
Uses Pydantic to validate the JSON.
- adsorpy.molecule_lib.RADII: Final[dict[str, float]] = {'Ac': 2.8, 'Ag': 2.53, 'Al': 2.25, 'Am': 2.83, 'Ar': 1.83, 'As': 1.88, 'Au': 2.32, 'B': 1.91, 'Ba': 3.03, 'Be': 1.98, 'Bi': 2.54, 'Bk': 3.4, 'Br': 1.86, 'C': 1.77, 'Ca': 2.62, 'Cd': 2.49, 'Ce': 2.88, 'Cf': 3.05, 'Cl': 1.82, 'Cm': 3.05, 'Co': 2.4, 'Cr': 2.45, 'Cs': 3.48, 'Cu': 2.38, 'Dy': 2.87, 'Er': 2.83, 'Es': 2.7, 'Eu': 2.87, 'F': 1.46, 'Fe': 2.44, 'Ga': 2.32, 'Gd': 2.83, 'Ge': 2.29, 'H': 1.2, 'He': 1.43, 'Hf': 2.63, 'Hg': 2.45, 'Ho': 2.81, 'I': 2.04, 'In': 2.43, 'Ir': 2.41, 'K': 2.73, 'Kr': 2.25, 'La': 2.98, 'Li': 2.12, 'Lu': 2.74, 'Mg': 2.51, 'Mn': 2.45, 'Mo': 2.45, 'N': 1.66, 'Na': 2.5, 'Nb': 2.56, 'Nd': 2.95, 'Ne': 1.58, 'Ni': 2.4, 'Np': 2.82, 'O': 1.5, 'Os': 2.48, 'P': 1.9, 'Pa': 2.88, 'Pb': 2.6, 'Pd': 2.15, 'Pr': 2.92, 'Pt': 2.29, 'Pu': 2.81, 'Rb': 3.21, 'Re': 2.49, 'Rh': 2.44, 'Ru': 2.46, 'S': 1.89, 'Sb': 2.47, 'Sc': 2.58, 'Se': 1.82, 'Si': 2.19, 'Sm': 2.9, 'Sn': 2.42, 'Sr': 2.84, 'Ta': 2.53, 'Tb': 2.79, 'Tc': 2.44, 'Te': 1.99, 'Th': 2.93, 'Ti': 2.46, 'Tl': 2.47, 'Tm': 2.79, 'U': 2.71, 'V': 2.42, 'W': 2.57, 'Xe': 2.06, 'Y': 2.75, 'Yb': 2.8, 'Zn': 2.39, 'Zr': 2.52}¶
Key-value pairs of chemical symbols and van der Waals radii.
- Reference:
S. Alvarez, “A cartography of the van der Waals territories,” Dalton Trans., vol. 42, no. 24, pp. 8617-8636, Jun. 2013, doi: 10.1039/C3DT50599E.
- adsorpy.molecule_lib.discorectangle(radius, distance, x_offset=0.0, y_offset=0.0)[source]¶
Create a disco-rectangle using the union of two circles and a rectangle.
The circles are automatically approximated using linear segments (error of 1% or less).
- 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).
- adsorpy.molecule_lib.dogbonium(scale=1.0)[source]¶
Make a molecule shaped like a bone. Used as a pathological case.
- adsorpy.molecule_lib.polygonium(verts=3, scale=1.0, roundedness=0.0)[source]¶
Create a simple regular polygon with optional rounding.
- 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, reference_lattice_spacing=1.0)[source]¶
Read files in the xyz format of VASP.
- Parameters:
file_name (
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 to filter out a slab.x_offset (
float) – The offset in the x direction.y_offset (
float) – The offset in the y 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.reference_lattice_spacing (float)
- Return type:
- Returns:
The molecule polygon read from the xyz file.
- adsorpy.molecule_lib._rotation_matrix(roll, pitch, yaw)[source]¶
Compute the 3D rotation matrix using roll, pitch, and yaw.
- class adsorpy.molecule_lib.MoleculeViewer(atomkeys, atompos, colours, init_roll=None, init_pitch=None, init_yaw=None, init_x_offset=None, init_y_offset=None, lattice=None)[source]¶
Bases:
QDialogMolecule spatial orientation and structural viewport configuration dashboard.
Manages dynamic 3D rotational coordinate matrices (roll, pitch, yaw) for complex molecular clusters and applies linear structural spatial clipping filters.
- Variables:
_settings – Persistent configuration handle cached across software operational cycles.
atomkeys – Active slice mappings capturing atomic parameters matching current view states.
atompos – Active slice mappings capturing 3D coordinates matching current view states.
colours – Active slice mappings capturing style colour tokens matching current view states.
lattice (
float) – Lattice physical constant constraint baseline scaling factor. Defaults to 1.0.show_bonds (
bool) – State indicator controlling rendering toggles for chemical covalent bounds.atom_toggles (
dict[str,QCheckBox]) – Active reference mapping linking atomic symbol labels to operational checkboxes.orig_atomkeys – Immutable baseline array tracking atomic keys loaded from source files.
orig_atompos – Immutable matrix holding coordinates across 3D vector parameters.
orig_colours – Immutable map listing style colour tokens for individual elements.
roll – Current rotation angle around the longitudinal axis.
pitch – Current elevation transformation offset angle.
yaw – Current horizontal rotation transformation offset angle.
x_offset – Baseline translation margin parallel to the abscissa.
y_offset – Baseline translation margin parallel to the ordinate.
min_z – Bounding minimum depth coordinate calculated from raw coordinates.
max_z – Bounding maximum depth coordinate calculated from raw coordinates.
z_cutoff – Active height clipping plane value used to filter hidden elements.
- Parameters:
Initialise matrix array buffers, orientation sliders, and plotting canvas frames.
- __init__(atomkeys, atompos, colours, init_roll=None, init_pitch=None, init_yaw=None, init_x_offset=None, init_y_offset=None, lattice=None)[source]¶
Initialise matrix array buffers, orientation sliders, and plotting canvas frames.
- property disabled_molecules: list[str] | None¶
Get a sorted list of disabled atom name keys or None if empty.
Identifies inactive elements via unchecked toggles and sorts them by ascending atomic weight indices using the master database registry.
- Returns:
Chronologically sorted elements or None if all toggles are active.
- _init_data(atomkeys, atompos, colours, init_roll=None, init_pitch=None, init_yaw=None, init_x_offset=None, init_y_offset=None)[source]¶
Convert list inputs into persistent raw NumPy matrices and configure boundaries.
- Parameters:
atomkeys (
list[str] |ndarray[tuple[int],dtype[str_]]) – list of strings of chemical symbols.atompos (
ndarray[tuple[Literal[3],int],dtype[double]]) – Intercept array tracking three-dimensional coordinates of atoms.colours (
list[str] |ndarray[tuple[int],dtype[str_]]) – Vector mapping hexadecimal colour tracking pointers.init_roll (
float|None) – Baseline matrix orientation transformation offset.init_pitch (
float|None) – Baseline matrix elevation transformation offset.init_yaw (
float|None) – Baseline matrix horizontal rotation transformation offset.init_x_offset (
float|None) – Baseline translation margin parallel to the abscissa.init_y_offset (
float|None) – Baseline translation margin parallel to the ordinate.
- Return type:
tuple[ndarray[tuple[int],dtype[str_]],ndarray[tuple[Literal[3],int],dtype[double]],ndarray[tuple[int],dtype[str_]]]- Returns:
Tuple containing configured baseline instance data arrays.
- _fetch_setting(name, default, return_type=None)[source]¶
Query registry fields from the application storage dictionary profile.
- Parameters:
- Return type:
- Returns:
Configured properties mapped to native execution type constraints.
- _create_filter_panel()[source]¶
Build the panel component hosting Z-cutoff adjustments and checkboxes.
- Return type:
- Returns:
Main target layout framework representing Column A.
- _create_plot_panel()[source]¶
Build the panel viewport frame displaying rendered molecular assets.
- Return type:
- Returns:
Main canvas workspace framework representing Column B.
- _add_slider_panel(target_layout)[source]¶
Append transformation sliders directly across the bottom container.
- Parameters:
target_layout (
QVBoxLayout|QHBoxLayout) – Top-level root layout accepting row insertions.- Return type:
- update_z_cutoff(value)[source]¶
Slot targeting real-time spinbox adjustments to update pipeline state.
- apply_atom_filters()[source]¶
Calculate boolean masks against root datasets and handle redraw requests.
- Return type:
- setup_bond_controls(layout)[source]¶
Create and connect the atomic bond visualisation toggle.
- Parameters:
layout (
QHBoxLayout|QVBoxLayout) – The QLayout instance (e.g., QVBoxLayout) where the checkbox should be added.- Return type:
- update_values(val, name, box_widget)[source]¶
Unifies slider-to-backend slot to keep widgets cleanly scoped.
- Parameters:
val (
float) – The value to update the attribute to.name (
str) – The name of the parameter to update.box_widget (
QDoubleSpinBox) – The QDoubleSpinBox widget to update.
- Return type:
- setup_lattice_controls(layout)[source]¶
Create and connect a standalone double spinbox for lattice spacing.
- Parameters:
layout (
QHBoxLayout|QVBoxLayout) – The layout instance where the widget should be added.- Return type:
- update_lattice_value(float_val)[source]¶
Directly sync the backend lattice variable and re-render the SVG canvas.
- submit_values(slider_widget, name, box_widget)[source]¶
Unified spinbox-to-slider slot handling native numerical typing.
- Parameters:
slider_widget (
QSlider) – The QSlider instance.name (
str) – The name of the parameter to update using setattr().box_widget (
QDoubleSpinBox) – The QDoubleSpinBox instance to link to the slider.
- Return type:
- transform()[source]¶
Transform the 3D atom coordinates using the roll, pitch, yaw, x-offset, and y-offset.
- _circles(pts, idx1, idx2, offset)[source]¶
Create svg Circles using the atom coordinates.
- Parameters:
- Return type:
list[Circle]- Returns:
A list of svg Circles.
- draw()[source]¶
Draw the molecule projection as a 2D SVG file with 4 tiles.
Top left: xy. Top right: yz. Bottom left: xz. Bottom right: xy van der Waals projection with reference.
- Return type:
- staticMetaObject = PySide6.QtCore.QMetaObject("MoleculeViewer" inherits "QDialog": )¶
- adsorpy.molecule_lib.first_time_loader(file_name, roll=0.0, pitch=0.0, yaw=0.0, x_offset=0.0, y_offset=0.0, ignore_atoms=None, z_trim=None, reference_lattice_spacing=1.0)[source]¶
Load molecule for the first time to save settings. Uses PySide6.
- Parameters:
file_name (
Path) – File path/name for the .xyz file to load the molecule from.ignore_atoms (
str|list[str] |None) – List of atoms to ignore. Leave empty to interactively toggle all.roll (
float) – Roll angle in degrees. Leave empty for default.pitch (
float) – Pitch angle in degrees.yaw (
float) – Yaw angle in degrees.x_offset (
float) – X offset in angstrom.y_offset (
float) – Y offset in angstrom.z_trim (
float|None) – Z trimming factor in angstrom. Filter all atoms with lower z values.reference_lattice_spacing (
float) – spacing for the reference lattice in angstrom.
- Return type:
- Returns:
“file_name”: str,
”roll”: float,
”pitch”: float,
”yaw”: float,
”x_offset”: float,
”y_offset”: float,
”ignore_atoms”: list[str],
”z_trim”: float | None
- adsorpy.molecule_lib._xyz_verifier(atomkeys, atompos, listed_molecule_count)[source]¶
Check if the .xyz file is of the correct format.
- Parameters:
- Raises:
If the .xyz file has no listed molecule count or an invalid count.
if the .xyz file’s molecule count does not match the read molecule count.
if the .xyz file contains bad molecule names.
if the atom keys and atom coordinate lists are not equal in length.
if coordinates are nan or infinite.
if the coordinates are not 3D.
- Return type:
- adsorpy.molecule_lib._initialise_reader(file_name, ignore_atoms=None, z_trim=None)[source]¶
Initialise the xyz_reader and first_time_loader.