Skip to content

Using Mace

geodesic_ts_hess_irc_mace

geodesic_ts_hess_irc_mace(reactant, product, calc_kwargs, logger, clean_up=True)

Perform geodesic, transition state, and intrinsic reaction coordinate (IRC) calculations using MACE.

Parameters:

  • reactant (Atoms) –

    The reactant structure.

  • product (Atoms) –

    The product structure.

  • calc_kwargs (dict) –

    Keyword arguments for the ASE calculator.

  • 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 geodesic, TS, and IRC jobs.

Source code in ts_workflow_examples/geodesic_ts_with_hessian/using_mace.py
def geodesic_ts_hess_irc_mace(
        reactant: Atoms,
        product: Atoms,
        calc_kwargs: Dict[str, Any],
        logger: logging.Logger,
        clean_up: bool = True,
) -> List[Dict[str, Any]]:
    """
    Perform geodesic, transition state, and intrinsic reaction coordinate (IRC) calculations using MACE.

    Parameters
    ----------
    reactant : Atoms
        The reactant structure.
    product : Atoms
        The product structure.
    calc_kwargs : dict
        Keyword arguments for the ASE calculator.
    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 geodesic, TS, and IRC jobs.
    """
    # Create NEB job
    job1 = strip_decorator(geodesic_job)(reactant, product, calc_kwargs=calc_kwargs)
    logger.info("Geodesic job done.")

    # Create TS job with custom Hessian
    job2 = strip_decorator(ts_job)(job1['highest_e_atoms'], use_custom_hessian=True, **calc_kwargs)
    logger.info("TS job with custom Hessian done.")

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

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

    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]