from pymatgen.analysis.phase_diagram import PhaseDiagram from pymatgen.analysis.diffraction.xrd import XRDCalculator # create Dash app as normal app = dash.Dash(assets_folder=SETTINGS.ASSETS_PATH) # create our crystal structure using pymatgen from pymatgen.core.structure import Structure from pymatgen.core.lattice import Lattice structure = Structure(Lattice.cubic(4.2), ["Na", "K"], [[0, 0, 0], [0.5, 0.5, 0.5]]) xrd_component = ctc.XRayDiffractionComponent(initial_structure=structure) # example layout to demonstrate capabilities of component my_layout = Container([ H1("XRDComponent Example"), H3("Generated from Structure object"), xrd_component.layout(), ]) # as explained in "preamble" section in documentation ctc.register_crystal_toolkit(app=app, layout=my_layout) # allow app to be run using "python structure.py" # in production, deploy behind gunicorn or similar # see Dash documentation for more information if __name__ == "__main__": app.run_server(debug=True, port=8050)
import crystal_toolkit.components as ctc from crystal_toolkit.settings import SETTINGS from crystal_toolkit.helpers.layouts import H1, H2, Container, Button # create Dash app as normal app = dash.Dash(assets_folder=SETTINGS.ASSETS_PATH) # create our crystal structure using pymatgen from pymatgen.core.structure import Structure from pymatgen.core.lattice import Lattice xrd_component = ctc.XRayDiffractionComponent() # example layout to demonstrate capabilities of component my_layout = Container([ H1("XRDComponent Example (Structure Added After Loading)"), xrd_component.layout(), Button("Load XRD", id="load-xrd-button"), ]) # as explained in "preamble" section in documentation ctc.register_crystal_toolkit(app=app, layout=my_layout) @app.callback(Output(xrd_component.id(), "data"), [Input("load-xrd-button", "n_clicks")]) def load_structure(n_clicks): structure = Structure(Lattice.cubic(4.2), ["Na", "K"], [[0, 0, 0], [0.5, 0.5, 0.5]]) return structure
# nested layout this will need to be enabled -- consult Dash documentation # for more information. # app.config["suppress_callback_exceptions"] = True path = os.path.dirname(os.path.realpath(__file__)) bandstructure_symm_line = loadfn(path + "/GaN_bs.json") density_of_states = loadfn(path + "/GaN_dos.json") # # create the Crystal Toolkit component bsdos_component = ctc.BandstructureAndDosComponent( bandstructure_symm_line=bandstructure_symm_line, density_of_states=density_of_states, id="bs_dos", ) # example layout to demonstrate capabilities of component my_layout = Container([ H1("Band Structure and Density of States Example"), bsdos_component.layout(), ]) # wrap your app.layout with crystal_toolkit_layout() # to ensure all necessary components are loaded into layout ctc.register_crystal_toolkit(app, layout=my_layout) # allow app to be run using "python structure.py" # in production, deploy behind gunicorn or similar # see Dash documentation for more information if __name__ == "__main__": app.run_server(debug=True, port=8050)
from pymatgen.ext.matproj import MPRester from pymatgen.analysis.phase_diagram import PhaseDiagram from pymatgen.analysis.diffraction.xrd import XRDCalculator # create Dash app as normal app = dash.Dash(assets_folder=SETTINGS.ASSETS_PATH) # create our crystal structure using pymatgen from pymatgen.core.structure import Structure from pymatgen.core.lattice import Lattice structure = Structure(Lattice.cubic(4.2), ["Na", "K"], [[0, 0, 0], [0.5, 0.5, 0.5]]) xrd_component = ctc.XRayDiffractionComponent() # example layout to demonstrate capabilities of component my_layout = Container([ H1("XRDComponent Example (Empty, No Structure Defined)"), xrd_component.layout(), ]) # as explained in "preamble" section in documentation ctc.register_crystal_toolkit(app=app, layout=my_layout) # allow app to be run using "python structure.py" # in production, deploy behind gunicorn or similar # see Dash documentation for more information if __name__ == "__main__": app.run_server(debug=True, port=8050)
# nested layout this will need to be enabled -- consult Dash documentation # for more information. # app.config["suppress_callback_exceptions"] = True path = os.path.dirname(os.path.realpath(__file__)) bandstructure_symm_line = loadfn(path + "/GaN_bs.json") density_of_states = loadfn(path + "/GaN_dos.json") # # create the Crystal Toolkit component bsdos_component = ctc.BandstructureAndDosComponent( bandstructure_symm_line=bandstructure_symm_line, density_of_states=density_of_states, id="bs_dos", ) # example layout to demonstrate capabilities of component my_layout = Container( [H1("Electronic Band Structure and Density of States Example"), bsdos_component.layout(),] ) # wrap your app.layout with crystal_toolkit_layout() # to ensure all necessary components are loaded into layout ctc.register_crystal_toolkit(app, layout=my_layout) # allow app to be run using "python structure.py" # in production, deploy behind gunicorn or similar # see Dash documentation for more information if __name__ == "__main__": app.run_server(debug=True, port=8050)