Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 37 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,54 @@ represent atomistic structures in python. The `structuretoolkit` is integrated i
## Disclaimer
The `structuretoolkit` is currently under development.

## Example
## Example

```python
import structuretoolkit as stk
from ase.build import bulk

structure = bulk("Al", cubic=True)
stk.analyse_cna_adaptive(structure)
stk.analyse.get_adaptive_cna_descriptors(structure)
stk.plot3d(structure)
```

## Features
### Analysis
* `get_neighbors`
* `get_neighborhood`
* `analyse_phonopy_equivalent_atoms`
* `get_steinhardt_parameter_structure`
* `analyse_centro_symmetry`
* `analyse_diamond_structure`
* `analyse_cna_adaptive`
* `analyse_voronoi_volume`
* `analyse_find_solids`
* `get_mean_positions`
* `get_average_of_unique_labels`
* `get_interstitials`
* `get_layers`
* `get_voronoi_vertices`
* `get_voronoi_neighbors`
* `get_delaunay_neighbors`
* `cluster_positions`
* `get_strain`
* `stk.analyse.get_neighbors()`
* `stk.analyse.get_neighborhood()`
* `stk.analyse.get_equivalent_atoms()`
* `stk.analyse.get_steinhardt_parameters()`
* `stk.analyse.get_centro_symmetry_descriptors()`
* `stk.analyse.get_diamond_structure_descriptors()`
* `stk.analyse.get_adaptive_cna_descriptors()`
* `stk.analyse.get_voronoi_volumes()`
* `stk.analyse.find_solids()`
* `stk.analyse.get_mean_positions()`
* `stk.analyse.get_average_of_unique_labels()`
* `stk.analyse.get_interstitials()`
* `stk.analyse.get_layers()`
* `stk.analyse.get_voronoi_vertices()`
* `stk.analyse.get_voronoi_neighbors()`
* `stk.analyse.get_delaunay_neighbors()`
* `stk.analyse.get_cluster_positions()`
* `stk.analyse.get_strain()`

### Build
* `grainboundary_build`
* `grainboundary_info`
* `get_sqs_structures`
* `B2`
* `C14`
* `C15`
* `C36`
* `D03`
* `stk.build.get_grainboundary_info()`
* `stk.build.grainboundary()`
* `stk.build.high_index_surface()`
* `stk.build.get_high_index_surface_info()`
* `stk.build.sqs_structures()`
* `stk.build.B2()`
* `stk.build.C14()`
* `stk.build.C15()`
* `stk.build.C36()`
* `stk.build.D03()`

### Visualize
* `plot3d`
* `stk.visualize.plot3d()`

