# MIF 2.1
# MIF Example File: cgbench.mif
# Description: Sample benchmark for CGEvolve, based
#              off muMAG Standard Problem #1

Parameter seed 1
RandomSeed $seed

Parameter lmap 1  ;# line_minimum_angle_precision, in degrees
Parameter eprec 1e-12
Parameter gra 80
Parameter grc 50
Parameter  method Fletcher-Reeves  ;# one of Fletcher-Reeves or Polak-Ribiere


set pi [expr {4*atan(1.0)}]
set mu0 [expr {4*$pi*1e-7}]

Parameter cellsize 4 ;# Cell size in nm
set cellsize [expr {$cellsize*1e-9}] ;# Convert to meters

Parameter RandomAnisotropy 0.0 ;# Scaling for random anisotropy
## term.  If set to 0, then uniform 0.5 kJ/m anisotropy as
## specified in muMAG Standard Problem #1 is applied.

Specify Oxs_BoxAtlas:atlas {
  xrange {0 2e-6}
  yrange {0 1e-6}
  zrange {0 20e-9}
}

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

Specify Oxs_UniformExchange {
  A  13e-12
}

Specify Oxs_FixedZeeman {
   field {0.0 100. 10.}
}

if {$RandomAnisotropy>0.0} {
  Specify Oxs_UniaxialAnisotropy [subst {
    K1 { Oxs_RandomScalarField {
        range_min [expr {$RandomAnisotropy*0.5e3}]
        range_max [expr {$RandomAnisotropy*5.0e3}]
    }}
    axis { Oxs_RandomVectorField {
        min_norm 1.0
        max_norm 1.0
    }}
  }]
} else {
  Specify Oxs_UniaxialAnisotropy {
    K1 0.5e3
    axis {1 0 0}
  }
}

Specify Oxs_Demag {}

Specify Oxs_CGEvolve:evolve [subst {
   comment { DEFAULT SETTINGS:
      gradient_reset_angle 80
      gradient_reset_count 50
      minimum_bracket_step 0.05
      maximum_bracket_step 10
      line_minimum_angle_precision 5
      line_minimum_relwidth 1
      energy_precision 1e-10
      method Fletcher-Reeves  comment {Fletcher-Reeves or Polak-Ribiere}
      preconditioner none     comment { One of none, msv, diagonal }
   }
   line_minimum_angle_precision $lmap
   energy_precision $eprec
   gradient_reset_angle $gra
   gradient_reset_count $grc
   method $method
}]

Specify Oxs_MinDriver {
 evolver :evolve
 stopping_mxHxm {1e3 1.0 0.01 1e-5}
 mesh :mesh
 Ms 8.0e5
 m0 { Oxs_RandomVectorField {
   min_norm 1.0
   max_norm 1.0
 }}
}

#Destination table   mmDataTable
#Schedule DataTable table Step 5

Destination archive mmArchive
Schedule DataTable archive Step 1
#Schedule DataTable archive Stage 1

Schedule Oxs_MinDriver::Magnetization archive Stage 1
