Exemplo n.º 1
0
def robocrystallographer(
    structure: Structure,
    condenser_kwargs: Optional[dict] = None,
    describer_kwargs: Optional[dict] = None,
) -> str:
    """Gets the robocrystallographer description of a structure.

    Args:
        structure: A structure.
        condenser_kwargs: Keyword arguments that will be passed to
            :obj:`robocrys.condense.StructureCondenser`.
        describer_kwargs: Keyword arguments that will be passed to
            :obj:`robocrys.describe.StructureDescriber`.

    Returns:
        The description.
    """
    condenser_kwargs = condenser_kwargs if condenser_kwargs else {}
    describer_kwargs = describer_kwargs if describer_kwargs else {}

    sc = StructureCondenser(**condenser_kwargs)
    describer = StructureDescriber(**describer_kwargs)

    if not any(
        [hasattr(s, "oxi_state") for s in structure.composition.elements]):
        try:
            structure.add_oxidation_state_by_guess(max_sites=-80)
        except ValueError:
            warnings.warn("Could not add oxidation states!")

    condensed_structure = sc.condense_structure(structure)
    description = describer.describe(condensed_structure)
    print(description)
    return description
Exemplo n.º 2
0
        def run_robocrys_analysis(new_store_contents):

            print("Robocrys callback fired")

            struct = self.from_data(new_store_contents)

            try:

                condenser = StructureCondenser()
                describer = StructureDescriber()

                condensed_structure = condenser.condense_structure(struct)

                description = describer.describe(condensed_structure)

            except Exception as exc:

                description = str(exc)

            return MessageContainer(
                MessageBody([
                    f"{description} – ",
                    html.A(
                        f"🤖 robocrys v{robocrys_version}",
                        href=
                        "https://github.com/hackingmaterials/robocrystallographer",
                        style={"white-space": "nowrap"},
                    ),
                ]),
                kind="dark",
            )
Exemplo n.º 3
0
    def update_contents(self, new_store_contents):

        struct = self.from_data(new_store_contents)

        condenser = StructureCondenser()
        describer = StructureDescriber()

        condensed_structure = condenser.condense_structure(struct)

        description = describer.describe(condensed_structure)

        return MessageContainer(MessageBody([
            f"{description} – ",
            html.A(
                f"🤖 robocrys v{robocrys_version}",
                href="https://github.com/hackingmaterials/robocrystallographer",
                style={"white-space": "nowrap"},
            ),
        ]),
                                kind="dark")
Exemplo n.º 4
0
    def update_contents(self, new_store_contents):

        struct = self.from_data(new_store_contents)

        condenser = StructureCondenser()
        describer = StructureDescriber()

        condensed_structure = condenser.condense_structure(struct)

        description = describer.describe(condensed_structure)

        return html.Blockquote(
            [
                f"{description} – ",
                html.A(
                    f"🤖 robocrys v{robocrys_version}",
                    href="https://github.com/hackingmaterials/robocrystallographer",
                    style={"white-space": "nowrap"},
                ),
            ],
            className="mpc-blockquote",
        )
Exemplo n.º 5
0
    def __init__(self, materials, robocrys, **kwargs):
        """Runs robocrystallographer to get the condensed structure and
        structure description.

        Args:
            materials (Store): Store of materials documents.
            robocrys (Store): Store of condensed structure and
                text structure description.
            **kwargs: Keyword arguments that will get passed to the builder
                super method.
        """
        self.materials = materials
        self.robocrys = robocrys

        self.condenser = StructureCondenser()
        self.describer = StructureDescriber(describe_symmetry_labels=False)

        super().__init__(source=materials,
                         target=robocrys,
                         ufn=self.calc,
                         projection=["structure"],
                         **kwargs)
 def __init__(
     self, condenser_kwargs: Optional[dict] = None, distorted_tol: float = 0.6
 ):
     condenser_kwargs = condenser_kwargs if condenser_kwargs else {}
     self._sc = StructureCondenser(**condenser_kwargs)
     self._distorted_tol = distorted_tol