# MIF 2.1
# MIF Example File: antidots-filled.mif
# Description: Example of an array of cylinders and surrounding matrix of
#  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 320e-9
Parameter yrange 160e-9
Parameter zrange  20e-9

Parameter xcount 4
Parameter ycount 2
Parameter holerad 20e-9  ;# Hole radius, in meters

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

proc AntiDots { Ms1 Ms2  x y z } {
    global xblocksize yblocksize holeradsq
    # Determine position relative to corresponding antidot center
    set x [expr {fmod($x,$xblocksize)-0.5*$xblocksize}]
    set y [expr {fmod($y,$yblocksize)-0.5*$yblocksize}]
    if {$x*$x + $y*$y < $holeradsq} {
	return $Ms2
    }
    return $Ms1
}

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 {
 A { Oxs_ScriptScalarField {
    atlas :atlas
    script {AntiDots 13e-12 30e-12}
    script_args rawpt
 } }
}

Specify Oxs_UniaxialAnisotropy:Co {
 K1 { Oxs_ScriptScalarField {
    atlas :atlas
    script {AntiDots 0 520e3}
    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 {
 basename antidots-filled
 evolver :evolve
 comment {1 deg/ns = 17453293 rad/sec; If Ms=8.6e5, and lambda is small,
         then mxh=1e-6 translates into dm/dt = 2e5 rad/sec = 0.01 deg/ns}
 stopping_dm_dt 0.1
 mesh :mesh
 Ms { Oxs_ScriptScalarField {
    atlas :atlas
    script {AntiDots 8e5 14e5}
    script_args rawpt
 } }
 m0 {0.99498744 0.1 0}
}
