# MIF 2.1
# MIF Example File: acsample.mif
# Description: Example with an ac applied field, in the (1,0,0) direction
set pi [expr {4*atan(1.0)}]
set mu0 [expr {4*$pi*1e-7}]

RandomSeed 1

Parameter cellsize 3e-9

Parameter amp 100   ;# Amplitude of the applied field, in mT
Parameter freq 0.8  ;# Frequency of applied field, in GHz

# Convert field amplitude from mT to A/m
set amp [expr {$amp*0.001/$mu0}]

# Convert freq from GHz to natural frequency in rad/sec
set freq [expr {$freq*1e9*2*$pi}]

Specify Oxs_BoxAtlas:atlas {
  xrange {0 150e-9}
  yrange {0  75e-9}
  zrange {0   6e-9}
}

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

Specify Oxs_CubicAnisotropy {
  K1  -4.5e3
  axis1 {1 0 0}
  axis2 {0 1 0}
}

Specify Oxs_UniformExchange {
  A  9e-12
}

Specify Oxs_ScriptUZeeman {
   script_args total_time
   script SineField
}

proc SineField { total_time } {
   global amp freq
   set Hx [expr {$amp*sin($freq*$total_time)}]
   set dHx [expr {$amp*$freq*cos($freq*$total_time)}]
   return [list $Hx 0 0 $dHx 0 0]
}

Specify Oxs_Demag {}

Specify Oxs_RungeKuttaEvolve:evolve {
  alpha 0.05
  method rkf54s
}

Specify Oxs_TimeDriver [subst {
 basename acsample
 evolver :evolve
 comment {run for 20 ns total, with a stage event triggered every 1 ns.}
 stopping_time 1e-9
 stage_count 20
 mesh :mesh
 Ms 800e3
 m0 { 1 0.02 0.01 }
}]
