Skip to content

Commit

Permalink
Merge branch 'develop' into coupled_cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
EBB2675 committed Sep 25, 2024
2 parents 022c1fa + 5d162aa commit bf1f6f4
Show file tree
Hide file tree
Showing 47 changed files with 326 additions and 788 deletions.
36 changes: 36 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cff-version: 1.2.0
title: NOMAD Simulations
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: José M.
family-names: Pizarro
orcid: 'https://orcid.org/0000-0002-6751-8192'
- given-names: Esma B.
family-names: Boydas
orcid: 'https://orcid.org/0009-0005-6729-4706'
- given-names: Nathan
family-names: Daelman
orcid: 'https://orcid.org/0000-0002-7647-1816'
- given-names: Alvin Noe
family-names: Ladines
orcid: 'https://orcid.org/0000-0003-0077-2097'
- given-names: Bernadette
family-names: Mohr
orcid: 'https://orcid.org/0000-0003-0903-0073'
- given-names: Joseph F.
family-names: Rudzinski
orcid: 'https://orcid.org/0000-0003-3403-640X'
doi:
repository-code: 'https://github.com/nomad-coe/nomad-simulations'
url: 'https://nomad-coe.github.io/nomad-simulations/'
abstract: >-
`nomad-simulations` is a plugin for the NOMAD software (https://zenodo.org/doi/10.5281/zenodo.8366162)
providing a common data standard and analysis tools for parsed Materials Science and Quantum Chemistry
simulations. This standard is used as a template and is populated by the many available NOMAD parsers to transform their
inputs / outputs into a structured data format. This plugin is community-driven, and users are encourage to
contribute towards providing Findable, Accessible, Interoperable, and Reusable (FAIR) data.
license: Apache-2.0
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@
![](https://coveralls.io/repos/github/nomad-coe/nomad-simulations/badge.svg?branch=develop)
![](https://img.shields.io/pypi/v/nomad-simulations)
![](https://img.shields.io/pypi/pyversions/nomad-simulations)
[![DOI](https://zenodo.org/badge/744481756.svg)](https://zenodo.org/badge/latestdoi/744481756)



# `nomad-simulations`

This is a plugin for [NOMAD](https://nomad-lab.eu) which contains the base sections definitions for materials science simulations. This schema can be used at any prefered level by the user, it can be modified and extended, and we welcome external collaborators.
The `nomad-simulations` is an open-source Python package for managing Materials Science simulation data. It is following the plugin architechture of [NOMAD](https://nomad-lab.eu). This package contains a set of section definitions (Python classes) with quantities (attributes) and methods defined to automate data extraction from different simulation codes. These section definitions can be used at any prefered level by the user, they can be modified and extended, and we welcome external collaborators.

Read more in the [official documentation](https://nomad-coe.github.io/nomad-simulations/) page.


## Getting started

`nomad-simulations` can be installed as a PyPI package using `pip`:

> [!WARNING]
> Unfortunately, the current plugin mechanism is not supported by the latest nomad-lab version on PyPI and therefore an index url pointing to the NOMAD Gitlab registry needs to be added.
```sh
pip install nomad-simulations
pip install nomad-simulations --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple
```


Expand Down Expand Up @@ -48,6 +55,11 @@ The plugin is still under development. If you would like to contribute, install
uv pip install -e '.[dev]'
```

**Note:** If you do not use `uv`, you need to add the `--index-url` flag as in the PyPI command for installing the package:
```sh
pip install -e '.[dev]' --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple
```


### Run the tests

Expand Down Expand Up @@ -138,7 +150,7 @@ Read the [NOMAD plugin documentation](https://nomad-lab.eu/prod/v1/staging/docs/
Modify the script under `/nomad/scripts/install_default_plugins.sh` and add the path to this repository pointing to the `@develop` branch:
```sh
<other-content-in-install_default_plugins.sh...>
pip install git+https://github.com/nomad-coe/nomad-simulations.git@develop
git+https://github.com/nomad-coe/nomad-simulations.git@develop
```

Then, go to your NOMAD folder, activate your NOMAD virtual environment and run:
Expand All @@ -160,6 +172,8 @@ plugins:
**Note!**
Once you modify your `nomad.yaml` file adding `include`, all the default plugins will be disconnected, so you will need to include them as well.

## How to cite this work
Pizarro, J.M., Boydas, E.B., Daelman, N., Ladines, A.N., Mohr, B. & Rudzinski, J.F., NOMAD Simulations [Computer software]. https://doi.org/xxxxx

## Main contributors
| Name | E-mail | Topics | Github profiles |
Expand Down
28 changes: 7 additions & 21 deletions src/nomad_simulations/schema_packages/__init__.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
#
# 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.
#

from nomad.config.models.plugins import SchemaPackageEntryPoint
from pydantic import Field


class NOMADSimulationsEntryPoint(SchemaPackageEntryPoint):
dos_energy_tolerance: float = Field(
8.01088e-21,
description='Tolerance of the DOS energies in Joules to match the reference of energies in the DOS normalize function.',
description='Tolerance (in joules) of the DOS energies to match the reference of energies in the DOS normalize function.',
)
dos_intensities_threshold: float = Field(
1e-8,
description='Threshold value at which the DOS intensities are considered non-zero.',
description='Threshold value (in joules^-1) at which the DOS intensities are considered non-zero.',
)
occupation_tolerance: float = Field(
1e-3,
description='Tolerance for the occupation of a eigenstate to be non-occupied.',
)
fermi_surface_tolerance: float = Field(
1e-8,
description='Tolerance for energies to be close to the Fermi level and hence define the Fermi surface of a material.',
description='Tolerance (in joules) for energies to be close to the Fermi level and hence define the Fermi surface of a material.',
)
symmetry_tolerance: float = Field(
0.1, description='Tolerance for the symmetry analyzer used from MatID.'
Expand All @@ -48,6 +30,10 @@ class NOMADSimulationsEntryPoint(SchemaPackageEntryPoint):
64,
description='Limite of the number of atoms in the unit cell to be treated for the system type classification from MatID to work. This is done to avoid overhead of the package.',
)
equal_cell_positions_tolerance: float = Field(
1e-12,
description='Tolerance (in meters) for the cell positions to be considered equal.',
)

def load(self):
from nomad_simulations.schema_packages.general import m_package
Expand Down
18 changes: 0 additions & 18 deletions src/nomad_simulations/schema_packages/atoms_state.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
#
# 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.
#

from typing import TYPE_CHECKING, Any, Optional, Union

import ase
Expand Down
18 changes: 0 additions & 18 deletions src/nomad_simulations/schema_packages/general.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
#
# 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.
#

from typing import TYPE_CHECKING

if TYPE_CHECKING:
Expand Down
18 changes: 0 additions & 18 deletions src/nomad_simulations/schema_packages/model_method.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
#
# 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
from typing import TYPE_CHECKING, Optional

Expand Down
88 changes: 70 additions & 18 deletions src/nomad_simulations/schema_packages/model_system.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
#
# 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
from typing import TYPE_CHECKING, Optional

Expand Down Expand Up @@ -296,6 +278,46 @@ class Cell(GeometricSpace):
""",
)

def _check_positions(self, positions_1, positions_2) -> list:
# Check that all the `positions`` of `cell_1` match with the ones in `cell_2`
check_positions = []
for i1, pos1 in enumerate(positions_1):
for i2, pos2 in enumerate(positions_2):
if np.allclose(
pos1, pos2, atol=configuration.equal_cell_positions_tolerance
):
check_positions.append([i1, i2])
break
return check_positions

def is_equal_cell(self, other) -> bool:
"""
Check if the cell is equal to an`other` cell by comparing the `positions`.
Args:
other: The other cell to compare with.
Returns:
bool: True if the cells are equal, False otherwise.
"""
# TODO implement checks on `lattice_vectors` and other quantities to ensure the equality of primitive cells
if not isinstance(other, Cell):
return False

# If the `positions` are empty, return False
if self.positions is None or other.positions is None:
return False

# The `positions` should have the same length (same number of positions)
if len(self.positions) != len(other.positions):
return False
n_positions = len(self.positions)

check_positions = self._check_positions(
positions_1=self.positions, positions_2=other.positions
)
if len(check_positions) != n_positions:
return False
return True

def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
super().normalize(archive, logger)

Expand Down Expand Up @@ -339,6 +361,36 @@ def __init__(self, m_def: 'Section' = None, m_context: 'Context' = None, **kwarg
# Set the name of the section
self.name = self.m_def.name

def is_equal_cell(self, other) -> bool:
"""
Check if the atomic cell is equal to an`other` atomic cell by comparing the `positions` and
the `AtomsState[*].chemical_symbol`.
Args:
other: The other atomic cell to compare with.
Returns:
bool: True if the atomic cells are equal, False otherwise.
"""
if not isinstance(other, AtomicCell):
return False

# Compare positions using the parent sections's `__eq__` method
if not super().is_equal_cell(other=other):
return False

# Check that the `chemical_symbol` of the atoms in `cell_1` match with the ones in `cell_2`
check_positions = self._check_positions(
positions_1=self.positions, positions_2=other.positions
)
try:
for atom in check_positions:
element_1 = self.atoms_state[atom[0]].chemical_symbol
element_2 = other.atoms_state[atom[1]].chemical_symbol
if element_1 != element_2:
return False
except Exception:
return False
return True

def to_ase_atoms(self, logger: 'BoundLogger') -> Optional[ase.Atoms]:
"""
Generates an ASE Atoms object with the most basic information from the parsed `AtomicCell`
Expand Down
18 changes: 0 additions & 18 deletions src/nomad_simulations/schema_packages/numerical_settings.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
#
# 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.
#

from itertools import accumulate, chain, tee
from typing import TYPE_CHECKING, Optional, Union

Expand Down
18 changes: 0 additions & 18 deletions src/nomad_simulations/schema_packages/outputs.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
#
# 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.
#

from typing import TYPE_CHECKING, Optional

import numpy as np
Expand Down
18 changes: 0 additions & 18 deletions src/nomad_simulations/schema_packages/physical_property.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
#
# 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.
#

from functools import wraps
from typing import TYPE_CHECKING, Any, Optional

Expand Down
Loading

2 comments on commit bf1f6f4

@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.py1902189%13–15, 201–204, 228, 283–284, 352–353, 355, 537, 549–550, 611–615, 630–634, 641
   basis_set.py2452988%8–9, 122–133, 172–185, 236–237, 419–423, 445–446, 490–493, 612, 643, 645
   general.py89891%4–7, 121, 185, 295–296, 306
   model_method.py2657771%10–12, 171–174, 177–184, 276–277, 297, 318–339, 355–381, 384–401, 755, 766, 808–815, 853, 872, 952, 1009, 1084, 1198
   model_system.py2962392%25–27, 378, 572–575, 622–629, 803–804, 1025–1029, 1035–1036, 1044–1045, 1050, 1073
   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
   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.py701480%8–11, 65–74, 83–84, 89, 92
TOTAL252949880% 

Tests Skipped Failures Errors Time
401 0 💤 0 ❌ 0 🔥 5.720s ⏱️

@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.py1902189%13–15, 201–204, 228, 283–284, 352–353, 355, 537, 549–550, 611–615, 630–634, 641
   basis_set.py2452988%8–9, 122–133, 172–185, 236–237, 419–423, 445–446, 490–493, 612, 643, 645
   general.py89891%4–7, 121, 185, 295–296, 306
   model_method.py2657771%10–12, 171–174, 177–184, 276–277, 297, 318–339, 355–381, 384–401, 755, 766, 808–815, 853, 872, 952, 1009, 1084, 1198
   model_system.py2962392%25–27, 378, 572–575, 622–629, 803–804, 1025–1029, 1035–1036, 1044–1045, 1050, 1073
   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
   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.py701480%8–11, 65–74, 83–84, 89, 92
TOTAL252949880% 

Tests Skipped Failures Errors Time
401 0 💤 0 ❌ 0 🔥 5.683s ⏱️

Please sign in to comment.