Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Customizing pd_entries in FormationEnergyDiagram #204

Open
misaraty opened this issue Aug 7, 2024 · 2 comments
Open

Comments

@misaraty
Copy link

misaraty commented Aug 7, 2024

Problem

I'd like to customize pd_entries in the FormationEnergyDiagram setup as shown below:

ents = MPR.get_entries_in_chemsys(['Mg', 'Ga', 'N']) or ents = loadfn("Ga_Mg_N.json")
sc_dir = "Mg_Ga/"
fed = FormationEnergyDiagram.with_directories(
    directory_map={
        "bulk": sc_dir + "bulk_sc",
        0: sc_dir + "q=0",
        -1: sc_dir + "q=-1",
        1: sc_dir + "q=1",
    },
    defect=ens,
    pd_entries=ents,
    dielectric=10,
)

I have locally calculated the decomposition phases and competing phases (e.g., mp-1095013 MgGa, mp-844 POSCAR_Ca3N2, mp-1184449 POSCAR_CaMg149, mp-25 POSCAR_N2). I'm wondering if I should modify the pd_entries similar to this:

pd_entries = [
    {"Data": {"run_type": "GGA", "mp-1095013-GGA ComputedStructureEntry": "Mg2 Ga2 (MgGa)", "Energy (Final)": "-8.1302 eV (-2.0325 eV/atom)"}},
    {"Data": {"run_type": "GGA", "mp-1094626-GGA ComputedStructureEntry": "Mg5 Ga1 (Mg5Ga)", "Energy (Final)": "-11.1926 eV (-1.8654 eV/atom)"}}
]

or

pd_entries = [
    {"Mg2 Ga2 (MgGa)", "-8.1302 eV"},
    {"Mg5 Ga1 (Mg5Ga)", "-11.1926 eV"}
]

Thank you!

Proposed Solution

What would be the simplest way to write pd_entries for locally calculated competing phases? Thank you once again!

Alternatives

No response

@jmmshn
Copy link
Collaborator

jmmshn commented Sep 27, 2024

If I understand correctly. I would recommend and you write a function that takes the dictionaries from your local calculations and convert it to ComputedEntry's from pymatgen I think that will make the subsequent steps the same.

@jmmshn
Copy link
Collaborator

jmmshn commented Feb 25, 2025

Reply to a request for more details:

The following is AI generated but seems to be fine.

def parse_vasprun_to_entry(vasprun_path):
    """
    Parse a vasprun.xml file to create a ComputedStructureEntry.
    
    Args:
        vasprun_path (str): Path to vasprun.xml file
        
    Returns:
        ComputedStructureEntry: A computed entry with structure and energy data
    """
    # Parse vasprun.xml
    try:
        vasprun = Vasprun(vasprun_path, parse_dos=False, parse_eigen=False)
    except Exception as e:
        print(f"Error parsing {vasprun_path}: {str(e)}")
        return None
    
    # Get the final structure and energy
    structure = vasprun.final_structure
    energy = vasprun.final_energy
    
    # Create basic parameters dictionary
    parameters = {
        "potcar_symbols": vasprun.potcar_symbols,
        "functional": vasprun.get_xc_functional(),
        "is_spin_polarized": vasprun.is_spin,
    }
    
    # Create the computed entry
    entry = ComputedStructureEntry( # may be replace with ComputedEntry
        structure,
        energy,
        parameters=parameters,
        entry_id=os.path.dirname(vasprun_path)
    )
   
    return entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants