Is there a neat way to figure out if a crystal structure in pymatgen is 2D or 3D? If we have a molecule we can feed its coordinates to (say) the ConvexHull method in scipy. Is there way to do the same for structure objects?
Yes you can indeed identify a crystsal structure's dimensionality in pymatgen. This is done by
pymatgen.analysis.dimensionality.get_dimensionality_gorai, which detects whether a structure is 3D, 2D (layered), or 1D (linear chains or molecules).
However, I highly recommend you to check out ASE, where the building and dimensionality identification of layered 2D structures are rather straightforward.
from ase.build import graphene, mx2, bulk from ase.geometry.dimensionality import analyze_dimensionality def get_dim(atoms, method='RDA'): return analyze_dimensionality(atoms, method=method).dimtype # Graphene monolayer graphene_atoms = graphene() dim1 = get_dim(graphene_atoms) print(dim1) # 2D # 3-layer MoS2 MoS2_atoms = mx2(formula='MoS2', kind='2H', a=3.18, thickness=3.19) dim2 = get_dim(MoS2_atoms) print(dim2) # 2D # Cu bulk Cu_atoms = bulk('Cu', 'fcc', a=4.0) dim3 = get_dim(Cu_atoms) print(dim3) # 3D