Facing some problem. Please help ...

34 views
Skip to first unread message

Ankit Saha

unread,
Jun 20, 2026, 2:51:33 AMJun 20
to mumax2
  I am running a simulation at 77 K in which a 100 mT external magnetic field is applied for 100 ns. I want to study the system dynamics 10 ns after the field is applied and 10 ns after it is removed. However, the simulation has taken nearly 16 hours and has only progressed to 8.87 ns. Is my code correct? please help....

nx:= 384*2
ny:= 256
nz:= 64

SetGridSize(nx,ny,nz)
SetCellSize(1e-9,1e-9,1e-9)

Msat=0.8e6
Aex=10e-12
alpha=0.1

sep:=100e-9
major:=169.7e-9
minor:=84.85e-9
d:= sep/2 + major/2 //distance between the center of ellipse and center of simulation

ell:= ellipse(major,minor)
e1:=ell.transl(d,0,0)
e2:=ell.transl(-d,0,0)
geo:=(e1.Add(e2)).Intersect(layers(nz/2 -1,nz/2))
SetGeom(geo)

defRegion(1,e1)
defRegion(2,e2)

m.setRegion(1,randomMag())
relax()
m.setRegion(2,randomMag())
relax()
save(m)

autosave(m,1e-11)
autosave(B_demag,1e-11)

FixDt = 5e-14
Temp = 77
B_ext=Vector(0,0,100e-3)
run(100e-9)
B_ext=Vector(0,0,0)
run(20e-9)


Josh Lauzier

unread,
Jun 20, 2026, 5:16:59 AMJun 20
to mumax2
Hi,

A few things:

One, you do not need to use a FixDt to use temperature anymore, you can use adaptive timestepping instead. Just don't set a FixDt.

Two, your simulation is very large, but most of it is empty space. You will reduce the time considerably by shrinking the simulation box, if that is possible. If you absolutely must use a large box because you're trying to save B_demag, I recommend doing the simulation with a small box first, and save the magnetization. Then do a separate simulation where you load the magnetization into a full large box only at the points you actually need it, and save the B_demag from that. If you do actually need to keep the full simulation size as is, unfortunately the simulation is going to pretty slow, it's a large system size.

Third, doing 2 relax()'s will be rather slow, especially with no applied field. Is there a specific reason for doing it twice? This seems likely to be redundant.

Fourth, the exchange length in your system is ~5nm. You may be able to get away with a larger cell size. Based on the exchange length, ~2.5nm would work- however, this might lead to issues with a larger staircase effect at the edges of the ellipse, so you may have to stick with your current cellsize depending on how sensitive what you are studying is to the discretization at the edges of the ellipse. The edgesmooth setting may help with this. I would guess you probably want to stay at 1nm, but I will mention it for completeness.

Last, rather than doing 100e-9 ns of run, I would recommend doing 10ns (or however long you're interested in for the actual dynamics). Then relax/minimize to get to equilibrium, and then switch back to run for the dynamics for the 10ns after the field is off. (You will need to be a little careful with this, as the temperature will be disabled during the relax/minimize, so perhaps you do something like run(10e-9), relax, run(10e-9), turn off B_ext, then the final run(20e-9). But it is probably still worth doing with how much time it saves, that would still cut off ~80ns with no meaningful impact on the results)

Best,
Josh L.

Ankit Saha

unread,
Jun 20, 2026, 9:17:50 AM (14 days ago) Jun 20
to mumax2
Thank you for replying...
now is it fine?


nx:= 384*2
ny:= 256
nz:= 64

SetGridSize(nx,ny,nz)
SetCellSize(1e-9,1e-9,1e-9)

Msat=0.8e6
Aex=10e-12
alpha=0.1

sep:=100e-9
major:=169.7e-9
minor:=84.85e-9
d:= sep/2 + major/2 //distance between the center of ellipse and center of simulation

ell:= ellipse(major,minor)
e1:=ell.transl(d,0,0)
e2:=ell.transl(-d,0,0)
geo:=(e1.Add(e2)).Intersect(layers(nz/2 -1,nz/2))
SetGeom(geo)

defRegion(1,e1)
defRegion(2,e2)

m.setRegion(1,uniform(1,0,0))
m.setRegion(2,uniform(1,0,0))
relax()
save(m)

autosave(m,1e-11)
autosave(B_demag,1e-11)
tableautosave(1e-12)

Temp = 77
B_ext=Vector(0,0,100e-3)
run(10e-9)
relax()
B_ext=Vector(0,0,0)
run(10e-9)



Josh Lauzier

unread,
Jun 20, 2026, 8:35:53 PM (13 days ago) Jun 20
to mumax2
Hi,

That should work. You may want to do

B_ext=Vector(0,0,100e-3)
run(10e-9)
relax()
run(10e-9)
B_ext=Vector(0,0,0)
run(10e-9) 

so that the thermal field is not suddenly turned back on at the exact same time B_ext is set to 0,0,0. It probably does not matter, but to be safe.

Also, as mentioned in point 2, I would highly recommend reducing your simulation box, if possible. You can very easily reduce it to 
nx:= 512
ny:= 128
nz:= 4

and get a very large speed up, without changing any of the actual physics. If this isn't possible, it will likely still be a fairly long simulation.

Cheers,
Josh L.
Reply all
Reply to author
Forward
0 new messages