// NaN's when slonczewski parameters not OK
Nx := 64
Ny := 32
Nz := 1

sX := 160e-9
sY := 80e-9
sZ := 5e-9
 
setgridsize(Nx, Ny, Nz)
setcellsize(sX/Nx, sY/Ny, sZ/Nz)

Msat  = 800e3
Aex   = 13e-12
alpha = 1

maxdt    = 1e-12

// Set a initial magnetisation to C-state
m = uniform(1, 1, 0.001)

run(3e-9)

alpha        = 0.01
lambda       = 1
Pol          = 0.5669
epsilonprime = 0

pdeg := 1    
prad := pdeg * pi / 180.0
px := cos(prad)
py := sin(prad)
fixedlayer = vector(px, py, 0)

Jtot := -0.008  // total current in amps
carea := sX * sY
jc := Jtot / carea  
print("Current density is: " ,  jc)
 
J = vector(0, 0, jc)

//autosave(m, 1e-12)
tableautosave(10e-12)

save(sttorque)
m0 := m.average()
expect("mx", m0[0], 0.9586285, 1e-3)
expect("my", m0[1], 0.2039081, 1e-3)
expect("mz", m0[2], 0.0000000, 1e-3)

run(1e-9)
m1 := m.average()
expect("mx", m1[0], 0.6440672, 1e-3)
expect("my", m1[1], 0.5133638, 1e-3)
expect("mz", m1[2],-0.1571195, 1e-3)

run(1e-9)
m2 := m.average()
expect("mx", m2[0], -0.9574024, 1e3)
expect("my", m2[1],  0.2069624, 1e3)
expect("mz", m2[2],  0.0096634, 1e3)

