def test_replicate_gp(): """ Based on gp_test_al.out, ensures that given hyperparameters and DFT calls a GP model can be reproduced and correctly re-predict forces and uncertainties :return: """ os.system('cp test_files/sample_h2_otf.out .') parsed = OtfAnalysis('sample_h2_otf.out') positions = parsed.position_list forces = parsed.force_list gp_model = parsed.make_gp() structures = parsed.output_md_structures() assert np.isclose(structures[-1].positions, positions[-1]).all() assert np.isclose(structures[-1].forces, forces[-1]).all() final_structure = structures[-1] pred_for, pred_stds = predict_on_structure(final_structure, gp_model) assert np.isclose(final_structure.forces, pred_for).all() assert np.isclose(final_structure.stds, pred_stds).all() set_of_structures = structures[-3:-1] for structure in set_of_structures: pred_for, pred_stds = predict_on_structure(structure, gp_model) assert np.isclose(structure.forces, pred_for, atol=1e-6).all() assert np.isclose(structure.stds, pred_stds, atol=1e-6).all() os.system('rm sample_slab_otf.out')
def test_replicate_gp(): """ Based on gp_test_al.out, ensures that given hyperparameters and DFT calls a GP model can be reproduced and correctly re-predict forces and uncertainties :return: """ parsed = OtfAnalysis('test_files/VelocityVerlet.log') positions = parsed.position_list forces = parsed.force_list gp_model = parsed.make_gp(kernel_name="two_plus_three_body_mc") structures = parsed.output_md_structures() assert np.isclose(structures[-1].positions, positions[-1]).all() assert np.isclose(structures[-1].forces, forces[-1]).all() final_structure = structures[-1] pred_for, pred_stds = predict_on_structure(final_structure, gp_model) assert np.isclose(final_structure.forces, pred_for, rtol=1e-3).all() assert np.isclose(final_structure.stds, pred_stds, rtol=1e-3).all() set_of_structures = structures[-3:-1] for structure in set_of_structures: pred_for, pred_stds = predict_on_structure(structure, gp_model) assert np.isclose(structure.forces, pred_for, rtol=1e-3, atol=1e-6).all() assert np.isclose(structure.stds, pred_stds, rtol=1e-3, atol=1e-6).all()
def test_output_md_structures(): parsed = OtfAnalysis('test_files/VelocityVerlet.log') positions = parsed.position_list forces = parsed.force_list structures = parsed.output_md_structures() assert np.isclose(structures[-1].positions, positions[-1]).all() assert np.isclose(structures[-1].forces, forces[-1]).all()
def test_output_md_structures(): os.system('cp test_files/sample_slab_otf.out .') parsed = OtfAnalysis('sample_slab_otf.out') positions = parsed.position_list forces = parsed.force_list structures = parsed.output_md_structures() assert np.isclose(structures[-1].positions, positions[-1]).all() assert np.isclose(structures[-1].forces, forces[-1]).all()