How to collect each magnetic moment component of each layer/Region

89 views
Skip to first unread message

Apukumar jana

unread,
Aug 19, 2025, 6:09:26 AMAug 19
to mumax2
Dear All,

I am doing a simulation of two layers/regions.
I want to use a term like: Crossproduct of mx of upper layer and my component of down layer.

I will be grateful if you please let me know how to save each magnetic component of each layer.

Thanks and regards
Apu

Josh Lauzier

unread,
Aug 26, 2025, 4:09:56 AMAug 26
to mumax2
Hi,

Based on your wording, I assume you want to use this for a custom field term, not just save them? If you just want to save them, you can do something like save( m.Comp(0).region(1) ).

For a custom field term using a crossproduct, you could do something like:


u1:=ConstVector(1,0,0)
u2:=ConstVector(0,1,0)

//term applied to upper layer
mx_upper_appliedtoupper:=   Mul(Dot(m,u1),u1)
my_lower_appliedtoupper:= Mul(Dot( Shifted(m,0,0,-1),shifted(u2,0,0,-1)),u2)
upperterm:= Cross(mx_upper_appliedtoupper ,my_lower_appliedtoupper)
uppertermMasked:=Masked(upperterm, layer(0))

//term applied to lower layer
mx_upper_appliedtolower:= Mul(Dot(Shifted(m,0,0,1),Shifted(u1,0,0,1)),u1)
my_lower_appliedtolower:= Mul(Dot(m,u2),u2) 
lowerterm:=  Cross(mx_upper_appliedtolower ,my_lower_appliedtolower)
lowertermMasked:= Masked(lowerterm,layer(1))

AddFieldTerm(uppertermMasked )
AddFieldTerm(lowertermMasked )

Best,
Josh L.

AKJ

unread,
Sep 22, 2025, 11:35:09 PMSep 22
to mumax2
Hi Josh L.

I am thankful for the method you provided. 

Beside, I followed bit different path to do the cross product of (m1, m2), where m1 is magnetization of layer 1 and m2 is magnetization of layer 2.
               
               First, I defined mij (i is the region number and j is x,y, or z) as m.comp(j).Region(i).average(). Then I collected the X, Y and Z component of the cross product by simple algebra. 
               Second, I used these components as magnetic field component with some scaling parameter : Bext = vector(Cross_X, Cross_Y, Cross_Z)


Thanks and regards
Apu Kumar Jana

Josh Lauzier

unread,
Oct 19, 2025, 2:08:12 AMOct 19
to mumax2
Hi,

Glad to hear! One word of warning i would give: When you define a user custom quantity such as with "mij:= m.comp(j).Region(i).average()", it may not update dynamically when you step forward in time as m changes, it will stay at the value that it was first defined. So I would recommend checking to make sure it is actually updating as expected. If that is working, it should be good to go; there are often many different ways to define an equivalent custom field term, so whichever way you find most convenient is fine.

Cheers,
Josh L.

AKJ

unread,
Oct 20, 2025, 11:50:58 PMOct 20
to mumax2
Hi,
Thank you for your suggestion. I checked the time time evolution of each component and noticed it's changes. I am attaching an image. Please let me know your comment.


Thanks and Regards
Apu Kumar Jana


Screenshot 2025-10-21 124935.png

Reply all
Reply to author
Forward
0 new messages