Commit be9b972e authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Added exception handling when reference from scc to system is missing, added...

Added exception handling when reference from scc to system is missing, added bravais_lattice to Encyclopedia.material.
parent 4b4e9fa9
Pipeline #66936 passed with stages
in 28 minutes and 45 seconds
......@@ -50,6 +50,31 @@ class Material(MSection):
Position of each atom, given in relative coordinates.
"""
)
bravais_lattice = Quantity(
type=str,
description="""
The Bravais lattice type in the Pearson notation, where the first
lowercase letter indicates the crystal system, and the second uppercase
letter indicates the lattice type.
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
"""
)
class Calculation(MSection):
......
......@@ -75,8 +75,9 @@ class EncyclopediaNormalizer(Normalizer):
pass
# NOTE: System normalizer
def get_bravais_lattice(self) -> None:
pass
def get_bravais_lattice(self, material: Material, section_system: Dict) -> None:
bravais_lattice = section_system["section_symmetry"][0]["bravais_lattice"]
material.bravais_lattice = bravais_lattice
# NOTE: Band structure normalizer
def get_brillouin_zone(self) -> None:
......@@ -502,6 +503,7 @@ class EncyclopediaNormalizer(Normalizer):
self.get_number_of_atoms(material, std_atoms)
self.get_atom_labels(material, std_atoms)
self.get_atomic_density(calculation, repr_atoms)
self.get_bravais_lattice(material, system)
# Put the encyclopedia section into backend
self._backend.add_mi2_section(sec_enc)
......@@ -112,7 +112,7 @@ class SystemBasedNormalizer(Normalizer, metaclass=ABCMeta):
else:
sequences.append(frames)
# If no frames exist, consider all existing sccs
# If no frame_sequences exist, consider all existing sccs
if len(sequences) == 0:
try:
sccs = self._backend.get_sections(s_scc)
......@@ -132,9 +132,15 @@ class SystemBasedNormalizer(Normalizer, metaclass=ABCMeta):
indices = [0, -2, -1]
else:
break
for scc_idx in [seq[idx] for idx in indices]:
system_idx = sccs[scc_idx][r_scc_to_system]
systems.append(system_idx)
for idx in indices:
scc_idx = seq[idx]
scc = sccs[scc_idx]
try:
system_idx = scc[r_scc_to_system]
except KeyError:
self.logger.info("section_single_configuration_calculation is missing a reference into a system.")
else:
systems.append(system_idx)
if len(systems) == 0:
self.logger.error('no "representative" section system found')
......
......@@ -54,3 +54,4 @@ def test_bulk_information(geometry_optimization: Encyclopedia):
assert go.material.number_of_atoms == 4
assert go.material.atom_labels == ["Na", "Na", "Na", "Na"]
assert go.calculation.atomic_density == pytest.approx(4.0e+30, rel=0.000001, abs=None)
assert go.material.bravais_lattice == "cF"
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