encyclopedia.py 20.6 KB
Newer Older
1
import numpy as np
2
from nomad.metainfo import MSection, Section, SubSection, Quantity, MEnum, Reference
3
from nomad.datamodel.metainfo.public import section_k_band, section_dos, section_thermodynamical_properties
4
from nomad.metainfo.search_extension import Search
Lauri Himanen's avatar
Lauri Himanen committed
5
from elasticsearch_dsl import Text, Keyword
6
7


8
class WyckoffVariables(MSection):
9
10
11
    m_def = Section(
        a_flask=dict(skip_none=True),
        description="""
12
        Contains the variables associated with a Wyckoff set.
13
14
15
        """
    )
    x = Quantity(
16
        type=np.dtype(np.float64),
17
18
19
20
21
        description="""
        The x variable if present.
        """
    )
    y = Quantity(
22
        type=np.dtype(np.float64),
23
24
25
26
27
        description="""
        The y variable if present.
        """
    )
    z = Quantity(
28
        type=np.dtype(np.float64),
29
30
31
32
        description="""
        The z variable if present.
        """
    )
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47


class WyckoffSet(MSection):
    m_def = Section(
        a_flask=dict(skip_none=True),
        description="""
        Section for storing Wyckoff set information.
        """
    )
    wyckoff_letter = Quantity(
        type=str,
        description="""
        The Wyckoff letter for this set.
        """
    )
48
49
50
51
52
53
54
55
56
57
58
59
60
    indices = Quantity(
        type=np.dtype('i4'),
        shape=["1..*"],
        description="""
        Indices of the atoms belonging to this group.
        """
    )
    element = Quantity(
        type=str,
        description="""
        Chemical element at this Wyckoff position.
        """
    )
61
    variables = SubSection(sub_section=WyckoffVariables.m_def, repeats=False)
62
63


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
class LatticeParameters(MSection):
    m_def = Section(
        a_flask=dict(skip_none=True),
        description="""
        Lattice parameters of the idealized cell. The lattice parameters can
        only be reported consistently after idealization and may not perfectly
        correspond to the original simulation cell.
        """,
        a_search="lattice_parameters"
    )
    a = Quantity(
        type=float,
        description="""
        Length of the first basis vector.
        """,
        a_search=Search()
    )
    b = Quantity(
        type=float,
        description="""
        Length of the second basis vector.
        """,
        a_search=Search()
    )
    c = Quantity(
        type=float,
        description="""
        Length of the third basis vector.
        """,
        a_search=Search()
    )
    alpha = Quantity(
        type=float,
        description="""
        Angle between second and third basis vector.
        """,
        a_search=Search()
    )
    beta = Quantity(
        type=float,
        description="""
        Angle between first and third basis vector.
        """,
        a_search=Search()
    )
    gamma = Quantity(
        type=float,
        description="""
        Angle between first and second basis vector.
        """,
        a_search=Search()
    )


118
class IdealizedStructure(MSection):
119
120
121
    m_def = Section(
        a_flask=dict(skip_none=True),
        description="""
122
123
124
125
126
        Contains structural information for an idealized representation of the
        material used in the calculation. This idealization is used for
        visualizing the material and for calculating the structural properties.
        The properties of the idealized structure may slightly vary from the
        original structure used in the calculation.
127
128
        """,
        a_search="idealized_structure",
129
    )
130
131
132
    atom_labels = Quantity(
        type=str,
        shape=['1..*'],
133
        description="""
134
        Type (element, species) of each atom.
135
136
        """
    )
137
    atom_positions = Quantity(
138
        type=np.dtype(np.float64),
139
        shape=['number_of_atoms', 3],
140
        description="""
141
142
143
144
145
        Atom positions given in coordinates that are relative to the idealized
        cell.
        """
    )
    lattice_vectors = Quantity(
146
        type=np.dtype(np.float64),
147
148
149
150
151
152
153
154
        shape=[3, 3],
        description="""
        Lattice vectors of the idealized structure. For bulk materials it is
        the Bravais cell. This cell is representative and is idealized to match
        the detected symmetry properties.
        """
    )
    lattice_vectors_primitive = Quantity(
155
        type=np.dtype(np.float64),
156
157
158
159
160
161
162
163
164
165
166
167
168
        shape=[3, 3],
        description="""
        Lattice vectors of the the primitive unit cell in a form to be visualized
        within the idealized cell. This cell is representative and is
        idealized to match the detected symmemtry properties.
        """
    )
    periodicity = Quantity(
        type=np.bool,
        shape=[3],
        description="""
        Automatically detected true periodicity of each lattice direction. May
        not correspond to the periodicity used in the calculation.
169
170
        """
    )
