Esempio n. 1
0
def test_make_cpd_and_vertices(mocker, tmpdir):
    tmpdir.chdir()
    mock = mocker.patch("pydefect.cli.main_functions.RelativeEnergies")
    mock.from_yaml.return_value = RelativeEnergies({"HHe": -1.0})

    args = Namespace(rel_energy_yaml="a.yaml", target="HHe", elements=None)
    make_cpd_and_vertices(args)

    actual = Path("target_vertices.yaml").read_text()
    expected = """target: HHe
A:
  chem_pot:
    H: 0.0
    He: -2.0
  competing_phases:
  - H
  impurity_phases: []
B:
  chem_pot:
    H: -2.0
    He: 0.0
  competing_phases:
  - He
  impurity_phases: []
"""
    assert actual == expected
Esempio n. 2
0
def test_std_rel_energies(composition_energies):
    actual = composition_energies.std_rel_energies
    expected_ref = StandardEnergies({"H": 0.0, "O": 1.0, "Cl": 12.0})
    expected_rel = RelativeEnergies({
        'ClO': -5.0,
        'ClO2': -3.666666666666667,
        'H2O': -1.0
    })
    assert actual[0] == expected_ref
    assert actual[1] == expected_rel
Esempio n. 3
0
def make_cpd_and_vertices(args):
    rel_energies = RelativeEnergies.from_yaml(args.rel_energy_yaml)
    if args.target:
        elements = args.elements or \
                   Composition(args.target).chemical_system.split("-")
    else:
        elements = args.elements or list(rel_energies.all_element_set)

    cpd_maker = ChemPotDiagMaker(rel_energies, elements, args.target)
    cpd = cpd_maker.chem_pot_diag
    cpd.to_json_file()
    cpd.to_target_vertices.to_yaml_file()
Esempio n. 4
0
def relative_energies():
    return RelativeEnergies({"MgO2": -3.0, "MgAlO2": -1.0})
Esempio n. 5
0
def cpd_maker():
    return ChemPotDiagMaker(RelativeEnergies({
        "MgO2": -3.0,
        "MgAlO2": -2.5
    }),
                            elements=["Mg", "O"])
import crystal_toolkit.components as ctc
import dash_html_components as html
from crystal_toolkit.settings import SETTINGS
from jupyter_dash import JupyterDash
from pydefect.analyzer.dash_components.cpd_energy_dash import CpdEnergyComponent
from pydefect.analyzer.defect_energy import DefectEnergySummary, DefectEnergies, \
    DefectEnergy
from pydefect.chem_pot_diag.chem_pot_diag import RelativeEnergies, \
    ChemPotDiagMaker

if __name__ == "__main__":
    app = JupyterDash(suppress_callback_exceptions=True,
                      assets_folder=SETTINGS.ASSETS_PATH)

    #    relative_energies = RelativeEnergies({"MgCaO2": -100.0})
    relative_energies = RelativeEnergies({"MgCaBaO2": -100.0})
    # cpd = ChemPotDiagMaker(relative_energies,
    #                        elements=["Mg", "Ca", "O"],
    #                        target="MgCaO2").chem_pot_diag
    cpd = ChemPotDiagMaker(relative_energies,
                           elements=["Mg", "Ca", "Ba", "O"],
                           target="MgCaBaO2").chem_pot_diag

    energy = DefectEnergy(0.0, {"corr": 1.0}, is_shallow=False)
    defect_energy_summary = DefectEnergySummary(
        title="test",
        defect_energies={
            "Va_O1":
            DefectEnergies(atom_io={"O": -1},
                           charges=[0],
                           defect_energies=[energy])