Commit 10f93ca2 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Added support for atom_forces and energy_total.

parent 91758775
......@@ -86,16 +86,23 @@ class CP2KOutputParser(FileParser):
adHoc=self.adHoc_cp2k_section_quickstep_atom_information(),
otherMetaInfo=["atom_label", "atom_position"]
),
# SCF
# Single Configuration Calculation
SM(
sections=["section_single_configuration_calculation"],
startReStr=" SCF WAVEFUNCTION OPTIMIZATION",
subMatchers=[
SM(
sections=["section_scf_iteration"],
startReStr=r"\s+\d+\s+\S+\s+{f}\s+{f}\s+{f}\s+(?P<energy_total_scf_iteration__hartree>{f})\s+{f}".format(f=self.f_regex),
startReStr=r"\s+\d+\s+\S+\s+{0}\s+{0}\s+{0}\s+(?P<energy_total_scf_iteration__hartree>{0})\s+{0}".format(self.f_regex),
repeats=True,
),
SM(
startReStr=r" ENERGY\| Total FORCE_EVAL \( \w+ \) energy \(a\.u\.\):\s+(?P<energy_total__hartree>{0})".format(self.f_regex),
),
SM(
startReStr=r" ATOMIC FORCES in \[a\.u\.\]",
adHoc=self.adHoc_atom_forces()
),
]
),
SM(
......@@ -318,3 +325,34 @@ class CP2KOutputParser(FileParser):
parser.backend.addArrayValues("atom_label", labels)
return wrapper
def adHoc_atom_forces(self):
"""Used to extract the final atomic forces printed at the end of an
ENERGY_FORCE calculation is the PRINT setting is on.
"""
def wrapper(parser):
# Uninterestring lines
parser.fIn.readline()
parser.fIn.readline()
end_str = " SUM"
end = False
force_array = []
# Loop through coordinates until the sum of forces is read
while not end:
line = parser.fIn.readline()
if line.startswith(end_str):
end = True
else:
forces = line.split()[-3:]
forces = [float(x) for x in forces]
force_array.append(forces)
force_array = np.array(force_array)
# If anything found, push the results to the correct section
if len(force_array) != 0:
parser.backend.addArrayValues("atom_forces", force_array, unit="force_au")
return wrapper
......@@ -59,15 +59,37 @@ class TestXCFunctional(unittest.TestCase):
#===============================================================================
class TestSectionSCFIteration(unittest.TestCase):
class TestSectionSingleConfigurationCalculation(unittest.TestCase):
results = get_results("section_scf_iteration", "section_scf_iteration")
results = get_results("section_single_configuration_calculation", "section_single_configuration_calculation")
def test_energy_total(self):
def test_energy_total_scf_iteration(self):
energy_total = self.results["energy_total_scf_iteration"].value
expected_result = convert_unit(np.array(-32.2320848878), "hartree")
self.assertTrue(np.array_equal(energy_total[0], expected_result))
def test_energy_total(self):
energy_total = self.results["energy_total"].value
expected_result = convert_unit(np.array(-31.297885372811063), "hartree")
self.assertTrue(np.array_equal(energy_total, expected_result))
def test_atom_forces(self):
atomic_forces = self.results["atom_forces"].value
expected_result = convert_unit(
np.array([
[0.00000000, 0.00000000, 0.00000000],
[0.00000000, 0.00000001, 0.00000001],
[0.00000001, 0.00000001, 0.00000000],
[0.00000001, 0.00000000, 0.00000001],
[-0.00000001, -0.00000001, -0.00000001],
[-0.00000001, -0.00000001, -0.00000001],
[-0.00000001, -0.00000001, -0.00000001],
[-0.00000001, -0.00000001, -0.00000001],
]),
"force_au"
)
self.assertTrue(np.array_equal(atomic_forces, expected_result))
#===============================================================================
class TestSectionSystemDescription(unittest.TestCase):
......@@ -105,7 +127,7 @@ if __name__ == '__main__':
suites = []
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestXCFunctional))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestSectionSCFIteration))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestSectionSingleConfigurationCalculation))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestSectionSystemDescription))
alltests = unittest.TestSuite(suites)
unittest.TextTestRunner(verbosity=0).run(alltests)
......@@ -9,13 +9,14 @@
DBCSR| Communication thread load 87
**** **** ****** ** PROGRAM STARTED AT 2016-02-09 13:34:02.198
**** **** ****** ** PROGRAM STARTED AT 2016-02-22 21:55:14.594
***** ** *** *** ** PROGRAM STARTED ON lauri-Lenovo-Z50-70
** **** ****** PROGRAM STARTED BY lauri
***** ** ** ** ** PROGRAM PROCESS ID 6187
***** ** ** ** ** PROGRAM PROCESS ID 5052
**** ** ******* ** PROGRAM STARTED IN /home/lauri/Dropbox/nomad-dev/nomad-l
ab-base/parsers/cp2k/test/unittests/c
p2k_2.6.2/section_scf_iteration
p2k_2.6.2/section_single_configuratio
n_calculation
CP2K| version string: CP2K version 2.6.2
CP2K| source code revision number: svn:15893
......@@ -46,12 +47,12 @@
MEMORY| system memory details [Kb]
MEMORY| rank 0 min max average
MEMORY| MemTotal 8070384 8070384 8070384 8070384
MEMORY| MemFree 5390436 5390436 5390436 5390436
MEMORY| Buffers 268264 268264 268264 268264
MEMORY| Cached 1674216 1674216 1674216 1674216
MEMORY| Slab 138856 138856 138856 138856
MEMORY| SReclaimable 107848 107848 107848 107848
MEMORY| MemLikelyFree 7440764 7440764 7440764 7440764
MEMORY| MemFree 3544704 3544704 3544704 3544704
MEMORY| Buffers 267372 267372 267372 267372
MEMORY| Cached 2047768 2047768 2047768 2047768
MEMORY| Slab 298472 298472 298472 298472
MEMORY| SReclaimable 254424 254424 254424 254424
MEMORY| MemLikelyFree 6114268 6114268 6114268 6114268
*** Fundamental physical constants (SI units) ***
......@@ -478,7 +479,7 @@
Total charge density on r-space grids: -0.0000000043
Total charge density g-space grids: -0.0000000043
1 NoMix/Diag. 0.40E+00 0.9 0.75558724 -32.2320848878 -3.22E+01
1 NoMix/Diag. 0.40E+00 0.8 0.75558724 -32.2320848878 -3.22E+01
Trace(PS): 32.0000000000
Electronic density on regular grids: -31.9999999956 0.0000000044
......@@ -494,7 +495,7 @@
Total charge density on r-space grids: 0.0000000033
Total charge density g-space grids: 0.0000000033
3 Broy./Diag. 0.40E+00 1.3 0.09691469 -31.1974003416 -5.56E-02
3 Broy./Diag. 0.40E+00 1.4 0.09691469 -31.1974003416 -5.56E-02
Trace(PS): 32.0000000000
Electronic density on regular grids: -31.9999999897 0.0000000103
......@@ -550,7 +551,7 @@
Total charge density on r-space grids: 0.0000000051
Total charge density g-space grids: 0.0000000051
10 Broy./Diag. 0.40E+00 1.4 5.6405E-09 -31.2978852054 -1.66E-06
10 Broy./Diag. 0.40E+00 1.3 5.6405E-09 -31.2978852054 -1.66E-06
*** SCF run converged in 10 steps ***
......@@ -653,13 +654,13 @@
ROUTINE CALLS TOT TIME [s] AVE VOLUME [Bytes] PERFORMANCE [MB/s]
MP_Group 5 0.000
MP_Bcast 12 0.000 5. 0.23
MP_Allreduce 171 0.000 42. 37.09
MP_Bcast 12 0.000 5. 0.25
MP_Allreduce 171 0.000 42. 38.42
MP_Sync 4 0.000
MP_Alltoall 183 0.000 15743. 11370.76
MP_Alltoall 183 0.000 15743. 12047.92
MP_Wait 264 0.000
MP_ISend 88 0.001 13472. 1173.83
MP_IRecv 88 0.000 13472. 12693.24
MP_ISend 88 0.001 13472. 1836.51
MP_IRecv 88 0.000 13472. 13441.60
MP_Memory 264 0.000
-------------------------------------------------------------------------------
......@@ -731,32 +732,33 @@
-------------------------------------------------------------------------------
SUBROUTINE CALLS ASD SELF TIME TOTAL TIME
MAXIMUM AVERAGE MAXIMUM AVERAGE MAXIMUM
CP2K 1 1.0 0.003 0.003 16.373 16.373
qs_forces 1 2.0 0.000 0.000 16.283 16.283
qs_energies_scf 1 3.0 0.000 0.000 14.589 14.589
scf_env_do_scf 1 4.0 0.000 0.000 13.674 13.674
scf_env_do_scf_inner_loop 10 5.0 0.017 0.017 13.674 13.674
rebuild_ks_matrix 11 6.7 0.000 0.000 8.997 8.997
qs_ks_build_kohn_sham_matrix 11 7.7 0.001 0.001 8.997 8.997
sum_up_and_integrate 11 8.7 0.003 0.003 8.715 8.715
integrate_v_rspace 11 9.7 8.596 8.596 8.711 8.711
qs_ks_update_qs_env 10 6.0 0.000 0.000 7.942 7.942
qs_rho_update_rho 11 6.0 0.000 0.000 5.914 5.914
calculate_rho_elec 11 7.0 5.677 5.677 5.913 5.913
qs_ks_update_qs_env_forces 1 3.0 0.000 0.000 1.056 1.056
build_core_hamiltonian_matrix_ 1 3.0 0.000 0.000 0.638 0.638
init_scf_run 1 4.0 0.000 0.000 0.584 0.584
scf_env_initial_rho_setup 1 5.0 0.000 0.000 0.583 0.583
fft_wrap_pw1pw2 120 9.8 0.001 0.001 0.519 0.519
fft_wrap_pw1pw2_150 54 10.1 0.028 0.028 0.475 0.475
fft3d_s 121 11.7 0.335 0.335 0.344 0.344
build_core_ppnl_forces 1 4.0 0.341 0.341 0.341 0.341
CP2K 1 1.0 0.003 0.003 16.479 16.479
qs_forces 1 2.0 0.000 0.000 16.388 16.388
qs_energies_scf 1 3.0 0.000 0.000 14.665 14.665
scf_env_do_scf 1 4.0 0.000 0.000 13.723 13.723
scf_env_do_scf_inner_loop 10 5.0 0.001 0.001 13.723 13.723
rebuild_ks_matrix 11 6.7 0.000 0.000 9.054 9.054
qs_ks_build_kohn_sham_matrix 11 7.7 0.001 0.001 9.054 9.054
sum_up_and_integrate 11 8.7 0.004 0.004 8.756 8.756
integrate_v_rspace 11 9.7 8.630 8.630 8.752 8.752
qs_ks_update_qs_env 10 6.0 0.000 0.000 8.002 8.002
qs_rho_update_rho 11 6.0 0.000 0.000 5.971 5.971
calculate_rho_elec 11 7.0 5.718 5.718 5.971 5.971
qs_ks_update_qs_env_forces 1 3.0 0.000 0.000 1.052 1.052
build_core_hamiltonian_matrix_ 1 3.0 0.000 0.000 0.671 0.671
init_scf_run 1 4.0 0.000 0.000 0.601 0.601
scf_env_initial_rho_setup 1 5.0 0.000 0.000 0.601 0.601
fft_wrap_pw1pw2 120 9.8 0.001 0.001 0.553 0.553
fft_wrap_pw1pw2_150 54 10.1 0.029 0.029 0.502 0.502
fft3d_s 121 11.7 0.353 0.353 0.366 0.366
build_core_ppnl_forces 1 4.0 0.345 0.345 0.345 0.345
-------------------------------------------------------------------------------
**** **** ****** ** PROGRAM ENDED AT 2016-02-09 13:34:18.639
**** **** ****** ** PROGRAM ENDED AT 2016-02-22 21:55:31.153
***** ** *** *** ** PROGRAM RAN ON lauri-Lenovo-Z50-70
** **** ****** PROGRAM RAN BY lauri
***** ** ** ** ** PROGRAM PROCESS ID 6187
***** ** ** ** ** PROGRAM PROCESS ID 5052
**** ** ******* ** PROGRAM STOPPED IN /home/lauri/Dropbox/nomad-dev/nomad-l
ab-base/parsers/cp2k/test/unittests/c
p2k_2.6.2/section_scf_iteration
p2k_2.6.2/section_single_configuratio
n_calculation
Markdown is supported
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