---materialsim-grain-growth.nlogo
来自「NETLOGO」· NLOGO 代码 · 共 1,163 行 · 第 1/3 页
NLOGO
1,163 行
heightheight35014511atomsTEXTBOX121720535(1) Simulation starting pointSLIDER235149464182annealing-temperatureannealing-temperature0100011%BUTTON237308392347measure grains nowgrain-countNIL1TOBSERVERTNILPLOT11378263566Grain Size (log-log)log (time)log (avg grain size)0.0200.00.01.0truefalsePENS"average-grain-size" 1.0 0 -16777216 falseMONITOR268437376486Grain Sizeaverage-grain-size31BUTTON11315111355gogoT1TOBSERVERNILNILSLIDER235185463218fraction-element2fraction-element2010011NILBUTTON93620069start with random arrangementmakes-initial-box-randomNIL1TOBSERVERTNILBUTTON978200111import imageimport-imageNIL1TOBSERVERTNILMONITOR380438493487Log Grain Sizelogaverage-grain-size21MONITOR378379472428Log timelogtime21MONITOR267379374428Simulation timeMCS01MONITOR380491493540Growth exponentgrain-growth-exponent21TEXTBOX11295150313(4) Run simulationTEXTBOX236127326145Special featuresSLIDER235265423298measurement-frequencymeasurement-frequency1100111NILTEXTBOX2381832836Simulation sizeCHOOSER10135111180atom-shapeatom-shape"hex" "hexline" "thin-line" "line" "circ" "square" "spikes90" "default"0BUTTON115135200180apply shapeask turtles [set shape atom-shape]NIL1TOBSERVERTNILBUTTON1020479237drawturtle-drawT1TOBSERVERTNILBUTTON1024379286erase allerase-allNIL1TOBSERVERTNILSLIDER82204200237brush-sizebrush-size16411NILTEXTBOX11185101203(3) Draw grainsCHOOSER82242200287draw-colordraw-color45 55 85 105 150TEXTBOX237244367262Grain measurementTEXTBOX13360181378Grain size plot and calculationsTEXTBOX10115186133(2) Change the shape of atomsBUTTON117315194355go oncego\nNIL1TOBSERVERTNIL@#$#@#$#@WHAT IS IT?-----------Most materials are not continuous arrangements of atoms, but rather 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.This model is part of the MaterialSim (Blikstein & Wilensky, 2004) curricular package. To learn more about MaterialSim, see http://ccl.northwestern.edu/materialsim/. HOW IT WORKS------------The basic algorithm of the simulation is simple: atoms are trying to be as stable as possible. Their stability is based on the number of equal neighbors: the more equal neighbors (i.e. atoms with the same orientation) an atom has, the more stable it is. If it has many different neighbors, it is unstable, and not likely to be in that position for long, because during the simulation atoms will try to relocate to more stable positions. Therefore, the steps are:1) Choose a random atom.2) Calculate its present energy (which is correlated with the stability). This calculation is done by simply counting the number of different neighbors.3) Randomly choose a new orientation for the chosen atom, amongst the orientations of its neighbors. We still don't know if that new attempted orientation will be maintained. We have to calculate the energy in this new situation in order to know.4) Calculate the free energy of the chosen element with the new, tentative orientation. Again, we just count the number of different neighbors.5) Comparison of the two values for free energy: the lowest value "wins", i.e., the less different neighbors an atom have, more stable it is.6) Repeat steps 1-6.The ANNEALING-TEMPERATURE slider controls the probability of maintaining an re-orientation which yields more instability. The FRACTION-ELEMENT-2 slider defines the percentage of second-phase particles to be created when the user setups the simulation. Those particles and not movable and are not subject to grain growth. Atoms see those particles as a different neighbor.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. HOW TO USE IT-------------(1) Simulation starting point:IMPORT IMAGE: Resets the simulation, and imports an image file in the JPG, BMP, GIF or PNG file formats. The image will be automatically resized to fit into the view, but maintaining its original aspect ratio. Note that the image MUST HAVE THE SAME ASPECT RATIO AS THE VIEW. In other words, if the view 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 WIDTH and HEIGHT sliders, the view's size and the patch size to get the best results.START WITH RANDOM ARRANGEMENT: Resets the simulation, and starts it with a random orientation for each atom.GO-ONCE: Runs the simulation, one time step at a time.GO: Runs the simulation continuously until either the GO button is pressed again, or just one grain survives.(2) Change the shape of the atomsThe ATOM-SHAPE chooser has many different shapes, such as circle, hexagon, line, circle with spikes, thin line, and square.After choosing the ATOM-SHAPE, click on APPLY to change the shape. This can also be done during the simulation.(3) Draw grainsYou can draw grains with the mouse, using different brush sizes and colors. The DRAW button activates drawing, the ERASE ALL button erases the screen and sets all the atoms to red, the BRUSH-SIZE slider controls the radius of the brush and the DRAW-COLOR chooser changes the numeric value of the drawing color.(4) Run simulationGO: runs the simulation continuouslyGO ONCE: runs the simulation, one step at a time.Simulation sizeWIDTH: x (horizontal) dimension of the sample.HEIGHT: y (vertical) dimension of the sampleSpecial featuresANNEALING-TEMP: 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.FRACTION-ELEMENT2: This slider controls the amount of dispersed second-phase particles throughout the sample. Those particles slow down or stop grain growth.Grain measurementMEASUREMENT-FREQUENCY: 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 MEASUREMENT-FREQUENCY is too large, and the user wants to evaluate grain size at a specific moment, this button can be used. Note that this does not alter the plot.Plots and monitorsGrain Size (log-log): Grain size vs. time, in a log-log scale. Under normal conditions (ANNEALING-TEMP = 0 and FRACTION-ELEMENT-2 = 0), this plot should be a straight line with an angular coefficient of approximately 0.5.SIMULATION TIME and LOG TIME: time steps of the simulation so far (and its log)GRAIN SIZE and LOG GRAIN SIZE: grain size (is atoms) and its log.GROWTH EXPONENT: the angular coefficient of the GRAIN SIZE plot. This number should approach 0.5 with ANNEALING-TEMP = 0 and FRACTION-ELEMENT2 = 0.THINGS TO NOTICE----------------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 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.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?