I am new to this thread. I am trying to do a simple exercise on solving the LLG equation. The equation reads:
$\frac{d\vec{m}}{dt} = -\gamma(\vec{m} \times\vec{H})$.
Given a normalized input state ($m_x$, $m_y$, $m_z$) = (1,1,1) and $\vec{H} = 2\vec{z}$, the expected output should preserve $m_z$ while $m_x$ and $m_y$ should oscillate sinusoidally. The problem is that this code is not preserving the norm. If I force it to preserve norm after each iteration, then the $m_z$ drops.
Any help is much appreciated.
Attaching the code for convenience:
# solving LLG without damping
%pylab inline
gamma = 2.87e10;
tnodes = 100; tmax = 200e-12;
tstep = float(tmax)/tnodes;
trange = linspace(0, tmax, tnodes);
m = zeros((3, 100));
def update_m(tstep, minit, Heff):
mfinal = minit - tstep * gamma * cross(minit, Heff);
#mfinal = normalize_m(mfinal)
return mfinal;
def normalize_m(m):
return m/norm(m);
m_0 = (1,1,1);
Heff = (0, 0, 2);
m[:,0] = normalize_m(m_0);
for i in arange(1, len(trange)):
m[:, i] = update_m(tstep, m[:, i-1], Heff);
mx = m[0, :]; my = m[1, :]; mz = m[2, :];
plot(trange/1e-12, mx);
plot(trange/1e-12, my);
plot(trange/1e-12, mz);