Simulation of Grain Growth Under the Influence of Foreign Particles

A computer program in C

Written by: Michael Lieberthal

The Department of Materials Engineering

The 2D simulation of grain growth, with and without the addition of foreign particles, is handled using a Monte-Carlo method whereby a grain's orientation is changed randomly and the new orientation is always accepted if it is energetically favoured. If not, a probability function is utilized, which takes into consideration the system's temperature, and then the orientation is either accepted or rejected.

The Program:

5 user-defined variables are used and can be changed before compilation:

• NUMPARTICLE is the number of foreign paricles, if any.
• PARTICLE if the maximum number of orientations a grain can be allocated.
• TEMP is the system's temperature. It can vary from 0.0 to about 2.0
• MAXARR is the system's length and width.
• MCS is the number of Monte-Carlo steps.
A matrix representing the system is generated with dimensions: MAXARR x MAXARR, each cell represents a grain of unit area.
Each cell is randomly allocated an "orientation" from 0 to PARTICLE-1. Then, NUMPARTICLE number of foreign particles are allocated at random positions with orientation number equal to PARTICLE.

A special procedure is used to translate the orientation matrix into a 2-colour matrix which identifies nearest-neighbour grains having the same orientation and marks them with a grain boundary as well as all other unit cells with no similar-orientation neighbours.

This latter matrix is drawn in black and white. (Black being the brain boundary as well as the foreign paricle unit cells).

Each grain is then randomly selected and a new orientation is randomly chosen. The previous state energy is calculated as well as the proposed state one. The program examines each of the specific cell's neares neighbours, each neighbour whose orientation is different adds a unit of energy. A neighbour having the same orientation adds no energy. The sum is added and represents the cells' energetic contribution (dE). If the new state has a lower energy it is accepted. Otherwise a probability function, taking into account both the energy and the temperature (TEMP), is calculated (exp(-dE/TEMP)). A random number is generated, if its value is less then the calculated value, the new orientation is accepted.

This procedure is repeated for all the grain cells exept those having foreign particles. They are not concidered since they are not allowed, in this program, to move.
After all the cells have been considered, the new grain boundaries are found and displayed.

The orientation change of the cells is a Monte-Carlo step. The number of which is defined in the MCS variable.

Edge conditions are avoided by having each side be a continuation of the opposite one.
The program uses the OpenGL library of graphic commands for C.

List of procedures:

• initMatrix: Generates numbers for the Random Number Generator, allocates orientations for the unit grains and inserts the foreign particles randomly.
• drawBoundary: Converts the orientation matrix into a black and white matrix drawing bouandaries around same orientation neighbours or single unit cells, draws foreign particle cells in different colour then other cells. It takes into account same orientation cells which are on opposite sides of the matrix, making them part of a larger cell.
• display: Draws the matrix generated in drawBoundary.
• changeOrientation: Randomly selects a cell and a new orientation for it. If the new state is more favourable energetically it is changed, otherwise a probability function is calculated and compared to a random number. The result determines if the new state is accepted. drawBoundary is called again and the resulting system is drawn. This is repeated for the designated number of Monte-Carlo steps.
• changeValue: Changes the value of a cell to a new one if required.
• energyCalc: Calculates the energy contribution of a specific cell having a pre-allocated orientation or a new proposed one.
• myinit: Initialized the OpenGL graphics.
• printmatrix: A procedure which may be used to print the values of the orientation and boundary matrices.
• myReshape: OpenGL window procedure.
• main: Initializes matrix and display.
Examples: