NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo Models Library:
Sample Models/Chemistry & Physics/Materials Science/Crystallization

(back to the library)

Crystallization Basic

[screen shot]

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


This model shows how grains are formed as a metal crystallizes.

As a metal cools, it solidifies. The first atoms to solidify have a random orientation. But when an atom solidifies next to an already solidified atom, the first atom orients itself with the solid atom, thus creating a crystal "grain". As more atoms solidify, the grains grow. Within each grain, all the atoms are oriented the same, but different grains have different orientations.

Two grains next to each other form what is called a grain boundary. When a metal is stressed, such as when it is pulled from both ends, deformations occur in the crystal structure. As more stress is applied, these deformations pass through the crystal structure, allowing the metal to bend. Grain boundaries prevent deformations from flowing through the metal. Therefore, pieces of metal with fewer grain boundaries tend to be ductile, while pieces of metal with more grain boundaries tend to be brittle.


Liquid metal is placed in a room with a constant temperature much lower than that of the metal. As heat leaves the metal, the metal begins to solidify. Liquid atoms are free to rotate, but solid atoms (gray) are literally frozen. If a liquid atom is next to a solid atom, it will orient itself with it, otherwise it will rotate randomly.

Note that the actual number of atoms is small compared to a real metal sample and the metal is only two-dimensional.



SETUP: Resets the simulation, and sets the metal to the correct size. GO-ONCE: Runs the simulation for one time step. GO: Runs the simulation continuously until either the GO button is pressed again, or all of the atoms are frozen.


WIDTH: How many atoms wide the metal is. HEIGHT: How many atoms high the metal is. (Ignored if CIRCLE? switch is on.) ROOM-TEMP: Varies the temperature of the room. INIT-METAL-TEMP: Varies the initial temperature of the metal. MELTING-TEMP: Varies the temperature at which the metal solidifies.


AVE-METAL-TEMP: Monitors the average temperature of all the atoms. TIME: Keeps track of the time that has elapsed during each run.


CIRCLE?: If on, pressing SETUP produces a circular piece of metal. Otherwise, you get a square or rectangular piece of metal. (If CIRCLE? is on, the size of the circle is determined by the WIDTH slider, and the HEIGHT slider is ignored.) HISTOGRAM?: Turns the histogram plotting on and off. Turning off the histogram speeds up the model.


AVERAGE METAL TEMPERATURE: Plots the average temperature of all the metal over time. NUMBER SOLIDIFIED: Plots how many metal atoms are below the melting temperature over time. TEMPERATURES: Histograms how many atoms are in each temperature range. (Note that the colors of the histogram match the actual colors of the atoms.)


Set HEIGHT to 19. Try to obtain the largest grains possible by systematically changing the three temperature variables. Are there multiple settings that achieve this affect? Now find the settings that result in the smallest grains. Are there multiple settings that achieve this affect?

Compare the time it takes for the metal to completely crystallize using each of the settings you found in the above paragraph. To do this, use the TIME monitor. How does crystallization time relate to grain size?

Keeping the HEIGHT 19, what is the fewest number of grains you can make? Why can you not make only one grain? From what part of the metal does crystallization always start from? Does setting CIRCLE? to OFF make any difference?

Set the ROOM-TEMP to be 20, the INIT-METAL-TEMP to be 1550, and the MELTING-TEMP to be 500. Set CIRCLE? to OFF. Now try various settings for HEIGHT and WIDTH. Which setting achieves the largest size of grains? Which setting achieves the fewest number of grains?


Some metal applications require that the metal's grains form long strips across the metal. To achieve this, only one side of the metal is cooled. This causes all of the crystals to begin on one side of the metal, and consequently grow across its length. This is called directional solidification. In the Procedures window, change the code so one side of the room is much cooler than the others.

Other metal applications require that metal consist of a single grain. One way to do this is to crystallize the metal in a magnetic field. This induces polarization in the metal atoms, causing them to line up. Add a procedure to the code that creates a magnetic field in the room.


In the setup procedure, a turtle is created on every patch within the requested dimensions. This is achieved by asking every patch satisfying certain conditions to sprout 1.

Note how we can draw a multi-colored histogram. The histogram primitive can only draw in one color at a time, but we work around this by calling it over and over again, plotting only one bar each time, changing the pen color each time.

With every time step, each atom's temperature changes to the average of everything around it. To do this, each turtle has a list of all of its neighboring turtles. In this model, every patch surrounding a given turtle is either occupied by a turtle or considered to be outside the metal. Therefore, the new temperature is then taken as the average of the temperatures of the neighbor list, plus the room temperature multiplied by the maximum number of neighbors minus the number of neighbors that particular turtle has. Therefore, turtles completely surrounded by other turtles don't average in the room temperature to their temperature, but turtles on the edge of the metal will.


Crystallization Directed Crystallization Moving


Original implementation: Carrie Hobbs, for the Center for Connected Learning and Computer-Based Modeling.


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 2002 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

This model was created as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227.

(back to the NetLogo Models Library)