NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo Models Library:
Curricular Models/MaterialSim

(back to the library)

MaterialSim Grain Growth

[screen shot]

If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web


Most materials are not continuous arrangements of atoms. Rather, they are composed of thousands or millions of microscopic crystals, known as grains. This model shows how the configuration and sizes of these grains change over time. Grain size is a very important characteristic for evaluating the mechanical properties of materials; it is exhaustively studied in metallurgy and materials science.

Usually this kind of study is made by careful analysis and comparison of pictures taken in microscopes, sometimes with the help of image analysis software. Recently, as the processing power of computers has increased, a new and promising approach has been made possible: computer simulation of grain growth.

Anderson, Srolovitz et al. proposed the most widely known and employed theory for computer modeling and simulation of grain growth, using the Monte Carlo method. Instead of considering the grains as spheres, and being obliged to make numerous geometrical approximations, Anderson proposed that the computer would simulate the behavior of each individual atom in the system. Each atom would follow a very simple rule: it will always try to have, in its immediate neighborhood, as many atoms as possible with the same orientation as it. It will do so by randomly (hence Monte Carlo) re-orienting itself and seeing if it is more stable than it was before. If it is, it will stay in its new orientation, and if not, it will revert back to its previous orientation.

This model is part of the MaterialSim (Blikstein & Wilensky, 2004) curricular package. To learn more about MaterialSim, see


The basic algorithm of the simulation is simple: each atom continuously tries to be as stable as possible. Its stability is based on the number of neighbors with similar orientations: the more similar neighbors, the more stable it is. If it has only few similar neighbors, it will try to relocate to a more stable position. The steps for each tick in the model are:

  1. Choose a random atom.
  2. Ask that atom to calculate its present energy (based on its stability). The atom does this by counting how many similar neighbors it has.
  3. The atom then chooses at random one of its neighbors, and orients itself in the same direction as that neighbor.
  4. The same atom then calculates its energy, based on this new, tentative orientation.
  5. Finally the atom compares the energy levels in each of the two states: the lowest value "wins", i.e., the more similar neighbors, the more stable the atom is.
  6. Repeat steps 1-6.

The annealing-temperature slider controls the probability of maintaining a reorientation that yields less stability. The percent-element2 slider defines the percentage of second-phase particles to be created when the user setups the simulation. Those particles are not movable and are not subject to grain growth. Atoms with element2-particles as neighbors will see them as dissimilar.

Note that the actual number of atoms is small compared to a real metal sample. Also, real materials are three-dimensional, while this model is 2D.


(1) Simulation starting point.

starting-point: You can start from a random arrangement or a picture from a microscope. File formats accepted are: .jpg, .png, .bmp, and .gif. The image will be automatically resized to fit into the world, but maintaining its original aspect ratio. Note that the image MUST HAVE THE SAME ASPECT RATIO AS THE WORLD. In other words, if the world is square, the image should be square as well. Prior to importing the image, it is recommended to clean it up using an image editing software (increase contrast, remove noise). Try to experiment various combinations of values for the view's size and the patch size to get the best results

percent-element2: You can also determine if you want a certain percentage of a second element, sometimes called grain refiner.

setup: Sets up the model as indicated.

(2) Change the shape of atoms.

Different shapes might help visualize the atomic planes, or the proportion of different types of grains.

atom-shape: Choose which shape you want.

apply-shape: Re-draws all the atoms with the shape you chose.

(3) Draw/edit grains (optional)

You can use this to "draw" new grain structures, or edit the grains at any point during the simulation.

draw: When this button is pressed down, you can change the color (orientation) of atoms in the model.

brush-size: This determines how many atoms’ orientation you change at a time.

erase-all: This changes the orientation of all atoms.

draw-color: Here you can change the color (and orientation) that that you change atoms to, when you draw on them.

(4) Run Model.

You can choose to have the model keep repeating the steps (as described above) or to run just one tick. Running just one tick will allow you to see more clearly what happens over time.

