def test_make_chem_pot_diag_from_mp_yaml(mp_query, tmpdir, cpd_corr): tmpdir.chdir() tmpdir.join("tmp.yaml").write("""O: -1.61154565 Mg: -0.00912097""") actual = make_chem_pot_diag_from_mp(target=Composition("MgO"), atom_energy_yaml="tmp.yaml") assert actual == cpd_corr
def test_make_chem_pot_diag_from_mp(composition, mp_query, cpd): actual = make_chem_pot_diag_from_mp(target=composition) mp_query.assert_called_once_with( ["Mg", "O"], properties=["task_id", "full_formula", "final_energy"]) assert actual == cpd assert actual.target == cpd.target assert actual.vertex_elements == cpd.vertex_elements
def test_make_chem_pot_diag_from_mp_additional_elem(mp_query, cpd_corr): actual = make_chem_pot_diag_from_mp(target=Composition("Mg"), additional_elements=["O"], atom_energy_yaml="pbesol", vertex_elements=["Mg", "O"]) assert actual == cpd_corr assert actual.vertex_elements == cpd_corr.vertex_elements
def test_make_chem_pot_diag_from_mp_additional_elem(mp_query, tmpdir, cpd_corr): tmpdir.chdir() tmpdir.join("tmp.yaml").write("""O: -1.61154565 Mg: -0.00912097""") actual = make_chem_pot_diag_from_mp(target=Composition("Mg"), additional_elements=["O"], atom_energy_yaml="tmp.yaml", vertex_elements=["Mg", "O"]) assert actual.vertex_elements == [Element.Mg, Element.O]
def make_chem_pot_diag(args) -> None: if args.elements: cpd = make_chem_pot_diag_from_mp(additional_elements=args.elements, target=args.target, atom_energy_yaml=args.atom_energy_yaml) else: comp_es = [] for d in args.dirs: vasprun = Vasprun(d / defaults.vasprun) composition = vasprun.final_structure.composition energy = float(vasprun.final_energy) # type is FloatWithUnit comp_es.append(CompositionEnergy(composition, energy, "local")) if args.update: cpd = ChemPotDiag.from_yaml(args.yaml) replace_comp_energy(cpd, comp_es) else: cpd = ChemPotDiag(comp_es, args.target) cpd.to_yaml(args.yaml)
def test_make_chem_pot_diag_from_mp_w_vise_functional(mp_query, cpd_corr): actual = make_chem_pot_diag_from_mp(target=Composition("MgO"), atom_energy_yaml="pbesol") cpd_corr.to_yaml() assert actual == cpd_corr