Skip to content

Using Mace

neb_ts_no_hess_irc_mace

neb_ts_no_hess_irc_mace(reactant, product, run_neb_kwargs, calc_kwargs1, logger, clean_up=True)

Perform NEB, transition state (TS) without custom Hessian, and intrinsic reaction coordinate (IRC) calculations using MACE.

Parameters:

  • reactant (Atoms) –

    The reactant structure.

  • product (Atoms) –

    The product structure.

  • run_neb_kwargs (dict) –

    Keyword arguments for the ASE's nudged elastic band function.

  • calc_kwargs1 (dict) –

    Keyword arguments for the ASE calculator for NEB, TS, and IRC jobs.

  • logger (Logger) –

    Logger for logging information.

  • clean_up (bool, default: True ) –

    Whether to clean up raw files after completion, by default True.

Returns:

  • List[Dict[str, Any]]

    List containing results from NEB, TS, and IRC jobs.

Source code in ts_workflow_examples/neb_ts_without_hessian/using_mace.py
def neb_ts_no_hess_irc_mace(
        reactant: Atoms,
        product: Atoms,
        run_neb_kwargs: Dict[str, Any],
        calc_kwargs1: Dict[str, Any],
        logger: logging.Logger,
        clean_up: bool = True
) -> List[Dict[str, Any]]:
    """
    Perform NEB, transition state (TS) without custom Hessian, and intrinsic reaction coordinate (IRC)
    calculations using MACE.

    Parameters
    ----------
    reactant : Atoms
        The reactant structure.
    product : Atoms
        The product structure.
    run_neb_kwargs : dict
        Keyword arguments for the ASE's nudged elastic band function.
    calc_kwargs1 : dict
        Keyword arguments for the ASE calculator for NEB, TS, and IRC jobs.
    logger : logging.Logger
        Logger for logging information.
    clean_up : bool, optional
        Whether to clean up raw files after completion, by default True.

    Returns
    -------
    List[Dict[str, Any]]
        List containing results from NEB, TS, and IRC jobs.
    """
    # Create NEB job
    job1 = strip_decorator(neb_job)(
        reactant,
        product,
        run_neb_kwargs=run_neb_kwargs,
        **calc_kwargs1,
    )
    logger.info("Created NEB job.")

    # Create TS job with custom Hessian
    job2 = strip_decorator(ts_job)(
        job1['neb_results']['highest_e_atoms'],
        use_custom_hessian=False,
        **calc_kwargs1,
    )
    logger.info("Created TS job with custom Hessian.")

    # Create IRC job in forward direction
    job3 = strip_decorator(irc_job)(
        job2['atoms'],
        direction='forward',
        **calc_kwargs1,
    )
    logger.info("Created IRC job in forward direction.")

    # Create IRC job in reverse direction
    job4 = strip_decorator(irc_job)(
        job2['atoms'],
        direction='reverse',
        **calc_kwargs1,
    )
    logger.info("Created IRC job in reverse direction.")

    logger.info("All jobs executed successfully.")

    if clean_up:
        # Delete the raw files
        directory_patterns = ["quacc-*", "tmp*"]

        # Delete directories matching patterns
        for pattern in directory_patterns:
            for dir_path in glob.glob(pattern):
                if os.path.isdir(dir_path):
                    shutil.rmtree(dir_path)

    return [job1, job2, job3, job4]