Nanochemistry
nano.py module
API reference
- pyphyschemtools.nano.get_coordination_numbers(mol: Atoms, cutoff: float = None)[source]
Calculates the coordination number (CN) for each atom in an ASE Atoms object.
This function determines how many neighbors each atom has based on a distance threshold. If no cutoff is provided, it automatically estimates one based on the 1st percentile of the interatomic distance distribution.
- Parameters:
mol (ase.Atoms) – The structural model (nanoparticle, molecule, or crystal).
cutoff (float, optional) – The distance threshold (in Angstroms) to define a chemical bond. Defaults to None (automatic detection).
- Returns:
- A tuple containing:
cn (numpy.ndarray): An array of integers representing the CN of each atom.
used_cutoff (float): The actual cutoff value used for the calculation.
- Return type:
tuple
- pyphyschemtools.nano.view_coordination(mol: Atoms, cutoff: float = None, stick_radius: float = 0.1, sphere_scale: float = 0.6, w=600, h=400, color_map='YlOrRd')[source]
Visualizes a structure using py3Dmol with atoms color-coded by coordination number.
This function computes the coordination environment and generates a 3D ball-and-stick model where colors represent the connectivity (e.g., surface vs. bulk atoms). A Matplotlib legend is displayed alongside the 3D view.
The color logic is optimized for nanoparticles: - CN < 5 : Pastel (low coordination/isolated) - CN 5-13: Sequential Gradient (surface to bulk transition) - CN > 13: Deep Dark (high density/interstitials)
- Parameters:
mol (ase.Atoms) – The structural model to visualize.
cutoff (float, optional) – Distance threshold for bond detection. Defaults to None (auto-detect).
stick_radius (float, optional) – The thickness of the bonds in the 3D view. Defaults to 0.1.
sphere_scale (float, optional) – The size multiplier for the atomic spheres. Defaults to 0.6.
w (float, optional) – Width of the window Defaults to 600
h (float, optional) – Height of the window Defaults to 400
color_map (str, optional) – The Matplotlib colormap to use for discrete CN values. Defaults to “YlOrRd” (recommended!).
- Returns:
The interactive viewer object.
- Return type:
py3Dmol.view