# create the Structure object structure = Structure(Lattice.cubic(4.2), ["Na", "K"], [[0, 0, 0], [0.5, 0.5, 0.5]]) from pymatgen import MPRester # create an input structure as an example structure_component = ctc.StructureMoleculeComponent( MPRester().get_structure_by_material_id("mp-804"), id="structure_in") # and a way to view the transformed structure structure_component_transformed = ctc.StructureMoleculeComponent( MPRester().get_structure_by_material_id("mp-804"), id="structure_out") # and the transformation component itself transformation_component = ctc.AllTransformationsComponent( input_structure_component=structure_component, ) # example layout to demonstrate capabilities of component my_layout = html.Div([ html.H1("TransformationComponent Example"), html.H2("Standard Layout"), transformation_component.layout(), html.H3("Example Input Structure"), structure_component.layout(size="500px"), html.H3("Example Transformed Structure"), structure_component_transformed.layout(size="500px"), html.H3("JSON View of Transformations"), JsonView(id="json"), ]) # tell crystal toolkit about your app and layout
# struct_component.attach_from(transformation_component, origin_store_name="out") # TODO: change to link to struct_or_mol instead of graph ? # download_component = ctc.DownloadPanelComponent(links={"default": struct_component.id()}) search_component = ctc.SearchComponent() upload_component = ctc.StructureMoleculeUploadComponent() transformation_component = ctc.AllTransformationsComponent( transformations=[ "SupercellTransformationComponent", "AutoOxiStateDecorationTransformationComponent", "CubicSupercellTransformationComponent", "GrainBoundaryTransformationComponent", "MonteCarloRattleTransformationComponent", "SlabTransformationComponent", "SubstitutionTransformationComponent", ] ) struct_component = ctc.StructureMoleculeComponent( links={"default": transformation_component.id()} ) robocrys_panel = ctc.RobocrysComponent(links={"default": transformation_component.id()}) xrd_panel = ctc.XRayDiffractionPanelComponent( links={"default": transformation_component.id()} ) # pbx_component = ctc.PourbaixDiagramPanelComponent(origin_component=struct_component)
logger = logging.getLogger(app.title) # endregion ################################################################################ # region INSTANTIATE CORE COMPONENTS ################################################################################ supercell = ctc.SupercellTransformationComponent() # grain_boundary = ctc.GrainBoundaryTransformationComponent() # oxi_state = ctc.AutoOxiStateDecorationTransformationComponent() # slab = ctc.SlabTransformationComponent() # substitution = ctc.SubstitutionTransformationComponent() transformation_component = ctc.AllTransformationsComponent( transformations=[supercell ] # , slab, grain_boundary, oxi_state, substitution], ) struct_component = ctc.StructureMoleculeComponent( links={"default": transformation_component.id("out")}) # struct_component.attach_from(transformation_component, origin_store_name="out") # TODO: change to link to struct_or_mol instead of graph ? # download_component = ctc.DownloadPanelComponent(links={"default": struct_component.id()}) search_component = ctc.SearchComponent() upload_component = ctc.StructureMoleculeUploadComponent() # robocrys_component = ctc.RobocrysComponent(origin_component=struct_component) # magnetism_component = ctc.MagnetismComponent(origin_component=struct_component) # xrd_component = ctc.XRayDiffractionPanelComponent(origin_component=struct_component)
from pymatgen.ext.matproj import MPRester # create an input structure as an example structure = MPRester().get_structure_by_material_id("mp-804") structure_in = dcc.Store(id="structure_in", data=structure.as_dict()) # patch, this should be a JSON component ... structure_in.id = lambda: "structure_in" # and the transformation component itself transformation_component = ctc.AllTransformationsComponent( transformations=[ "AutoOxiStateDecorationTransformationComponent", "SupercellTransformationComponent", # "SlabTransformationComponent", # "SubstitutionTransformationComponent", "CubicSupercellTransformationComponent", # "GrainBoundaryTransformationComponent" ], input_structure=structure_in, ) # example layout to demonstrate capabilities of component my_layout = html.Div([ html.H1("TransformationComponent Example"), html.H2("Standard Layout"), transformation_component.layout(), html.H3("Example Input Structure"), JsonView(src=structure.as_dict()), html.H3("Example Transformed Structure"), JsonView(src={}, id="structure_out"),
# region INSTANTIATE CORE COMPONENTS ################################################################################ # struct_component.attach_from(transformation_component, origin_store_name="out") # TODO: change to link to struct_or_mol instead of graph ? # download_component = ctc.DownloadPanelComponent(links={"default": struct_component.id()}) search_component = ctc.SearchComponent() upload_component = ctc.StructureMoleculeUploadComponent() transformation_component = ctc.AllTransformationsComponent( transformations=[ "SupercellTransformationComponent", "AutoOxiStateDecorationTransformationComponent", "CubicSupercellTransformationComponent", ] ) struct_component = ctc.StructureMoleculeComponent( links={"default": transformation_component.id()} ) # robocrys_component = ctc.RobocrysComponent(origin_component=struct_component) # magnetism_component = ctc.MagnetismComponent(origin_component=struct_component) # xrd_component = ctc.XRayDiffractionPanelComponent(origin_component=struct_component) # pbx_component = ctc.PourbaixDiagramPanelComponent(origin_component=struct_component) # # symmetry_component = ctc.SymmetryComponent(origin_component=struct_component) # localenv_component = ctc.LocalEnvironmentPanel()