Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the gui code to main #22

Merged
merged 33 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c704b68
update env
srmnitc Apr 4, 2023
19eca7f
update gui
srmnitc Apr 5, 2023
1be2525
update enc
srmnitc Apr 5, 2023
b3afa19
update example
srmnitc Apr 5, 2023
86bccab
update env and example
srmnitc Apr 5, 2023
0ac1824
update note
srmnitc Apr 5, 2023
5677e88
update example
srmnitc Apr 6, 2023
8d3ffeb
update example
srmnitc Apr 6, 2023
1466d11
Merge pull request #10 from pyscal/viola_2
srmnitc Apr 6, 2023
c0e9ed5
clean the notebook
srmnitc Apr 6, 2023
cffc1e2
update example
srmnitc Apr 6, 2023
22524ec
clear output
srmnitc Apr 6, 2023
aa1a982
update gui
srmnitc Apr 18, 2023
1be97b8
Merge pull request #12 from pyscal/viola_2
srmnitc Apr 18, 2023
ae8308a
remove unused packages
srmnitc Apr 18, 2023
69ee8df
seperate binder and regular envs
srmnitc Apr 18, 2023
fa8531a
Merge pull request #14 from pyscal/main
srmnitc Apr 18, 2023
7f8c7be
Merge pull request #16 from pyscal/main
srmnitc May 3, 2023
55102bd
add debugging buttons
srmnitc May 3, 2023
945cd8f
add gui files
srmnitc May 3, 2023
02ab3ee
add more vis options
srmnitc May 3, 2023
4158883
Merge pull request #17 from pyscal/main
srmnitc May 3, 2023
bc05080
update example
srmnitc May 3, 2023
cb2dc16
fix iframe
srmnitc May 3, 2023
09fbb73
update files
srmnitc May 4, 2023
e0e9b68
Merge pull request #18 from pyscal/main
srmnitc Jun 7, 2023
4c8b3c9
fix multi-species viz
srmnitc Jun 7, 2023
a849350
add special write formats
srmnitc Jun 7, 2023
7a10910
update gui elements
srmnitc Jun 13, 2023
48f05fd
add vacacancy routines
srmnitc Jun 13, 2023
d9f2658
Merge pull request #21 from pyscal/main
srmnitc Jun 13, 2023
03d3dc6
fixes for gui
srmnitc Jun 13, 2023
8437a2e
update methods
srmnitc Jun 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .binder/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: rdf
channels:
- conda-forge
dependencies:
- python >3.8
- conda-forge/label/pyscal_dev::pyscal
- rdflib
- pyyaml
- jupyterlab
- graphviz
- python-graphviz
- pyyaml
- ase
- ipycytoscape
- voila
- plotly
- jupyterlab-dash
- networkx
40 changes: 38 additions & 2 deletions example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,53 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "89e1aaca-34b3-472c-8002-1cc11d078f8d",
"metadata": {
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Al', 'Ni']\n"
]
}
],
"source": [
"struct_l12 = g.create_structure(\"l12\", element=['Al', 'Ni'], \n",
" lattice_constant=3.57)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "17b9ad8b-bf22-4161-9864-40fa6d224d79",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "61a43f15c15e4a71a52599b4e6be62a3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"CytoscapeWidget(cytoscape_layout={'name': 'cola', 'avoidOverlap': True, 'animate': True}, cytoscape_style=[{'s…"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"g.visualise()"
]
},
{
"cell_type": "markdown",
"id": "e83523ad-f684-42fe-84e1-da8125201a0d",
Expand Down
877 changes: 877 additions & 0 deletions example_gui.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pyscal_rdf/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ def to_file(self, sample, filename=None, format="lammps-dump"):
asesys = sys.to_ase()
write(filename, asesys, format="vasp")
else:
#asesys = sys.to_ase()
#write(filename, asesys, format=format)
sys.to_file(filename, format=format)

def serialize(self, filename, format='turtle'):
Expand Down
Empty file added pyscal_rdf/gui/__init__.py
Empty file.
31 changes: 31 additions & 0 deletions pyscal_rdf/gui/auto_query.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from ipywidgets import HBox, VBox, Layout
from pyscal_rdf.gui.create import output, dropdown, button, checkbox, textbox, header, upload, text
from pyscal_rdf.gui.properties import dataprops, options

class AutoQuery:
def __init__(self, theme="teal"):
self.first_line = text("Find all samples with..")
self.property_dropdown = dropdown("", options,
value="Bravais lattice ")
self.compare_options = dropdown("", [" equal to ",
" in between ",
" equal to either "],
value=" equal to ")
self.compare_output = output(theme=theme)
self.input_output = output(theme=theme)
self.input_field_1 = textbox("", value="bcc", dtype="text")
self.input_field_2 = textbox("", value="", dtype="text")
self.run_button = button("Run query", theme=theme)
self.show_button = button("Show query", theme=theme)
self.result_output = output(theme=theme)
self.plot_structure_button = button("Plot structure", theme=theme)
self.visualise_graph_button = button("Visualise graph", theme=theme)
self.result_plotter = output(theme=theme)
self.w1 = HBox(children=[ self.property_dropdown,
self.compare_output,
self.input_output])
self.panel = VBox(children=[self.first_line,
self.w1,
HBox(children=[self.run_button, self.show_button]),
self.result_output,
self.result_plotter])
103 changes: 103 additions & 0 deletions pyscal_rdf/gui/create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import ipywidgets as widgets
from ipywidgets import Layout
from pyscal_rdf.gui.themes import themes
import panel as pn
pn.extension()

def output(theme="teal"):
"""
Create an ouput widget
"""
output = widgets.Output(layout={'border': '1px solid %s'%themes[theme]["border"]})
return output

def dropdown(description, options, value=None, disabled=False, tooltip="Select value", theme="teal"):
if value is None:
value = options[0]

dropdown = widgets.Dropdown(
options = options,
value = value,
description = description,
description_long = description,
disabled=disabled,
tooltip=tooltip,
)
return dropdown

def button(description, disabled=False, tooltip="Click me", theme="teal"):
button = widgets.Button(
description=description,
disabled=disabled,
button_style='',
tooltip=tooltip,
)
button.style.button_color = themes[theme]["button"]
return button

def checkbox(description, value=True, theme="teal"):
checkbox = widgets.Checkbox(
value=value,
description=description,
disabled=False
)
return checkbox

def textbox(description, value, dtype, theme="teal", disabled=False, tooltip="Enter value"):
if dtype == "int":
inttext = widgets.IntText(
value=value,
description=description,
disabled=disabled,
tooltip=tooltip,
)
return inttext
elif dtype == "float":
inttext = widgets.FloatText(
value=value,
description=description,
disabled=disabled,
tooltip=tooltip,
)
return inttext
elif dtype == "text":
inttext = widgets.Text(
value=value,
description=description,
disabled=disabled,
tooltip=tooltip,
)
return inttext
elif dtype == "textarea":
inttext = widgets.Textarea(
value=value,
description=description,
disabled=disabled,
tooltip=tooltip,
layout=Layout(width="auto", height="100%")
)
return inttext

def header(text, tooltip="", theme="teal"):
color = themes[theme]["header"]
header = widgets.HTML(value = f"<b><font color='{color}'>{text}</b>",tooltip=tooltip)
return header

def text(text, tooltip="", theme="teal"):
color = themes[theme]["text"]
header = widgets.HTML(value = f"<font color='{color}'>{text}", tooltip=tooltip)
return header

def upload(theme="teal", tooltip="Select file to upload"):
upload = widgets.FileUpload(
accept='',
multiple=False,
tooltip=tooltip,
)
return upload

def download(filename, theme="teal"):
download = pn.widgets.FileDownload(file=filename,
embed=True)
return download

29 changes: 29 additions & 0 deletions pyscal_rdf/gui/create_element.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from ipywidgets import HBox, VBox, Layout
from pyscal_rdf.gui.create import dropdown, button, checkbox, textbox, header
from pyscal.crystal_structures import elements, structures
el_list = list(elements.keys())

class CreateElement:
def __init__(self, theme="teal"):
#create widgets
self.dropdown = dropdown('Element',
el_list,
value="Fe",
theme=theme)
self.run_button = button('Generate',
theme=theme)
self.checkbox = checkbox('Add to graph',
theme=theme)
self.repetition_box = textbox('Repetitions',
value=1,
theme=theme,
dtype="int")
self.text = "Create using element symbol"
self.header = header(self.text,
theme=theme, tooltip="create an element")
self.panel = VBox(children=[self.header,
self.dropdown,
self.checkbox,
self.repetition_box,
self.run_button])

42 changes: 42 additions & 0 deletions pyscal_rdf/gui/create_gb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from ipywidgets import HBox, VBox, Layout
from pyscal_rdf.gui.create import output, dropdown, button, checkbox, textbox, header
from pyscal.crystal_structures import elements, structures
st_list = list(structures.keys())

class CreateGB:
def __init__(self, theme="teal"):
#create widgets
self.axis_box = textbox('Axis',
value="0 0 1",
theme=theme,
dtype="text",)
self.gb_plane_box = textbox('GB Plane',
value="3 -1 0",
theme=theme,
dtype="text")
self.rep_box = textbox('Repetitions',
value="1 1 1",
theme=theme,
dtype="text")
#self.sigma_dropdown = dropdown('Sigma',
# value=5,
# theme=theme,
# dtype="int")
self.sigma_button = button('Find sigma',
theme=theme,
disabled=False,
tooltip="Calculate possible sigma values, only 10 results are shown")
self.gb_plane_button = button('Find possible GB planes',
theme=theme,
disabled=False,
tooltip="Calculate possible gb plane, only 10 results are shown")
self.run_button = button('Generate',
theme=theme,
disabled=True,
tooltip="Creating a structure using the above methods is necessary. Reading in a file does not work")
self.widget_list = [self.axis_box, self.sigma_button]
self.panel = HBox(children=self.widget_list)
self.sigma_dropdown = None
self.sigma_hb = None
self.gb_plane_dropdown = None
self.gb_plane_hb = None
46 changes: 46 additions & 0 deletions pyscal_rdf/gui/create_structure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from ipywidgets import HBox, VBox, Layout
from pyscal_rdf.gui.create import output, dropdown, button, checkbox, textbox, header
from pyscal.crystal_structures import elements, structures
st_list = list(structures.keys())
el_list = ["H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "K", "Ar", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Ni", "Co", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "I", "Te", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"]

class CreateStructure:
def __init__(self, theme="teal"):
#create widgets
self.dropdown = dropdown('Structure',
st_list,
value="bcc",
theme=theme)
self.run_button = button('Generate',
theme=theme)
self.checkbox = checkbox('Add to graph',
theme=theme)
self.repetition_box = textbox('Repetitions',
value=1,
theme=theme,
dtype="int")
self.lattice_parameter_box = textbox('LatticeParameter',
value=1,
theme=theme,
dtype="float")
self.element_box = dropdown('Element',
el_list,
value="Fe",
theme=theme)
self.element_box_2 = dropdown('Element',
el_list,
value="Al",
theme=theme,
disabled=True)

self.text = "Create a bulk structure"
self.header = header(self.text, theme=theme)
self.panel = VBox(children=[self.header,
self.dropdown,
self.checkbox,
self.repetition_box,
self.lattice_parameter_box,
self.element_box,
self.element_box_2,
self.run_button])

21 changes: 21 additions & 0 deletions pyscal_rdf/gui/create_vacancy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from ipywidgets import HBox, VBox, Layout
from pyscal_rdf.gui.create import output, dropdown, button, checkbox, textbox, header
from pyscal.crystal_structures import elements, structures
st_list = list(structures.keys())

class CreateVacancy:
def __init__(self, theme="teal"):
#create widgets
self.vacancy_dropdown = dropdown('Add vacancy',
["concentration", "number"],
theme=theme,
)
self.vacancy_box = textbox('',
value="0",
theme=theme,
dtype="text")
self.run_button = button('Generate',
theme=theme,
disabled=True,
tooltip="Add either vacancy concentration or number")
self.panel = VBox(children=[HBox(children=[self.vacancy_dropdown, self.vacancy_box]), self.run_button])
11 changes: 11 additions & 0 deletions pyscal_rdf/gui/ontology.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from ipywidgets import HBox, VBox, Layout
from pyscal_rdf.gui.create import output, dropdown, button, checkbox, textbox, header, upload

class Ontology:
def __init__(self, theme="teal"):
#create widgets
self.text = "pyscal-rdf uses the Computational Material Sample Ontology"
self.header = header(self.text, theme=theme)
self.output = output()
self.panel = VBox(children=[self.header,
self.output])
Loading