# MIF 2.1

set basename spinxfer-onespin

set pi [expr 4*atan(1.0)]
set mu0 [expr 4*$pi*1e-7]

Parameter I 0   ;# 1e-6
Parameter Happ 10.0 ;# Field in mT

Parameter Ms  860e3

Parameter Polarization 0.4

Parameter theta 40  ;# Polarization direction,
Parameter phi   90  ;# in spherical coordinates

Parameter length 125e-9
Parameter width  125e-9
Parameter thick    5e-9

set current_density [expr {$I/($length*$width)}]

Specify Oxs_BoxAtlas:atlas [subst {
  xrange {0 $length}
  yrange {0 $width}
  zrange {0 $thick}
}]

Specify Oxs_RectangularMesh:mesh [subst {
  cellsize {$length $width $thick}
  atlas :atlas
}]

# Applied field
Specify Oxs_UZeeman [subst {
  multiplier [expr {0.001/$mu0}]
  Hrange {
     { 0 0 $Happ  0 0 0  2 }
  }
}]


# Demag
Specify Oxs_Demag {}

# Evolver
set theta [expr {$theta*$pi/180.}]
set phi   [expr {$phi*$pi/180.}]

Specify Oxs_SpinXferEvolve:evolve [subst {
  alpha 0.014
  start_dm 0.01
  mp {[expr {sin($theta)*cos($phi)}]
      [expr {sin($theta)*sin($phi)}]
      [expr {cos($theta)}]}
  J $current_density
  P $Polarization
}]

# Driver
Specify Oxs_TimeDriver [subst {
 basename $basename
 evolver :evolve
 stopping_dm_dt  1e-9
 stopping_time   1.0
 mesh :mesh
 Ms $Ms
 m0 { 1 0 0}
}]