### Common
* `stk.common.ase_to_pymatgen()`
* `stk.common.pymatgen_to_ase()`
* `stk.common.ase_to_pyscal()`
21 changes: 13 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,20 @@
keywords='pyiron',
packages=find_packages(exclude=["*tests*", "*docs*", "*binder*", "*conda*", "*notebooks*", "*.ci_support*"]),
install_requires=[
'aimsgb==0.1.1',
'ase==3.22.1',
'matplotlib==3.7.0',
'numpy==1.24.2',
'phonopy==2.17.1',
'pymatgen==2022.11.7',
'scipy==1.10.0',
'scikit-learn==1.2.1',
'spglib==2.0.2',
'matplotlib==3.7.0', # ase already requires matplotlib
'numpy==1.24.2', # ase already requires numpy
'scipy==1.10.0', # ase already requires scipy
],
extras_require={
"grainboundary": ['aimsgb==0.1.1', 'pymatgen==2022.11.7'],
"pyscal": ['pyscal2==2.10.20'],
"nglview": ['nglview==3.0.4'],
"plotly": ['plotly==5.14.1'],
"clusters": ['scikit-learn==1.2.1'],
"symmetry": ['spglib==2.0.2'],
"surface": ['spglib==2.0.2', 'pymatgen==2022.11.7'],
"phonopy": ['phonopy==2.17.1', 'spglib==2.0.2'],
},
cmdclass=versioneer.get_cmdclass(),
)
72 changes: 50 additions & 22 deletions structuretoolkit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,70 @@
# Analyse
from structuretoolkit.analyse.distance import get_distances_array, find_mic
from structuretoolkit.analyse.neighbors import get_neighbors, get_neighborhood
from structuretoolkit.analyse.phonopy import analyse_phonopy_equivalent_atoms
from structuretoolkit.analyse.pyscal import (
get_steinhardt_parameter_structure,
analyse_centro_symmetry,
analyse_diamond_structure,
analyse_cna_adaptive,
analyse_voronoi_volume,
analyse_find_solids,
)
from structuretoolkit.analyse.spatial import (
from structuretoolkit.analyse import (
get_distances_array,
find_mic,
get_neighbors,
get_neighborhood,
get_equivalent_atoms,
get_steinhardt_parameters,
get_centro_symmetry_descriptors,
get_diamond_structure_descriptors,
get_adaptive_cna_descriptors,
get_voronoi_volumes,
find_solids,
get_mean_positions,
get_average_of_unique_labels,
get_interstitials,
get_layers,
get_voronoi_vertices,
get_voronoi_neighbors,
get_delaunay_neighbors,
cluster_positions,
get_cluster_positions,
get_strain,
get_symmetry,
# for backwards compatibility
get_cluster_positions as cluster_positions,
get_equivalent_atoms as analyse_phonopy_equivalent_atoms,
get_steinhardt_parameters as get_steinhardt_parameter_structure,
get_centro_symmetry_descriptors as analyse_centro_symmetry,
get_diamond_structure_descriptors as analyse_diamond_structure,
get_adaptive_cna_descriptors as analyse_cna_adaptive,
get_voronoi_volumes as analyse_voronoi_volume,
find_solids as analyse_find_solids,
)
from structuretoolkit.analyse.strain import get_strain
from structuretoolkit.analyse.symmetry import get_symmetry

# Build
from structuretoolkit.build.aimsgb import grainboundary_build, grainboundary_info
from structuretoolkit.build.compound import B2, C14, C15, C36, D03
from structuretoolkit.build.sqs import get_sqs_structures
from structuretoolkit.build.surface import high_index_surface, high_index_surface_info
from structuretoolkit.build import (
grainboundary,
get_grainboundary_info,
B2,
C14,
C15,
C36,
D03,
sqs_structures,
high_index_surface,
get_high_index_surface_info,
# for backwards compatibility
grainboundary as grainboundary_build,
get_grainboundary_info as grainboundary_info,
sqs_structures as get_sqs_structures,
get_high_index_surface_info as high_index_surface_info,
)

# Other
from structuretoolkit.helper import (
# Visualize
from structuretoolkit.visualize import plot3d

# Common
from structuretoolkit.common import (
ase_to_pymatgen,
pymatgen_to_ase,
ase_to_pyscal,
get_atomic_numbers,
get_extended_positions,
get_vertical_length,
get_wrapped_coordinates,
select_index,
center_coordinates_in_unit_cell,
apply_strain,
SymmetryError,
)
from structuretoolkit.visualize import plot3d
48 changes: 48 additions & 0 deletions structuretoolkit/analyse/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from structuretoolkit.analyse.distance import get_distances_array, find_mic
from structuretoolkit.analyse.neighbors import get_neighbors, get_neighborhood
from structuretoolkit.analyse.phonopy import get_equivalent_atoms
from structuretoolkit.analyse.pyscal import (
get_steinhardt_parameters,
get_centro_symmetry_descriptors,
get_diamond_structure_descriptors,
get_adaptive_cna_descriptors,
get_voronoi_volumes,
find_solids,
ase_to_pyscal,
)
from structuretoolkit.analyse.spatial import (
get_mean_positions,
get_average_of_unique_labels,
get_interstitials,
get_layers,
get_voronoi_vertices,
get_voronoi_neighbors,
get_delaunay_neighbors,
get_cluster_positions,
)
from structuretoolkit.analyse.strain import get_strain


def get_symmetry(
structure, use_magmoms=False, use_elements=True, symprec=1e-5, angle_tolerance=-1.0
):
"""
Args:
structure (ase.atoms.Atoms): Atomistic Structure object
use_magmoms (bool): Whether to consider magnetic moments (cf. get_initial_magnetic_moments())
use_elements (bool): If False, chemical elements will be ignored
symprec (float): Symmetry search precision
angle_tolerance (float): Angle search tolerance

Returns:
symmetry (:class:`structuretoolkit.analyse.symmetry.Symmetry`): Symmetry class
"""
from structuretoolkit.analyse.symmetry import get_symmetry

return get_symmetry(
structure=structure,
use_magmoms=use_magmoms,
use_elements=use_elements,
symprec=symprec,
angle_tolerance=angle_tolerance,
)
10 changes: 8 additions & 2 deletions structuretoolkit/analyse/neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
# Distributed under the terms of "New BSD License", see the LICENSE file.

import numpy as np
from sklearn.cluster import AgglomerativeClustering
from scipy.sparse import coo_matrix
from scipy.special import gamma
from scipy.spatial.transform import Rotation
from scipy.special import sph_harm
from scipy.spatial import cKDTree
import warnings
import itertools
from structuretoolkit.helper import get_extended_positions, get_average_of_unique_labels
from structuretoolkit.common.helper import (
get_extended_positions,
get_average_of_unique_labels,
)

__author__ = "Joerg Neugebauer, Sam Waseda"
__copyright__ = (
Expand Down Expand Up @@ -905,6 +907,8 @@ def cluster_by_vecs(
`euclidean` is accepted.

"""
from sklearn.cluster import AgglomerativeClustering

if distance_threshold is None and n_clusters is None:
distance_threshold = np.min(self.filled.distances)
dr = self.flattened.vecs
Expand Down Expand Up @@ -952,6 +956,8 @@ def cluster_by_distances(
obtained from the clustered vectors is used for the distance clustering. Otherwise
neigh.distances is used.
"""
from sklearn.cluster import AgglomerativeClustering

if distance_threshold is None:
distance_threshold = 0.1 * np.min(self.flattened.distances)
dr = self.flattened.distances
Expand Down
7 changes: 4 additions & 3 deletions structuretoolkit/analyse/phonopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Distributed under the terms of "New BSD License", see the LICENSE file.

import numpy as np
from phonopy.structure.atoms import PhonopyAtoms
import spglib as spg

__author__ = "Osamu Waseda"
__copyright__ = (
Expand All @@ -18,7 +16,7 @@
__date__ = "Sep 1, 2018"


def analyse_phonopy_equivalent_atoms(structure, symprec=1e-5, angle_tolerance=-1.0):
def get_equivalent_atoms(structure, symprec=1e-5, angle_tolerance=-1.0):
"""
Args: (read phonopy.structure.spglib for more details)
symprec:
Expand All @@ -29,6 +27,9 @@ def analyse_phonopy_equivalent_atoms(structure, symprec=1e-5, angle_tolerance=-1
is used to judge symmetry.

"""
import spglib as spg
from phonopy.structure.atoms import PhonopyAtoms

positions = structure.get_scaled_positions()
cell = structure.cell
types = structure.get_chemical_symbols()
Expand Down
Loading