171
172
    number_of_atoms = Quantity(
        type=int,
173
        description="""
174
175
176
177
        Number of atoms in the idealized structure."
        """
    )
    cell_volume = Quantity(
178
179
        type=np.dtype(np.float64),
        unit="m ** 3",
180
181
182
183
        description="""
        Volume of the idealized cell. The cell volume can only be reported
        consistently after idealization and may not perfectly correspond to the
        original simulation cell.
184
185
        """,
        a_search=Search()
186
    )
187
    wyckoff_sets = SubSection(sub_section=WyckoffSet.m_def, repeats=True)
188
    lattice_parameters = SubSection(sub_section=LatticeParameters.m_def)
189
190
191
192
193


class Bulk(MSection):
    m_def = Section(
        a_flask=dict(skip_none=True),
194
        a_search="bulk",
195
196
        description="""
        Contains information that is specific to bulk crystalline materials.
197
198
        """
    )
199
    bravais_lattice = Quantity(
200
        type=MEnum("aP", "mP", "mS", "oP", "oS", "oI", "oF", "tP", "tI", "hR", "hP", "cP", "cI", "cF"),
201
202
203
        description="""
        The Bravais lattice type in the Pearson notation, where the first
        lowercase letter indicates the crystal system, and the second uppercase
204
205
        letter indicates the lattice type. The value can only be one of the 14
        different Bravais lattices in three dimensions.
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222

        Crystal system letters:

        a = Triclinic
        m = Monoclinic
        o = Orthorhombic
        t = Tetragonal
        h = Hexagonal and Trigonal
        c = Cubic

        Lattice type letters:

        P = Primitive
        S (A, B, C) = One side/face centred
        I = Body centered
        R = Rhombohedral centring
        F = All faces centred
223
224
        """,
        a_search=Search()
225
    )
226
227
228
229
    crystal_system = Quantity(
        type=MEnum("triclinic", "monoclinic", "orthorhombic", "tetragonal", "trigonal", "hexagonal", "cubic"),
        description="""
        The detected crystal system. One of seven possibilities in three dimensions.
230
231
        """,
        a_search=Search()
232
    )
233
234
235
236
237
238
239
    has_free_wyckoff_parameters = Quantity(
        type=bool,
        description="""
        Whether the material has any Wyckoff sites with free parameters. If a
        materials has free Wyckoff parameters, at least some of the atoms are
        not bound to a particular location in the structure but are allowed to
        move with possible restrictions set by the symmetry.
240
241
        """,
        a_search=Search()
242
    )
243
244
245
246
247
    point_group = Quantity(
        type=MEnum("1", "-1", "2", "m", "2/m", "222", "mm2", "mmm", "4", "-4", "4/m", "422", "4mm", "-42m", "4/mmm", "3", "-3", "32", "3m", "-3m", "6", "-6", "6/m", "622", "6mm", "-6m2", "6/mmm", "23", "m-3", "432", "-43m", "m-3m"),
        description="""
        Point group in Hermann-Mauguin notation, part of crystal structure
        classification. There are 32 point groups in three dimensional space.
248
249
        """,
        a_search=Search()
250
    )
251
252
253
    space_group_number = Quantity(
        type=int,
        description="""
254
255
        Integer representation of the space group, part of crystal structure
        classification, part of material definition.
256
257
        """,
        a_search=Search()
258
259
260
261
262
    )
    space_group_international_short_symbol = Quantity(
        type=str,
        description="""
        International short symbol notation of the space group.
263
264
        """,
        a_search=Search()
265
    )
266
267
268
269
    structure_prototype = Quantity(
        type=str,
        description="""
        The prototypical material for this crystal structure.
270
271
        """,
        a_search=Search()
272
    )
