-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathstructure_magnetic.py
49 lines (41 loc) · 1.48 KB
/
structure_magnetic.py
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
from __future__ import annotations
import dash
from dash import html
from pymatgen.core import Lattice, Structure
import crystal_toolkit.components as ctc
from crystal_toolkit.settings import SETTINGS
app = dash.Dash(assets_folder=SETTINGS.ASSETS_PATH)
# create the Structure object
structure = Structure(
Lattice.cubic(3.0),
["Ni", "Ti"],
[[0, 0, 0], [0.5, 0.5, 0.5]],
site_properties={"magmom": [[-2.0, 1.0, 0.0], [1.0, 1.0, -1.0]]},
# site_properties={"magmom": [3.0, -2.0]},
)
# create the Crystal Toolkit component
structure_component = ctc.StructureMoleculeComponent(structure, id="struct")
# example layout to demonstrate capabilities of component
layout = html.Div(
[
html.H1("StructureMoleculeComponent Example"),
html.H2("Standard Layout"),
structure_component.layout(size="400px"),
html.H2("Optional Additional Layouts"),
html.H3("Screenshot Layout"),
structure_component.screenshot_layout(),
html.H3("Options Layout"),
structure_component.options_layout(),
html.H3("Title Layout"),
structure_component.title_layout(),
html.H3("Legend Layout"),
structure_component.legend_layout(),
]
)
# tell crystal toolkit about your app and layout
ctc.register_crystal_toolkit(app, layout=layout)
# run this app with "python path/to/this/file.py"
# in production, deploy behind gunicorn or similar
# see Dash docs for more info
if __name__ == "__main__":
app.run(debug=True, port=8050)