Py switching (NIST problem 4)

39 views
Skip to first unread message

Денис Кричевский

unread,
Aug 27, 2024, 10:11:12 AM8/27/24
to Boris Computational Spintronics
Hello Serban!

Thank you for your software. I found it very user-friedly.
I am beginer in micromagnetic simulations and currently struggling with typical NIST problems. I stuck on NIST problem 4 (which is exercise 2 in the BORIS manual). The results I got for M vs time differ significanlty from the ones presented in the manual and NIST website. Could you please check my script and give a hint of what I am doing wrong? Thank you in advance.

#script for NiFe (permaloy) switching

import matplotlib.pyplot as plt
import math as mth
import numpy as np
from NetSocks import NSClient
ns = NSClient(); ns.configure(True)

#Make a ferromagnetic mesh with given rectangle, cubic cellsize, and set modules
Py = ns.Ferromagnet([500e-9, 125e-9, 3e-9], [3e-9])
Py.modules(['demag','exchange', 'Zeeman'])
ns.fmscellsize([3e-9, 3e-9, 3e-9])
#setting material parameters
ns.setparam(meshname='Py', paramname='K1', value=0)
ns.setparam(meshname='Py', paramname='A', value=13e-12)
ns.setparam(meshname='Py', paramname='Ms', value=800e3)
ns.setparam(meshname='Py', paramname='damping', value=1e-2)

#setting initial configuration of magnetization
ns.setangle(meshname='Py', polar='55', azimuthal='45')

#setting ODE configuration
ns.setode(equation='LLGStatic',evaluation='SDesc')
ns.setdt(1e-12)

#ground state calculation
ns.Hpolar_seq([Py, [1e6, 55, 45, 0, 55, 45, 20], 'mxh', 1e-5, 'none'])

ns.saveovf2mag('Py', filename = 'ground_state_Py_NP_500_125_3nm_(111).ovf')
ns.reset()

H_value = 25e-3 * 0.8e6 #from T to A/m
H_value_y = H_value*np.sin(170*mth.pi/180)
H_value_x = H_value*np.cos(170*mth.pi/180)
H_value_z = H_value*np.sin(5*mth.pi/180)

ns.setode(equation='LLGStatic',evaluation='RKF45')
ns.setdt(5e-12)

ns.setsavedata('switching_dynamics_Py_NP.txt', ['time'], ['<M>'])

ns.Hxyz([Py, [H_value_x, H_value_y, 0], 'time', 1e-12, 'none'])
ns.reset()
ns.Relax(['time', 5e-9,  'time', 5e-12])

#output file has field (x, y, z components) in columns 0, 1, 2, and average magnetisation (x, y, z components) in columns 3, 4, 5
switching_data = ns.Get_Data_Columns('switching_dynamics_Py_NP.txt', [0, 1, 2, 3])
#plot time vs <Mxyz>
plt.axes(xlabel = 'Time (ns)', ylabel = '<M> (kA/m)')
plt.plot(np.array(switching_data[0])*1e9, np.array(switching_data[1])/800e3, label='Mx')
plt.plot(np.array(switching_data[0])*1e9, np.array(switching_data[2])/800e3, label='My')
plt.plot(np.array(switching_data[0])*1e9, np.array(switching_data[3])/800e3, label='Mz')
plt.legend()
plt.show()




Serban Lepadatu

unread,
Aug 28, 2024, 2:52:20 AM8/28/24
to Boris Computational Spintronics
Hi,

There are a few problems:

1) When you solve for dynamics, instead of setting LLGStatic equation (which has no precessional term), you should set the LLG equation
2) The damping value should be 0.02 not 0.01
3) I would use a more precise conversion from T to A/m, i.e. multiply by 1e7/(4*np.pi) instead of 0.8e6.

The cellsize you set is fine, but I would set it to [5e-9, 5e-9, 3e-9] instead as this integer-divides all dimensions. Also you don't need to set an initial timestep for RKF45 as it's an adaptive timestep method.

Regards,
Serban

Denis Krichevsky

unread,
Aug 28, 2024, 3:18:58 AM8/28/24
to Boris Computational Spintronics
Thank you for your help! What dumb mistakes.

Denis

среда, 28 августа 2024 г. в 09:52:20 UTC+3, Serban Lepadatu:
Reply all
Reply to author
Forward
0 new messages