Skip to content

core

Core recipes for the NewtonNet code.

has_newtonnet module-attribute

has_newtonnet = bool(find_spec('newtonnet'))

has_sella module-attribute

has_sella = bool(find_spec('sella'))

freq_job

freq_job(
    atoms: Atoms,
    temperature: float = 298.15,
    pressure: float = 1.0,
    copy_files: (
        SourceDirectory
        | dict[SourceDirectory, Filenames]
        | None
    ) = None,
    additional_fields: dict[str, Any] | None = None,
    **calc_kwargs
) -> VibThermoSchema

Perform a frequency calculation using the given atoms object.

Parameters:

  • atoms (Atoms) –

    The atoms object representing the system.

  • temperature (float, default: 298.15 ) –

    The temperature for the thermodynamic analysis.

  • pressure (float, default: 1.0 ) –

    The pressure for the thermodynamic analysis.

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

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

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

    Additional fields to add to the results dictionary.

  • **calc_kwargs

    Custom kwargs for the NewtonNet calculator. Set a value to quacc.Remove to remove a pre-existing key entirely. For a list of available keys, refer to the newtonnet.utils.ase_interface.MLAseCalculator calculator.

Returns:

  • VibThermoSchema

    Dictionary of results. See the type-hint for the data structure.

Source code in quacc/recipes/newtonnet/core.py
@job
@requires(
    has_newtonnet, "NewtonNet must be installed. Refer to the quacc documentation."
)
def freq_job(
    atoms: Atoms,
    temperature: float = 298.15,
    pressure: float = 1.0,
    copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
    additional_fields: dict[str, Any] | None = None,
    **calc_kwargs,
) -> VibThermoSchema:
    """
    Perform a frequency calculation using the given atoms object.

    Parameters
    ----------
    atoms
        The atoms object representing the system.
    temperature
        The temperature for the thermodynamic analysis.
    pressure
        The pressure for the thermodynamic analysis.
    copy_files
        Files to copy (and decompress) from source to the runtime directory.
    additional_fields
        Additional fields to add to the results dictionary.
    **calc_kwargs
        Custom kwargs for the NewtonNet calculator. Set a value to
        `quacc.Remove` to remove a pre-existing key entirely. For a list of available
        keys, refer to the `newtonnet.utils.ase_interface.MLAseCalculator` calculator.

    Returns
    -------
    VibThermoSchema
        Dictionary of results. See the type-hint for the data structure.
    """
    settings = get_settings()
    calc_defaults = {
        "model_path": settings.NEWTONNET_MODEL_PATH,
        "settings_path": settings.NEWTONNET_CONFIG_PATH,
        "hess_method": "autograd",
    }
    calc_flags = recursive_dict_merge(calc_defaults, calc_kwargs)

    calc = NewtonNet(**calc_flags)
    final_atoms = Runner(atoms, calc, copy_files=copy_files).run_calc()

    summary = Summarize(
        additional_fields={"name": "NewtonNet Frequency"} | (additional_fields or {})
    ).run(final_atoms, atoms)

    vib = VibrationsData(final_atoms, summary["results"]["hessian"])
    return VibSummarize(
        vib,
        directory=summary["dir_name"],
        additional_fields={"name": "ASE Vibrations and Thermo Analysis"},
    ).vib_and_thermo(
        "ideal_gas",
        energy=summary["results"]["energy"],
        temperature=temperature,
        pressure=pressure,
    )

relax_job

relax_job(
    atoms: Atoms,
    opt_params: OptParams | None = None,
    copy_files: (
        SourceDirectory
        | dict[SourceDirectory, Filenames]
        | None
    ) = None,
    additional_fields: dict[str, Any] | None = None,
    **calc_kwargs
) -> OptSchema

Relax a structure.

Parameters:

  • atoms (Atoms) –

    Atoms object

  • opt_params (OptParams | None, default: None ) –

    Dictionary of custom kwargs for the optimization process. For a list of available keys, refer to quacc.runners.ase.Runner.run_opt.

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

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

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

    Additional fields to add to the results dictionary.

  • **calc_kwargs

    Dictionary of custom kwargs for the NewtonNet calculator. Set a value to quacc.Remove to remove a pre-existing key entirely. For a list of available keys, refer to the newtonnet.utils.ase_interface.MLAseCalculator calculator.

