/*
	Test different energy contributions,
	reference solutions from OOMMF (energy.mif).
*/

l := 512e-9
w := 256e-9
d := 40e-9
c := 4e-9
vol := l * w * d * (pi/4)

setcellsize(c, c, d)
setgridsize(128, 64, 1)
setgeom(ellipse(l, w))

Msat  = 860E3
Aex   = 13E-12
Ku1   = 50
alpha = 3
anisU = vector(1,0,0)

m = vortex(1, 1) 
relax()

E1_tot := E_total.get()
E1_exc := E_exch.get()
E1_ani := E_anis.get()
E1_dem := E_demag.get()
E1_zee := E_zeeman.get()


B_ext = vector(100e-3, 0, 0)
relax()

E2_tot := E_total.get()
E2_exc := E_exch.get()
E2_ani := E_anis.get()
E2_dem := E_demag.get()
E2_zee := E_zeeman.get()


// OOMMF energy density differences:
OOMMF_tot := (12274.249330 - (-56507.645615 ) ) * vol
OOMMF_exc := ( 5038.693945 - (    71.438905 ) ) * vol
OOMMF_ani := (   19.517039 - (     0.271210 ) ) * vol
OOMMF_dem := ( 7216.038345 - ( 29186.031229 ) ) * vol
OOMMF_zee := (    0        - (-85765.386961 ) ) * vol


tol := 1e-18

expect("E_anis"  , E1_ani - E2_ani, OOMMF_ani, 1e-21)
expect("E_zeeman", E1_zee - E2_zee, OOMMF_zee, tol)
expect("E_exch"  , E1_exc - E2_exc, OOMMF_exc, tol)
expect("E_demag" , E1_dem - E2_dem, OOMMF_dem, tol)
expect("E_total" , E1_tot - E2_tot, OOMMF_tot, tol)
