File size: 2,418 Bytes
1c703f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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())