def test_Atoms_get_energy(): """Tests get_energy method. """ from matdb.atoms import Atoms at1 = Atoms("Si8",positions=[[0,0,0],[0.25,0.25,0.25],[0.5,0.5,0],[0.75,0.75,0.25], [0.5,0,0.5],[0.75,0.25,0.75],[0,0.5,0.5],[0.25,0.75,0.75]], cell=[5.43,5.43,5.43]) at1.add_param("vasp_energy", 4532) assert at1.get_energy() == 4532
def test_Atoms_attributes(tmpdir): """Tests the some of the attributes of an atoms object. """ from matdb.calculators import Vasp from matdb.atoms import Atoms from matdb.utility import _set_config_paths, reporoot from os import path _set_config_paths("AgPd_Enumerated", str(tmpdir)) target = str(tmpdir.join("atom_attributes")) globals_setup(target) if not path.isdir(target): mkdir(target) at1 = Atoms("Si8",positions=[[0,0,0],[0.25,0.25,0.25],[0.5,0.5,0],[0.75,0.75,0.25], [0.5,0,0.5],[0.75,0.25,0.75],[0,0.5,0.5],[0.25,0.75,0.75]], cell=[5.43,5.43,5.43]) kwargs = {"kpoints":{"rmin":50}, "potcars": {"directory":"./tests/vasp", "versions":{"Si": '05Jan2001'}}, "xc":"pbe"} potSW = Vasp(at1, target, str(tmpdir), 0, **kwargs) at1.set_calculator(potSW) at1.add_property("vasp_force", [[-18057.59589857, -18057.59589857, -18057.59589857], [ -2997.55626529, -2997.55626529, -2997.55626529], [ 3044.17916471, 3044.17916471, -34130.71583118], [ 18969.1757571 , 18969.1757571 , 11159.15815145], [ 3044.17916471, -34130.71583118, 3044.17916471], [ 18969.1757571 , 11159.15815145, 18969.1757571 ], [-34130.71583118, 3044.17916471, 3044.17916471], [ 11159.15815145, 18969.1757571 , 18969.1757571 ]]) at1.add_param("vasp_energy", 1234) assert at1.get_energy() == 1234 at1.rm_param("vasp_energy") assert not "vasp_energy" in at1.info["params"] at1.rm_property("vasp_force") assert not "vasp_force" in at1.info["properties"] at1.params = {"vasp_energy": 1234} assert at1.vasp_energy == 1234 at1.properties["vasp_force"] = [[-18057.59589857, -18057.59589857, -18057.59589857], [ -2997.55626529, -2997.55626529, -2997.55626529], [ 3044.17916471, 3044.17916471, -34130.71583118], [ 18969.1757571 , 18969.1757571 , 11159.15815145], [ 3044.17916471, -34130.71583118, 3044.17916471], [ 18969.1757571 , 11159.15815145, 18969.1757571 ], [-34130.71583118, 3044.17916471, 3044.17916471], [ 11159.15815145, 18969.1757571 , 18969.1757571 ]] assert "vasp_force" in at1.info["properties"]