def test_ener_shift(self): dp_random.seed(0) data = DeepmdDataSystem(['system_0', 'system_1'], 5, 10, 1.0) data.add('energy', 1, must=True) ener_shift0 = data.compute_energy_shift(rcond=1) all_stat = make_stat_input(data, 4, merge_sys=False) ener_shift1 = EnerFitting._compute_output_stats(all_stat, rcond=1) np.testing.assert_almost_equal(ener_shift0, ener_shift1)
def test_ener_shift(self): dp_random.seed(0) data = DeepmdDataSystem(['system_0', 'system_1'], 5, 10, 1.0) data.add('energy', 1, must=True) ener_shift0 = data.compute_energy_shift(rcond=1) all_stat = make_stat_input(data, 4, merge_sys=False) descrpt = DescrptSeA(6.0, 5.8, [46, 92], neuron=[25, 50, 100], axis_neuron=16) fitting = EnerFitting(descrpt, neuron=[240, 240, 240], resnet_dt=True) ener_shift1 = fitting._compute_output_stats(all_stat, rcond=1) np.testing.assert_almost_equal(ener_shift0, ener_shift1)
def test_merge_all_stat(self): dp_random.seed(0) data0 = DeepmdDataSystem(['system_0', 'system_1'], 5, 10, 1.0) data0.add('energy', 1, must=True) dp_random.seed(0) data1 = DeepmdDataSystem(['system_0', 'system_1'], 5, 10, 1.0) data1.add('energy', 1, must=True) dp_random.seed(0) data2 = DeepmdDataSystem(['system_0', 'system_1'], 5, 10, 1.0) data2.add('energy', 1, must=True) dp_random.seed(0) all_stat_0 = make_stat_input(data0, 10, merge_sys=False) dp_random.seed(0) all_stat_1 = make_stat_input(data1, 10, merge_sys=True) all_stat_2 = merge_sys_stat(all_stat_0) dp_random.seed(0) all_stat_3 = _make_all_stat_ref(data2, 10) #################################### # only check if the energy is concatenated correctly #################################### dd = 'energy' # if 'find_' in dd: continue # if 'natoms_vec' in dd: continue # if 'default_mesh' in dd: continue # print(all_stat_2[dd]) # print(dd, all_stat_1[dd]) d1 = np.array(all_stat_1[dd]) d2 = np.array(all_stat_2[dd]) d3 = np.array(all_stat_3[dd]) # print(dd) # print(d1.shape) # print(d2.shape) # self.assertEqual(all_stat_2[dd], all_stat_1[dd]) self._comp_data(d1, d2) self._comp_data(d1, d3)
def test_ener_shift_assigned(self): dp_random.seed(0) ae0 = dp_random.random() data = DeepmdDataSystem(['system_0'], 5, 10, 1.0) data.add('energy', 1, must=True) all_stat = make_stat_input(data, 4, merge_sys=False) descrpt = DescrptSeA(6.0, 5.8, [46, 92], neuron=[25, 50, 100], axis_neuron=16) fitting = EnerFitting(descrpt, neuron=[240, 240, 240], resnet_dt=True, atom_ener=[ae0, None, None]) ener_shift1 = fitting._compute_output_stats(all_stat, rcond=1) # check assigned energy np.testing.assert_almost_equal(ae0, ener_shift1[0]) # check if total energy are the same natoms = data.natoms_vec[0][2:] tot0 = np.dot(data.compute_energy_shift(rcond=1), natoms) tot1 = np.dot(ener_shift1, natoms) np.testing.assert_almost_equal(tot0, tot1)