diff --git a/src/nomad_simulations/model_system.py b/src/nomad_simulations/model_system.py index 7303b1bb..ff2709d7 100644 --- a/src/nomad_simulations/model_system.py +++ b/src/nomad_simulations/model_system.py @@ -35,7 +35,7 @@ from nomad import config from nomad.units import ureg -from nomad.atomutils import Formula, get_normalized_wyckoff, search_aflow_prototype +from nomad.atomutils import Formula, get_normalized_wyckoff, search_aflow_prototype, get_composition from nomad.metainfo import Quantity, SubSection, SectionProxy, MEnum, Section, Context from nomad.datamodel.data import ArchiveSection @@ -901,6 +901,16 @@ class ModelSystem(System): """, ) + composition_formula = Quantity( + type=str, + shape=[], + description=""" + The overall composition of the system with respect to its subsystems. + The syntax for a system composed of X and Y with x and y components of each, + respectively, is X(x)Y(y). + """, + ) + model_system = SubSection(sub_section=SectionProxy('ModelSystem'), repeats=True) def resolve_system_type_and_dimensionality( @@ -967,6 +977,20 @@ def normalize(self, archive, logger) -> None: if is_not_representative(self, logger): return + # Traversing the System Hierarchy + def set_branch_composition(system, subsystems): + subsystems_labels = [subsystem.get("branch_label") for subsystem in subsystems] + system.composition = get_composition(subsystems_labels) + + def traverse_system_recurs(system): + subsystems = system.get("model_system") + if subsystems: + set_branch_composition(system, subsystems) + for subsystem in subsystems: + traverse_system_recurs(subsystem) + + traverse_system_recurs(self) + # Extracting ASE Atoms object from the originally parsed AtomicCell section if self.cell is None or len(self.cell) == 0: logger.warning( @@ -1000,4 +1024,4 @@ def normalize(self, archive, logger) -> None: if sec_chemical_formula.m_cache: self.elemental_composition = sec_chemical_formula.m_cache.get( 'elemental_composition', [] - ) + ) \ No newline at end of file diff --git a/src/nomad_simulations/utils/utils.py b/src/nomad_simulations/utils/utils.py index e2fe582f..a98a605b 100644 --- a/src/nomad_simulations/utils/utils.py +++ b/src/nomad_simulations/utils/utils.py @@ -125,7 +125,8 @@ def is_not_representative(model_system, logger: BoundLogger): if model_system is None: logger.warning('The `ModelSystem` is empty.') return None + #? Can we somehow only print this warning once in the case of many systems? if not model_system.is_representative: - logger.warning('The `ModelSystem` was not found to be representative.') + # logger.warning('The `ModelSystem` was not found to be representative.') return True return False