Crystallization Basic

Crystallization Basic preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)



Tagged by Tim Denton over 12 years ago

chemistry and physics 

Tagged by Reuven M. Lerner almost 11 years ago


Tagged by Reuven M. Lerner almost 11 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 407 times • Downloaded 102 times • Run 1 time
Download the 'Crystallization Basic' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


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 in a publication, we ask that you include these citations for the model itself and for the NetLogo software:


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.

Comments and Questions

Click to Run Model

turtles-own [
  temp                ;; this turtle's temperature
  neighboring-turtles ;; agentset of surrounding turtles
  sides-exposed       ;; how many sides turtle has exposed

globals [
  ave-metal-temp   ;; shows average temperature of all metal
  num-frozen       ;; keeps track of how many atoms are frozen
  temp-range       ;; for histogram
  colors           ;; used both to color turtles, and for histogram
  pens             ;; keeps track of all the histogram's pen names

to setup
  set colors sentence (white - 1) [cyan sky blue violet magenta red]
  set pens []
  set temp-range (init-metal-temp - melting-temp) / (length colors - 1)
  ;; create turtles everywhere inside the given box range
  ask patches [
    if (not circle? and ((abs pycor) < height / 2) and ((abs pxcor) < width / 2))
       or (circle? and distancexy 0 0 < height / 2)
      sprout 1
        set shape "T"
        set temp init-metal-temp
  ask turtles [
    set neighboring-turtles (turtles at-points [[-1  1] [ 0  1] [1  1]
                                                [-1  0] [ 0  0] [1  0]
                                                [-1 -1] [ 0 -1] [1 -1]])
    set sides-exposed (9 - (count neighboring-turtles))
  set ave-metal-temp init-metal-temp

to go
  ;; stop if all turtles are below melting temp
  if (max ([temp] of turtles) < melting-temp) [ stop ]
  ;; otherwise...
  set num-frozen 0
  ask turtles [ cool-turtles ]
  ask turtles [ set-color ]
  ask turtles [ rotate ]
  set ave-metal-temp (mean [temp] of turtles)

;; turtle procedure -- if metal is liquid and it is next to a solid,
;; change its heading to that of the solid; otherwise, just rotate
;; randomly

to rotate
  if (temp >= melting-temp) [
    let frozen-neighbors (neighboring-turtles with [temp <= melting-temp])
    ifelse (any? frozen-neighbors)
      [ set heading ([heading] of (one-of frozen-neighbors)) ]
      [ rt random-float 360 ]

;; turtle procedure -- sets turtle's temp to ave temp of all
;; neighboring turtles and patches added turtle's own temp in twice so
;; it changes more slowly

to cool-turtles
  let total-temp ((sum [temp] of neighboring-turtles) + (room-temp * sides-exposed) + temp)
  set temp (total-temp / 10)

;; turtle procedure

to set-color
  ;; create index ranging from 1 to 8 for all melting colors
  let index (floor ((temp - melting-temp) / temp-range)) + 1
  ifelse (index < 0 ) [
    set color white - 1
    set num-frozen (num-frozen + 1)
    if index >= length colors
      [ set index (length colors) - 1 ]
    set color item index colors

; Copyright 2002 Uri Wilensky.
; See Info tab for full copyright and license.

There are 10 versions of this model.

Uploaded by When Description Download
Uri Wilensky about 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky over 11 years ago Updated version tag Download this version
Uri Wilensky over 11 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky over 12 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky about 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 14 years ago Model from NetLogo distribution Download this version
Uri Wilensky about 14 years ago Crystallization Basic Download this version

Attached files

File Type Description Last updated
Crystallization Basic.png preview Preview for 'Crystallization Basic' about 11 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.