Skip to content

_base

Base jobs for GULP.

GEOM_FILE_NOPBC module-attribute

GEOM_FILE_NOPBC = 'gulp.xyz'

GEOM_FILE_PBC module-attribute

GEOM_FILE_PBC = 'gulp.cif'

GULP_CMD module-attribute

GULP_CMD = f'{GULP_CMD} < gulp.gin > gulp.got'

logger module-attribute

logger = getLogger(__name__)

run_and_summarize

run_and_summarize(
    atoms: Atoms,
    library: str | None = None,
    keyword_defaults: list[str] | None = None,
    option_defaults: list[str] | None = None,
    keyword_swaps: list[str] | None = None,
    option_swaps: list[str] | None = None,
    additional_fields: dict[str, Any] | None = None,
    copy_files: (
        SourceDirectory
        | dict[SourceDirectory, Filenames]
        | None
    ) = None,
    **calc_kwargs
) -> RunSchema

Base job function for GULP recipes.

Parameters:

  • atoms (Atoms) –

    Atoms object

  • library (str | None, default: None ) –

    Filename of the potential library file, if required.

  • keyword_defaults (list[str] | None, default: None ) –

    Default keywords for calculator.

  • option_defaults (list[str] | None, default: None ) –

    Default options for calculator.

  • keyword_swaps (list[str] | None, default: None ) –

    List of custom keyword kwargs for the GULP calculator. To remove entries from the defaults, put a # in front of the name. For a list of available keys, refer to the ase.calculators.gulp.GULP calculator.

  • option_swaps (list[str] | None, default: None ) –

    Dictionary of custom options kwargs for the GULP calculator. To remove entries from the defaults, put a # in front of the name. For a list of available keys, refer to the ase.calculators.gulp.GULP calculator.

  • additional_fields (dict[str, Any] | None, default: None ) –

    Additional field to supply to the summarizer.

  • copy_files (SourceDirectory | dict[SourceDirectory, Filenames] | None, default: None ) –

    Files to copy (and decompress) from source to the runtime directory.

  • **calc_kwargs

    Any other keyword arguments to pass to the GULP calculator.

Returns:

Source code in quacc/recipes/gulp/_base.py
def run_and_summarize(
    atoms: Atoms,
    library: str | None = None,
    keyword_defaults: list[str] | None = None,
    option_defaults: list[str] | None = None,
    keyword_swaps: list[str] | None = None,
    option_swaps: list[str] | None = None,
    additional_fields: dict[str, Any] | None = None,
    copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
    **calc_kwargs,
) -> RunSchema:
    """
    Base job function for GULP recipes.

    Parameters
    ----------
    atoms
        Atoms object
    library
        Filename of the potential library file, if required.
    keyword_defaults
        Default `keywords` for calculator.
    option_defaults
        Default `options` for calculator.
    keyword_swaps
        List of custom `keyword` kwargs for the GULP calculator. To remove entries
        from the defaults, put a `#` in front of the name. For a list of
        available keys, refer to the `ase.calculators.gulp.GULP` calculator.
    option_swaps
        Dictionary of custom `options` kwargs for the GULP calculator. To remove entries
        from the defaults, put a `#` in front of the name. For a list of
        available keys, refer to the `ase.calculators.gulp.GULP` calculator.
    additional_fields
        Additional field to supply to the summarizer.
    copy_files
        Files to copy (and decompress) from source to the runtime directory.
    **calc_kwargs
        Any other keyword arguments to pass to the `GULP` calculator.

    Returns
    -------
    RunSchema
        Dictionary of results from [quacc.schemas.ase.summarize_run][]
    """
    keyword_defaults = keyword_defaults or []

    if not atoms.pbc.any():
        if "opti" in keyword_defaults and "conv" not in keyword_defaults:
            keyword_defaults += ["conv"]
        keyword_defaults = [k for k in keyword_defaults if k not in ["gwolf", "conp"]]

    option_defaults += [
        (
            f"output cif {GEOM_FILE_PBC}"
            if atoms.pbc.any()
            else f"output xyz {GEOM_FILE_NOPBC}"
        )
    ]

    keywords = merge_list_params(keyword_defaults, keyword_swaps)
    options = merge_list_params(option_defaults, option_swaps)

    gulp_keywords = " ".join(keywords)
    gulp_options = list(options)

    if SETTINGS.GULP_LIB:
        os.environ["GULP_LIB"] = str(SETTINGS.GULP_LIB)
    atoms.calc = GULP(
        command=GULP_CMD,
        keywords=gulp_keywords,
        options=gulp_options,
        library=library,
        **calc_kwargs,
    )
    final_atoms = run_calc(
        atoms,
        geom_file=GEOM_FILE_PBC if atoms.pbc.any() else GEOM_FILE_NOPBC,
        copy_files=copy_files,
    )

    if (
        SETTINGS.CHECK_CONVERGENCE
        and "opti" in gulp_keywords
        and not final_atoms.calc.get_opt_state()
    ):
        msg = "Optimization did not converge."
        raise RuntimeError(msg)

    return summarize_run(final_atoms, atoms, additional_fields=additional_fields)