File size: 6,013 Bytes
372e97d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import os

os.environ['KMP_DUPLICATE_LIB_OK']='True'

import gradio as gr
from interface_connection import compute_supercell_a, compute_supercell_b, gpaw_calc_energy

with gr.Blocks() as latmatcher:
    gr.Markdown(
        "## Craft custom materials that precisely fit your needs wit our MaterialMattcher.\n Not sure from waht materials to start? Simply tell us your desired properties.")

    with gr.Tabs():
        with gr.TabItem(label="file"):
            with gr.Row():
                with gr.Column(scale=1, min_width=400):
                    file_source_a = gr.Dropdown(["c2db.json", ".xyz", "bespoke.json"],
                                                label="format", info="Select file format")
                    file_material_a = gr.File(label="material A file", )
                with gr.Column(scale=1, min_width=400):
                    file_source_b = gr.Dropdown(["c2db.json", ".xyz", "bespoke.json"],
                                                label="format", info="Select file format")
                    file_material_b = gr.File(label="material B file", )

            max_angle = gr.Slider(0, 180, label=" max Angle:", step=1)
            max_strain = gr.Slider(0, 1, label=" max Strain:", step=0.05)

            msc_button = gr.Button("Compute minimum super cel")

            file_angle = gr.Text(label="Optimum Angle:")
            file_strain = gr.Text(label="Best Strain:")
            file_material_ab = gr.File(label="Result", )

            plot_overlap = gr.Plot()

            msc_button.click(compute_supercell_a,
                             inputs=[file_material_a, file_material_b, file_source_a, file_source_b, max_angle,
                                     max_strain],
                             outputs=[file_material_ab, file_angle, file_strain, plot_overlap])

        with gr.TabItem(label="data"):
            with gr.Row():
                with gr.Column(scale=1, min_width=400):
                    gr.Markdown(
                        "## Host lattice:")

                    host_lattice = gr.Textbox(label="Host lattice:", lines=4)
                    host_atoms = gr.Textbox(label="Host atoms:", lines=50)

                with gr.Column(scale=1, min_width=400):
                    gr.Markdown("## Guest lattice:")

                    guest_lattice = gr.Textbox(label="Guest lattice:", lines=4)
                    guest_atoms = gr.Textbox(label="Guest atoms:", lines=50)

            max_angle = gr.Slider(0, 180, label=" max Angle:", step=1)
            max_strain = gr.Slider(0, 1, label=" max Strain:", step=0.05)
            msc_button = gr.Button("Compute minimum super cel")
            file_angle = gr.Text(label="Optimum Angle:")
            file_strain = gr.Text(label="Best Strain:")

            msc_button.click(compute_supercell_b,
                             inputs=[host_lattice, guest_lattice,
                                     host_atoms, guest_atoms,
                                     max_angle, max_strain],
                             outputs=[file_angle, file_strain])

        with gr.Tabs():
            with gr.TabItem(label="GPAW calculator"):
                file_gpaw_format = gr.Dropdown([".xyz", "bespoke.json"],
                                            label="format", info="Select file format")
                file_gpaw= gr.File(label="input file (xyz+celll or bespoke.json )", )

                with gr.Row():
                    convergence_forces=gr.Slider(0.001,0.1, label="convergence forces", step=0.0001)
                    hund=gr.Dropdown(["True", "False"],label="hund", value="True" )
                    xc=gr.Dropdown(["PBE","LDA"], allow_custom_value=True,label="xc", value="PBE")
                    basis=gr.Dropdown(["dzp", None], allow_custom_value=True,label="basis", value=None)

                gr.Markdown("Mixer:")
                with gr.Row():
                    beta = gr.Slider(0.000, 0.05, label="beta:", step=0.0001,value=0.01 )
                    method = gr.Dropdown(["sum","difference", None], allow_custom_value=True, label="method:")
                    weight = gr.Dropdown([100,200, None], allow_custom_value=True, label="weight:", value=100)
                    backend= gr.Dropdown(["pulay", None], allow_custom_value=True, label="backend:", value=None)

                gr.Markdown("Mode:")

                with gr.Row():
                    ecut=gr.Slider(100, 1000, label="ecut:", step=10,value=800 )
                    mode_name=gr.Dropdown(["pw", None], allow_custom_value=True, label="mode_name:", value="pw")

                maxiter = gr.Slider(100, 2000, label="maxiter:", step=10,value=100 )

                kpts=gr.Textbox(label="KPTS:", info="kpts in dictionary list form")

                gr.Markdown("log info:")
                log_file_name=gr.Textbox(label="Name of log file",lines=1,value="gpaw_exp.log",)
                mail=gr.Textbox( label="Mail:",
                                 info="email at witch you wish to get the log file",
                                 lines=1,
                                 value="tomutvoicuandrei@gmail.com",)

                gpaw_energy_button = gr.Button("Compute energy with GPAW calculator")
                gpaw_energy=gr.Textbox(label="Potential energy:", info="computed energy:")

                gpaw_energy_button.click(gpaw_calc_energy,
                                 inputs=[file_gpaw_format,
                                        file_gpaw,
                                         convergence_forces,
                                         hund,
                                         xc, basis,
                                         beta, method,
                                         weight,backend,
                                         ecut, mode_name,
                                         maxiter, kpts,
                                         log_file_name, mail],
                                 outputs=[gpaw_energy])

latmatcher.launch(share=False)