-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Random parser improvements #239
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ | |
Scf, | ||
BasisSetContainer, | ||
CoreHole, | ||
KMesh, | ||
) | ||
from nomad.parsing.file_parser import TextParser, Quantity | ||
from simulationworkflowschema import ( | ||
|
@@ -257,6 +258,11 @@ def convert_eigenvalues(string): | |
r'scf.ElectronicTemperature\s+(\S+)', | ||
repeats=False, | ||
), | ||
Quantity( | ||
'scf.Kgrid', | ||
r'scf.Kgrid\s+(\d+\s+\d+\s+\d+)', | ||
repeats=False, | ||
) | ||
Quantity('scf.dftD', r'scf.dftD\s+([a-z]+)', repeats=False), | ||
Quantity('version.dftD', r'version.dftD\s+([23])', repeats=False), | ||
Quantity( | ||
|
@@ -726,18 +732,39 @@ def parse_method(self): | |
else: | ||
sec_electronic.van_der_waals_method = '' | ||
|
||
def parse_eigenvalues(self): | ||
def parse_eigenvalues_and_kmesh(self): | ||
eigenvalues = BandEnergies() | ||
|
||
sec_k_mesh = KMesh() | ||
self.archive.run[-1].method[-1].k_mesh = sec_k_mesh | ||
|
||
k_mesh_grid = mainfile_parser.get('scf.Kgrid') | ||
if k_mesh_grid is not None: | ||
sec_k_mesh.grid = k_mesh_grid | ||
|
||
self.archive.run[-1].calculation[-1].eigenvalues.append(eigenvalues) | ||
values = mainfile_parser.get('eigenvalues') | ||
if values is not None: | ||
kpoints = values.get('kpoints') | ||
if kpoints is not None: | ||
eigenvalues.kpoints = kpoints | ||
eigenvalues.n_kpoints = len(kpoints) | ||
# OpenMX uses only inversion symmetry so every k-point except gamma-point has multiplicity of 2 | ||
ondracka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
kpoints_multiplicities = [] | ||
for kpoint in kpoints: | ||
if np.allclose(kpoint, [[0.0, 0.0, 0.0]], rtol=0.0): | ||
kpoints_multiplicities.append(1) | ||
else: | ||
kpoints_multiplicities.append(2) | ||
sec_k_mesh.points = np.array(kpoints).astype(complex) | ||
sec_k_mesh.multiplicities = kpoints_multiplicities | ||
eigenvalues.kpoints_multiplicities = kpoints_multiplicities | ||
else: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe a comment saying There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe |
||
eigenvalues.kpoints = [[0, 0, 0]] | ||
eigenvalues.n_kpoints = 1 | ||
eigenvalues.kpoints_multiplicities = [1] | ||
sec_k_mesh.points = [[0, 0, 0]] | ||
sec_k_mesh.multiplicities = [1] | ||
values = values.get('eigenvalues') | ||
if values is not None: | ||
if self.spinpolarized: | ||
|
@@ -915,4 +942,4 @@ def parse(self, mainfile: str, archive: EntryArchive, logger): | |
except (IndexError, AttributeError): | ||
pass | ||
|
||
self.parse_eigenvalues() | ||
self.parse_eigenvalues_and_kmesh() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
BasisSetContainer, | ||
AtomParameters, | ||
KMesh, | ||
Scf, | ||
) | ||
from runschema.system import System, Atoms | ||
from runschema.calculation import ( | ||
|
@@ -3248,6 +3249,8 @@ def parse_method(self, run): | |
sec_method.dft = sec_dft | ||
sec_electronic = Electronic() | ||
sec_method.electronic = sec_electronic | ||
sec_scf = Scf() | ||
sec_method.scf = sec_scf | ||
Comment on lines
+3252
to
+3253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the existence of the if (threshold := run.get_header('scf_threshold_energy_change')) is not None:
sec_method.scf = Scf(threshold_energy_change = threshold) |
||
|
||
starting_magnetization = run.get_header('starting_magnetization') | ||
spin_orbit_mode = run.get_header('spin_orbit_mode') | ||
|
@@ -3260,6 +3263,8 @@ def parse_method(self, run): | |
sec_kmesh.n_points = run.get_header('k_points', {}).get('nk', 1) | ||
sec_kmesh.points = run.get_header('k_points', {}).get('points', None) | ||
|
||
sec_scf.threshold_energy_change = run.get_header('scf_threshold_energy_change') | ||
|
||
g_vector_sticks = run.get_header('g_vector_sticks', {}).get('Sum', None) | ||
if g_vector_sticks is not None: | ||
names = [ | ||
|
@@ -3330,7 +3335,6 @@ def parse_method(self, run): | |
|
||
# other method variables | ||
names = [ | ||
'scf_threshold_energy_change', | ||
'x_qe_core_charge_realspace', | ||
'x_qe_exact_exchange_fraction', | ||
'x_qe_diagonalization_algorithm', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,10 @@ def RyB_to_N(value): | |
return (value * ureg.rydberg / ureg.bohr).to_base_units().magnitude | ||
|
||
|
||
def Ry_to_eV(value): | ||
return (value * ureg.rydberg).to_base_units().magnitude | ||
|
||
|
||
Comment on lines
+40
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm kind of confused about the naming: should it rather be "Ry_to_J"? |
||
def test_scf(parser): | ||
archive = EntryArchive() | ||
parser.parse('tests/data/quantumespresso/HO_scf/benchmark2.out', archive, None) | ||
|
@@ -73,6 +77,7 @@ def test_scf(parser): | |
assert sec_method.dft.xc_functional.exchange[0].name == 'GGA_X_PBE' | ||
assert sec_method.electronic.n_electrons[0] == 8 | ||
assert sec_method.electronic.n_spin_channels == 1 | ||
assert sec_method.scf.threshold_energy_change.magnitude == approx(Ry_to_eV(1e-6)) | ||
sec_atoms = sec_method.atom_parameters | ||
assert len(sec_atoms) == 2 | ||
assert sec_atoms[1].label == 'H' | ||
|
@@ -157,6 +162,7 @@ def test_multirun(parser): | |
assert sec_runs[2].calculation[0].scf_iteration[ | ||
11 | ||
].time_physical.magnitude == approx(1189.6) | ||
assert sec_method.scf.threshold_energy_change.magnitude == approx(Ry_to_eV(1e-5)) | ||
|
||
|
||
def test_md(parser): | ||
|
@@ -168,6 +174,7 @@ def test_md(parser): | |
sec_method = sec_run.method[0] | ||
assert len(sec_method.k_mesh.points) == 1 | ||
assert sec_method.electronic.n_spin_channels == 1 | ||
assert sec_method.scf.threshold_energy_change.magnitude == approx(Ry_to_eV(1e-8)) | ||
sec_sccs = sec_run.calculation | ||
assert len(sec_sccs) == 50 | ||
assert archive.run[0].system[6].atoms.positions[1][2].magnitude == approx( | ||
|
@@ -217,6 +224,7 @@ def test_vcrelax(parser): | |
assert sec_method.electronic.smearing.kind == 'tetrahedra' | ||
assert sec_method.electronic.smearing.width is None | ||
assert sec_method.electronic.n_spin_channels == 1 | ||
assert sec_method.scf.threshold_energy_change.magnitude == approx(Ry_to_eV(1e-8)) | ||
|
||
|
||
def test_noncolmag(parser): | ||
|
@@ -243,3 +251,4 @@ def test_noncolmag(parser): | |
== (0.01 * ureg.rydberg).to_base_units().magnitude | ||
) | ||
assert sec_method.electronic.n_spin_channels is None | ||
assert sec_method.scf.threshold_energy_change.magnitude == approx(Ry_to_eV(1e-8)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have your request about the k-line density scheduled next.