FMR simulations using sinc in time

49 views
Skip to first unread message

Mateusz Zelent

unread,
Jul 24, 2024, 6:26:28 PM7/24/24
to Boris Computational Spintronics
Hi Serban,

can you help me to verify my simulations. I would like to calculate dipolar coupled bilayers at low external magnetic field. Can you please check my simulation code to get the correct answer? It seems to me that I am still doing something wrong because the magnetization dynamics is still close to zero. 


from NetSocks import NSClient, Shape

ns = NSClient(); ns.configure(True)

l,w,t = [3000e-9,3000e-9,20e-9]
YIGL = ns.Ferromagnet([3000e-9, 3000e-9, 50e-9], [5e-9, 5e-9, 10e-9],meshname="YIGL")
YIGL.modules(['Zeeman', 'exchange','demag'])
YIGL.pbc('x', 8)
YIGL.pbc('y', 8)

disc_xsize = 1000e-9
disc_ysize = 1000e-9

dims = [(l/2)-(disc_xsize/2), (w/2)-(disc_ysize/2), 60e-9, (l/2)+(disc_xsize/2), (w/2)+(disc_ysize/2), 80e-9]

dims = [0,0, 60e-9, l,w, 80e-9]
print(dims)

DISC = ns.Ferromagnet(dims, [5e-9, 5e-9, 10e-9],meshname="DISC")
ns.delrect(meshname="DISC")
DISC.modules(['Zeeman', 'exchange','demag'])
DISC.pbc('x', 8)
DISC.pbc('y', 8)
ns.shape_disk("DISC", 600e-9,600e-9,l/2,w/2,0,20e-9)  

ns.addmodule('supermesh', 'sdemag')
ns.pbc('supermesh', 'x', 8)
ns.pbc('supermesh', 'y', 8)
ns.multiconvolution(1)

gamma = 2.212761569e5

MsDISC = DISC.param.Ms.setparam()
ADISC = DISC.param.A.setparam()

DISC.param.Ms=810e3
DISC.param.A=20e-12
DISC.param.D=0
# DISC.param.grel = gamma / 2.212761569e5
DISC.param.damping = 0.0001

YIGL.param.Ms=139e3
YIGL.param.D=0
YIGL.param.A=4e-12
# YIGL.param.grel = gamma / 2.212761569e5
YIGL.param.damping = 0.0001


YIGL.setangle([89.001, 0.01])
DISC.setangle([89.001, 0.01])

ns.cuda(1)

## RELAXATION
YIGL.setangle([89.001, 0.01])
DISC.setangle([89.001, 0.01])

ns.cuda(1)
ns.displaydetail(50e-9)
ns.vecrep(DISC, 4)
   
B0 = 0.005 #Tesla
H0 = 795775*B0

azymuth = 180.0001
polar = 271

YIGL.setangle([polar, azymuth])
DISC.setangle([polar, azymuth])

ns.setfield("YIGL",H0, azimuthal=azymuth, polar=polar)
ns.setfield("DISC",H0, azimuthal=azymuth, polar=polar)
ns.setfield("supermesh",H0, azimuthal=azymuth, polar=polar)



ns.setode('LLGStatic', 'SDesc')
ns.Relax(['mxh', 5e-14])
 

### DYNAMICS
import numpy as np
f_cut = 15e9  # Maximum cutoff frequency (Hz)
df = 0.1e9  # Frequency resolution (Hz)

# Calculate sampling time step
t_sampl = 0.5 / (f_cut * 1.25)  # Sampling time step (s)

# Calculate the total number of samples needed to achieve the desired frequency resolution
n_of_samples = int(np.ceil(1 / (df * t_sampl)))

# Total time to simulate; increasing this gives you more frequency points in the transform
total_time = 4e-9

# Frequency array for the FFT
freq = np.fft.fftfreq(n_of_samples, t_sampl)

# Debug information
print(f"Sampling time step (t_sampl): {t_sampl:.2e} s")
print(f"Number of samples (n_of_samples): {n_of_samples}")
print(f"Total simulation time (total_time): {total_time:.2e} s")
print(f"Maximum frequency (freq.max()): {freq.max()/1e9:.2f} GHz")
print(f"Frequency resolution (freq[1]): {freq[1]/1e9:.2f} GHz")

# Simulation parameters for the LLG solver
ns.setode('LLG', 'RK4')
dt=2e-13
ns.setdt(dt)

print(250e-15, t_sampl)
# Field and excitation field strength


ns.setdata('commbuf')

ns.iterupdate(100)


ns.setstage('Hequation',"supermesh")

# Set stage stop and data save intervals
ns.editstagestop(0, 'time', total_time)
ns.editdatasave(0, 'time', t_sampl)

# Define the equation constants
# Excitation field (A/m)



# Define excitation field as a sinc function
phi = 0.00001 * np.pi / 180
theta = 89.99999 * np.pi / 180

B0=0.005 #Tesla
H0 = 795775*B0
He = H0 * 0.01
ns.equationconstants('H0', H0)
ns.equationconstants('theta', theta)
ns.equationconstants('phi', phi)
ns.equationconstants('t0', 2e-9)
ns.equationconstants('He', He)
ns.equationconstants('fc', f_cut)
ns.editstagevalue(0,'H0*sin(theta)*cos(phi), H0*sin(theta)*sin(phi), H0*cos(theta))+ He*sinc(2*PI*fc*(t-t0)')



ns.editstagestop(0, 'time', total_time)
ns.editdatasave(0, 'time', t_sampl)
# print(int(t_sampl/dt))

# ns.editdatasave(0, 'iter', int(t_sampl/dt))
import os
path = 'R:/Boris/v5DP_2e14_0005T/'
try:
    os.makedirs(path)
except OSError as error:
    print(error)    
ns.saveovf2mag(f'{path}fmr_%time%.ovf', bufferCommand = True)

ns.cuda(1)
ns.reset()
ns.Run()

Mateusz Zelent

unread,
Jul 26, 2024, 4:36:00 AM7/26/24
to Boris Computational Spintronics
Hi,

I think I've managed to achieve satisfactory results, but could you check if I'm making any significant mistakes, particularly with the supermesh?

Notebook attached.  
Boris_fmr_multilayerconvolution_example.ipynb

Serban Lepadatu

unread,
Aug 5, 2024, 5:39:00 AM8/5/24
to Boris Computational Spintronics
Hi,

Looks like there's a mistake in this line (brackets in equation not right).

ns.editstagevalue(0,'H0*sin(theta)*cos(phi), H0*sin(theta)*sin(phi), H0*cos(theta))+ He*sinc(2*PI*fc*(t-t0)')

I would change to:

ns.editstagevalue(0,'H0*sin(theta)*cos(phi), H0*sin(theta)*sin(phi), H0*cos(theta)+ He*sinc(2*PI*fc*(t-t0))')

Also setfield command doesn't take "supermesh" as a parameter. If you want to apply the same field to all meshes simply don't specify the mesh name.

Regards,
Serban
Reply all
Reply to author
Forward
0 new messages