matcalc.backend package

Provides various backends of running simulations.

is_lammps_backend() → bool[source]

Whether calculations run with the LAMMPS backend (MATCALC_BACKEND is not ASE).

run_pes_calc(*arg, **kwargs) → SimulationResult[source]

Executes the potential energy surface (PES) calculation using the appropriate backend.

This function determines the backend to use for the PES calculation based on the environment variable MATCALC_BACKEND. If the variable is set to “ASE” (case-insensitive) or is not explicitly provided, the ASE backend is used. Otherwise, the LAMMPS backend is selected. The function then forwards the arguments and keyword arguments to the respective backend function for execution.

Parameters:
  • *arg – Positional arguments forwarded to the selected backend.

  • **kwargs – Keyword arguments forwarded to the selected backend.

Returns:

SimulationResult from the ASE or LAMMPS backend.

to_backend_calculator(calculator: str | Calculator) → Calculator[source]

Return the calculator to use with the active backend.

Under the ASE backend, a model name is loaded with PESCalculator.load_universal and a calculator is returned unchanged. Under the LAMMPS backend the result is a LAMMPSCalculator, so that the force field is resolved once (e.g. a MatGL model exported to TorchScript), unsupported models fail immediately, and code that evaluates the calculator directly through ASE also uses LAMMPS: a model name is built directly with load_lammps_calculator() (no ASE calculator is created), and a calculator object is converted with to_lammps_calculator().

Parameters:

calculator – Model name or ASE calculator.

Returns:

Calculator for the active backend.

Raises:

TypeError – Under the LAMMPS backend, if the model or calculator has no LAMMPS representation.

Submodules