diff --git a/common/python/nomadcore/atoms2nomad.py b/common/python/nomadcore/atoms2nomad.py new file mode 100644 index 0000000000000000000000000000000000000000..95fc97ff0531798a67edaea2a1a8288a66a88ece --- /dev/null +++ b/common/python/nomadcore/atoms2nomad.py @@ -0,0 +1,27 @@ +import numpy as np + +from nomadcore.unit_conversion.unit_conversion import convert_unit + + +def ase_atoms_to_section_system(backend, atoms, new_section=True): + """Add ASE Atoms object as metainfo to section_system. + + If new_section is True, open and close a new section_system, + returning its gIndex.""" + + if new_section: + gIndex = backend.openSection('section_system') + + backend.addArrayValues('atom_labels', + np.array(atoms.get_chemical_symbols())) + backend.addArrayValues('atom_positions', + convert_unit(atoms.positions, 'angstrom')) + backend.addArrayValues('simulation_cell', + convert_unit(atoms.cell, 'angstrom')) + backend.addArrayValues('configuration_periodic_dimensions', + np.array(atoms.pbc)) + + # Return system ref if we opened it, else None: + if new_section: + backend.closeSection('section_system', gIndex) + return gIndex diff --git a/common/python/nomadcore/cube_reader.py b/common/python/nomadcore/cube_reader.py new file mode 100644 index 0000000000000000000000000000000000000000..5aa48c6cd5d1e5a318388bf50f2b0c18d8938f6c --- /dev/null +++ b/common/python/nomadcore/cube_reader.py @@ -0,0 +1,40 @@ +import numpy as np +from ase.io import read + +from nomadcore.atoms2nomad import ase_atoms_to_section_system + +class CubeError(OSError): + pass + + +def read_cube_file(backend, file_name): + try: + d = read(file_name, format = 'cube', full_output = True) + + except Exception as err: + raise CubeError(err) + + data = d['data'] + atoms = d['atoms'] + origin = d['origin'] + nx, ny, nz = data.shape + displacements = np.array([atoms.cell[i]/data.shape[i] for i in range(3)]) + + system = ase_atoms_to_section_system(backend, atoms) + + singleconfig = backend.openSection('section_single_configuration_calculation') + volumetric = backend.openSection('section_volumetric_data') + + backend.addValue('volumetric_data_nx', nx) + backend.addValue('volumetric_data_ny', ny) + backend.addValue('volumetric_data_nz', nz) + + backend.addArrayValues('volumetric_data_origin', origin) + backend.addArrayValues('volumetric_data_displacements', displacements) + + backend.addValue('volumetric_data_multiplicity', 1) + backend.addArrayValues('volumetric_data_values', data[None]) + backend.closeSection('section_volumetric_data', volumetric) + + backend.addValue('single_configuration_calculation_to_system_ref', system) + backend.closeSection('section_single_configuration_calculation', singleconfig) diff --git a/nomadcore/constants/structure_types.py b/nomadcore/constants/structure_types.py index ab584aa5adb9770bf213d88b3fbcb53185a24c6c..20c4a5ad4f1818dbfb274791e5203d71c998ecbb 100644 --- a/nomadcore/constants/structure_types.py +++ b/nomadcore/constants/structure_types.py @@ -4001,7 +4001,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-', 'Strukturbericht Designation': 'A11', 'Wyckoff Positions': 'f', 'aflow_prototype_id': 'A_oC8_64_f', - 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_oC8_64_f.html', + 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_oC8_64_f.alpha-Ga.html', 'atom_labels': ['Ga', 'Ga', 'Ga', 'Ga'], 'atom_positions': [[0.0, 1.18658047e-10, 3.665979e-11], [0.0, -1.18658047e-10, -3.665979e-11], @@ -5728,7 +5728,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-', 'Strukturbericht Designation': 'A6', 'Wyckoff Positions': 'a', 'aflow_prototype_id': 'A_tI2_139_a', - 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_tI2_139_a.html', + 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_tI2_139_a.In.html', 'atom_labels': ['In'], 'atom_positions': [[0.0, 0.0, 0.0]], 'lattice_vectors': [[3.2512769800000005e-10, 0.0, 0.0], @@ -5854,7 +5854,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-', 'Strukturbericht Designation': 'Aa', 'Wyckoff Positions': 'a', 'aflow_prototype_id': 'A_tI2_139_a', - 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_tI2_139_a.html', + 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_tI2_139_a.alpha-Pa.html', 'atom_labels': ['Pa'], 'atom_positions': [[0.0, 0.0, 0.0]], 'lattice_vectors': [[3.925e-10, 0.0, 0.0], @@ -7518,7 +7518,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-', 'Strukturbericht Designation': 'A7', 'Wyckoff Positions': 'c', 'aflow_prototype_id': 'A_hR2_166_c', - 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_hR2_166_c.html', + 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_hR2_166_c.alpha-As.html', 'atom_labels': ['As', 'As'], 'atom_positions': [[1.37328129e-10, 1.37328129e-10, 1.37328129e-10], [-1.37328129e-10, -1.37328129e-10, -1.37328129e-10]], @@ -7977,7 +7977,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-', 'Strukturbericht Designation': '-', 'Wyckoff Positions': 'c', 'aflow_prototype_id': 'A_hR2_166_c', - 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_hR2_166_c.html', + 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_hR2_166_c.C.html', 'atom_labels': ['C', 'C'], 'atom_positions': [[0.0, 0.0, 1.6740000000000337e-10], [0.0, 0.0, 8.369999999999966e-10]], @@ -8113,7 +8113,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-', 'Strukturbericht Designation': 'A10', 'Wyckoff Positions': 'a', 'aflow_prototype_id': 'A_hR1_166_a', - 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_hR1_166_a.html', + 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_hR1_166_a.alpha-Hg.html', 'atom_labels': ['Hg'], 'atom_positions': [[0.0, 0.0, 0.0]], 'lattice_vectors': [[2.9288947099999997e-10, @@ -8135,7 +8135,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-', 'Strukturbericht Designation': '-', 'Wyckoff Positions': 'c', 'aflow_prototype_id': 'A_hR2_166_c', - 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_hR2_166_c.html', + 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_hR2_166_c.beta-O.html', 'atom_labels': ['O', 'O'], 'atom_positions': [[0.0, 0.0, 6.125583e-11], [0.0, 0.0, -6.125583e-11]], 'lattice_vectors': [[1.6445e-10, -9.4945252e-11, 3.76033333e-10], @@ -8151,7 +8151,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-', 'Strukturbericht Designation': 'Ai', 'Wyckoff Positions': 'a', 'aflow_prototype_id': 'A_hR1_166_a', - 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_hR1_166_a.html', + 'aflow_prototype_url': 'http://www.aflowlib.org/CrystalDatabase/A_hR1_166_a.beta-Po.html', 'atom_labels': ['Po'], 'atom_positions': [[0.0, 0.0, 0.0]], 'lattice_vectors': [[2.98911671e-10, -2.1818147e-11, -2.1818147e-11],