Hi,
You can achieve this using the Masked() command. There isn't a direct regions method, but Masked takes a Quantity and a Shape, so you will need to create a Shape that matches your regions. For example, here is a slightly modified example, following the '
Custom effective field terms' API example, but with a different anisotropy vector in each region:
cs := 1e-9
setcellsize(cs,cs,cs)
setgridsize(64,64,2)
firstshape := layer(0)
secondshape := layer(1)
defregion(0, firstshape
)
defregion(1, secondshape
)
Ms := 1100e3
K := 0.5e6
u1 := ConstVector(1, 0, 0)
anisField1 := Mul( Const(2*K/Ms) , Mul( Dot(u1, m), u1))
anisEdens1:= Mul( Const(-0.5*Ms) , Dot( anisField1, m))
anisFieldmasked1 := Masked(anisField1, firstshape
)
anisEdensmasked1 := Masked(anisEdens1, firstshape
)
u2 := ConstVector(-1, 0, 0)
anisField2 := Mul( Const(2*K/Ms) , Mul( Dot(u2, m), u2))
anisEdens2:= Mul( Const(-0.5*Ms) , Dot( anisField2, m))
anisFieldmasked2 := Masked(anisField2, secondshape
)
anisEdensmasked2 := Masked(anisEdens2, secondshape
)
AddFieldTerm(anisField1)
AddEdensTerm(anisEdens1)
AddFieldTerm(anisField2)
AddEdensTerm(anisEdens2)
Best,
Josh L.