Configuring Physical Quantities via Array Inputs in Nanotube Simulations

21 views
Skip to first unread message

Qwenthur

unread,
Oct 21, 2025, 5:45:16 AMOct 21
to mumax2

Hi all,

Below is the code for setting up radial or azimuthal magnetization states in nanotubes. It allows for the configuration of complex magnetization states in Cartesian coordinates without requiring excessive region definitions.

If I want to excite a radial magnetic field of the form B0*cos(wt)cos(nφ), where n is an integer and φ is the azimuthal angle, or if I need to set up some complex anisu, can this also be achieved using a similar approach? On the API page, I only see commands like m.setarray, but not something like b_ext.setarray.

If this is not possible,when simulating double-layer or even multi-layer tubular antiferromagnetic or ferrimagnetic structures, 256 regions might be insufficient. Has anyone encountered this limitation and found a workaround?


Best regards,

Qwenthur

//

mask := newslice(3, od, od, tz)  

angle := 0.0  

for i := 0; i < tz; i++ {

 for j := 0; j < od; j++ {

  for k := 0; k < od; k++ {

   r := index2coord(j, k, i)  

   x := r.x()

   y := r.y()

   z := r.z()

   

   if x == 0 && y > 0 {

    angle = pi / 2

   } else if x == 0 && y <= 0 {

    angle = -pi / 2

   } else if x > 0 {

    angle = atan(y / x)

   } else {

    angle = pi - atan(-y/x)

   }

   mx := cos(angle)

   my := sin(angle)

   mz := 0

   mask.set(0, j, k, i, mx)

   mask.set(1, j, k, i, my)

   mask.set(2, j, k, i, mz)

   

  }

 }

}

m.setarray(mask)  

//

 

Josh Lauzier

unread,
Oct 21, 2025, 5:57:10 PMOct 21
to mumax2
Hi,

Look to the B_ext.add() method. There is an example on the examples page under the spinning hard disk example. The method is essentially the same as what you're doing here. For excitations like B_ext, you can also load a fully custom OVF using the loadfile command (m can also be done via loadfile).

For actual material parameters like anisu, you will be limited to 256 regions, you cannot do something arbitrarily complex. Your options there would be to find a way to cleverly reuse regions, edit the source code to increase the number of regions, or look to mumax+ which does not have region restrictions for material parameters.

Best,
Josh L.

Qwenthur

unread,
Oct 22, 2025, 8:01:33 AM (14 days ago) Oct 22
to mumax2

Thank you so much for the clear explanation and helpful suggestions!  I'll try those methods you mentioned.
Reply all
Reply to author
Forward
0 new messages