Simulation Results Differ Significantly After Code Adjustments.

20 views
Skip to first unread message

Qwenthur

unread,
Aug 24, 2025, 7:17:55 AMAug 24
to mumax2

Hi all,

 I made some adjustments to an existing simulation, but the results became very strange afterward. To troubleshoot, I removed all the newly added elements from the modified simulation, reverting it to match the original setup. However, the results still appear abnormal.

While the two codes are syntactically different, they should logically perform the same task. Why do their simulation results differ so drastically?

 

code1

//

SetGridSize(200, 100, 2)

SetCellSize(2e-9, 2e-9, 2e-9)

 

wire := cuboid(6e-9, 200e-9, 2e-9).transl(0, 0, 1e-9)

bottom_layer := cuboid(400e-9, 200e-9, 2e-9).transl(0, 0, -1e-9)

setgeom(wire.add(bottom_layer))

 

defregion(1, wire)

defregion(2, bottom_layer)

 

Msat.setregion(1, 580e3)  

Aex.setregion(1, 15e-12)

alpha.setregion(1, 0.01)  

m.setregion(1, uniform(0, -1, 0))

 

Msat.setregion(2, 140e3)  

Aex.setregion(2, 3e-12)

Ku1.setregion(2, 1e4)

AnisU.setregion(2, vector(0, 1, 0))

alpha.setregion(2,1e-4)

m.setregion(2, uniform(0, 1, 0))

 

ext_interexchange(1,2,0)

 

minimize()

 

autosave(m, 2e-12)

tableautosave(2e-12)

 

f := 25.6e9

B0 := 2e-3

B_ext.setregion(1, vector(B0*sin(2*pi*f*t), 0, 0))

 

run(400e-12)

//

 

code2

//

SetGridSize(200, 100, 2)

SetCellSize(2e-9, 2e-9, 2e-9)

 

wire := cuboid(4e-9, 200e-9, 2e-9).transl(0, 0, 1e-9)

bottom_layer := cuboid(400e-9, 200e-9, 2e-9).transl(0, 0, -1e-9)

setgeom(wire.add(bottom_layer))

 

defregion(201, wire)

 

Msat.setregion(201, 580e3)  

Aex.setregion(201, 15e-12)

alpha.setregion(201, 0.01)  

m.setregion(201, uniform(0, -1, 0))

 

for i := 1;i<201;i++{

    defregion(i, xrange(-200e-9+(i-1)*2e-9, -200e9+i*2e-9).intersect(zrange(0, inf).rotx(pi)))

    

    Msat.setregion(i, 140e3)

    Aex.setregion(i, 3e-12)

    Ku1.setregion(i, 1e4)

    AnisU.setregion(i, vector(0, 1, 0))

    alpha.setregion(i,1e-4)

    m.setregion(i, uniform(0, 1, 0))

}

 

ext_interexchange(201 , 100, 0)

ext_interexchange(201 , 101, 0)  

 

minimize()

 

autosave(m, 2e-12)

tableautosave(2e-12)

 

f := 25.6e9

B0 := 2e-3

B_ext.setregion(0, vector(B0*sin(2*pi*f*t), 0, 0))

 

run(400e-12)

//

 

Additionally, when I set the "wire" region to 0 versus 201, the outcomes are completely different. Why does this happen? Is region 0 a special label that cannot be overwritten or occupied?

 

I’d be very grateful for any thoughts or suggestions you might have.

 

Best regards,

Qwenthur

Josh Lauzier

unread,
Aug 24, 2025, 4:45:04 PMAug 24
to mumax2
Hi,

There is a typo. In your altered script, "defregion(i, xrange(-200e-9+(i-1)*2e-9, -200e9+i*2e-9).intersect(zrange(0, inf).rotx(pi)))" is not actually setting the regions. All of your regions are in the default region (which is 0). If you view your script in the gui, it will be very visible. This seems to be because of a typo, it should be:

defregion(i, xrange(-200e-9+(i-1)*2e-9, -200e-9+i*2e-9).intersect(zrange(0, inf).rotx(pi)))


You were missing a - in the -200e-9, which meant the xrange was always never valid for any cells. It's always a good idea to check your geometry and regions in the gui before looking at the results, it can catch a lot of errors that would be hard to notice otherwise.

region 0 is a little special, because it is the region that all cells are initialized to by default. It can be changed, used, etc, like a normal region otherwise, though. You just need to be very careful that you did not miss setting a region.

Best,
Josh L.

Qwenthur

unread,
Aug 25, 2025, 5:32:29 AMAug 25
to mumax2

Thank you for your reply.  I made such a simple mistake. I will make sure to check the GUI carefully next time. Thank you! ❤️
Reply all
Reply to author
Forward
0 new messages