Skip to content

Commit

Permalink
mostly working implementation of particle cell
Browse files Browse the repository at this point in the history
  • Loading branch information
jrudz committed Dec 5, 2024
1 parent e9e830a commit 12a446f
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 683 deletions.
5 changes: 0 additions & 5 deletions src/nomad_simulations/schema_packages/atoms_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,6 @@ class State(Entity):

def __init__(self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs):
super().__init__(m_def, m_context, **kwargs)
self.labels = None


class AtomsState(State):
Expand Down Expand Up @@ -651,7 +650,3 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
self.chemical_symbol = self.resolve_chemical_symbol(logger=logger)
if self.atomic_number is None:
self.atomic_number = self.resolve_atomic_number(logger=logger)

# Set the labels
if self.chemical_symbol is not None:
self.labels = self.chemical_symbol
29 changes: 11 additions & 18 deletions src/nomad_simulations/schema_packages/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ def _set_system_branch_depth(
)

#! Generalize from checks for atomic systems, error with CG input
def resolve_composition_formula(self, system_parent: ModelSystem) -> None:
def resolve_composition_formula(
self, system_parent: ModelSystem, logger: 'BoundLogger'
) -> None:
"""Determine and set the composition formula for `system_parent` and all of its
descendants.
Expand All @@ -246,13 +248,15 @@ def set_composition_formula(
to the atom indices stored in system.
"""
if not subsystems:
atom_indices = (
system.atom_indices if system.atom_indices is not None else []
particle_indices = (
system.particle_indices
if system.particle_indices is not None
else []
)
subsystem_labels = (
[np.array(labels)[atom_indices]]
[np.array(labels)[particle_indices]]
if labels
else ['Unknown' for atom in range(len(atom_indices))]
else ['Unknown' for atom in range(len(particle_indices))]
)
else:
subsystem_labels = [
Expand Down Expand Up @@ -284,18 +288,7 @@ def get_composition_recurs(system: ModelSystem, labels: list[str]) -> None:
# ! CG: system_parent.cell[0].particles_state instead of atoms_state!
labels = []
if system_parent.cell is not None:
if system_parent.cell[0].name == 'AtomicCell':
labels = (
[atom.labels for atom in system_parent.cell[0].atoms_state]
if system_parent.cell[0].atoms_state is not None
else []
)
elif system_parent.cell[0].name == 'ParticleCell':
labels = (
[atom.labels for atom in system_parent.cell[0].particles_state]
if system_parent.cell[0].particles_state is not None
else []
)
labels = system_parent.cell[0].get('labels', logger=logger)

get_composition_recurs(system=system_parent, labels=labels)

Expand All @@ -322,7 +315,7 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:

if is_not_representative(model_system=system_parent, logger=logger):
continue
self.resolve_composition_formula(system_parent=system_parent)
self.resolve_composition_formula(system_parent=system_parent, logger=logger)


m_package.__init_metainfo__()
2 changes: 1 addition & 1 deletion src/nomad_simulations/schema_packages/model_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def resolve_orbital_references(
# If the child is not an "active_atom", the normalization will not run
if active_atom.type != 'active_atom':
continue
indices = active_atom.atom_indices
indices = active_atom.particle_indices
for index in indices:
try:
active_atoms_state = atoms_state[index]
Expand Down
Loading

1 comment on commit 12a446f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/nomad_simulations
   __init__.py4250%3–4
   _version.py11282%5–6
src/nomad_simulations/schema_packages
   __init__.py15287%39–41
   atoms_state.py1932189%13–15, 201–204, 228, 283–284, 352–353, 355, 537, 549–550, 620–624, 639–643, 650
   basis_set.py2402888%8–9, 122–133, 172–185, 208, 391–395, 417–418, 462–465, 584, 615, 617
   general.py90594%128, 192, 302–303, 313
   model_method.py2697871%10–12, 171–174, 177–184, 276–277, 297, 318–339, 355–381, 384–401, 587, 780, 791, 833–840, 878, 897, 977, 1034, 1109, 1223
   model_system.py3986384%46–52, 238, 257, 261, 264, 267, 293, 387–388, 415–420, 426, 429, 432–435, 453–454, 460–462, 576–577, 594–595, 622–624, 637–646, 778–781, 828–835, 1009–1010, 1234–1238, 1244–1245, 1253–1254, 1259, 1283
   numerical_settings.py2596176%12–14, 217, 219–220, 223–226, 230–231, 238–241, 250–253, 257–260, 262–265, 270–273, 279–282, 469–496, 571, 606–609, 633, 636, 681, 683–686, 690, 694, 741, 745–766, 821–822, 889
   outputs.py1201092%9–10, 252–255, 295–298, 323, 325, 362, 381
   particles_state.py321262%17–19, 104–109, 112–116
   physical_property.py102793%20–22, 202, 331–333
   variables.py861286%8–10, 98, 121, 145, 167, 189, 211, 233, 256, 276
src/nomad_simulations/schema_packages/properties
   band_gap.py51590%8–10, 135–136
   band_structure.py1232580%9–11, 232–265, 278, 285, 321–322, 325, 372–373, 378
   energies.py42979%7–9, 36, 57, 82, 103, 119, 134
   fermi_surface.py17476%7–9, 40
   forces.py22673%7–9, 36, 56, 79
   greens_function.py991387%7–9, 210–211, 214, 235–236, 239, 260–261, 264, 400
   hopping_matrix.py29583%7–9, 58, 94
   permittivity.py48883%7–9, 97–105
   spectral_profile.py26012851%9–11, 57–60, 95–98, 199–300, 356–368, 393–396, 416, 421–424, 466–502, 526, 573–576, 592–593, 598–604
   thermodynamics.py752764%7–9, 35, 56, 72, 81, 90, 101, 110, 137, 147, 157, 172–174, 177, 193, 213–215, 218, 234, 254–256, 259
src/nomad_simulations/schema_packages/utils
   utils.py791877%8–11, 56–57, 66–75, 84–85, 90, 93, 170–171
TOTAL267555179% 

Tests Skipped Failures Errors Time
402 0 💤 1 ❌ 0 🔥 7.093s ⏱️

Please sign in to comment.