Commit 2807136c authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Restructured Encyclopedia metainfo.

parent 713797b7
Pipeline #71233 passed with stages
in 31 minutes and 39 seconds
......@@ -61,34 +61,90 @@ class WyckoffSet(MSection):
variables = SubSection(sub_section=WyckoffVariables.m_def, repeats=False)
class Material(MSection):
class IdealizedStructure(MSection):
m_def = Section(
a_flask=dict(skip_none=True),
a_elastic=dict(type=InnerDoc),
description="""
Section for storing the data that links an Encyclopedia entry into a
specific material.
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.
"""
)
# Material-specific
material_type = Quantity(
type=MEnum(bulk="bulk", two_d="2D", one_d="1D", unavailable="unavailable"),
atom_labels = Quantity(
type=str,
shape=['1..*'],
description="""
"Character of physical system's geometry, e.g. bulk, 2D, 1D... ",
Type (element, species) of each atom.
"""
)
material_hash = Quantity(
type=str,
atom_positions = Quantity(
type=np.dtype('f8'),
shape=['number_of_atoms', 3],
description="""
A fixed length, unique material identifier in the form of a hash
digest.
Atom positions given in coordinates that are relative to the idealized
cell.
"""
)
lattice_vectors = Quantity(
type=np.dtype('f8'),
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(
type=np.dtype('f8'),
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.
"""
)
lattice_parameters = Quantity(
type=np.dtype('f8'),
shape=[6],
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.
"""
)
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.
"""
)
number_of_atoms = Quantity(
type=int,
description="""
Number of atoms in the bravais cell."
Number of atoms in the idealized structure."
"""
)
cell_volume = Quantity(
type=float,
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.
"""
)
class Bulk(MSection):
m_def = Section(
a_flask=dict(skip_none=True),
a_elastic=dict(type=InnerDoc),
description="""
Contains information that is specific to bulk crystalline materials.
"""
)
bravais_lattice = Quantity(
......@@ -123,21 +179,6 @@ class Material(MSection):
The detected crystal system. One of seven possibilities in three dimensions.
"""
)
formula = Quantity(
type=str,
description="""
Formula giving the composition and occurrences of the elements in the
Hill notation for the irreducible unit cell.
"""
)
formula_reduced = Quantity(
type=str,
description="""
Formula giving the composition and occurrences of the elements in the
Hill notation for the irreducible unit cell. In this reduced form the
number of occurences have been divided by the greatest common divisor.
"""
)
has_free_wyckoff_parameters = Quantity(
type=bool,
description="""
......@@ -147,26 +188,6 @@ class Material(MSection):
move with possible restrictions set by the symmetry.
"""
)
material_classification = Quantity(
type=str,
description="""
Contains the compound class and classification of the material
according to springer materials in JSON format.
"""
)
material_name = Quantity(
type=str,
description="""
Most meaningful name for a material.
"""
)
periodicity = Quantity(
type=np.bool,
shape=[3],
description="""
Periodicity of each lattice direction.
"""
)
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="""
......@@ -206,70 +227,67 @@ class Material(MSection):
Classification of the material according to the historically grown "strukturbericht".
"""
)
wyckoff_sets = SubSection(sub_section=WyckoffSet.m_def, repeats=True)
# Calculation-specific
atom_labels = Quantity(
type=str,
shape=['1..*'],
class Material(MSection):
m_def = Section(
a_flask=dict(skip_none=True),
a_elastic=dict(type=InnerDoc),
description="""
Type (element, species) of each atom,
Section for storing the data that links an Encyclopedia entry into a
specific material.
"""
)
atom_positions = Quantity(
type=np.dtype('f8'),
shape=['number_of_atoms', 3],
material_type = Quantity(
type=MEnum(bulk="bulk", two_d="2D", one_d="1D", unavailable="unavailable"),
description="""
Position of each atom, given in relative coordinates.
"Broad structural classification for the material, e.g. bulk, 2D, 1D... ",
"""
)
cell_normalized = Quantity(
type=np.dtype('f8'),
shape=[3, 3],
material_hash = Quantity(
type=str,
description="""
Unit cell in normalized form, meaning the bravais cell. This cell is
representative and is idealized to match the detected symmetry
properties.
A fixed length, unique material identifier in the form of a hash
digest.
"""
)
cell_primitive = Quantity(
type=np.dtype('f8'),
shape=[3, 3],
material_name = Quantity(
type=str,
description="""
Definition of the primitive unit cell in a form to be visualized well
within the normalized cell. This cell is representative and is
idealized to match the detected symmemtry properties.
Most meaningful name for a material.
"""
)
wyckoff_sets = SubSection(sub_section=WyckoffSet.m_def, repeats=True)
cell_angles_string = Quantity(
material_classification = Quantity(
type=str,
description="""
A summary of the cell angles, part of material definition.
Contains the compound class and classification of the material
according to springer materials in JSON format.
"""
)
cell_volume = Quantity(
type=float,
formula = Quantity(
type=str,
description="""
Cell volume for a specific calculation. The cell volume can only be
reported consistently after normalization. Thus it corresponds to the
normalized cell that is idealized to fit the detected symmetry and may
not perfectly correspond to the original simulation cell.
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.
"""
)
lattice_parameters = Quantity(
type=np.dtype('f8'),
shape=[6],
formula_reduced = Quantity(
type=str,
description="""
Lattice parameters of a specific calculation. The lattice parameters
can only be reported consistently after normalization. Thus they
correspond to the normalized cell that is idealized to fit the detected
symmetry and may not perfectly correspond to the original simulation
cell.
Formula giving the composition and occurrences of the elements in the
Hill notation whre the number of occurences have been divided by the
greatest common divisor.
"""
)
# The idealized structure for this material
idealized_structure = SubSection(sub_section=IdealizedStructure.m_def, repeats=False)
# Bulk-specific properties
bulk = SubSection(sub_section=Bulk.m_def, repeats=False)
class Method(MSection):
m_def = Section(
......@@ -498,6 +516,13 @@ class ElectronicBandStructure(MSection):
Stores information related to an electronic band structure.
"""
)
scc_index = Quantity(
type=int,
description="""
Index of the single configuration calculation that contains the band
structure.
"""
)
fermi_level = Quantity(
type=float,
unit=units.J,
......@@ -551,6 +576,13 @@ class ElectronicDOS(MSection):
Stores the electronic density of states (DOS).
"""
)
scc_index = Quantity(
type=int,
description="""
Index of the single configuration calculation that contains the density
of states.
"""
)
fermi_level = Quantity(
type=float,
unit=units.J,
......@@ -588,12 +620,6 @@ class Properties(MSection):
are used by the NOMAD Encyclopedia.
"""
)
scc_index = Quantity(
type=int,
description="""
Index of a representative single configuration calculation."
"""
)
atomic_density = Quantity(
type=float,
unit=units.m**(-3),
......@@ -628,12 +654,6 @@ class Encyclopedia(MSection):
Section which stores information for the NOMAD Encyclopedia.
"""
)
mainfile_uri = Quantity(
type=str,
description="""
Path of the main file.
"""
)
material = SubSection(sub_section=Material.m_def, repeats=False)
method = SubSection(sub_section=Method.m_def, repeats=False)
properties = SubSection(sub_section=Properties.m_def, repeats=False)
......
This diff is collapsed.
......@@ -73,17 +73,19 @@ def test_1d_metainfo(one_d: LocalBackend):
"""
enc = one_d.get_mi2_section(Encyclopedia.m_def)
# Material
assert enc.material.material_type == "1D"
assert enc.material.formula == "C6H4"
assert enc.material.formula_reduced == "C3H2"
assert np.array_equal(enc.material.periodicity, [True, False, False])
material = enc.material
assert material.material_type == "1D"
assert material.formula == "C6H4"
assert material.formula_reduced == "C3H2"
# Representative system
assert enc.material.number_of_atoms == 10
assert enc.material.atom_labels == ["C", "C", "C", "C", "C", "C", "H", "H", "H", "H"]
assert enc.material.atom_positions is not None
assert enc.material.cell_normalized is not None
assert np.allclose(enc.material.lattice_parameters, [4.33793652e-10, 0, 0, 0, 0, 0], atol=0)
# Idealized structure
ideal = enc.material.idealized_structure
assert ideal.number_of_atoms == 10
assert ideal.atom_labels == ["C", "C", "C", "C", "C", "C", "H", "H", "H", "H"]
assert ideal.atom_positions is not None
assert ideal.lattice_vectors is not None
assert np.array_equal(ideal.periodicity, [True, False, False])
assert np.allclose(ideal.lattice_parameters, [4.33793652e-10, 0, 0, 0, 0, 0], atol=0)
def test_2d_metainfo(two_d: LocalBackend):
......@@ -91,18 +93,20 @@ def test_2d_metainfo(two_d: LocalBackend):
"""
enc = two_d.get_mi2_section(Encyclopedia.m_def)
# Material
assert enc.material.material_type == "2D"
assert enc.material.formula == "C2"
assert enc.material.formula_reduced == "C"
assert np.array_equal(enc.material.periodicity, [True, True, False])
# Representative system
assert enc.material.number_of_atoms == 2
assert enc.material.atom_labels == ["C", "C"]
assert enc.material.atom_positions is not None
assert enc.material.cell_normalized is not None
assert enc.material.cell_primitive is not None
assert np.allclose(enc.material.lattice_parameters, [2.46559821e-10, 2.46559821e-10, 0, 120 / 180 * np.pi, 0, 0], atol=0)
material = enc.material
assert material.material_type == "2D"
assert material.formula == "C2"
assert material.formula_reduced == "C"
# Idealized structure
ideal = enc.material.idealized_structure
assert ideal.number_of_atoms == 2
assert ideal.atom_labels == ["C", "C"]
assert ideal.atom_positions is not None
assert ideal.lattice_vectors is not None
assert ideal.lattice_vectors_primitive is not None
assert np.array_equal(ideal.periodicity, [True, True, False])
assert np.allclose(ideal.lattice_parameters, [2.46559821e-10, 2.46559821e-10, 0, 120 / 180 * np.pi, 0, 0], atol=0)
def test_bulk_metainfo(bulk: LocalBackend):
......@@ -110,36 +114,40 @@ def test_bulk_metainfo(bulk: LocalBackend):
"""
enc = bulk.get_mi2_section(Encyclopedia.m_def)
# Material
assert enc.material.material_type == "bulk"
assert enc.material.formula == "Si2"
assert enc.material.formula_reduced == "Si"
assert enc.material.material_name == "Silicon"
assert enc.material.structure_type == "diamond"
assert enc.material.structure_prototype == "C"
assert enc.material.strukturbericht_designation == "A4"
# Symmetry
assert enc.material.crystal_system == "cubic"
assert enc.material.bravais_lattice == "cF"
assert enc.material.has_free_wyckoff_parameters is False
assert enc.material.point_group == "m-3m"
assert enc.material.wyckoff_sets is not None
assert enc.material.space_group_number == 227
assert enc.material.space_group_international_short_symbol == "Fd-3m"
# Representative system
assert enc.material.number_of_atoms == 8
assert enc.material.atom_labels == ["Si", "Si", "Si", "Si", "Si", "Si", "Si", "Si"]
assert enc.material.atom_positions is not None
assert enc.material.cell_normalized is not None
assert enc.material.cell_primitive is not None
assert np.array_equal(enc.material.periodicity, [True, True, True])
assert enc.material.lattice_parameters is not None
assert enc.material.cell_volume == pytest.approx(5.431**3 * 1e-30)
# Calculation
assert enc.properties.atomic_density == pytest.approx(4.99402346512432e+28)
assert enc.properties.mass_density == pytest.approx(8 * 28.0855 * 1.6605389e-27 / (5.431**3 * 1e-30)) # Atomic mass in kg/m^3
material = enc.material
assert material.material_type == "bulk"
assert material.formula == "Si2"
assert material.formula_reduced == "Si"
assert material.material_name == "Silicon"
# Bulk
bulk = enc.material.bulk
assert bulk.crystal_system == "cubic"
assert bulk.bravais_lattice == "cF"
assert bulk.has_free_wyckoff_parameters is False
assert bulk.point_group == "m-3m"
assert bulk.wyckoff_sets is not None
assert bulk.space_group_number == 227
assert bulk.structure_type == "diamond"
assert bulk.structure_prototype == "C"
assert bulk.strukturbericht_designation == "A4"
assert bulk.space_group_international_short_symbol == "Fd-3m"
# Idealized structure
ideal = enc.material.idealized_structure
assert ideal.number_of_atoms == 8
assert ideal.atom_labels == ["Si", "Si", "Si", "Si", "Si", "Si", "Si", "Si"]
assert ideal.atom_positions is not None
assert ideal.lattice_vectors is not None
assert ideal.lattice_vectors_primitive is not None
assert np.array_equal(ideal.periodicity, [True, True, True])
assert ideal.lattice_parameters is not None
assert ideal.cell_volume == pytest.approx(5.431**3 * 1e-30)
# Properties
prop = enc.properties
assert prop.atomic_density == pytest.approx(4.99402346512432e+28)
assert prop.mass_density == pytest.approx(8 * 28.0855 * 1.6605389e-27 / (5.431**3 * 1e-30)) # Atomic mass in kg/m^3
def test_1d_material_identification():
......@@ -404,9 +412,10 @@ def test_1d_structure_structure_at_cell_boundary():
"C",
]
assert np.allclose(enc.material.atom_positions, expected_pos)
assert np.array_equal(enc.material.atom_labels, expected_labels)
assert np.allclose(enc.material.cell_normalized, expected_cell)
ideal = enc.material.idealized_structure
assert np.allclose(ideal.atom_positions, expected_pos)
assert np.array_equal(ideal.atom_labels, expected_labels)
assert np.allclose(ideal.lattice_vectors, expected_cell)
def test_2d_structure_structure_at_cell_boundary():
......@@ -444,9 +453,10 @@ def test_2d_structure_structure_at_cell_boundary():
"C",
]
assert np.allclose(enc.material.atom_positions, expected_pos)
assert np.array_equal(enc.material.atom_labels, expected_labels)
assert np.allclose(enc.material.cell_normalized, expected_cell)
ideal = enc.material.idealized_structure
assert np.allclose(ideal.atom_positions, expected_pos)
assert np.array_equal(ideal.atom_labels, expected_labels)
assert np.allclose(ideal.lattice_vectors, expected_cell)
def test_method_dft_metainfo(single_point):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment