Skip to content

Commit c39e2fb

Browse files
authored
Aiida plugin (#72)
* add the aiida plugin * update uv.lock & pyproject.toml * fix pre-commit * improve property match check; fix aiida plugin * aiida-plugin: make group optional * print uuid for structure that errors * switch to ase conversion
1 parent a3ee788 commit c39e2fb

File tree

12 files changed

+1776
-225
lines changed

12 files changed

+1776
-225
lines changed

examples/aiida_archive/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
optimade.jsonl
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"id": "4453cd37-17fd-4022-b571-ccd639bb6bd0", "type": "structures", "links": null, "meta": null, "attributes": {"immutable_id": "4453cd37-17fd-4022-b571-ccd639bb6bd0", "last_modified": "2025-02-21T17:24:17.741830+00:00", "elements": ["C"], "nelements": 1, "elements_ratios": [1.0], "chemical_formula_descriptive": "C2", "chemical_formula_reduced": "C", "chemical_formula_hill": null, "chemical_formula_anonymous": "A", "dimension_types": [1, 1, 1], "nperiodic_dimensions": 3, "lattice_vectors": [[0.0, 1.777412397431, 1.777412397431], [1.777412397431, 0.0, 1.777412397431], [1.777412397431, 1.777412397431, 0.0]], "space_group_symmetry_operations_xyz": null, "space_group_symbol_hall": null, "space_group_symbol_hermann_mauguin": null, "space_group_symbol_hermann_mauguin_extended": null, "space_group_it_number": null, "cartesian_site_positions": [[0.0, 0.0, 1.777412397431], [0.8887061987155, 2.6661185961465, 0.8887061987155]], "nsites": 2, "species": [{"name": "C", "chemical_symbols": ["C"], "concentration": [1.0], "mass": null, "original_name": null, "attached": null, "nattached": null}], "species_at_sites": ["C", "C"], "assemblies": null, "structure_features": [], "_optimake_test_extra": null, "_optimake_ctime": "2025-02-21T17:24:17.534593+00:00", "_optimake_energy": -492.9169718438, "_optimake_band_gap": 4.0381280210178, "_optimake_is_band_gap_direct": false, "_optimake_csv_property": 1}, "relationships": null}

examples/aiida_archive/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Aiida example
2+
3+
The example AiiDA database contains three crystals:
4+
5+
- diamond (C<sub>2</sub>) (uuid: `4453cd37-17fd-4022-b571-ccd639bb6bd0`);
6+
- GaAs (uuid: `598c08c4-793f-4afb-b39e-d0c947821c6f`);
7+
- MgO (uuid: `c52d8ad2-2440-4b00-99ab-39b987d88c18`),
8+
9+
where C<sub>2</sub> and GaAs have band structures calculated with Quantum Espresso, and MgO has no calculations done on it. The band structure calculation provenance is shown in the following schematic:
10+
11+
```mermaid
12+
graph LR;
13+
A("Initial crystal<br>(StructureData)") --> B["PwBandsWorkChain"];
14+
B --> C("Relaxed crystal<br>(StructureData)");
15+
B --> D("SCF parameters<br>(Dict)");
16+
B --> E("Band structure<br>(BandsData)");
17+
E --> F["get_bandgap<br>(CalcFunctionNode)"];
18+
F --> G("Band gap results<br>(Dict)");
19+
20+
style A fill:#004400;
21+
style B fill:#442200;
22+
style C fill:#004400;
23+
style D fill:#004400;
24+
style E fill:#004400;
25+
style F fill:#442200;
26+
style G fill:#004400;
27+
```
28+
29+
We want to include the "Relaxed crystal" nodes as OPTIMADE structures, and include custom properties from the various other AiiDA nodes (e.g. the band gap value from the "Band gap results" node). The example `optimade.yaml` shows how to achieve this.

examples/aiida_archive/data.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
id,csv_property
2+
4453cd37-17fd-4022-b571-ccd639bb6bd0,1
3+
598c08c4-793f-4afb-b39e-d0c947821c6f,2
4+
c52d8ad2-2440-4b00-99ab-39b987d88c18,3

examples/aiida_archive/example.aiida

1.59 MB
Binary file not shown.

