Skip to content

Commit

Permalink
Added initial modules for ModelMethod and Outputs
Browse files Browse the repository at this point in the history
Fixed conditions in AtomicCell normalizer
  • Loading branch information
JosePizarro3 committed Jan 29, 2024
1 parent de186a5 commit 300fd2a
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 17 deletions.
21 changes: 7 additions & 14 deletions simulationdataschema/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,20 @@
from nomad.datamodel.metainfo.basesections import Simulation as BaseSimulation
from nomad.metainfo import SubSection
from .model_system import ModelSystem
from .model_method import ModelMethod
from .outputs import Outputs


class Simulation(BaseSimulation, EntryData):
""" """

# m_def = Section(extends_base_section=True)

model_system = SubSection(sub_section=ModelSystem.m_def, repeats=True)
# method = SubSection(
# sub_section=Method.m_def,
# description='''
# The input methodological parameters used for the computation.
# ''',
# repeats=True,
# )
# calculation = SubSection(
# sub_section=Calculation.m_def,
# description='''
# The output of a computation. It can reference a specific system and method section.
# ''',
# repeats=True,
# )

model_method = SubSection(sub_section=ModelMethod.m_def, repeats=True)

outputs = SubSection(sub_section=Outputs.m_def, repeats=True)

def _set_system_tree_index(self, system_parent: ModelSystem, tree_index: int = 0):
for system_child in system_parent.model_system:
Expand Down
52 changes: 52 additions & 0 deletions simulationdataschema/model_method.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD. See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD.
# See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import re
import numpy as np

from nomad.units import ureg
from nomad.datamodel.data import ArchiveSection
from nomad.metainfo import Quantity, SubSection, SectionProxy, MEnum


class ModelMethod(ArchiveSection):
""" """

normalizer_level = 1

def normalize(self, archive, logger):
super().normalize(archive, logger)
self.logger = logger
6 changes: 3 additions & 3 deletions simulationdataschema/model_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def normalize(self, archive, logger):
return

# If the labels and atomic_numbers are not specified, we return with an error
if not self.labels and not self.atomic_numbers:
if self.labels is None and self.atomic_numbers is None:
logger.error(
"Could not read parsed AtomicCell.labels or AtomicCell.atomic_positions."
)
Expand All @@ -267,7 +267,7 @@ def normalize(self, archive, logger):
atomic_numbers = self.atomic_numbers

# Labels
if not atomic_labels and atomic_numbers is not None:
if atomic_labels is None and atomic_numbers is not None:
try:
atomic_labels = [
ase.data.chemical_symbols[number] for number in atomic_numbers
Expand All @@ -286,7 +286,7 @@ def normalize(self, archive, logger):
self.m_cache["ase_atoms"] = ase_atoms

# Atomic numbers
if atomic_labels is not None and not atomic_numbers:
if atomic_labels is not None and atomic_numbers is None:
atomic_numbers = ase_atoms.get_atomic_numbers()
self.atomic_numbers = atomic_numbers

Expand Down
52 changes: 52 additions & 0 deletions simulationdataschema/outputs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD. See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD.
# See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import re
import numpy as np

from nomad.units import ureg
from nomad.datamodel.data import ArchiveSection
from nomad.metainfo import Quantity, SubSection, SectionProxy, MEnum


class Outputs(ArchiveSection):
""" """

normalizer_level = 2

def normalize(self, archive, logger):
super().normalize(archive, logger)
self.logger = logger

0 comments on commit 300fd2a

Please sign in to comment.