Out-of-plane Hysteresis loop in Mumax plus

207 views
Skip to first unread message

Seok In YOON

unread,
Jul 20, 2025, 3:24:51 PM7/20/25
to mumax2
Dear Mumax community members,

Hello, I am Seok In YOON.

I am now trying to use Mumax+ in the Google Colab Pro system to draw the hysteresis loop about the FM layer. 

Unfortunately, I am unable to draw the correct out-of-plane hysteresis loop.
Could you help me find where my code is wrong?
download.png
from mumaxplus import Ferromagnet, Grid, World
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# Simulation parameter
world = World(cellsize=(1e-9, 1e-9, 1e-9))
grid_size = (256, 64, 1)
fm = Ferromagnet(world, Grid(grid_size))

fm.msat = 750e3
fm.aex = 15e-12
fm.dind = 1e-3
fm.ku1 = 5e5
fm.alpha = 0.03
fm.anisU = (0, 0, 1)

# initial magnetization and direction
init_mag = np.zeros(fm.grid.size + (3,))
init_mag[:, :, :, 0] = 0.0
init_mag[:, :, :, 1] = 0.0
init_mag[:, :, :, 2] = 1.0
fm.magnetization.set(init_mag.transpose(3, 2, 1, 0))

fm.minimize()

# Field sweep simulation
B_max = 2  # T
B_step = 0.04  # T
field_sweep = np.concatenate([
    np.arange(0, B_max + B_step, B_step),
    np.arange(B_max, -B_max - B_step, -B_step),
    np.arange(-B_max, B_max + B_step, B_step)
])

loop_log = []
for B in field_sweep:
    fm.bias_magnetic_field.set((0, 0, B))  # 반드시 .set() 사용
    fm.minimize()
    m = np.mean(fm.magnetization.get(), axis=(1, 2, 3))
    loop_log.append([B, m[2]])

# convert the data
df = pd.DataFrame(loop_log, columns=["B_T", "mz"])

# draw the hysteresis loop
plt.figure(figsize=(10, 6))
plt.plot(df['B_T'], df['mz'], 'b.-', linewidth=2, markersize=4)
plt.xlabel('External Magnetic Field B (Tesla)', fontsize=12)
plt.ylabel('Normalized Magnetization mz', fontsize=12)
plt.title('Magnetic Hysteresis (M-H) Loop', fontsize=14)
plt.grid(True, alpha=0.3)
plt.axhline(y=0, color='k', linestyle='--', alpha=0.5)
plt.axvline(x=0, color='k', linestyle='--', alpha=0.5)
plt.show()


Josh Lauzier

unread,
Jul 20, 2025, 6:21:28 PM7/20/25
to mumax2
Hi,

I haven't had the chance to test out Mumax+ extensively yet, but my guess is that it is the same symmetry breaking issue previously reported in mumax3. You can fix it by applying a very small canting to the field, or adding some noise. For more details see these previous discussions.

Best,
Josh L.

Seok In YOON

unread,
Jul 21, 2025, 10:25:20 AM7/21/25
to mumax2
Thank you!

I was able to obtain the correct hysteresis loop!

Sincerely yours,
Seok In YOON

2025년 7월 21일 월요일 오전 7시 21분 28초 UTC+9에 Josh Lauzier님이 작성:
Reply all
Reply to author
Forward
0 new messages