Rotating multi-part geometry from z to x - MuMax3

29 views
Skip to first unread message

Pravan Chakravarthy

unread,
Jul 4, 2026, 1:14:25 PMJul 4
to mumax2
Hi there,

Hope you're doing well. I have the following geometry in MuMax3, composed of a combination of twisted and straight ellipses:

// --- Section 1: first straight (no twist yet, angle = 0) ---
shape1 := layer(0).intersect(ellipse(r1, r2))
for i := 1; i < N_straight; i++ {
    shape1 = shape1.add(layer(i).intersect(ellipse(r1, r2)))
}

// --- Section 2: positive twist ---
for i := 0; i < N_twist; i++ {
    angle := twist * i / (N_twist - 1)
    shape1 = shape1.add(layer(i + N_straight).intersect(ellipse(r1, r2).rotz(angle)))
}

// --- Section 3: second straight (holds at final twist angle) ---
for i := N_straight + N_twist; i < 2*N_straight+N_twist; i++ {
    shape1 = shape1.add(layer(i).intersect(ellipse(r1, r2).rotz(twist)))
}

// --- Section 4: negative twist (back down from `twist` to 0) ---
for i := 0; i < N_twist; i++ {
    angle := -twist * i / (N_twist - 1)
    shape1 = shape1.add(layer(i + (2*N_straight + N_twist)).intersect(ellipse(r1, r2).rotz(angle)))
}

// --- Section 5: third straight (back to angle = 0) ---
for i := 2*N_straight + 2*N_twist; i < 3*N_straight+2*N_twist; i++ {
    shape1 = shape1.add(layer(i).intersect(ellipse(r1, r2)))
}

setgeom(shape1)

In order to remove surface charges, I need to rotate the whole shape so it lies on the x-axis instead of the z-axis. I have tried adding `roty(pi/2)` within each `shape1.add()` call, applying `roty(pi/2)` once at the end, and replacing `layer` with `xrange`. However, in all of these cases, the geometry either fails to realize entirely or only produces one of the straight sections.

Would you be able to suggest fixes to the above code to allow the structure to rotate properly, or alternatively, would you be able to modify the `ext_rmSurfaceCharge` function so that I can use it along z without having to rotate the structure?

Thanks for your help!
Pravan Chakravarthy

Josh Lauzier

unread,
Jul 6, 2026, 12:05:44 AMJul 6
to mumax2
Hi,

Can you post the full script? It makes it easier to troubleshoot.

roty(pi/2) is indeed the command you want, so probably there is just some slight typo or unexpected interaction (the order you apply transformations can matter). I would just apply it once at the end, not in the loop. My guess is that your rotation is being applied before the intersection applies or something.

However, you can also just form the chain on the x-axis directly. Instead of ellipse which is 2D, you can just use ellipsoid intersected with xrange. Something like:

SetGridsize(100, 100, 50)
SetCellsize(1e-6/100, 1e-6/100, 1e-6/50)

r1:=200e-9
r2:=500e-9
r3:=150e-9

shape1:=ellipsoid(r1, r2, r3).intersect(xrange(0,100e-9))
shapebase:=ellipsoid(r1, r2, r3).intersect(xrange(0,100e-9))

for i := 0; i < 10; i++ {
theta := i * pi / 10
shape1 = shape1.add(shapebase.rotx(i*pi/10).transl(i*150e-9,0,0))
m.SetInShape(shapebase.rotx(i*pi/10).transl(i*150e-9,0,0),uniform(0, cos(theta), sin(theta)))
}

setgeom(shape1)
save(m)

Of course you can adjust r1,r2,r3, and the intersect range etc accordingly. This might be a bit easier, but either way should ultimately be equivalent.

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