From 0e2879e79fde86909fb9e5bd6a8a9d331fe9527a Mon Sep 17 00:00:00 2001 From: robinzyb <38876805+robinzyb@users.noreply.github.com> Date: Wed, 21 Feb 2024 11:01:04 +0100 Subject: [PATCH 1/2] convert npt_i cell to angstrom when parsing from cp2k output --- cp2kdata/block_parser/cells.py | 3 +++ .../v2022.2/aimd_npt_i/deepmd/set.000/box.npy | Bin 920 -> 920 bytes .../aimd_npt_i/deepmd/set.000/virial.npy | Bin 920 -> 920 bytes 3 files changed, 3 insertions(+) diff --git a/cp2kdata/block_parser/cells.py b/cp2kdata/block_parser/cells.py index b165f29..bc5f579 100644 --- a/cp2kdata/block_parser/cells.py +++ b/cp2kdata/block_parser/cells.py @@ -127,6 +127,9 @@ def parse_all_md_cells(output_file: List[str], match["alpha"], match["beta"], match["gamma"]] cell = np.array(cell, dtype=float) cell[3:] = init_cell_angles + # convert bohr to angstrom + cell[:3] = cell[:3] * au2A + # make sure cell length are in angstrom and cell angles are in degree before sent to cellpar_to_cell cell = cellpar_to_cell(cell) all_md_cells.append(cell) diff --git a/tests/test_dpdata/v2022.2/aimd_npt_i/deepmd/set.000/box.npy b/tests/test_dpdata/v2022.2/aimd_npt_i/deepmd/set.000/box.npy index c359c72089267142c7ff8da79650b137b10d776f..ae130cccf908a81c498ee14b7a7a48ca07eab3aa 100644 GIT binary patch literal 920 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-hB^wCnmP)#3giMVV-VP^?7)Bn5G#MRsz~PX3EbuoE5A|A^c{n+3QqSB zE1&pqvzTTzZgYs0pSSws*)>man?tPp=3km`@0+RO^cS)68GkBm?j_M4zcn8vPO>{ literal 920 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-hB^wCnmP)#3giMVV-VP^?7)Bn5Gx=0&j0iLjYc@lAy$6g?1^)hf5&YO zvGPwX7^e$H8RK*hvGS)&Q@$PEi`yJxiYh0{||?k@o-q diff --git a/tests/test_dpdata/v2022.2/aimd_npt_i/deepmd/set.000/virial.npy b/tests/test_dpdata/v2022.2/aimd_npt_i/deepmd/set.000/virial.npy index 6c80b810a72f1aa8cba960e362c672dc9d69db63..4331fcc4bdb6681cc0843cf9efcefa6b6c88fe15 100644 GIT binary patch literal 920 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-hB^wCnmP)#3giN=_{N=jZ*Ds|xQg;OrfJTyduH`>^~1lL_QCj@f6jek zYU}KamM#|AbAtVC-qAr92~ChwfsGorEh=cdTy;bP7m#2{8BrX zgG_H698~f)+UYf{)6dlzI<)#O_;9{w(SELzbu}|Y-r2+W z3zo0Dt@+i+Ve`9woyMEr;PNnjhTxC#ISxh+-D|G~Kbz}o;oTS3x{8nX_0k(I{gwCumxu8KzRYChGC5#B$)?Fs^Mvk!XA9IM>!&T-uQF9- zRa@~Vdl>(8<3)i7EZPUsmTGTp`STSn593EqXI?iYSoc85a{af_F%}1;IF_op{NA+R zxX_DDKCCvb1QnT+8l8H&cvC2+x&ph zY<{ky&u8{41k3-O-~HVl#_yPUlGn!F?7*IPGTaN2zQE;SeE&^tzA`Qr2RLuPkDMc+ zcVMOIn)&q^7x#PfFN>P4^2Z*=SL6O9BWA93z-U49i&ejVz~y25chg@h?-0;Gz_`f9 z^T$`V1A)hSuGf2C-ftKB#wr2yN7{>8=3Nbt|oT0dbTQbc#U20A7@Z{1w&2;ASP+QAwO}3_NAxfqR5m`$Y z%d&;6(okyTN|Z*~@5Uh06eV92X{ce6GeS(WA!_>K@ek;F_qo2N+(Kbqu?wk+bdfDr z=*x8M1O_`%$!BvIY-NS+f=;HDR_Nr4oj+Zs(JQupy-HT8*mf9?$6>^Wa~PKx|2r>f zgPr?xG8Ls!d>fSE=H&SV=hNAZ7jLk8oNaS)NdnZ#Op#>@<_X-fZ?&%d+UY}GQ^rpw zHR^P_3}lP!#4)R**+}!=^`7aDg(`yv^*xK;OOB=i?$|zI?fEN-8uaL6U^4y6X~fR= z?eEAQBbNLrY44Sx7_JhD4|-1!Vk71K zI)jd|GiYY5byy5)s@`?(1`}|{eoK!kT76vvb!WcCJ~YUId!N&|={iG9Gs{yAcWDT_ z!?-} Date: Wed, 21 Feb 2024 11:07:37 +0100 Subject: [PATCH 2/2] change the assertion of the test_cube.py file to make the test correct. --- tests/test_cube/test_cube.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/test_cube/test_cube.py b/tests/test_cube/test_cube.py index 9bab8b6..14e8ddc 100644 --- a/tests/test_cube/test_cube.py +++ b/tests/test_cube/test_cube.py @@ -56,8 +56,19 @@ def test_mav(self, cube_and_answer): mav_answer = np.load(os.path.join(answer_dir, "mav.npy")) mav_x_answer = mav_answer[0] mav_answer = mav_answer[1] - assert np.all(mav == mav_answer) - assert np.all(mav_x == mav_x_answer) + + np.testing.assert_almost_equal(mav, + mav_answer, + decimal=8, + err_msg = 'mav failed' + ) + np.testing.assert_almost_equal(mav_x, + mav_x_answer, + decimal=8, + err_msg = 'mav_x failed' + ) + #assert np.all(mav == mav_answer) + #assert np.all(mav_x == mav_x_answer)