Returns:

Source code in quacc/recipes/newtonnet/core.py
@job
@requires(
    has_newtonnet, "NewtonNet must be installed. Refer to the quacc documentation."
)
def relax_job(
    atoms: Atoms,
    opt_params: OptParams | None = None,
    copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
    additional_fields: dict[str, Any] | None = None,
    **calc_kwargs,
) -> OptSchema:
    """
    Relax a structure.

    Parameters
    ----------
    atoms
        Atoms object
    opt_params
        Dictionary of custom kwargs for the optimization process. For a list
        of available keys, refer to [quacc.runners.ase.Runner.run_opt][].
    copy_files
        Files to copy (and decompress) from source to the runtime directory.
    additional_fields
        Additional fields to add to the results dictionary.
    **calc_kwargs
        Dictionary of custom kwargs for the NewtonNet calculator. Set a value to
        `quacc.Remove` to remove a pre-existing key entirely. For a list of available
        keys, refer to the `newtonnet.utils.ase_interface.MLAseCalculator` calculator.

    Returns
    -------
    OptSchema
        Dictionary of results, specified in [quacc.schemas.ase.Summarize.opt][].
        See the type-hint for the data structure.
    """
    settings = get_settings()
    calc_defaults = {
        "model_path": settings.NEWTONNET_MODEL_PATH,
        "settings_path": settings.NEWTONNET_CONFIG_PATH,
    }
    opt_defaults = {"optimizer": Sella} if has_sella else {}

    calc_flags = recursive_dict_merge(calc_defaults, calc_kwargs)
    opt_flags = recursive_dict_merge(opt_defaults, opt_params)

    calc = NewtonNet(**calc_flags)
    dyn = Runner(atoms, calc, copy_files=copy_files).run_opt(**opt_flags)

    return _add_stdev_and_hess(
        Summarize(
            additional_fields={"name": "NewtonNet Relax"} | (additional_fields or {})
        ).opt(dyn)
    )

static_job

static_job(
    atoms: Atoms,
    copy_files: (
        SourceDirectory
        | dict[SourceDirectory, Filenames]
        | None
    ) = None,
    additional_fields: dict[str, Any] | None = None,
    **calc_kwargs
) -> RunSchema

Carry out a single-point calculation.

Parameters:

  • atoms (Atoms) –

    Atoms object

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

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

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

    Additional fields to add to the results dictionary.

  • **calc_kwargs

    Custom kwargs for the NewtonNet calculator. Set a value to quacc.Remove to remove a pre-existing key entirely. For a list of available keys, refer to the newtonnet.utils.ase_interface.MLAseCalculator calculator.

Returns:

Source code in quacc/recipes/newtonnet/core.py
@job
@requires(
    has_newtonnet, "NewtonNet must be installed. Refer to the quacc documentation."
)
def static_job(
    atoms: Atoms,
    copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
    additional_fields: dict[str, Any] | None = None,
    **calc_kwargs,
) -> RunSchema:
    """
    Carry out a single-point calculation.

    Parameters
    ----------
    atoms
        Atoms object
    copy_files
        Files to copy (and decompress) from source to the runtime directory.
    additional_fields
        Additional fields to add to the results dictionary.
    **calc_kwargs
        Custom kwargs for the NewtonNet calculator. Set a value to
        `quacc.Remove` to remove a pre-existing key entirely. For a list of available
        keys, refer to the `newtonnet.utils.ase_interface.MLAseCalculator` calculator.

    Returns
    -------
    RunSchema
        Dictionary of results, specified in [quacc.schemas.ase.Summarize.run][].
        See the type-hint for the data structure.
    """
    settings = get_settings()
    calc_defaults = {
        "model_path": settings.NEWTONNET_MODEL_PATH,
        "settings_path": settings.NEWTONNET_CONFIG_PATH,
    }
    calc_flags = recursive_dict_merge(calc_defaults, calc_kwargs)

    calc = NewtonNet(**calc_flags)
    final_atoms = Runner(atoms, calc, copy_files=copy_files).run_calc()

    return Summarize(
        additional_fields={"name": "NewtonNet Static"} | (additional_fields or {})
    ).run(final_atoms, atoms)