Skip to content

jarvis

Convert an OPTIMADE structure, in the format of StructureResource to a JARVIS Atoms object.

For more information on the NIST-JARVIS repository, see their website.

This conversion function relies on the jarvis-tools package.

Contributing author

This conversion function was contributed by Kamal Choudhary (@knc6).

get_jarvis_atoms(optimade_structure)

Get jarvis Atoms from OPTIMADE structure.

Caution

Cannot handle partial occupancies.

Parameters:

Name Type Description Default
optimade_structure StructureResource

OPTIMADE structure.

required

Returns:

Type Description
Atoms

A jarvis Atoms object.

Source code in optimade/adapters/structures/jarvis.py
def get_jarvis_atoms(optimade_structure: OptimadeStructure) -> Atoms:
    """Get jarvis `Atoms` from OPTIMADE structure.

    Caution:
        Cannot handle partial occupancies.

    Parameters:
        optimade_structure: OPTIMADE structure.

    Returns:
        A jarvis `Atoms` object.

    """
    if "optimade.adapters" in repr(globals().get("Atoms")):
        warn(JARVIS_NOT_FOUND, AdapterPackageNotFound)
        return None

    attributes = optimade_structure.attributes

    # Cannot handle partial occupancies
    if StructureFeatures.DISORDER in attributes.structure_features:
        raise ConversionError(
            "jarvis-tools cannot handle structures with partial occupancies."
        )

    return Atoms(
        lattice_mat=attributes.lattice_vectors,
        elements=[specie.name for specie in attributes.species],
        coords=attributes.cartesian_site_positions,
        cartesian=True,
    )