Skip to content

Commit

Permalink
marked issues from calls to ase functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernadette-Mohr committed Dec 3, 2024
1 parent c84d77e commit 243cbb6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/nomad_simulations/schema_packages/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 []
)
Expand Down
30 changes: 17 additions & 13 deletions src/nomad_simulations/schema_packages/model_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ class Cell(GeometricSpace):
""",
)

# TODO: default "unavailable"?
type = Quantity(
type=MEnum('original', 'primitive', 'conventional'),
description="""
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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="""
Expand Down Expand Up @@ -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', []
)

0 comments on commit 243cbb6

Please sign in to comment.