ubermag / help

Repository for raising issues and requesting help on Ubermag
BSD 2-Clause "Simplified" License
11 stars 3 forks source link

External field #274

Closed SeregaKR closed 8 months ago

SeregaKR commented 8 months ago

Good afternoon. I'm trying to add the external field to my calculation. The procedure I want to implement is as follows:

  1. Turn on the external field of 1T
  2. Do minimize and relax runs
  3. Turn the field off
  4. repeat step 2

So, as far as I understand from the Docs, I need to set up the mm.Zeeman(H=H0) -> where H0 is my field. I wrote the code as follows, but it doesn't seem to work.

#setting the field and energy terms
field_angle = 15*math.pi/180
H0 = (1*math.cos(field_angle),1*math.sin(field_angle),5e-3)

system.energy = mm.Exchange(A=1.1e-11) + mm.DMI(D=0, crystalclass="T") + mm.Demag() + mm.Zeeman(H=H0) + mm.UniaxialAnisotropy(K=0, u=(0, 0, 1))

#minimize and relax
rd = mc.RelaxDriver()
md = mc.MinDriver()
rd.drive(system)
md.drive(system)

#Stop the field
system.energy.zeeman.H = (0,0,0)

#minimize and relax
rd.drive(system)
md.drive(system)

When I check the generated mx3 file for mumax3, I see no changes in B_ext as expected. The same procedure written specifically for mumax3 would be as below:

#setting the field and energy terms
fig_angle := 15*pi/180
B_ext=vector(1*cos(fig_angle),1*sin(fig_angle),5e-3)

#minimize and relax
minimize()
relax()

#Stop the field
B_ext=vector(0.0,0.0,0.0)

#minimize and relax
minimize()
relax()

Any idea what's going wrong? I'm using 2023.10 version.

samjrholt commented 8 months ago

Hi @SeregaKR,

In ubermag all values are given in SI units including the Zeeman field. So curently you are applying a 1 A/m external field rather than a 1 T external field. You can convert T to A/m my dividing by mu0.

H0 = np.array([1*math.cos(field_angle),1*math.sin(field_angle),5e-3]) / mm.consts.mu0

(We do this as technically Tesla is magnetic induction rather than magnetic field strength)

SeregaKR commented 8 months ago

Hello @samjrholt . Thank you for the reply. Everything seems to be working now.