import pandas as pd import os import periodictable from .vasp_utils import get_band_structure from .structure_propriety import DBPropriety, Source def get_atomic_number(element_name): # Find the element element = getattr(periodictable, element_name, None) # Check if the element exists if element is not None and hasattr(element, 'number'): return element.number else: return "Element not found" def read_jarvis(file_path): db = pd.read_json(file_path) return db def get_jarvis_instance(jr_data, jr_id): jarvis_el = jr_data[jr_data['jid'] == jr_id] return jarvis_el def from_jarvis_formula(jarvis_el): return jarvis_el["formula"].values[0] def from_jarvis_structure(jarvis_el): structure = { 'cell': jarvis_el["atoms"].values[0]['lattice_mat'], 'atoms': [get_atomic_number(e) for e in jarvis_el["atoms"].values[0]['elements']], 'positions': jarvis_el["atoms"].values[0]['coords'], 'pbc': [True, True, False] } return structure def from_jarvis_energy(jarvis_el): return None def from_jarvis_band_gap(jarvis_el): return None def from_jarvis_band_structure(jarvis_el): jid=jarvis_el["jid"].values[0] vasp_xml_path="DB/Databases/JARVIS/JARVIS2D/OPT-Bandst/{}/vasprun.xml".format(jid) if os.path.isfile(vasp_xml_path): try: band_structure, numerics=get_band_structure(vasp_xml_path) source = Source(tipe="computation", author_id="JARVIS", description={"calculator": "VASP", "calculator_files": vasp_xml_path, }, cite="https://jarvis.nist.gov") band_structure = DBPropriety(name="band_structure", value=numerics, source=source) return band_structure except: return None return None def from_jarvis_density_of_states(jarvis_el): return None # # file_path = "/Users/voicutomut/Documents/GitLab/bespoke-interface/DB_experiments/JARVIS2D/d2-12-12-2022.json" # jar = read_jarvis(file_path) # print(jar.head()) # jr = get_jarvis_instance(jar, "JVASP-76515") # # print(jr) # print(jr.head()) # print(from_jarvis_formula(jr)) # print(jr["atoms"].values[0]['cartesian']) # print(jr["atoms"].values[0].keys())