Commit 73e24472 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Fixed an issue with simulation cell parsing, added cell files to unittests.

parent a2b5aed6
......@@ -56,7 +56,6 @@ env/
# CP2K files
test/**/*.wfn
test/**/*.cube
test/**/*.cell
test/**/*.restart
test/**/*.restart.bak-1
test/**/*.restart.bak-2
......
......@@ -402,7 +402,7 @@ class CommonMatcher(object):
"""
self.section_system_index = gIndex
self.cache_service.push_value("number_of_atoms")
self.cache_service.push_array_values("simulation_cell", unit="angstrom")
# self.cache_service.push_array_values("simulation_cell", unit="angstrom")
self.cache_service.push_array_values("configuration_periodic_dimensions")
self.cache_service.push_array_values("atom_labels")
......
......@@ -245,6 +245,9 @@ class CP2KGeoOptParser(MainHierarchicalParser):
if energy is not None:
self.cache_service["frame_sequence_potential_energy"].append(energy[0])
def onClose_section_system(self, backend, gIndex, section):
self.cache_service.push_array_values("simulation_cell", unit="angstrom")
def onClose_section_method(self, backend, gIndex, section):
traj_file = self.file_service.get_file_by_id("trajectory")
traj_format = self.cache_service["trajectory_format"]
......
......@@ -33,6 +33,7 @@ class CP2KMDParser(MainHierarchicalParser):
self.energy_freq = None
self.cell_freq = None
self.md_quicksteps = []
self.ensemble = None
#=======================================================================
# Globally cached values
......@@ -156,6 +157,7 @@ class CP2KMDParser(MainHierarchicalParser):
}
sampling = sampling_map.get(sampling)
if sampling is not None:
self.ensemble = sampling
backend.addValue("ensemble_type", sampling)
# Sampling type
......@@ -274,6 +276,11 @@ class CP2KMDParser(MainHierarchicalParser):
systemGID = backend.openSection("section_system")
single_conf_gids.append(sectionGID)
# If NPT is run, and the cell file is not available, output the
# simulation cel only on the first step to section_system
if i_step == 0 and self.ensemble == "NPT" and self.cell_iterator is None:
self.cache_service.push_array_values("simulation_cell", unit="angstrom")
# Trajectory
if freqs["trajectory"][1] and self.traj_iterator is not None:
if (i_step + 1) % freqs["trajectory"][0] == 0 or (i_step == last_step and add_last_traj):
......@@ -320,7 +327,8 @@ class CP2KMDParser(MainHierarchicalParser):
if (i_step + 1) % freqs["cell"][0] == 0:
line = next(self.cell_iterator)
cell = np.reshape(line, (3, 3))
self.cache_service["simulation_cell"] = cell
self.backend.addArrayValues("simulation_cell", cell, unit="angstrom")
# self.cache_service["simulation_cell"] = cell
# Output file
if md_steps:
......
......@@ -91,6 +91,7 @@ class CP2KSinglePointParser(MainHierarchicalParser):
let's get it dynamically just in case there's something wrong.
"""
self.cache_service.push_array_values("atom_positions", unit="angstrom")
self.cache_service.push_array_values("simulation_cell", unit="angstrom")
#===========================================================================
# adHoc functions
# Step Time [fs] Ax [Angstrom] Ay [Angstrom] Az [Angstrom] Bx [Angstrom] By [Angstrom] Bz [Angstrom] Cx [Angstrom] Cy [Angstrom] Cz [Angstrom] Volume [Angstrom^3]
0 0.000 6.0000000000 0.0000000000 0.0000000000 0.0000000000 6.0000000000 0.0000000000 0.0000000000 0.0000000000 6.0000000000 216.0000000000
1 0.500 5.9995865891 -0.0006884817 -0.0010127508 -0.0006884817 6.0022063627 -0.0015429583 -0.0010127508 -0.0015429583 6.0008306670 216.0944304520
2 1.000 5.9991635661 -0.0013715242 -0.0020124634 -0.0013715223 6.0044280501 -0.0030858637 -0.0020124619 -0.0030858693 6.0016525349 216.1887100692
3 1.500 5.9987354326 -0.0020507044 -0.0030038816 -0.0020506975 6.0066631407 -0.0046293928 -0.0030038779 -0.0046294135 6.0024678974 216.2830142465
4 2.000 5.9983081311 -0.0027276709 -0.0039930111 -0.0027276548 6.0089096419 -0.0061742363 -0.0039930078 -0.0061742825 6.0032801692 216.3776082058
5 2.500 5.9978882711 -0.0034040416 -0.0049866158 -0.0034040111 6.0111656733 -0.0077211182 -0.0049866223 -0.0077211991 6.0040935434 216.4728134845
6 3.000 5.9974821459 -0.0040812622 -0.0059914363 -0.0040812103 6.0134296600 -0.0092707652 -0.0059914716 -0.0092708864 6.0049124772 216.5689609536
7 3.500 5.9970947973 -0.0047604264 -0.0070132193 -0.0047603435 6.0157005634 -0.0108238027 -0.0070133129 -0.0108239647 6.0057410535 216.6663424164
8 4.000 5.9967291987 -0.0054420965 -0.0080557344 -0.0054419694 6.0179781365 -0.0123805881 -0.0080559250 -0.0123807875 6.0065823171 216.7651664221
9 4.500 5.9963856760 -0.0061261768 -0.0091200506 -0.0061259871 6.0202631442 -0.0139410237 -0.0091203831 -0.0139412562 6.0074377769 216.8655273092
10 5.000 5.9960617905 -0.0068118798 -0.0102043036 -0.0068116027 6.0225574669 -0.0155044063 -0.0102048226 -0.0155046726 6.0083072343 216.9673985082
# Step Time [fs] Ax [Angstrom] Ay [Angstrom] Az [Angstrom] Bx [Angstrom] By [Angstrom] Bz [Angstrom] Cx [Angstrom] Cy [Angstrom] Cz [Angstrom] Volume [Angstrom^3]
0 0.000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 956.4868456940
1 0.500 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 956.4868456940
2 1.000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 956.4868456940
3 1.500 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 956.4868456940
4 2.000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 956.4868456940
5 2.500 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 956.4868456940
6 3.000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 956.4868456940
7 3.500 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 956.4868456940
8 4.000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 956.4868456940
9 4.500 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 956.4868456940
10 5.000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 0.0000000000 0.0000000000 0.0000000000 9.8528000000 956.4868456940
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