Commit 6903225e authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Modified the system type detection to use the full MatID detection mechanism...

Modified the system type detection to use the full MatID detection mechanism that can better distinguish surfaces and 2D materials. Updated the system type detection to use config values.
parent 85b49e0f
Pipeline #66581 failed with stages
in 29 minutes and 54 seconds
......@@ -181,11 +181,17 @@ normalize = NomadConfig(
# The system size limit for running the dimensionality analysis. For very
# large systems the dimensionality analysis will get too expensive.
system_classification_with_clusters_threshold=50,
# Symmetry tolerane controls the precision used by spglib in order to find
# Symmetry tolerance controls the precision used by spglib in order to find
# symmetries. The atoms are allowed to move 1/2*symmetry_tolerance from
# their symmetry positions in order for spglib to still detect symmetries.
# The unit is angstroms.
symmetry_tolerance=0.1
symmetry_tolerance=0.1,
# Maximum number of atoms in the single cell of a 2D material for it to be
# considered valid.
max_2d_single_cell_size=7,
# The distance tolerance between atoms for grouping them into the same
# cluster. Used in detecting system type.
cluster_threshold=3.1,
)
client = NomadConfig(
......
......@@ -88,7 +88,7 @@ the *backend*s for data were designed for creating data only and not very *pytho
Properties define what data a section instance can hold. Properties are mapped to Python
*descriptors*.
- `section` specialized `parant` relation with the containing `Section`
- `section` specialized `parent` relation with the containing `Section`
#### SubSections
......
......@@ -25,6 +25,8 @@ import fractions
from matid import SymmetryAnalyzer
from matid.geometry import get_dimensionality
from matid import Classifier
from matid.classifications import Atom, Class0D, Class1D, Class3D, Material2D, Surface
from nomadcore.structure_types import structure_types_by_spacegroup as str_types_by_spg
......@@ -264,31 +266,32 @@ class SystemNormalizer(SystemBasedNormalizer):
def system_type_analysis(self, atoms) -> None:
"""
Determine the dimensionality and hence the system type of the system with
Matid. Write the system type to the backend.
Determine the system type with Matid. Write the system type to the
backend. If it is too expensive to run Matid's system detection or if
the system is too large to analyze, the system type is left undefined
"""
system_type = config.services.unavailable_value
try:
if atoms.get_number_of_atoms() > config.normalize.system_classification_with_clusters_threshold:
# it is too expensive to run Matid's cluster detection, just check pbc
dimensionality = np.sum(atoms.get_pbc())
else:
dimensionality = get_dimensionality(
atoms, cluster_threshold=3.1, return_clusters=False)
if dimensionality is None:
pass
elif dimensionality == 0:
if atoms.get_number_of_atoms() == 1:
try:
if atoms.get_number_of_atoms() <= config.normalize.system_classification_with_clusters_threshold:
classifier = Classifier(
max_2d_single_cell_size=config.normalize.max_2d_single_cell_size,
cluster_threshold=config.normalize.clusters_threshold
)
class_matid = classifier.classify(atoms)
if isinstance(class_matid, Class1D):
system_type = '1D'
elif isinstance(class_matid, Surface):
system_type = 'surface'
elif isinstance(class_matid, Material2D):
system_type = '2D'
elif isinstance(class_matid, Class3D):
system_type = 'bulk'
elif isinstance(class_matid, Atom):
system_type = 'atom'
else:
elif isinstance(class_matid, Class0D):
system_type = 'molecule / cluster'
elif dimensionality == 1:
system_type = '1D'
elif dimensionality == 2:
system_type = '2D / surface'
elif dimensionality == 3:
system_type = 'bulk'
except Exception as e:
self.logger.error(
'matid project system classification failed', exc_info=e, error=str(e))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment