diff --git a/src/nomad_simulations/schema_packages/general.py b/src/nomad_simulations/schema_packages/general.py index 9a2d48f0..59777858 100644 --- a/src/nomad_simulations/schema_packages/general.py +++ b/src/nomad_simulations/schema_packages/general.py @@ -217,6 +217,7 @@ def _set_system_branch_depth( system_parent=system_child, branch_depth=branch_depth + 1 ) + #! Generalize from checks for atomic systems, error with CG input def resolve_composition_formula(self, system_parent: ModelSystem) -> None: """Determine and set the composition formula for `system_parent` and all of its descendants. @@ -275,6 +276,7 @@ def get_composition_recurs(system: ModelSystem, atom_labels: list[str]) -> None: for subsystem in subsystems: get_composition_recurs(system=subsystem, atom_labels=atom_labels) + # ! CG: system_parent.cell[0].particles_state instead of atoms_state! atoms_state = ( system_parent.cell[0].atoms_state if system_parent.cell is not None else [] ) diff --git a/src/nomad_simulations/schema_packages/model_system.py b/src/nomad_simulations/schema_packages/model_system.py index f23c3e19..21cd6ad4 100644 --- a/src/nomad_simulations/schema_packages/model_system.py +++ b/src/nomad_simulations/schema_packages/model_system.py @@ -305,6 +305,7 @@ class Cell(GeometricSpace): """, ) + # TODO: default "unavailable"? type = Quantity( type=MEnum('original', 'primitive', 'conventional'), description=""" @@ -660,11 +661,11 @@ def to_particles(self, logger: 'BoundLogger') -> Optional[Particles]: self.periodic_boundary_conditions = [False, False, False] particles.set_pbc(pbc=self.periodic_boundary_conditions) - # # Lattice vectors - # if self.lattice_vectors is not None: - # ase_atoms.set_cell(cell=self.lattice_vectors.to('angstrom').magnitude) - # else: - # logger.info('Could not find `AtomicCell.lattice_vectors`.') + # Lattice vectors + if self.lattice_vectors is not None: + particles.set_cell(cell=self.lattice_vectors.to('angstrom').magnitude) + else: + logger.info('Could not find `ParticleCell.lattice_vectors`.') # Positions if self.positions is not None: @@ -1088,6 +1089,7 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None: self.m_cache['elemental_composition'] = formula.elemental_composition() +# TODO: generalize! indices instead of atom_indices, state instead of atoms_state... class ModelSystem(System): """ Model system used as an input for simulating the material. @@ -1252,6 +1254,7 @@ class ModelSystem(System): """, ) + # TODO: make this work with non_atomic systems: global_composition_formula of entire system with respect to lower layers composition_formula = Quantity( type=str, description=""" @@ -1367,11 +1370,12 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None: sec_symmetry = self.m_create(Symmetry) sec_symmetry.normalize(archive, logger) - # Creating and normalizing ChemicalFormula section - # TODO add support for fractional formulas (possibly add `AtomicCell.concentrations` for each species) - sec_chemical_formula = self.m_create(ChemicalFormula) - sec_chemical_formula.normalize(archive, logger) - if sec_chemical_formula.m_cache: - self.elemental_composition = sec_chemical_formula.m_cache.get( - 'elemental_composition', [] - ) + #! ChemicalFormula calls `ase_atoms = atomic_cell.to_ase_atoms(logger=logger)` and `ase_atoms.get_chemical_formula()` + # Creating and normalizing ChemicalFormula section + # TODO add support for fractional formulas (possibly add `AtomicCell.concentrations` for each species) + sec_chemical_formula = self.m_create(ChemicalFormula) + sec_chemical_formula.normalize(archive, logger) + if sec_chemical_formula.m_cache: + self.elemental_composition = sec_chemical_formula.m_cache.get( + 'elemental_composition', [] + )