examples/aiida_archive/optimade.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
config_version: 0.1.0
2+
3+
database_description: >-
4+
This example aiida database contains optimized structures and band structure calculations.
5+
6+
entries:
7+
- entry_type: structures
8+
entry_paths:
9+
aiida_file: example.aiida # Aiida archive file, or
10+
#aiida_profile: test-profile # Aiida profile
11+
aiida_group: optimade_structures
12+
property_paths:
13+
# If all properties are stored in the AiiDA database,
14+
# this can be omitted. But additional properties can be
15+
# provided via a csv file.
16+
- file: data.csv
17+
property_definitions:
18+
# ----
19+
- name: test_extra
20+
title: Test extra
21+
description: Nested extra for testing.
22+
type: string
23+
aiida_query:
24+
- project: extras.test.a
25+
# ----
26+
- name: ctime
27+
title: Creation time
28+
description: Time when the node was created.
29+
type: timestamp
30+
aiida_query:
31+
- project: ctime
32+
# ----
33+
- name: energy
34+
title: Total energy
35+
description: The total energy computed by DFT
36+
unit: eV
37+
type: float
38+
aiida_query:
39+
- incoming_node: WorkChainNode
40+
- outgoing_node: Dict
41+
edge_filters:
42+
label: scf_parameters
43+
- project: attributes.energy
44+
# ----
45+
- name: band_gap
46+
title: Band gap
47+
description: Band gap of the material.
48+
unit: eV
49+
type: float
50+
aiida_query:
51+
- incoming_node: WorkChainNode
52+
- outgoing_node: BandsData
53+
- outgoing_node: CalcFunctionNode
54+
- outgoing_node: Dict
55+
edge_filters:
56+
label: bandgap
57+
- project: attributes.value
58+
# ----
59+
- name: is_band_gap_direct
60+
title: Direct band gap
61+
description: Is the band gap direct?
62+
type: boolean
63+
aiida_query:
64+
- incoming_node: WorkChainNode
65+
- outgoing_node: BandsData
66+
- outgoing_node: CalcFunctionNode
67+
- outgoing_node: Dict
68+
edge_filters:
69+
label: bandgap
70+
- project: attributes.is_direct
71+
# property provided by csv file:
72+
- name: csv_property
73+
title: Test property
74+
description: Property from the csv file
75+
type: integer

pyproject.toml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ keywords = ["optimade", "jsonapi", "materials"]
88
dynamic = ["version"]
99

1010
classifiers = [
11-
"Development Status :: 4 - Beta",
12-
"Programming Language :: Python :: 3 :: Only",
13-
"Programming Language :: Python :: 3.10",
14-
"Programming Language :: Python :: 3.11",
15-
"Programming Language :: Python :: 3.12",
16-
"Intended Audience :: Science/Research",
17-
"Topic :: Database",
18-
"Topic :: Scientific/Engineering",
11+
"Development Status :: 4 - Beta",
12+
"Programming Language :: Python :: 3 :: Only",
13+
"Programming Language :: Python :: 3.10",
14+
"Programming Language :: Python :: 3.11",
15+
"Programming Language :: Python :: 3.12",
16+
"Intended Audience :: Science/Research",
17+
"Topic :: Database",
18+
"Topic :: Scientific/Engineering",
1919
]
2020

2121
dependencies = [
22-
"pydantic~=2.2",
23-
"optimade[server]~=1.1",
24-
"pyyaml~=6.0",
25-
"tqdm~=4.65",
26-
"requests~=2.31",
27-
"numpy >= 1.22, < 3",
28-
"click~=8.1"
22+
"pydantic~=2.2",
23+
"optimade[server]~=1.1",
24+
"pyyaml~=6.0",
25+
"tqdm~=4.65",
26+
"requests~=2.31",
27+
"numpy >= 1.22, < 3",
28+
"click~=8.1",
2929
]
3030

3131
[project.scripts]
@@ -43,7 +43,8 @@ version_scheme = "post-release"
4343
ase = ["ase ~= 3.22"]
4444
pymatgen = ["pymatgen >= 2023.9"]
4545
pandas = ["pandas >= 1.5, < 3"]
46-
ingest = ["optimade-maker[ase,pymatgen,pandas]"]
46+
aiida = ["aiida-core >= 2.6.3"]
47+
ingest = ["optimade-maker[ase,pymatgen,pandas,aiida]"]
4748
tests = ["pytest~=8.3", "pytest-cov~=6.0"]
4849
dev = ["ruff", "pre-commit", "mypy"]
4950

0 commit comments

Comments
 (0)