latmatcher / app.py
AndreiVoicuT's picture
Update app.py
174b314 verified
raw
history blame
No virus
3.09 kB
import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'
import gradio as gr
from interface_connection import compute_supercell_a, compute_supercell_b
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])
latmatcher.launch(share=False)