6  Algorithm

In this section the overall computational algorithm employed by the IMPETUS II for the solution of the atomic mixing model is outlined. The details on the methods employed can be found in this and the companion paper [4].
It is assumed that the material system, the experimental conditions and the original material structure are given. The transition to steady state refers to method described in section 4.
Initialisation
Set xR, the length of the mixing window
Set dt to its minimum value
Set up energy and range functions for original material structure
Record the concentrations in Qi i=1..n
Set the transition to steady state to be inactive
repeat (dose-stepping method
  If not the transition to steady state is not active then
    If the internal concentrations have changed significantly from Qi then
      Re-compute the energy and range functions.
      Record the concentrations in Qi, i=1..n
    Set xP so that there are no sharp interface or thin layers in the domain of the FDM, [0,xP]
    Set dx so that the internal concentrations are well-represented in [0,xP]
    Advance the solution in [0, xR] using the FDM
    Revise dt, based on the drift of the sum of the concentrations from unity
    If the internal concentrations have not changed over several dose steps then
      transition to steady state is activated
      Set dt to a large value
      Compute the constants in the formula (13)
  else
     Advance the solution by the extrapolation method in [0,xR] by evaluating (13)
     If an interface is nearing xR then the transition to steady-state solution in de-activated
      Set dt to its minimum value
  end if
    Compute the solution in [xP, xR] using the POST-D method
    Compute the solution in [xR, ¥] using the PRE-D method
    Compute the yields and the erosion rate.
end repeat