273
274
275
276
277
    structure_type = Quantity(
        type=str,
        description="""
        Classification according to known structure type, considering the point
        group of the crystal and the occupations with different atom types.
278
279
        """,
        a_search=Search()
280
    )
281
282
283
284
    strukturbericht_designation = Quantity(
        type=str,
        description="""
        Classification of the material according to the historically grown "strukturbericht".
285
286
        """,
        a_search=Search()
287
    )
288

289
290
291
292

class Material(MSection):
    m_def = Section(
        a_flask=dict(skip_none=True),
293
        a_search="material",
294
        description="""
295
296
        Contains an overview of the type of material that was detected in this
        entry.
297
298
        """
    )
299
300
    material_type = Quantity(
        type=MEnum(bulk="bulk", two_d="2D", one_d="1D", unavailable="unavailable"),
301
        description="""
302
        "Broad structural classification for the material, e.g. bulk, 2D, 1D... ",
303
304
        """,
        a_search=Search()
305
    )
306
    material_id = Quantity(
307
        type=str,
308
        description="""
309
310
        A fixed length, unique material identifier in the form of a hash
        digest.
311
312
        """,
        a_search=Search()
313
    )
314
315
    material_name = Quantity(
        type=str,
316
        description="""
317
        Most meaningful name for a material.
318
319
        """,
        a_search=Search()
320
    )
321
    material_classification = Quantity(
322
        type=str,
323
        description="""
324
325
        Contains the compound class and classification of the material
        according to springer materials in JSON format.
326
327
        """
    )
328
329
    formula = Quantity(
        type=str,
330
        description="""
331
332
333
        Formula giving the composition and occurrences of the elements in the
        Hill notation. For periodic materials the formula is calculated fom the
        primitive unit cell.
334
335
        """,
        a_search=Search()
336
    )
337
338
    formula_reduced = Quantity(
        type=str,
339
        description="""
340
        Formula giving the composition and occurrences of the elements in the
Lauri Himanen's avatar
Lauri Himanen committed
341
        Hill notation where the number of occurences have been divided by the
342
        greatest common divisor.
343
        """,
344
        a_search=Search()
345
    )
Lauri Himanen's avatar
Lauri Himanen committed
346
347
348
349
350
351
352
353
354
    species_and_counts = Quantity(
        type=str,
        description="""
        The formula separated into individual terms containing both the atom
        type and count. Used for searching parts of a formula.
        """,
        a_search=Search(mapping=Text(multi=True, fields={'keyword': Keyword()}))
    )
    species = Quantity(
355
356
        type=str,
        description="""
Lauri Himanen's avatar
Lauri Himanen committed
357
358
        The formula separated into individual terms containing only unique atom
        species. Used for searching materials containing specific elements.
359
        """,
Lauri Himanen's avatar
Lauri Himanen committed
360
        a_search=Search(mapping=Text(multi=True, fields={'keyword': Keyword()}))
361
    )
362

363
364
365
    # Bulk-specific properties
    bulk = SubSection(sub_section=Bulk.m_def, repeats=False)

366
367
368
    # The idealized structure for this material
    idealized_structure = SubSection(sub_section=IdealizedStructure.m_def, repeats=False)

369
370
371
372

class Method(MSection):
    m_def = Section(
        a_flask=dict(skip_none=True),
373
        a_search="method",
374
        description="""
375
376
        Contains an overview of the methodology that was detected in this
        entry.
377
378
379
        """
    )
    method_type = Quantity(
380
        type=MEnum("DFT", "GW", "unavailable", DFTU="DFT+U"),
381
        description="""
382
        Generic name for the used methodology.
383
384
        """,
        a_search=Search()
385
    )
386
387
388
389
    core_electron_treatment = Quantity(
        type=MEnum("full all electron", "all electron frozen core", "pseudopotential", "unavailable"),
        description="""
        How the core electrons are described.
390
391
        """,
        a_search=Search()
392
    )
393
394
395
396
    functional_long_name = Quantity(
        type=str,
        description="""
        Full identified for the used exchange-correlation functional.
397
398
        """,
        a_search=Search()
399
    )
