<jupyter_start><jupyter_text>Prismatic structures of Li2MnO3In this notebook I've developed a small interactive tool to view the final geometries of the prismatic models of Li$_2$MnO$_3$. Once the binder has loaded, just execute the cell below and then use the drop down menu's to choose the `model`, `Li concentration` and DFT `functional`. In order to execute the cell: select it with the left mouse button and press `Shift+Enter`.<jupyter_code># Execute this cell to visualize the structures and compare them to the original model.

import os
import json
import imolecule

from pymatgen import Structure
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer

from monty.io import zopen
from ipywidgets import interact, fixed, Dropdown

# Lists of various structural models, Li concentrations and functional settings
models = ["Li2MnO3_type", "inverted_p2_like", "202639_Li2MnO3_pristine",
"Li2MnO3_type_O_shifted", "inverted_p2_like_O_shifted", "symm_inverted_p2_like"]
li_concentrations = ["0", "0.25"]
functional_list = ["scan" , "pbeu_Mn3.9", "hse"]

# Set the atom sizes and colors for imolecule
element_properties={
    "Li": { "color": 0x66ff66, "radius": 0.85 },
    "O": { "color": 0xff0000, "radius": 0.7 },
    "Mn": { "color": 0xf00fff, "radius": 1.35 },
}

data_dir = os.path.join(os.getcwd(), "li2mno3_prism")

def get_energy(data_file):
    """
    Quick method for extracting the final energy from a calculation.
    """

    with zopen(data_file) as file:
        data = json.load(file)
        return data["output"]["final_energy"]

def visualize_prism(data_dir, model, li_conc, functional):
    
    conc_dir = str(li_conc) + "_li"
    
    if li_conc == "0":
        orig_path = os.path.join(data_dir, conc_dir, model, model + "_charged.json")
    else:
        orig_path = os.path.join(data_dir, conc_dir, model, model + ".json")
        
    orig_cat = Structure.from_file(orig_path)
    super_orig = orig_cat.copy()
    super_orig.make_supercell([2, 2, 2])
    super_orig.to("cif", "temp.cif")
    print()
    print("Original Structure")
    print("------------------")
    print()
    imolecule.draw("temp.cif", element_properties=element_properties)
    
    final_path = os.path.join(data_dir, conc_dir, model, functional + "_relax", "final_cathode.cif")
    final_cat = Structure.from_file(final_path)
    if functional == "hse":
        spg = SpacegroupAnalyzer(final_cat)
        super_final = spg.get_conventional_standard_structure()
    else:
        super_final = final_cat.copy()
    super_final.make_supercell([2, 2, 2])
    super_final.to("cif", "temp.cif")
    print()
    print("Final Structure")
    print("---------------")
    print()
    imolecule.draw("temp.cif", element_properties=element_properties)
    
# Interactive function for visualizing the structures
interact(visualize_prism,
         data_dir=fixed(data_dir),
         model=models, 
         li_conc=Dropdown(options=li_concentrations,
                         description="Li concentration"),
         functional=functional_list);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12199089134677944, 'fraction_numerical': 0.017891997397527653, 'mean_word_length': 3.789719626168224, 'pattern_counts': {'":': 11, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '121765', 'license': 'MIT', 'n_tokens_mistral': 1045, 'n_tokens_neox': 976, 'n_words': 258, 'path': 'batteries/prismatic/structures.ipynb', 'repo_name': 'mbercx/jupyter', 'size': '3074'}