# MIF 2.1
# MIF Example File: grill.mif
# Description: Two material species.

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

RandomSeed 1

Parameter AnisType K1 ;# Either K1 or Ha

# Note: The following values for Ms and K1 are specially selected
# so that they can be converted back and forth to Ha in double
# precision floating point arithmetic without rounding error.
set FeMs 1700e3
set FeK1   47e3
set CoMs 1400e3
set CoK1  520e3


Specify Oxs_ImageAtlas:atlas {
  xrange {0 400e-9}
  yrange {0 200e-9}
  zrange {0  20e-9}
  viewplane xy
  image grill.ppm
  colormap {
     red     Fe
     blue    Co
  }
}

Specify Oxs_RectangularMesh:mesh {
  cellsize {5e-9 5e-9 5e-9}
  atlas :atlas
}

Specify Oxs_Exchange6Ngbr {
  atlas :atlas
  A {
    Fe  Fe 21e-12
    Fe  Co 25e-12
    Co  Co 30e-12
  }
}

# Because Fe and hcp Co have different magneto-crystalline anistropy
# symmetries, we have to use two anisotropy objects to specify the
# simulation anisotropy energy.  First, we use an Oxs_UniaxialAnistropy
# object to specify the Co anisotropy; in this block we set K1 to 0
# inside the Fe region.  Then, we use an Oxs_CubicAnisotropy object
# to specify the Fe anisotropy; in that block K1 for Co is 0.
if {[string match K1 $AnisType]} {
   Specify Oxs_UniaxialAnisotropy:CoAnis [subst {
    K1 { Oxs_AtlasScalarField {
       atlas :atlas
       values {
          Fe    0
          Co  $CoK1
       }
    }}
    axis {1 1 1}
   }]

   Specify Oxs_CubicAnisotropy:FeAnis [subst {
    K1 { Oxs_AtlasScalarField {
       atlas :atlas
       values {
          Fe   $FeK1
          Co    0
       }
    }}
    axis1 {1 0 0}
    axis2 {0 1 0}
   }]
} else {
   Specify Oxs_UniaxialAnisotropy:CoAnis [subst {
    Ha { Oxs_AtlasScalarField {
       atlas :atlas
       values {
          Fe    0
          Co  [expr {2*$CoK1/$CoMs/$mu0}]
       }
    }}
    axis {1 1 1}
   }]

   Specify Oxs_CubicAnisotropy:FeAnis [subst {
    Ha { Oxs_AtlasScalarField {
       atlas :atlas
       values {
          Fe    [expr {2*$FeK1/$FeMs/$mu0}]
          Co    0
       }
    }}
    axis1 {1 0 0}
    axis2 {0 1 0}
   }]
}


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

Specify Oxs_Demag {}

Specify Oxs_CGEvolve {}

Specify Oxs_MinDriver [subst {
 evolver Oxs_CGEvolve
 stopping_mxHxm 0.1
 mesh :mesh
 Ms { Oxs_AtlasScalarField {
   atlas :atlas
   values {
      Fe $FeMs
      Co $CoMs
   }
 }}
 m0 {Oxs_RandomVectorField {
   min_norm 1.0
   max_norm 1.0
 }}
}]
