Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mif += ' m0 :m0\n'
for attr, value in driver:
if attr != 'evolver':
mif += f' {attr} {value}\n'
mif += '}\n\n'
# Saving results.
mif += 'Destination table mmArchive\n'
mif += 'Destination mags mmArchive\n\n'
mif += 'Schedule DataTable table Stage 1\n'
mif += 'Schedule Oxs_MinDriver::Magnetization mags Stage 1'
if isinstance(driver, oc.TimeDriver):
# Check evolver and set default if not passed.
if not hasattr(driver, 'evolver'):
if mm.ZhangLi() in system.dynamics:
driver.evolver = oc.SpinTEvolver()
elif mm.Slonczewski() in system.dynamics:
driver.evolver = oc.SpinXferEvolver()
else:
driver.evolver = oc.RungeKuttaEvolver()
elif not isinstance(driver.evolver, (oc.EulerEvolver,
oc.RungeKuttaEvolver,
oc.SpinTEvolver,
oc.SpinXferEvolver)):
msg = f'Cannot use {type(driver.evolver)} for evolver.'
raise TypeError(msg)
# Extract dynamics equation parameters.
if mm.Precession() in system.dynamics:
driver.evolver.gamma_G = system.dynamics.precession.gamma0
else:
import micromagneticmodel as mm
class ZhangLi(mm.ZhangLi):
"""Zhang-Li spin-transfer torque dynamics term.
This dynamics term models the Zhang-Li spin-transfer-torque term
in the Landau-Lifshitz-Gilbert equation. It is defined by the
velocity in the x-direction `u` and the non-adiabatic constant
`beta`.
.. math::
\\frac{\\text{d}\\mathbf{m}}{\\text{d}t} = -(\\mathbf{u}
\\cdot \\boldsymbol\\nabla)\\mathbf{m} + \\beta\\mathbf{m}
\\times \\big[(\\mathbf{u} \\cdot
\\boldsymbol\\nabla)\\mathbf{m}\\big]
`u` can be either contant in space or spatially varying, whereas
`beta` can be only constant in space. If `u` is constant, a single