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

set rungekutta 0

Parameter alpha 0.001

RandomSeed 1

Specify Oxs_BoxAtlas:atlas {
  xrange {0 10e-9}
  yrange {0 10e-9}
  zrange {0 10e-9}
}

Parameter cellsize 10e-9

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

Specify Oxs_UZeeman [subst {
  multiplier [expr 0.001/$mu0]
  Hrange {
     {  0  0  10   0  0  0   0 }
  }
}]

if {$rungekutta} {
    Specify Oxs_RungeKuttaEvolve:evolver [subst {
	alpha $alpha
        gamma_LL 2.21e5
	min_timestep 1e-9
	max_timestep 1e-9
	comment {
	    max_timestep 1e-13
	    error 0.01
	    energy_precision 1e-8
	}
    }]
} else {
    Specify Oxs_EulerEvolve:evolver [subst {
	alpha $alpha
        gamma_LL 2.21e5
	min_timestep 1e-11
	max_timestep 1e-11
	comment {
	    max_timestep 1e-9
            alpha 0.5
            gamma_LL 176880
            gamma_G  221100
	}
    }]
}

Specify Oxs_TimeDriver {
 basename onespin
 checkpoint_interval 15
 evolver :evolver
 stopping_time 200e-9
 comment {stopping_dm_dt 0.01}
 mesh :mesh
 Ms 8e5
 m0 {1 0 0}
}

# The following proc can be used to test results.
# Note: M = Ms.m = 8e5 m
proc AnalyticSolution { t } {
    global pi
    set theta [expr {2*atan(exp(-1.105e8*$t/$pi))}]
    set phi [expr {5.525e9*$t/$pi}]
    set sintheta [expr {sin($theta)}]
    set mx [expr {cos($phi)*$sintheta}]
    set my [expr {sin($phi)*$sintheta}]
    set mz [expr {cos($theta)}]
    return [list $theta $phi $mx $my $mz]
}

