Skip to content
Snippets Groups Projects
Commit 3438871a authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Merge branch 'master' into lauri_restructure

parents 0fd28ca1 b6f64de2
Branches
Tags
No related merge requests found
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
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)
...@@ -4001,7 +4001,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-', ...@@ -4001,7 +4001,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-',
'Strukturbericht Designation': 'A11', 'Strukturbericht Designation': 'A11',
'Wyckoff Positions': 'f', 'Wyckoff Positions': 'f',
'aflow_prototype_id': 'A_oC8_64_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_labels': ['Ga', 'Ga', 'Ga', 'Ga'],
'atom_positions': [[0.0, 1.18658047e-10, 3.665979e-11], 'atom_positions': [[0.0, 1.18658047e-10, 3.665979e-11],
[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': '-', ...@@ -5728,7 +5728,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-',
'Strukturbericht Designation': 'A6', 'Strukturbericht Designation': 'A6',
'Wyckoff Positions': 'a', 'Wyckoff Positions': 'a',
'aflow_prototype_id': 'A_tI2_139_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_labels': ['In'],
'atom_positions': [[0.0, 0.0, 0.0]], 'atom_positions': [[0.0, 0.0, 0.0]],
'lattice_vectors': [[3.2512769800000005e-10, 0.0, 0.0], 'lattice_vectors': [[3.2512769800000005e-10, 0.0, 0.0],
...@@ -5854,7 +5854,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-', ...@@ -5854,7 +5854,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-',
'Strukturbericht Designation': 'Aa', 'Strukturbericht Designation': 'Aa',
'Wyckoff Positions': 'a', 'Wyckoff Positions': 'a',
'aflow_prototype_id': 'A_tI2_139_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_labels': ['Pa'],
'atom_positions': [[0.0, 0.0, 0.0]], 'atom_positions': [[0.0, 0.0, 0.0]],
'lattice_vectors': [[3.925e-10, 0.0, 0.0], 'lattice_vectors': [[3.925e-10, 0.0, 0.0],
...@@ -7518,7 +7518,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-', ...@@ -7518,7 +7518,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-',
'Strukturbericht Designation': 'A7', 'Strukturbericht Designation': 'A7',
'Wyckoff Positions': 'c', 'Wyckoff Positions': 'c',
'aflow_prototype_id': 'A_hR2_166_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_labels': ['As', 'As'],
'atom_positions': [[1.37328129e-10, 1.37328129e-10, 1.37328129e-10], 'atom_positions': [[1.37328129e-10, 1.37328129e-10, 1.37328129e-10],
[-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': '-', ...@@ -7977,7 +7977,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-',
'Strukturbericht Designation': '-', 'Strukturbericht Designation': '-',
'Wyckoff Positions': 'c', 'Wyckoff Positions': 'c',
'aflow_prototype_id': 'A_hR2_166_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_labels': ['C', 'C'],
'atom_positions': [[0.0, 0.0, 1.6740000000000337e-10], 'atom_positions': [[0.0, 0.0, 1.6740000000000337e-10],
[0.0, 0.0, 8.369999999999966e-10]], [0.0, 0.0, 8.369999999999966e-10]],
...@@ -8113,7 +8113,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-', ...@@ -8113,7 +8113,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-',
'Strukturbericht Designation': 'A10', 'Strukturbericht Designation': 'A10',
'Wyckoff Positions': 'a', 'Wyckoff Positions': 'a',
'aflow_prototype_id': 'A_hR1_166_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_labels': ['Hg'],
'atom_positions': [[0.0, 0.0, 0.0]], 'atom_positions': [[0.0, 0.0, 0.0]],
'lattice_vectors': [[2.9288947099999997e-10, 'lattice_vectors': [[2.9288947099999997e-10,
...@@ -8135,7 +8135,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-', ...@@ -8135,7 +8135,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-',
'Strukturbericht Designation': '-', 'Strukturbericht Designation': '-',
'Wyckoff Positions': 'c', 'Wyckoff Positions': 'c',
'aflow_prototype_id': 'A_hR2_166_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_labels': ['O', 'O'],
'atom_positions': [[0.0, 0.0, 6.125583e-11], [0.0, 0.0, -6.125583e-11]], '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], 'lattice_vectors': [[1.6445e-10, -9.4945252e-11, 3.76033333e-10],
...@@ -8151,7 +8151,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-', ...@@ -8151,7 +8151,7 @@ structure_types_by_spacegroup = {1: [{'Notes': '-',
'Strukturbericht Designation': 'Ai', 'Strukturbericht Designation': 'Ai',
'Wyckoff Positions': 'a', 'Wyckoff Positions': 'a',
'aflow_prototype_id': 'A_hR1_166_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_labels': ['Po'],
'atom_positions': [[0.0, 0.0, 0.0]], 'atom_positions': [[0.0, 0.0, 0.0]],
'lattice_vectors': [[2.98911671e-10, -2.1818147e-11, -2.1818147e-11], 'lattice_vectors': [[2.98911671e-10, -2.1818147e-11, -2.1818147e-11],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment