AndreiVoicuT commited on
Commit
372e97d
1 Parent(s): 2671286

create app.py

Browse files

create app.py - web

Files changed (1) hide show
  1. app.py +119 -0
app.py ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ os.environ['KMP_DUPLICATE_LIB_OK']='True'
4
+
5
+ import gradio as gr
6
+ from interface_connection import compute_supercell_a, compute_supercell_b, gpaw_calc_energy
7
+
8
+ with gr.Blocks() as latmatcher:
9
+ gr.Markdown(
10
+ "## 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.")
11
+
12
+ with gr.Tabs():
13
+ with gr.TabItem(label="file"):
14
+ with gr.Row():
15
+ with gr.Column(scale=1, min_width=400):
16
+ file_source_a = gr.Dropdown(["c2db.json", ".xyz", "bespoke.json"],
17
+ label="format", info="Select file format")
18
+ file_material_a = gr.File(label="material A file", )
19
+ with gr.Column(scale=1, min_width=400):
20
+ file_source_b = gr.Dropdown(["c2db.json", ".xyz", "bespoke.json"],
21
+ label="format", info="Select file format")
22
+ file_material_b = gr.File(label="material B file", )
23
+
24
+ max_angle = gr.Slider(0, 180, label=" max Angle:", step=1)
25
+ max_strain = gr.Slider(0, 1, label=" max Strain:", step=0.05)
26
+
27
+ msc_button = gr.Button("Compute minimum super cel")
28
+
29
+ file_angle = gr.Text(label="Optimum Angle:")
30
+ file_strain = gr.Text(label="Best Strain:")
31
+ file_material_ab = gr.File(label="Result", )
32
+
33
+ plot_overlap = gr.Plot()
34
+
35
+ msc_button.click(compute_supercell_a,
36
+ inputs=[file_material_a, file_material_b, file_source_a, file_source_b, max_angle,
37
+ max_strain],
38
+ outputs=[file_material_ab, file_angle, file_strain, plot_overlap])
39
+
40
+ with gr.TabItem(label="data"):
41
+ with gr.Row():
42
+ with gr.Column(scale=1, min_width=400):
43
+ gr.Markdown(
44
+ "## Host lattice:")
45
+
46
+ host_lattice = gr.Textbox(label="Host lattice:", lines=4)
47
+ host_atoms = gr.Textbox(label="Host atoms:", lines=50)
48
+
49
+ with gr.Column(scale=1, min_width=400):
50
+ gr.Markdown("## Guest lattice:")
51
+
52
+ guest_lattice = gr.Textbox(label="Guest lattice:", lines=4)
53
+ guest_atoms = gr.Textbox(label="Guest atoms:", lines=50)
54
+
55
+ max_angle = gr.Slider(0, 180, label=" max Angle:", step=1)
56
+ max_strain = gr.Slider(0, 1, label=" max Strain:", step=0.05)
57
+ msc_button = gr.Button("Compute minimum super cel")
58
+ file_angle = gr.Text(label="Optimum Angle:")
59
+ file_strain = gr.Text(label="Best Strain:")
60
+
61
+ msc_button.click(compute_supercell_b,
62
+ inputs=[host_lattice, guest_lattice,
63
+ host_atoms, guest_atoms,
64
+ max_angle, max_strain],
65
+ outputs=[file_angle, file_strain])
66
+
67
+ with gr.Tabs():
68
+ with gr.TabItem(label="GPAW calculator"):
69
+ file_gpaw_format = gr.Dropdown([".xyz", "bespoke.json"],
70
+ label="format", info="Select file format")
71
+ file_gpaw= gr.File(label="input file (xyz+celll or bespoke.json )", )
72
+
73
+ with gr.Row():
74
+ convergence_forces=gr.Slider(0.001,0.1, label="convergence forces", step=0.0001)
75
+ hund=gr.Dropdown(["True", "False"],label="hund", value="True" )
76
+ xc=gr.Dropdown(["PBE","LDA"], allow_custom_value=True,label="xc", value="PBE")
77
+ basis=gr.Dropdown(["dzp", None], allow_custom_value=True,label="basis", value=None)
78
+
79
+ gr.Markdown("Mixer:")
80
+ with gr.Row():
81
+ beta = gr.Slider(0.000, 0.05, label="beta:", step=0.0001,value=0.01 )
82
+ method = gr.Dropdown(["sum","difference", None], allow_custom_value=True, label="method:")
83
+ weight = gr.Dropdown([100,200, None], allow_custom_value=True, label="weight:", value=100)
84
+ backend= gr.Dropdown(["pulay", None], allow_custom_value=True, label="backend:", value=None)
85
+
86
+ gr.Markdown("Mode:")
87
+
88
+ with gr.Row():
89
+ ecut=gr.Slider(100, 1000, label="ecut:", step=10,value=800 )
90
+ mode_name=gr.Dropdown(["pw", None], allow_custom_value=True, label="mode_name:", value="pw")
91
+
92
+ maxiter = gr.Slider(100, 2000, label="maxiter:", step=10,value=100 )
93
+
94
+ kpts=gr.Textbox(label="KPTS:", info="kpts in dictionary list form")
95
+
96
+ gr.Markdown("log info:")
97
+ log_file_name=gr.Textbox(label="Name of log file",lines=1,value="gpaw_exp.log",)
98
+ mail=gr.Textbox( label="Mail:",
99
+ info="email at witch you wish to get the log file",
100
+ lines=1,
101
+ value="tomutvoicuandrei@gmail.com",)
102
+
103
+ gpaw_energy_button = gr.Button("Compute energy with GPAW calculator")
104
+ gpaw_energy=gr.Textbox(label="Potential energy:", info="computed energy:")
105
+
106
+ gpaw_energy_button.click(gpaw_calc_energy,
107
+ inputs=[file_gpaw_format,
108
+ file_gpaw,
109
+ convergence_forces,
110
+ hund,
111
+ xc, basis,
112
+ beta, method,
113
+ weight,backend,
114
+ ecut, mode_name,
115
+ maxiter, kpts,
116
+ log_file_name, mail],
117
+ outputs=[gpaw_energy])
118
+
119
+ latmatcher.launch(share=False)