Lauri Himanen's avatar
Lauri Himanen committed
400
401
402
403
    functional_type = Quantity(
        type=str,
        description="""
        Basic type of the used exchange-correlation functional.
404
405
        """,
        a_search=Search()
Lauri Himanen's avatar
Lauri Himanen committed
406
    )
407
    method_id = Quantity(
408
409
        type=str,
        description="""
410
411
412
413
        A fixed length, unique method identifier in the form of a hash digest.
        The hash is created by using several method settings as seed. This hash
        is only defined if a set of well-defined method settings is available
        for the used program.
414
415
        """
    )
416
    group_eos_id = Quantity(
417
418
419
        type=str,
        description="""
        A fixed length, unique identifier for equation-of-state calculations.
420
421
        Only calculations within the same upload and with a method hash
        available will be grouped under the same hash.
422
423
        """,
        a_search=Search()
424
    )
425
    group_parametervariation_id = Quantity(
426
427
428
        type=str,
        description="""
        A fixed length, unique identifier for calculations where structure is
429
        identical but the used computational parameters are varied. Only
430
431
        calculations within the same upload and with a method hash available
        will be grouped under the same hash.
432
433
        """,
        a_search=Search()
434
    )
435
436
437
    gw_starting_point = Quantity(
        type=str,
        description="""
438
439
        The exchange-correlation functional that was used as a starting point
        for this GW calculation.
440
441
442
443
444
445
446
447
        """
    )
    gw_type = Quantity(
        type=MEnum("G0W0", "scGW"),
        description="""
        Basic type of GW calculation.
        """
    )
448
    smearing_kind = Quantity(
449
        type=str,
450
451
452
453
454
        description="""
        Smearing function used for the electronic structure calculation.
        """
    )
    smearing_parameter = Quantity(
455
        type=np.dtype(np.float64),
456
457
458
459
460
461
        description="""
        Parameter for smearing, usually the width.
        """
    )


462
class Calculation(MSection):
463
464
    m_def = Section(
        a_flask=dict(skip_none=True),
465
        a_search="calculation",
466
        description="""
467
468
        Contains an overview of the type of calculation that was detected in
        this entry.
469
470
        """
    )
471
    calculation_type = Quantity(
472
473
474
475
476
477
478
        type=MEnum(
            single_point="single point",
            geometry_optimization="geometry optimization",
            molecular_dynamics="molecular dynamics",
            phonon_calculation="phonon calculation",
            elastic_constants="elastic constants",
            qha_calculation="QHA calculation",
479
            gw_calculation="GW calculation",
480
481
482
483
            equation_of_state="equation of state",
            parameter_variation="parameter variation",
            unavailable="unavailable"),
        description="""
484
        Defines the type of calculation that was detected for this entry.
485
486
        """,
        a_search=Search()
487
    )
488
489


490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
class Energies(MSection):
    m_def = Section(
        a_flask=dict(skip_none=True),
        a_search="energies",
        description="""
        Contains different types of energies extracted from this entry. The
        energies are extracted from a representative calculation: for geometry
        optimization it is the last optimization step.
        """
    )
    energy_total = Quantity(
        type=np.dtype(np.float64),
        unit="eV",
        description="""
        Total energy.
        """,
        a_search=Search()
    )
    energy_total_T0 = Quantity(
        type=np.dtype(np.float64),
        unit="eV",
        description="""
        Total energy projected to T=0.
        """,
        a_search=Search()
    )
    energy_free = Quantity(
        type=np.dtype(np.float64),
        unit="eV",
        description="""
        Free energy.
        """,
        a_search=Search()
    )


