Miscellaneous

metatomic.torch.pick_device(model_devices: List[str], desired_device: str | None) str[source]

Select the best device according to the list of model_devices from a model, the user-provided desired_device and what’s available on the current machine.

If desired_device is provided, it is checked against the model_devices and the machine availability. If it contains a device index (e.g. "cuda:1"), the base device type ("cuda") is used for these checks, and the full string is returned if successful.

If desired_device is None or an empty string, the first available device from model_devices will be picked and returned.

Parameters:
  • model_devices (List[str]) – list of devices supported by a model in order of preference

  • desired_device (str | None) – user-provided desired device.

Return type:

str

metatomic.torch.pick_output(requested_output: str, outputs: Dict[str, ModelOutput], desired_variant: str | None = None) str[source]

Pick the output for the given requested_output from the availabilities of the model’s outputs, according to the optional desired_variant.

Parameters:
  • requested_output (str) – name of the output to pick a variant for

  • outputs (Dict[str, ModelOutput]) – all available outputs from the model

  • desired_variant (str | None) – if provided, try to pick this specific variant

Return type:

str

metatomic.torch.unit_conversion_factor(quantity: str, from_unit: str, to_unit: str)[source]

Get the multiplicative conversion factor from from_unit to to_unit. Both units must be valid and known for the given physical quantity. The set of valid quantities and units is available here.

Parameters:
  • quantity (str) – name of the physical quantity

  • from_unit (str) – current unit of the data

  • to_unit (str) – target unit of the data

Known quantities and units

The following quantities and units can be used with metatomic models. Adding new units and quantities is very easy, please contact us if you need something else! In the mean time, you can create metatomic.torch.ModelOutput with quantities that are not in this table. A warning will be issued and no unit conversion will be performed.

When working with one of the quantities in this table, the unit you use must be one of the registered unit.

quantity

units

length

angstrom (A), Bohr, meter, centimeter (cm), millimeter (mm), micrometer (um, µm), nanometer (nm)

energy

eV, meV, Hartree, kcal/mol, kJ/mol, Joule (J), Rydberg (Ry)

force

eV/Angstrom (eV/A), Hartree/Bohr

pressure

eV/Angstrom^3 (eV/A^3)

momentum

u*A/fs, u*A/ps, (eV*u)^(1/2), kg*m/s, hbar/Bohr

mass

u (Dalton), kg (kilogram), g (gram), electron_mass (m_e)

velocity

nm/fs, A/fs, m/s, nm/ps, Bohr*Hartree/hbar

charge

e, Coulomb (C)