ubermag / help

Repository for raising issues and requesting help on Ubermag
BSD 2-Clause "Simplified" License
11 stars 3 forks source link

Time-dependent Zeeman term and STT: urgent #240

Closed vinodnaikb closed 1 year ago

vinodnaikb commented 1 year ago

Good afternoon,

I'm trying to simulate Spin-Transfer Torque(slonczewski) with a time-dependent zeeman term. But the simulation is never completing. I tried the same in MuMax3, it is completing in just 30-45 seconds. But here I don't know whats te issue?

import discretisedfield as df import micromagneticmodel as mm import oommfc as oc

import math import numpy as np

Geometry

lx = 50e-9 # x dimension of the sample(m) ly = 100e-9 # y dimension of the sample (m) lz = 2e-9 # sample thickness (m)

V_FM=lxlylz #volume of the FM layer

Material (permalloy) parameters

Ms = 1e6 # saturation magnetisation (A/m) A = 20e-12 # exchange energy constant (J/m)

uniaxial anisotropy

K = 1e5 # uniaxial anisotropy constant (J/m**3) u = (0, 1, 0) # uniaxial anisotropy axis

Dynamics (LLG equation) parameters

gamma0 = 2.211e5 # gyromagnetic ratio (m/As) alpha=0.02

mesh = df.Mesh(p1=(0, 0, 0), p2=(lx, ly, lz), cell=(5e-9,5e-9,2e-9)) system = mm.System(name='constJT') system.m = df.Field(mesh, dim=3, value=(0.0141,-0.9999,0), norm=Ms)

mp=(0,1,0) J=7e10 P=2 Lambda=1 eps_prime=1

def decay(t): t_0 = 1e-10 return np.exp(-t / t_0)

system.energy =mm.Zeeman(H=(0, 0, 1e6), func=decay, dt=1e-13) system.energy +=mm.Exchange(A=A)+mm.Demag() system.energy

system.dynamics =mm.Precession(gamma0=gamma0)+mm.Damping(alpha=alpha) system.dynamics += mm.Slonczewski(J=J, mp=mp, P=P, Lambda=Lambda, eps_prime=eps_prime) system.dynamics

t =1e-09 # simulation time (s) n =100 # number of data saving steps

td = oc.TimeDriver() td.drive(system, t=t, n=n) # drive the system myplot = system.table.data.plot('t', ['mx','my','mz'])

The simulation is taking hours and hours and still not completing. when I omit the STT term in the dynamics, then it is working fine. please address the issue.

fangohr commented 1 year ago

Can you provide some more details, please. What Operating System are you on, which version of ubermag did you install in which way?

You say the simulation runs without the STT term - how long does that take?

When you switch on the STT term, are any data points being saved (and this is just slow) or are no files being saved?

If the runs take too long, you can choose a smaller system to reproduce the system.

When you run the same simulation with STT in Mumax3, do you do this via ubermag, or you use ubermag directly?

Do the examples provided at https://ubermag.github.io/api/_autosummary/micromagneticmodel.Slonczewski.html execute and terminate correctly?

vinodnaikb commented 1 year ago
  1. Windows 11, AMD Ryzen 9 5900HX, NVIDIA GeForce RTX 3050 GPU GDDR6 (4GB)
  2. ubermag through Conda
  3. Code
import discretisedfield as df
import micromagneticmodel as mm
import oommfc as oc

import math
import numpy as np

# Geometry
lx = 50e-9  # x dimension of the sample(m)
ly = 100e-9  # y dimension of the sample (m)
lz = 2e-9  # sample thickness (m)

V_FM=lx*ly*lz #volume of the FM layer

# Material  parameters
Ms = 1e6 # saturation magnetisation (A/m)
A = 20e-12  # exchange energy constant (J/m)

# Dynamics (LLG equation) parameters
gamma0 = 2.211e5  # gyromagnetic ratio (m/As)
alpha=0.02

mesh = df.Mesh(p1=(0, 0, 0), p2=(lx, ly, lz), cell=(5e-9,5e-9,2e-9))

system = mm.System(name='constJT')
system.m = df.Field(mesh, dim=3, value=(0.0141,-0.9999,0), norm=Ms)

mp=(0,1,0)
J=7e10
P=2 
Lambda=1
eps_prime=1

def decay(t):
    t_0 = 1e-10
    return np.exp(-t / t_0)

system.energy =mm.Zeeman(H=(0,0,1e6), func=decay, dt=1e-13)
system.energy +=mm.Exchange(A=A)+mm.Demag()

system.dynamics =mm.Precession(gamma0=gamma0)+mm.Damping(alpha=alpha)
system.dynamics += mm.Slonczewski(J=J, mp=mp, P=P, Lambda=Lambda, eps_prime=eps_prime)

t =1e-09  # simulation time (s)
n =100  # number of data-saving steps

td = oc.TimeDriver()
td.drive(system, t=t, n=n)  # drive the system
myplot = system.table.data.plot('t', ['mx','my','mz']) 
  1. when I executed the above code with STT and without the Zeeman term, it executed in 8 seconds.
  2. when executed with Zeeman term without the STT, it executed in approximately 35 seconds.
  3. when executed with both Zeeman and the STT term, at the start of the simulation five files are created : .mif, .odt, .omf(time driver and m0) and .json and nothing happens there after.
  4. I have run a similar simulation in Mumax3 directly, not through ubermag.
vinodnaikb commented 1 year ago

when using time and space dependent zeeman term along with a STT term, do we need to choose an evolver?

vinodnaikb commented 1 year ago

If i used RungeKutta evolver then it is getting executed.

vinodnaikb commented 1 year ago

when i am giving a zeeman field which has all the three components and are time dependent, then the simulation is not happening. Its just stuck.

lang-m commented 1 year ago

We are not sure, why this is not working with OOMMF an the time-dependence specified in Python. As a work-around you can add custom tcl to specify the time-dependence as follows:

tcl_strings = {}
tcl_strings['script'] = '''proc TimeFunction { total_time } {
  set t0 1e-10
  set f [expr {exp(-$total_time * $t0)}]
  set fprime [expr {-1 / $t0 * $f}]
  return [list 0 0 $f 0 0 $fprime]
}'''
tcl_strings['energy'] = 'Oxs_ScriptUZeeman'
tcl_strings['script_args'] = 'total_time'
tcl_strings['script_name'] = 'TimeFunction'

system.energy =mm.Zeeman(H=(0,0,1e6), tcl_strings=tcl_strings)

Please verify the results obtained with the code above and compare to the Mumax results.