OOF2: The Manual


Anneal (Anneal) — Move nodes randomly and accept the ones that meet the acceptance criterion.




  • Base class: SkeletonModifier
  • Parameters:

    Which nodes to move. Type: An object of the FiddleNodesTargets class.
    Acceptance criterion Type: An object of the SkelModCriterion class.
    Failed moves will be accepted if T>0 and exp(-diffE/T) > r, where diffE is the energy gained and r is a random number between 0 and 1. Type: A real number.
    Width of the distribution of attempted node motions, in units of the pixel size. Type: A real number.
    Iteration method. Type: An object of the IterationManager class.


Anneal is a Skeleton modifier that moves Nodes to random positions, accepting or rejecting moves according to the given criterion. It is similar to a simulated annealing simulation in statistical mechanics, from which it gets its name. Instead of minimizing the free energy of a system of particles, it minimizes the effective energy of a Skeleton.

The general procedure for a single iteration of Anneal is as follows:

  1. Collect target nodes according to the given targets parameter. The collected Nodes are re-ordered randomly to remove any potential artifacts from the original ordering of Nodes. This re-ordering is repeated at every iteration.

  2. Give each Node a single chance to move to a randomly assigned new position. OOF2 computes the new position from

      x_\mathrm{new} &= x_\mathrm{old} + \delta x \\
      y_\mathrm{new} &= y_\mathrm{old} + \delta y. \\

    \(\delta x\) and \(\delta y\) are random numbers chosen from a Gaussian distribution of width delta and mean 0.0. delta is in units of the Microstructure pixel size.

    Figure 6.59(a) shows a node (the big red dot) that is about to move to a new position. Before making the move, OOF2 computes the total effective energy of all of the neighboring elements of the node.

  3. After moving each Node, the given acceptance criterion decides whether or not the move is acceptable.

  4. If the move is unacceptable according to the acceptance criterion, OOF2 may still accept the move if the annealing is being done at a non-zero temperature. The parameter T sets the effective temperature of the annealing process. Unacceptable moves are accepted with a probability

      \[P = \exp{(-E_\mathrm{diff}/T)}\]

    where \(E_\mathrm{diff}\) is the difference between the effective energies of the new and old Element configurations.

Figure 6.59. Annealing


(a) A node moves by \(\delta x\) and \(\delta y\). The node move affects four neighboring elements, E0, E1, E2, and E3. (b) The node has moved to a new position. If the move doesn't satisfy the given acceptance criterion (computed based on its four affected elements), it'll be rejected and the node will move back to its original position.

Successful annealing usually requires a number of iterations. On each iteration, OOF2 makes one attempt to move each node. The number of iterations is controlled by the iteration parameter, which can be set to perform a fixed number of iterations or to stop after some condition is satisfied. See IterationManager for the details.

Statistics for each step of the annealing process are printed in the OOF2 Message window. For example,

Iteration 1: E = 1.1916e+01, deltaE=-1.2495e-01 ( 1.049%), Acceptance Rate = 19.1%
Iteration 2: E = 1.1391e+01, deltaE=-1.7564e-01 ( 1.542%), Acceptance Rate = 25.5%
Iteration 3: E = 1.0638e+01, deltaE=-1.1883e-01 ( 1.117%), Acceptance Rate = 22.3%
Iteration 4: E = 1.0095e+01, deltaE=-1.4345e-01 ( 1.421%), Acceptance Rate = 21.0%
Iteration 5: E = 9.5440e+00, deltaE=-8.3725e-02 ( 0.877%), Acceptance Rate = 21.0%

The listing shows the iteration number, the total energy (E) of the Skeleton, the absolute change in energy (deltaE) during the iteration, the percentage change in energy, and the move acceptance rate. If the change in energy or the acceptance rate gets too small, the annealing process is not being effective at improving the Skeleton. Using ConditionalIteration as the iteration parameter can stop the process when it becomes ineffective.

Figure 6.60 shows a Skeleton that has been refined once. Figure 6.61 shows the same skeleton after snapping nodes to the material boundaries. Snapping was done with a large α (0.9) so there are some badly misshapen elements. Notice that the border of the arrow shape does not coincide well with the element edges in many spots. Further iterations of SnapNodes does not improve matters. However, the Skeleton can be improved by Annealing. Annealing with targets=AllNodes, criterion=AverageEnergy(alpha=0.9), and delta=1.0 for 20 iterations produced the Skeleton shown in Figure 6.62. The Skeleton edges match the boundary of the arrow shape much more exactly. Further annealing would improve it even more, although SplitQuads and Rationalize should probably be used first.

Figure 6.60. A Slightly Refined Skeleton

A Slightly Refined Skeleton

A Skeleton for a Microstructure containing three materials. The material boundaries do not align well with the Element edges.

Figure 6.61. A Snapped Skeleton

Figure 6.62. An Annealed Skeleton

An Annealed Skeleton

The Skeleton from Figure 6.61 after being annealed. The resolution of the sharp corners has been much improved.

[Tip] Tip

Even though the example shown above concentrates on resolving tricky material boundaries (meaning it puts more emphasis on homogeneity than shape), Anneal can also be used to improve the shape energy of Skeletons. Since OOF2 isn't quite psychic, one needs to let it know whether one wants to work on homogeneity or shape energy. This is done by adjusting the alpha parameter which is part of the acceptance criterion parameter. If alpha is close to 1 Anneal will improve homogeneity (and create ugly elements). If alpha is close to 0 Anneal will improve the shape energy. Keep in mind that annealing for shape energy could disrupt material boundaries that have already been established. To avoid this, be sure to pin boundary nodes so that they will not move while annealing.

[Tip] Tip

A good way to anneal efficiently is to apply it only to Nodes that are in or near the problem areas of the Skeleton. This can be done by using Active Areas, or by choosing the targets carefully. One way to anneal only the Nodes near material boundaries is to select the nodes on interior boundaries (OOF.NodeSelection.Select_Internal_Boundaries) and their neighbors (OOF.NodeSelection.Expand_Node_Selection) and then Anneal with targets=SelectedNodes().