526
527
528
class Properties(MSection):
    m_def = Section(
        a_flask=dict(skip_none=True),
529
        a_search="properties",
530
531
532
533
534
535
        description="""
        Contains derived physical properties that are specific to the NOMAD
        Encyclopedia.
        """
    )
    atomic_density = Quantity(
536
        type=np.dtype(np.float64),
537
        unit="1 / m ** 3",
538
539
        description="""
        Atomic density of the material (atoms/volume)."
540
541
        """,
        a_search=Search()
542
543
    )
    mass_density = Quantity(
544
        type=np.dtype(np.float64),
545
        unit="kg / m ** 3",
546
547
        description="""
        Mass density of the material.
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
        """,
        a_search=Search()
    )
    band_gap = Quantity(
        type=np.dtype(np.float64),
        unit="eV",
        description="""
        Band gap value. If multiple spin channels are present, this value is
        taken from the channel with smallest band gap value.
        """,
        a_search=Search()
    )
    band_gap_direct = Quantity(
        type=bool,
        description="""
        Whether band gap is direct or not. If multiple spin channels are
        present, this value is taken from the channel with smallest band gap
        value.
        """,
        a_search=Search()
568
    )
569
    energies = SubSection(sub_section=Energies.m_def, repeats=False, a_search='energies')
570
571
572
573
574
    electronic_band_structure = Quantity(
        type=Reference(section_k_band.m_def),
        shape=[],
        description="""
        Reference to an electronic band structure.
575
        """,
576
        a_search=Search(value=lambda section: section.electronic_band_structure.m_proxy_url if section.electronic_band_structure is not None else None, mapping=Keyword())
577
578
579
580
581
582
    )
    electronic_dos = Quantity(
        type=Reference(section_dos.m_def),
        shape=[],
        description="""
        Reference to an electronic density of states.
583
        """,
584
        a_search=Search(value=lambda section: section.electronic_dos.m_proxy_url if section.electronic_dos is not None else None, mapping=Keyword())
585
    )
586
587
588
589
590
    phonon_band_structure = Quantity(
        type=Reference(section_k_band.m_def),
        shape=[],
        description="""
        Reference to a phonon band structure.
591
        """,
592
        a_search=Search(value=lambda section: section.phonon_band_structure.m_proxy_url if section.phonon_band_structure is not None else None, mapping=Keyword())
593
594
595
596
597
598
    )
    phonon_dos = Quantity(
        type=Reference(section_dos.m_def),
        shape=[],
        description="""
        Reference to a phonon density of states.
599
        """,
600
        a_search=Search(value=lambda section: section.phonon_dos.m_proxy_url if section.phonon_dos is not None else None, mapping=Keyword())
601
602
603
604
605
    )
    thermodynamical_properties = Quantity(
        type=Reference(section_thermodynamical_properties.m_def),
        shape=[],
        description="""
606
        Reference to a section containing thermodynamical properties.
607
        """,
608
        a_search=Search(value=lambda section: section.thermodynamical_properties.m_proxy_url if section.thermodynamical_properties is not None else None, mapping=Keyword())
609
    )
610
611


612
class EncyclopediaMetadata(MSection):
613
614
    m_def = Section(
        a_flask=dict(skip_none=True),
615
        a_search='encyclopedia',
616
        description="""
617
        Section which stores information for the NOMAD Encyclopedia.
618
        """
619
    )
620
621
622
623
    material = SubSection(sub_section=Material.m_def, repeats=False, a_search='material')
    method = SubSection(sub_section=Method.m_def, repeats=False, a_search='method')
    properties = SubSection(sub_section=Properties.m_def, repeats=False, a_search='properties')
    calculation = SubSection(sub_section=Calculation.m_def, repeats=False, a_search='calculation')
624
625
626
627
628
629
    status = Quantity(
        type=MEnum("success", "unsupported_material_type", "unsupported_calculation_type", "invalid_metainfo", "failure"),
        description="""
        The final Encyclopedia processing status for this entry. The meaning of the status is as follows:

        | Status                           | Description                                                                   |
Lauri Himanen's avatar
Lauri Himanen committed
630
        | -------------------------------- | ----------------------------------------------------------------------------- |
631
632
633
634
635
        | `"success"`                      | Processed successfully                                                        |
        | `"unsupported_material_type"`    | The detected material type is currenlty not supported by the Encyclopedia.    |
        | `"unsupported_calculation_type"` | The detected calculation type is currenlty not supported by the Encyclopedia. |
        | `"invalid_metainfo"`             | The entry could not be processed due to missing or invalid metainfo.          |
        | `"failure"`                      | The entry could not be processed due to an unexpected exception.              |
636
637
        """,
        a_search=Search()
638
    )