# MIF 2.1
# MIF Example File: checkerboard.mif

# Description: Example of a checkerboard array of two distinct species,
# both magnetically active.  The Oxs_ScriptScalarField is used to
# provide pointwise variation in material parameters.
#
set pi [expr {4*atan(1.0)}]
set mu0 [expr {4*$pi*1e-7}]

RandomSeed 1

Parameter xrange 640e-9
Parameter yrange 320e-9
Parameter zrange  20e-9

Parameter xcount 16
Parameter ycount  8

# Material parameters
set Ms1    8e5 ;# Saturation magnetization for species 1
set A1  13e-12 ;# Exchange coupling for species 1
set K1     0.0 ;# Uniaxial anisotropy constant for species 1

set Ms2   14e5 ;# Saturation magnetization for species 2
set A2  30e-12 ;# Exchange coupling for species 2
set K2   520e3 ;# Uniaxial anisotropy constant for species 2

set xblocksize [expr {$xrange/$xcount}]
set yblocksize [expr {$yrange/$ycount}]

proc CheckerBoard { Q1 Q2  x y z } {
   global xblocksize yblocksize holeradsq

   set xoff [expr {int(floor($x/$xblocksize))}]
   set yoff [expr {int(floor($y/$yblocksize))}]

   if {($xoff + $yoff) % 2 == 0} {
      return $Q1
   }
   return $Q2
}

Parameter xycellsize  5e-9
Parameter  zcellsize  5e-9

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

Specify Oxs_RectangularMesh:mesh [subst {
  cellsize {$xycellsize $xycellsize $zcellsize}
  atlas :atlas
}]

Specify Oxs_ExchangePtwise [subst {
 A { Oxs_ScriptScalarField {
    atlas :atlas
    script {CheckerBoard $A1 $A2}
    script_args rawpt
 } }
}]

Specify Oxs_UniaxialAnisotropy [subst {
 K1 { Oxs_ScriptScalarField {
    atlas :atlas
    script {CheckerBoard $K1 $K2}
    script_args rawpt
 } }
 axis {0 0 1}
}]

Specify Oxs_UZeeman [subst {
  multiplier [expr {0.001/$mu0}]
  Hrange {
     {   0   0   0   100   0   0   2 }
     { 100   0   0  -100   0   0   2 }
     {   0   0   0     0 100   0   4 }
     {  10  10  10    50  50  50   0 }
  }
}]

Specify Oxs_Demag {}

Specify Oxs_RungeKuttaEvolve:evolve {}

Specify Oxs_TimeDriver [subst {
 basename antidots-filled
 evolver :evolve
 stopping_dm_dt 0.1
 mesh :mesh
 Ms { Oxs_ScriptScalarField {
    atlas :atlas
    script {CheckerBoard $Ms1 $Ms2}
    script_args rawpt
 } }
 m0 {0.99498744 0.1 0}
}]
