Derivatives of spin dynamics simulations.

Derivatives of spin dynamics simulations.