Commit 30b1c39e authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Changes in tests.

parent a1a611bf
...@@ -312,6 +312,7 @@ class FileParser(object): ...@@ -312,6 +312,7 @@ class FileParser(object):
self.default_data_caching_level = CachingLevel.ForwardAndCache self.default_data_caching_level = CachingLevel.ForwardAndCache
self.default_section_caching_level = CachingLevel.Forward self.default_section_caching_level = CachingLevel.Forward
self.onClose = {} self.onClose = {}
self.caching_backend = None
def parse(self): def parse(self):
"""Parser the information from the given file(s). By default uses the """Parser the information from the given file(s). By default uses the
...@@ -342,7 +343,7 @@ class FileParser(object): ...@@ -342,7 +343,7 @@ class FileParser(object):
onClose[attr] = [callback] onClose[attr] = [callback]
# Setup the backend that caches ond handles triggers # Setup the backend that caches ond handles triggers
active_backend = ActiveBackend.activeBackend( self.caching_backend = ActiveBackend.activeBackend(
metaInfoEnv=self.backend.metaInfoEnv(), metaInfoEnv=self.backend.metaInfoEnv(),
cachingLevelForMetaName=self.caching_level_for_metaname, cachingLevelForMetaName=self.caching_level_for_metaname,
defaultDataCachingLevel=self.default_data_caching_level, defaultDataCachingLevel=self.default_data_caching_level,
...@@ -357,11 +358,11 @@ class FileParser(object): ...@@ -357,11 +358,11 @@ class FileParser(object):
self.backend.fileOut.write("[") self.backend.fileOut.write("[")
uri = "file://" + fileToParse uri = "file://" + fileToParse
parserInfo = {'name': 'cp2k-parser', 'version': '1.0'} parserInfo = {'name': 'cp2k-parser', 'version': '1.0'}
active_backend.startedParsingSession(uri, parserInfo) self.caching_backend.startedParsingSession(uri, parserInfo)
with open(fileToParse, "r") as fIn: with open(fileToParse, "r") as fIn:
parser = parserBuilder.buildParser(PushbackLineFile(fIn), active_backend, superContext=self) parser = parserBuilder.buildParser(PushbackLineFile(fIn), self.caching_backend, superContext=self)
parser.parse() parser.parse()
active_backend.finishedParsingSession("ParseSuccess", None) self.caching_backend.finishedParsingSession("ParseSuccess", None)
self.backend.fileOut.write("]\n") self.backend.fileOut.write("]\n")
def get_metainfos(self): def get_metainfos(self):
......
...@@ -35,7 +35,7 @@ def get_results(folder, metainfo_to_keep=None): ...@@ -35,7 +35,7 @@ def get_results(folder, metainfo_to_keep=None):
def get_result(folder, metaname): def get_result(folder, metaname):
results = get_results(folder, metaname) results = get_results(folder, metaname)
result = results[metaname] result = results[metaname]
return result.value return result
#=============================================================================== #===============================================================================
...@@ -61,20 +61,21 @@ class TestXCFunctional(unittest.TestCase): ...@@ -61,20 +61,21 @@ class TestXCFunctional(unittest.TestCase):
#=============================================================================== #===============================================================================
class TestSectionSingleConfigurationCalculation(unittest.TestCase): class TestSectionSingleConfigurationCalculation(unittest.TestCase):
results = get_results("section_single_configuration_calculation", "section_single_configuration_calculation") def setUp(self):
self.results = get_results("section_single_configuration_calculation", "section_single_configuration_calculation")
def test_energy_total_scf_iteration(self): def test_energy_total_scf_iteration(self):
energy_total = self.results["energy_total_scf_iteration"].value energy_total = self.results["energy_total_scf_iteration"]
expected_result = convert_unit(np.array(-32.2320848878), "hartree") expected_result = convert_unit(np.array(-32.2320848878), "hartree")
self.assertTrue(np.array_equal(energy_total[0], expected_result)) self.assertTrue(np.array_equal(energy_total[0], expected_result))
def test_energy_total(self): def test_energy_total(self):
energy_total = self.results["energy_total"].value energy_total = self.results["energy_total"]
expected_result = convert_unit(np.array(-31.297885372811063), "hartree") expected_result = convert_unit(np.array(-31.297885372811063), "hartree")
self.assertTrue(np.array_equal(energy_total, expected_result)) self.assertTrue(np.array_equal(energy_total, expected_result))
def test_atom_forces(self): def test_atom_forces(self):
atomic_forces = self.results["atom_forces"].value atomic_forces = self.results["atom_forces"]
expected_result = convert_unit( expected_result = convert_unit(
np.array([ np.array([
[0.00000000, 0.00000000, 0.00000000], [0.00000000, 0.00000000, 0.00000000],
...@@ -94,15 +95,16 @@ class TestSectionSingleConfigurationCalculation(unittest.TestCase): ...@@ -94,15 +95,16 @@ class TestSectionSingleConfigurationCalculation(unittest.TestCase):
#=============================================================================== #===============================================================================
class TestSectionSystemDescription(unittest.TestCase): class TestSectionSystemDescription(unittest.TestCase):
results = get_results("section_system_description", "section_system_description") def setUp(self):
self.results = get_results("section_system_description", "section_system_description")
def test_atom_label(self): def test_atom_label(self):
atom_labels = self.results["atom_label"].value atom_labels = self.results["atom_label"]
expected_labels = np.array(8*["Si"]) expected_labels = np.array(8*["Si"])
self.assertTrue(np.array_equal(atom_labels, expected_labels)) self.assertTrue(np.array_equal(atom_labels, expected_labels))
def test_simulation_cell(self): def test_simulation_cell(self):
cell = self.results["simulation_cell"].value cell = self.results["simulation_cell"]
n_vectors = cell.shape[0] n_vectors = cell.shape[0]
n_dim = cell.shape[1] n_dim = cell.shape[1]
self.assertEqual(n_vectors, 3) self.assertEqual(n_vectors, 3)
...@@ -111,17 +113,18 @@ class TestSectionSystemDescription(unittest.TestCase): ...@@ -111,17 +113,18 @@ class TestSectionSystemDescription(unittest.TestCase):
self.assertTrue(np.array_equal(cell, expected_cell)) self.assertTrue(np.array_equal(cell, expected_cell))
def test_number_of_atoms(self): def test_number_of_atoms(self):
n_atoms = self.results["number_of_atoms"].value n_atoms = self.results["number_of_atoms"]
self.assertEqual(n_atoms, 8) self.assertEqual(n_atoms, 8)
def test_atom_position(self): def test_atom_position(self):
atom_position = self.results["atom_position"].value atom_position = self.results["atom_position"]
expected_position = convert_unit(np.array([4.073023, 4.073023, 1.357674]), "angstrom") expected_position = convert_unit(np.array([4.073023, 4.073023, 1.357674]), "angstrom")
self.assertTrue(np.array_equal(atom_position[-1, :], expected_position)) self.assertTrue(np.array_equal(atom_position[-1, :], expected_position))
#=============================================================================== #===============================================================================
if __name__ == '__main__': if __name__ == '__main__':
pass
logger = logging.getLogger("cp2kparser") logger = logging.getLogger("cp2kparser")
logger.setLevel(logging.ERROR) logger.setLevel(logging.ERROR)
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
DBCSR| Communication thread load 87 DBCSR| Communication thread load 87
**** **** ****** ** PROGRAM STARTED AT 2016-02-22 21:55:14.594 **** **** ****** ** PROGRAM STARTED AT 2016-03-10 22:35:13.174
***** ** *** *** ** PROGRAM STARTED ON lauri-Lenovo-Z50-70 ***** ** *** *** ** PROGRAM STARTED ON lauri-Lenovo-Z50-70
** **** ****** PROGRAM STARTED BY lauri ** **** ****** PROGRAM STARTED BY lauri
***** ** ** ** ** PROGRAM PROCESS ID 5052 ***** ** ** ** ** PROGRAM PROCESS ID 7335
**** ** ******* ** PROGRAM STARTED IN /home/lauri/Dropbox/nomad-dev/nomad-l **** ** ******* ** PROGRAM STARTED IN /home/lauri/Dropbox/nomad-dev/nomad-l
ab-base/parsers/cp2k/test/unittests/c ab-base/parsers/cp2k/test/unittests/c
p2k_2.6.2/section_single_configuratio p2k_2.6.2/section_single_configuratio
...@@ -46,13 +46,13 @@ ...@@ -46,13 +46,13 @@
MEMORY| system memory details [Kb] MEMORY| system memory details [Kb]
MEMORY| rank 0 min max average MEMORY| rank 0 min max average
MEMORY| MemTotal 8070384 8070384 8070384 8070384 MEMORY| MemTotal 8070388 8070388 8070388 8070388
MEMORY| MemFree 3544704 3544704 3544704 3544704 MEMORY| MemFree 2886880 2886880 2886880 2886880
MEMORY| Buffers 267372 267372 267372 267372 MEMORY| Buffers 859068 859068 859068 859068
MEMORY| Cached 2047768 2047768 2047768 2047768 MEMORY| Cached 2349220 2349220 2349220 2349220
MEMORY| Slab 298472 298472 298472 298472 MEMORY| Slab 456984 456984 456984 456984
MEMORY| SReclaimable 254424 254424 254424 254424 MEMORY| SReclaimable 417916 417916 417916 417916
MEMORY| MemLikelyFree 6114268 6114268 6114268 6114268 MEMORY| MemLikelyFree 6513084 6513084 6513084 6513084
*** Fundamental physical constants (SI units) *** *** Fundamental physical constants (SI units) ***
...@@ -479,7 +479,7 @@ ...@@ -479,7 +479,7 @@
Total charge density on r-space grids: -0.0000000043 Total charge density on r-space grids: -0.0000000043
Total charge density g-space grids: -0.0000000043 Total charge density g-space grids: -0.0000000043
1 NoMix/Diag. 0.40E+00 0.8 0.75558724 -32.2320848878 -3.22E+01 1 NoMix/Diag. 0.40E+00 0.9 0.75558724 -32.2320848878 -3.22E+01
Trace(PS): 32.0000000000 Trace(PS): 32.0000000000
Electronic density on regular grids: -31.9999999956 0.0000000044 Electronic density on regular grids: -31.9999999956 0.0000000044
...@@ -487,7 +487,7 @@ ...@@ -487,7 +487,7 @@
Total charge density on r-space grids: -0.0000000017 Total charge density on r-space grids: -0.0000000017
Total charge density g-space grids: -0.0000000017 Total charge density g-space grids: -0.0000000017
2 Broy./Diag. 0.40E+00 1.4 0.05667976 -31.1418135481 1.09E+00 2 Broy./Diag. 0.40E+00 1.3 0.05667976 -31.1418135481 1.09E+00
Trace(PS): 32.0000000000 Trace(PS): 32.0000000000
Electronic density on regular grids: -31.9999999907 0.0000000093 Electronic density on regular grids: -31.9999999907 0.0000000093
...@@ -654,13 +654,13 @@ ...@@ -654,13 +654,13 @@
ROUTINE CALLS TOT TIME [s] AVE VOLUME [Bytes] PERFORMANCE [MB/s] ROUTINE CALLS TOT TIME [s] AVE VOLUME [Bytes] PERFORMANCE [MB/s]
MP_Group 5 0.000 MP_Group 5 0.000
MP_Bcast 12 0.000 5. 0.25 MP_Bcast 12 0.010 5. 0.01
MP_Allreduce 171 0.000 42. 38.42 MP_Allreduce 171 0.000 42. 31.37
MP_Sync 4 0.000 MP_Sync 4 0.000
MP_Alltoall 183 0.000 15743. 12047.92 MP_Alltoall 183 0.000 15743. 11176.59
MP_Wait 264 0.000 MP_Wait 264 0.000
MP_ISend 88 0.001 13472. 1836.51 MP_ISend 88 0.001 13472. 1589.34
MP_IRecv 88 0.000 13472. 13441.60 MP_IRecv 88 0.000 13472. 13580.33
MP_Memory 264 0.000 MP_Memory 264 0.000
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
...@@ -732,32 +732,33 @@ ...@@ -732,32 +732,33 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
SUBROUTINE CALLS ASD SELF TIME TOTAL TIME SUBROUTINE CALLS ASD SELF TIME TOTAL TIME
MAXIMUM AVERAGE MAXIMUM AVERAGE MAXIMUM MAXIMUM AVERAGE MAXIMUM AVERAGE MAXIMUM
CP2K 1 1.0 0.003 0.003 16.479 16.479 CP2K 1 1.0 0.031 0.031 17.001 17.001
qs_forces 1 2.0 0.000 0.000 16.388 16.388 qs_forces 1 2.0 0.001 0.001 16.583 16.583
qs_energies_scf 1 3.0 0.000 0.000 14.665 14.665 qs_energies_scf 1 3.0 0.035 0.035 14.881 14.881
scf_env_do_scf 1 4.0 0.000 0.000 13.723 13.723 scf_env_do_scf 1 4.0 0.000 0.000 13.705 13.705
scf_env_do_scf_inner_loop 10 5.0 0.001 0.001 13.723 13.723 scf_env_do_scf_inner_loop 10 5.0 0.038 0.038 13.705 13.705
rebuild_ks_matrix 11 6.7 0.000 0.000 9.054 9.054 rebuild_ks_matrix 11 6.7 0.000 0.000 8.992 8.992
qs_ks_build_kohn_sham_matrix 11 7.7 0.001 0.001 9.054 9.054 qs_ks_build_kohn_sham_matrix 11 7.7 0.003 0.003 8.992 8.992
sum_up_and_integrate 11 8.7 0.004 0.004 8.756 8.756 sum_up_and_integrate 11 8.7 0.004 0.004 8.699 8.699
integrate_v_rspace 11 9.7 8.630 8.630 8.752 8.752 integrate_v_rspace 11 9.7 8.574 8.574 8.696 8.696
qs_ks_update_qs_env 10 6.0 0.000 0.000 8.002 8.002 qs_ks_update_qs_env 10 6.0 0.000 0.000 7.928 7.928
qs_rho_update_rho 11 6.0 0.000 0.000 5.971 5.971 qs_rho_update_rho 11 6.0 0.000 0.000 5.952 5.952
calculate_rho_elec 11 7.0 5.718 5.718 5.971 5.971 calculate_rho_elec 11 7.0 5.705 5.705 5.952 5.952
qs_ks_update_qs_env_forces 1 3.0 0.000 0.000 1.052 1.052 qs_ks_update_qs_env_forces 1 3.0 0.000 0.000 1.064 1.064
build_core_hamiltonian_matrix_ 1 3.0 0.000 0.000 0.671 0.671 init_scf_run 1 4.0 0.007 0.007 0.735 0.735
init_scf_run 1 4.0 0.000 0.000 0.601 0.601 scf_env_initial_rho_setup 1 5.0 0.001 0.001 0.666 0.666
scf_env_initial_rho_setup 1 5.0 0.000 0.000 0.601 0.601 build_core_hamiltonian_matrix_ 1 3.0 0.000 0.000 0.637 0.637
fft_wrap_pw1pw2 120 9.8 0.001 0.001 0.553 0.553 fft_wrap_pw1pw2 120 9.8 0.001 0.001 0.562 0.562
fft_wrap_pw1pw2_150 54 10.1 0.029 0.029 0.502 0.502 fft_wrap_pw1pw2_150 54 10.1 0.028 0.028 0.515 0.515
fft3d_s 121 11.7 0.353 0.353 0.366 0.366 fft3d_s 121 11.7 0.363 0.363 0.430 0.430
build_core_ppnl_forces 1 4.0 0.345 0.345 0.345 0.345 qs_energies_init_hamiltonians 1 4.0 0.001 0.001 0.349 0.349
build_core_ppnl_forces 1 4.0 0.340 0.340 0.340 0.340
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
**** **** ****** ** PROGRAM ENDED AT 2016-02-22 21:55:31.153 **** **** ****** ** PROGRAM ENDED AT 2016-03-10 22:35:30.794
***** ** *** *** ** PROGRAM RAN ON lauri-Lenovo-Z50-70 ***** ** *** *** ** PROGRAM RAN ON lauri-Lenovo-Z50-70
** **** ****** PROGRAM RAN BY lauri ** **** ****** PROGRAM RAN BY lauri
***** ** ** ** ** PROGRAM PROCESS ID 5052 ***** ** ** ** ** PROGRAM PROCESS ID 7335
**** ** ******* ** PROGRAM STOPPED IN /home/lauri/Dropbox/nomad-dev/nomad-l **** ** ******* ** PROGRAM STOPPED IN /home/lauri/Dropbox/nomad-dev/nomad-l
ab-base/parsers/cp2k/test/unittests/c ab-base/parsers/cp2k/test/unittests/c
p2k_2.6.2/section_single_configuratio p2k_2.6.2/section_single_configuratio
......
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