ExternalMachineLearnedFFCalculator¶
- class ExternalMachineLearnedFFCalculator(ase_calculator_cls=None, *ase_calculator_args, **ase_calculator_kwargs)¶
Class for representing an ASE calculator.
- Parameters:
ase_calculator_cls (
ase.calculators.Calculator
|function()
| None) – An ASE calculator class constructor or a function that returns an ASE calculator which should be called. Default: None.ase_calculator_args (tuple) – The arguments that should be passed to the ASE calculator class constructor.
ase_calculator_kwargs (dict) – The keyword arguments that should be passed to the ASE calculator class constructor.
- dynamicalMatrixParameters()¶
This method is deprecated.
- Returns:
None always.
- Return type:
None
- metatext()¶
- Returns:
The metatext of the object or None if no metatext is present.
- Return type:
str | None
- setMetatext(metatext)¶
Set a given metatext string on the object.
- Parameters:
metatext (str | None) – The metatext string that should be set. A value of “None” can be given to remove the current metatext.
- uniqueString()¶
Return a unique string representing the state of the object.
- upgrade(configuration)¶
Method to upgrade the current calculator based on the given configuration.
- Parameters:
configuration (
AtomicConfiguration
sub-class) – The configuration the calculator will be used for.
Usage Examples¶
The ExternalMachineLearnedFFCalculator allows you to use an external machine-learned force field based on an ASE calculator in QuantumATK. The ASE calculator class constructor is passed as the first argument, and any additional arguments for the ASE calculator can be passed afterward.
Below is an example using the MatterSim pre-trained potential (requires MatterSim to be installed in a virtual environment).:
# Import external force field calculator
from mattersim.forcefield import MatterSimCalculator
# Create a ExternalMachineLearnedFFCalculator with the MatterSimCalculator
calculator = ExternalMachineLearnedFFCalculator(
MatterSimCalculator,
compute_stress=True,
device='cuda'
)
Alternatively, ExternalMachineLearnedFFCalculator can also be used as a wrapper.:
# Wrap the MatterSimCalculator with the ExternalMachineLearnedFFCalculator
WrappedMatterSimCalculator = ExternalMachineLearnedFFCalculator(MatterSimCalculator)
# Initialize the wrapped calculator with additional arguments
calculator = WrappedMatterSimCalculator(compute_stress=True, device='cuda')
Notes¶
External third-party ASE calculators can be used with the ExternalMachineLearnedFFCalculator. The external calculator must be installed in a virtual environment. It can then be imported and used by the ExternalMachineLearnedFFCalculator. Any additional arguments required by the external calculator can be passed to the wrapped calculator. The ExternalMachineLearnedFFCalculator will pass these arguments to the ASE calculator during initialization. The wrapped calculator can be used in QuantumATK as a regular calculator.