Microstructure Simulation ========================= .. include:: ../shared.rst Introduction ------------ Grain growth during solidification is modeled using Cellular Automata (CA), as described in the paper by Lian et al. [lian2018parallelized]_. To enable the simulation of grain growth, set ``config.calcGrains`` to ``true``. The simulation consists of two main stages: initialization of grains in the substrate and/or powder (if necessary), and the actual grain growth during solidification. .. [lian2018parallelized] Yanping Lian et al. “A parallelized three-dimensional cellular automaton model for grain growth during additive manufacturing”. In: Computational Mechanics 61 (2018), pp. 543-558 Parameters Overview ------------------- The parameters in the :ref:`JSON file` that are used in the grain growth simulation are: In the ``config`` section: ``config.CalcGrains`` ``config.SolidificationCriterion`` ``config.StopIfGrainsLimitBoxReached`` In the ``sizes`` section: ``sizes.GrainsLimitBox`` In the substrate and the powder settings: ``Substrate.initialNucleiDensity`` ``Powder.initialNucleiDensity`` In the material description: ``Grains`` section Grains Setup ------------ Initial grains in the substrate can be generated automatically inside the Grains Limit Box during initialization if necessary, or loaded from the previous layer in multilayer simulations. Grain initialization in the substrate will be performed if the ``Substrate.initGeometryVDBfile`` field is empty. or, if it is not empty, it the substrate is given as a VDB file which does not contain a grid named ``GrainsType``. Otherwise, grains are initialized inside a virtual box with sizes specified by the parameter ``sizes.GrainsLimitBox``. .. figure:: ../images/grainspic.png :width: 800px Cross-section of the initial grain structure in the substrate. Each grain is depicted with a different color. The external region and grains extending beyond the limit box are grey. If the parameter ``config.StopIfGrainsLimitBoxReached`` is set to ``true``, the simulation will terminate immediately after the melt pool reaches the grain limit box boundary. The initial nuclei density in the substrate is specified by the parameter ``Substrate.initialNucleiDensity`` (:math:`m^{-3}`), and the average grain volume is :math:`1/\texttt{Substrate.initialNucleiDensity}`. The initial nuclei density in the powder is set by the parameter ``Powder.initialNucleiDensity`` (:math:`m^{-3}`). Note that the grain size cannot be larger than a single powder particle. All powder particles have different grains at the initialization if the parameter ``Powder.initialNucleiDensity`` is small enough. The default value for ``Powder.initialNucleiDensity`` is 0, i.e., each powder particle consists of one grain. In the simulation, the solidification can be performed either when the temperature falls below the threshold value (in the fluid model), or when the grain growth is completed (in the CA model). To solidify when the temperature falls below :math:`T_\text{solidus}` set the ``config.SolidificationCriterion`` parameter to ``"Temperature"``. To solidify when the grain growth is fully completed in a cell and it becomes solid according the grains CA algorithm set ``config.SolidificationCriterion`` to ``"GrainsCA"``. Nucleation ---------- If the ``config.calcGrains`` parameter is set to ``true``, the material in use must contain the ``Grains`` section. This section must have all necessary parameters, as shown in the example below: .. code:: { ... "MaterialsLibrary": { ... "MyNewMaterial": { ... "Grains": { "GrowthCoeffs" : [1.8e-5, 1.6e-5, 2.3e-6], "Nucleation" : { "Bulk" : { "Density": 1e15, "CriticalTdiff": [9.5,0.5] }, "Surface": { "Density": 2.5e8, "CriticalTdiff": [2,0.1] } } } } } The grain growth velocity (m/s) is :math:`v = K_1 \Delta T + K_2\Delta T^2 + K_3\Delta T^3` , where the coefficients :math:`K_1` is in m/s/K, :math:`K_2` is in m/s/K :math:`{}^2`, :math:`K_3` is in m/s/K³ and the temperature difference :math:`\Delta T = \max(T_{liquidus} - T, 0)` is in K. New grains can appear from nucleation during solidification. There are two types of nucleation: new nuclei can appear in the liquid material (homogeneous bulk nucleation) and on the surface. The nucleation density has a Gaussian distribution formed from undercooling :math:`\Delta T` and follows the law: .. math:: \cfrac{d n_{v,s}}{d(\Delta T)} = \cfrac{n_{{max}_{v,s}}}{\Delta T_{\sigma_{v,s}} \sqrt{2\pi}} \exp\left(-\left[\cfrac{(\Delta T-\overline{\Delta T_{v,s}})}{\sqrt{2}\Delta T_{\sigma_{v,s}}}\right]^2\right), The user must specify the values for both the bulk nucleation and the nucleation on the surface: :math:`n_\text{max}` in :math:`\text{m}^{-3}`, :math:`\overline{\Delta T}`, and :math:`\Delta T_\sigma` in K. Specifically: ``MaterialsLibrary.MyMaterial.Grains.Bulk.Density`` is :math:n_{max}$` for the bulk nucleation, ``MaterialsLibrary.MyMaterial.Grains.Bulk.CriticalTdiff`` is :math:`[\overline{\Delta T}, \Delta T_\sigma]` for bulk; ``MaterialsLibrary.MyMaterial.Grains.Surface.Density`` is the :math:`n_{max}` for the surface nucleation, ``MaterialsLibrary.MyMaterial.Grains.Surface.CriticalTdiff`` represents :math:`[\overline{\Delta T}, \Delta T_\sigma]` for the surface nucleation. Results ------- After the simulation, the results of the grains growth is written to the :file:`geometry.vdb` file. It is a file in the openVDB format which can be opened with third party software such as ParaView or `blender`_. When the grain growth is simulated, in the file, the are two additional grids for grains: ``GrainsDirection`` integer vector values ``GrainsType`` integer vales You can use the script :program:`drawCrossSection.x` :ref:`script ` which comes with KiSSAM to get the cross-section images with the grain structure. For example, if the scanning strategy is set to single track with starting position :math:`y=0.0005`: .. code:: >./drawCrossSection.x geometry.vdb ysec1-grains.png --sec y 0.5 --grains Or, to highlight grain boundaries .. code:: >./drawCrossSection.x geometry.vdb ysec1-grains.png --sec y 0.5 --grains --hl_bound_grains