annealing-temperature: changes the probability of non-favorable orientation flips to happen. A 10% value, for instance, means that 10% of non-favorable flips will be maintained. This mimics the effect of higher temperatures.

Grain size plot and calculations

*ticks-per-measurement *: to increase the model's speed, the user can choose not to calculate grain size at every time step. If grain size is calculated at every ten time units (20, 30, 40 etc.), the performance is slightly increased. This only affects the plot and the monitors, but not the actual simulation.

measure grains now: if the user feels there is too much time between each grain measurement, and wants to calculate it immediately, this button can be used.

Plots and monitors

Grain Size (log-log): Grain size vs. time, in a log-log scale. Under normal conditions (annealing-temperature = 0 and percent-element2 = 0), this plot should be a straight line with an angular coefficient of approximately 0.5.

Grain Size: grain size

Log Time: log of ticks in the simulation so far

Log Grain Size: Log of the grain size

growth-exponent: the angular coefficient of the Grain Size (log-log) plot. This number should approach 0.5 with annealing-temperature = 0 and percent-element2 = 0.


When you setup with a random orientation and run the simulation, notice that the speed of growth decreases with time. Toward the end of the simulation, you might see just two or three grains that fight with each other for along time. One will eventually prevail, but this logarithmic decrease of speed is an important characteristic of grain growth. That is why the **Grain Size (log-log) plot is a straight line in a "log-log" scale. Notice also that if you draw two grains, one concave and one convex, their boundary will tend to be a straight line, if you let the simulation run long enough. Every curved boundary is unstable because many atoms at its interface will have more different than equal neighbors.


Increase the value of the annealing-temperature slider. What happens to the Grain Size (log-log) plot, and to the boundaries' shapes?

Try to increase the percent-element2 slider to 5%. Then choose “random arrangement” and click setup, and go. What happens to grain growth? Now try several values (1, 3, 5, 7, 9%), for instance. What happens with the final grain size? What about the Grain Size (log-log) plot and the **Growth Exponent?

One advanced use of this model would be to get a digital picture of a real metallic sample, reduce noise and increase contrast with image editing programs, and load into this model using the Import Image feature in the starting-point chooser. Don't forget to update the width and height of the view's size to accommodate the picture, and also to change the patch size in order to be able to see the whole sample.


This model assumes that the misorientation between two grains has no effect on their growth rates. Two grains with a very similar crystallographic orientation have the same growth rate as grains whose orientations differ by a lot. Try to take the angular misorientation into consideration.

When we insert second-phase particles, all of them have the same size. Try to create a slider that changes the size of these particles.


Rather than containing all of the code that updates variables used for plotting, the Grain Size (log-log) plot calls a procedure that does this. The reason is that there is quite a lot of code, and it would be difficult to work with inside the plot. Notice also that this code updates the global variables shown in the monitors to the right of the plot.

The model uses a hexagonal grid as opposed to the usual, square one. It also uses different shapes for different visualization purposes. Finally, it uses the import-pcolors primitive for image import.


Crystallization Basic Crystallization Directed Crystallization Moving


This model is part of the MaterialSim (Blikstein & Wilensky, 2004) curricular package. To learn more about MaterialSim, see

Two papers describing the use of this model in education are: Blikstein, P. & Wilensky, U. (2005) Less is More: Agent-Based Simulation as a Powerful Learning Tool in Materials Science. The IV International Conference on Autonomous Agents and Multiagent Systems. Utrecht, Netherlands.

Blikstein, P. & Wilensky, U. (2004) MaterialSim: An agent-based simulation toolkit for Materials Science learning. (PDF, 1.5 MB) Proceedings of the International Conference on Engineering Education. Gainesville, Florida.

The core algorithm of the model was developed at the University of Sao Paulo and published in: Blikstein, P. and Tschiptschin, A. P. Monte Carlo simulation of grain growth (II). Materials Research, Sao Carlos, 2 (3), p. 133-138, jul. 1999.

Available for download at: See also for more information (in Portuguese).


If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as:


Copyright 2005 Uri Wilensky.


This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at

(back to the NetLogo Models Library)