# MIF 2.1
#This file was generated by S. ROHART (Laboratoire de Physique des Solides, Université Paris-Sud, Orsay, FRANCE)
#as a demonstration of Oxs_DMExchange6Ngbr class, which enables DMI in OOMMF.
#It generates a skyrmion in a 100x100 nm nanodot
#
#Please quote S. ROHART and A. Thiaville Phys. Rev. B 2013 when using this class.

set D 4.
set DD [expr {$D/1000}]

Specify Oxs_MultiAtlas:atlas { 
  atlas { Oxs_BoxAtlas:world { 
       xrange { -50e-9 50e-9 }
       yrange { -50e-9 50e-9 }
       zrange { 0 0.6e-9 }
	   name world
  } }
}

Specify Oxs_RectangularMesh:mesh {
  cellsize { 0.5e-9 0.5e-9 0.6e-9 }
  atlas :atlas
}

Specify Oxs_UniformExchange:HeisenbergEx {
  A 1.6e-11
}

#uniform DMI is used here
Specify Oxs_DMExchange6Ngbr:DMEx [subst {
  default_D $DD
  atlas :atlas
  D { 
    world world $DD
  }
}]

Specify Oxs_UniaxialAnisotropy:Anisotropy {
	axis { 0 0 1}
	K1 0.51e6
}

Specify Oxs_EulerEvolve {
  alpha 0.5
  start_dm 0.01
  do_precess 0
}

Specify Oxs_TimeDriver [subst {
  evolver Oxs_EulerEvolve
  stopping_dm_dt 0.01
  mesh :mesh
  vector_field_output_format { text %.17g }
  scalar_output_format %.17g
  Ms { Oxs_ScriptScalarField { 
    script  dot
    atlas Oxs_MultiAtlas:atlas
    script_args { rawpt minpt maxpt }
  } }
  m0 { Oxs_ScriptVectorField { 
    script Skyrmion
	atlas Oxs_MultiAtlas:atlas
	script_args { rawpt minpt maxpt }
  } }
  basename Syrmion_D=$D
}]

Destination archive mmArchive
Schedule Oxs_TimeDriver::Magnetization archive stage 1

proc Skyrmion { x y z xmin ymin zmin xmax ymax zmax } {
	set xnorm  [expr {-2*$x/($xmax-$xmin)}]
	set ynorm  [expr {-2*$y/($ymax-$ymin)}]
	set radius [expr {$xnorm*$xnorm+$ynorm*$ynorm}]

	if {$radius <0.1} {return [list 0 0 1]}
	if {$radius > 0.2} {return [list 0 0 -1]}
    return [list  $xnorm $ynorm 0]
}

proc dot { x y z xmin ymin zmin xmax ymax zmax } {
	set xnorm  [expr {2*$x/($xmax-$xmin)}]
	set ynorm  [expr {2*$y/($ymax-$ymin)}]
	set radius [expr {$xnorm*$xnorm+$ynorm*$ynorm}]
	
	if {$radius<1} {return 1.1e6}
	return 0
}
