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?


1 Answer 1


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)[0].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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .