Calculators

using rascaline_torch::TorchCalculator = torch::intrusive_ptr<CalculatorHolder>
class CalculatorHolder : public torch::CustomClassHolder

Custom class holder to store, serialize and load rascaline calculators inside Torch(Script) modules.

Public Functions

inline CalculatorHolder(std::string name, std::string parameters)

Create a new calculator with the given name and JSON parameters

inline std::string name() const

Get the name of this calculator.

inline std::string c_name() const

Get the name used to register this calculator.

inline std::string parameters() const

Get the parameters of this calculator.

inline std::vector<double> cutoffs() const

Get all radial cutoffs used by this Calculator’s neighbors lists.

metatensor_torch::TorchTensorMap compute(std::vector<metatensor_torch::System> systems, TorchCalculatorOptions options = {})

Run a calculation for the given systems using the given options.

metatensor_torch::TorchTensorMap rascaline_torch::register_autograd(std::vector<metatensor_torch::System> systems, metatensor_torch::TorchTensorMap precomputed, std::vector<std::string> forward_gradients)

Register autograd nodes between system.positions and system.cell for each of the systems and the values in the precomputed TensorMap.

This is an advanced function must users should not need to use.

The autograd nodes backward() function will use the gradients already stored in precomputed, meaning that if any of the system’s positions requires_grad, precomputed must contain "positions" gradients. Similarly, if any of the system’s cell requires_grad, precomputed must contain "cell" gradients.

forward_gradients controls which gradients are left inside the TensorMap.