Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
revised docs
  • Loading branch information
tkphd committed Apr 26, 2019
1 parent 8ddcec7 commit 80b570d
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 125 deletions.
168 changes: 58 additions & 110 deletions README.md
@@ -1,7 +1,7 @@
# Phase field precipitate aging model

Phase field model for precipitate aging in ternary analogues to Ni-based superalloys.
Please cite using the following DOI:
Phase field model for precipitate aging in ternary analogues to Ni-based
superalloys. Please cite using the following DOI:

[![DOI](https://zenodo.org/badge/80764108.svg)](https://zenodo.org/badge/latestdoi/80764108)

Expand All @@ -17,30 +17,35 @@ Please cite using the following DOI:

## Background

This repository contains a phase-field model for solid-state transformations in
Inconel 625 based on [Zhou *et al.*](#zhou-2014), which is a ternary generalization
of the binary [KKS model](#kim-1999).

To capture δ, μ, and Laves precipitates in a γ matrix, I have
chosen Ni–30%Cr–2%Nb as the model system. The interdendritic regions in
additive manufacturing get enriched to Ni–31%Cr–13%Nb.
The four-phase three-component model is represented using two composition fields
(Cr and Nb) and three phase fields (δ, μ, and Laves). There is one
dependent composition (Ni) and one dependent phase (γ).
This repository contains a phase-field model for solid-state
transformations in Inconel 625 based on [Zhou *et al.*](#zhou-2014), which
involves a ternary generalization of the binary [KKS model](#kim-1999).

To capture δ and λ intermetallic precipitates in a γ matrix, I have chosen the
ternary Cr-Nb-Ni system. The three-phase three-component model is represented
using two composition fields (Cr and Nb) and two phase fields (δ and λ). There
is one dependent composition (Ni) and one dependent phase (γ). Based on
[ASTM F3056](#astm-f3056), combining Cr with Mo under the assumption that their
influences on the alloy are similar, this codebase considers system compositions
between (Ni--0.0202 Nb--0.2794 Cr) and (Ni--0.0269 Nb--0.3288 Cr), expressed as
molar fractions. Based on [DICTRA simulations](#keller-2018), this work
considers enrichment of interdendritic regions to compositions between
(Ni--0.1659 Nb--0.2473 Cr) and (Ni--0.1726 Nb--0.2967 Cr).

Free energies for each constituent phase are computed using a CALPHAD database,
simplified from [Du *et al.*](#du-2005) to enable one-to-one mapping of sublattice
compositions to system compositions. This database is provided in
[Du_Cr-Nb-Ni_simple.tdb](Du_Cr-Nb-Ni_simple.tdb). The CALPHAD expressions are
further simplified using 2<sup>nd</sup>-order Taylor series (paraboloid)
approximations.
simplified from [Du *et al.*](#du-2005) to enable one-to-one mapping of
sublattice compositions to system compositions. This modified database is
[provided](Du_Cr-Nb-Ni_simple.tdb). The CALPHAD expressions are further
simplified using 2<sup>nd</sup>-order Taylor series (paraboloid) approximations.

Further details are provided in [src/README](src/README.md) and
[thermo/README](thermo/README.md).

## Install

This repository contains Python code to handle the CALPHAD database and C++
code to perform the phase-field simulation. A Python 3 interpreter and
C++11 compiler are recommended. You will need to satisfy the following
dependencies:
This repository contains Python code to handle the CALPHAD database and C++ code
to perform the phase-field simulation. A Python 3 interpreter and C++11 compiler
are recommended. You will need to satisfy the following dependencies:

- Python
- [Cloudpickle](https://github.com/cloudpipe/cloudpickle)
Expand All @@ -54,10 +59,9 @@ dependencies:
- C++
- [CUDA](https://developer.nvidia.com/cuda-toolkit)
- [MMSP](https://github.com/mesoscale/mmsp)

After downloading MMSP, the core dependency of this model implementation,
please set the environmental variable `MMSP_PATH` to its location. If
you are using `bash`, do something similar to

After downloading MMSP, please set the environmental variable `MMSP_PATH`
to its location. If you are using `bash`, do something similar to

```bash
$ echo "MMSP_PATH=~/Downloads/mmsp" >> ~/.bashrc
Expand All @@ -69,16 +73,10 @@ documentation.

## Usage

1. `cd thermo; python CALPHAD_energies.py; python nucleation.py` This
will use pycalphad to read the database and extract expressions, which
are then manipulated and written into C-code by SymPy.
2. `make` (OpenMP, Nvidia CUDA compiler). This will compile the source
code into a binary, `alloy625`.
3. Run the code. Since your executable is built against
`MMSP.main.hpp`, the options of that program apply to your binary.
For usage suggestions, run `./alloy625 --help` or `./serial
--help` or `mpirun -np 1 parallel --help`, depending on which
executable you built. A typical MMSP run comprises two steps:
2. `make`. This will compile the source code into a binary, `src/alloy625`.
3. Run the code. Since your executable is built against `MMSP.main.hpp`,
the options of that program apply to your binary. For usage suggestions,
run `./alloy625 --help`. A typical MMSP run comprises two steps:
initialization and update loops. So you would normally do:
- `./alloy625 --example 2 data.dat`
- `./alloy625 data.dat 10000000 1000000`
Expand All @@ -87,66 +85,6 @@ documentation.
results.
4. Remix, run, and analyze your own variants.

## Details

Due to the paraboloid free energy representation, we can leverage the
[HiPerC](https://github.com/usnistgov/hiperc) project to implement the
equations of motion on the GPU using CUDA.

### Workflow

#### `MMSP::generate()`

Initial conditions are generated using the existing MMSP code, and written to a
compressed MMSP checkpoint, with no work assigned to the GPU.

#### Initialization

1. `main.cpp` was adapted from MMSP, rather than HiPerC.
2. The initial condition checkpoint gets read back into an MMSP::grid
object.
3. The Laplacian kernel gets written into const cache on the GPU.
4. 12 device arrays get allocated on the GPU: one old and one new for each
field variable.
1. `x_Cr`
2. `x_Nb`
3. `phi_del`
4. `phi_lav`
5. `x_gam_Cr`
6. `x_gam_Nb`
5. 12 identical host arrays get allocated on the CPU.

#### `MMSP::update()`

##### Before timestepping:

1. Data gets read from the MMSP::grid into the host arrays.
2. Data gets copied from the host to device arrays.

##### For each iteration:

1. Boundary conditions get applied on each of the "old" device arrays.
2. Laplacian values gets computed and recorded in each of the "new" arrays.
3. Boundary conditions get applied on each of the "new" device arrays.
4. Updated field values get computed from the "old" and "new" device
arrays.
5. Fictitious matrix phase compositions get computed and written into the
"new" device array.
6. At a fixed interval, stochastic nucleation occurs based on the local
composition and using an order-parameter-only model.

##### After timestepping:

1. Data gets copied from the 6 "new" device arrays into the corresponding
host arrays.
2. Data gets read from the host arrays into the MMSP::grid object.
3. The MMSP::grid object gets written to a compressed MMSP checkpoint.

### Cleanup

Arrays get freed from the host and device once the last checkpoint is
written.

## Contribute

Pull requests are welcome! Comments are also appreciated via
Expand All @@ -155,33 +93,46 @@ and [e-mail](mailto:trevor.keller@nist.gov).

## References

### ASTM F3056

"Standard Specification for Additive Manufacturing Nickel Alloy (UNS N06625)
with Powder Bed Fusion."
URL: https://www.astm.org/Standards/F3056.htm

### Du 2005

Du, Y.; Liu, S.; Chang, Y. and Yang, Y.
"A thermodynamic modeling of the Cr–Nb–Ni system."
*Calphad* **29** (2005) 140–148.
DOI: [10.1016/j.calphad.2005.06.001](http://dx.doi.org/10.1016/j.calphad.2005.06.001)
DOI: [10.1016/j.calphad.2005.06.001](https://doi.org/10.1016/j.calphad.2005.06.001)

### Jokisaari 2016

Jokisaari, A.M.; Permann, C.; Thornton, K.
"A nucleation algorithm for the coupled conserved-nonconserved phase field model."
*Computational Materials Science* **112** (2016) 128–138.
DOI: [10.1016/j.commatsci.2015.10.009](http://dx.doi.org/10.1016/j.commatsci.2015.10.009)
DOI: [10.1016/j.commatsci.2015.10.009](https://doi.org/10.1016/j.commatsci.2015.10.009)

### Karunaratne 2005

Karunaratne, M. S. A. and Reed, R. C.
"Interdiffusion of Niobium and Molybdenum in Nickel between 900 - 1300&deg;C."
*Defect and Diffusion Forum* **237-240** (2005) 420–425.
DOI: [10.4028/www.scientific.net/DDF.237-240.420](https://doi.org/10.4028/www.scientific.net/DDF.237-240.420)

### Kim 1999

Kim, S. G.; Kim, W. T. and Suzuki, T.
"Phase-field model for binary alloys."
*Physical Review E* **60** (1999) 7186–7197.
DOI: [10.1103/PhysRevE.60.7186](http://dx.doi.org/10.1103/PhysRevE.60.7186)
DOI: [10.1103/PhysRevE.60.7186](https://doi.org/10.1103/PhysRevE.60.7186)

### Karunaratne 2005
### Keller 2018

Karunaratne, M. S. A. and Reed, R. C.
"Interdiffusion of Niobium and Molybdenum in Nickel between 900 - 1300&deg;C."
*Defect and Diffusion Forum* **237-240** (2005) 420–425.
DOI: [10.4028/www.scientific.net/DDF.237-240.420](http://dx.doi.org/10.4028/www.scientific.net/DDF.237-240.420)
Keller, T.; Lindwall, G.; Ghosh, S.; Ma, L.; Lane, B.; Zhang, F.; Kattner, U.; Lass, E.; Heigel, J.; Idell, Y.; Williams, M.; Allen, A.; Guyer, J.; and Levine, L.
"Application of finite element, phase-field, and CALPHAD-based methods to additive manufacturing of Ni-based superalloys."
*Acta Materialia* **139** (2018) 244-253.
DOI: [10.1016/j.actamat.2017.05.003](https://doi.org/10.1016/j.actamat.2017.05.003)

### Provatas 2010

Expand All @@ -194,22 +145,19 @@ and [e-mail](mailto:trevor.keller@nist.gov).
Xu, G.; Liu, Y. and Kang, Z.
"Atomic Mobilities and Interdiffusivities for fcc Ni-Cr-Nb Alloys."
*Metallurgical Transactions B* **47B** (2016) 3126–3131.
DOI: [10.1007/s11663-016-0726-6](http://dx.doi.org/10.1007/s11663-016-0726-6)
DOI: [10.1007/s11663-016-0726-6](https://doi.org/10.1007/s11663-016-0726-6)

### Zhou 2014

Zhou, N.; Lv, D.; Zhang, H.; McAllister, D.; Zhang, F.; Mills, M. and
Wang, Y. "Computer simulation of phase transformation and plastic
deformation in IN718 superalloy: Microstructural evolution during
precipitation." *Acta Materialia* **65** (2014) 270–286. DOI:
[10.1016/j.actamat.2013.10.069](http://dx.doi.org/10.1016/j.actamat.2013.10.069)
[10.1016/j.actamat.2013.10.069](https://doi.org/10.1016/j.actamat.2013.10.069)

## License

As a work of the United States Government, this software is in the public
domain within the United States.

### Derivative Works
See [LICENSE](LICENSE.md).

The source files (`.py`, `.hpp`, and `.cpp`) in this repository
were written by an employee of the United States federal government in the
Expand All @@ -218,4 +166,4 @@ They are public domain. However, the Mesoscale Microstructure Simulation
Project (MMSP) is subject to the General Public License v3.0, and this
software `#include`s major aspects of that work. Therefore, if you are
not an employee of the US government, your derivative works will likely be
subject to the terms and conditions of the GPL.
subject to the terms and conditions of GPLv3.
12 changes: 12 additions & 0 deletions analysis/README.md
@@ -0,0 +1,12 @@
# Analysis Scripts

This directory contains several small programs to help with data conversion
and analysis.

- [adsorption](adsorption.cpp) computes the degree of solute adsorption to
the interface. For the KKS interfacial model, this ought to be zero; so
far, this has been borne out.
- [interface-composition](interface-composition.cpp) prints the composition
of points in γ-δ, δ-λ, and γ-λ interfaces extracted from MMSP grid data.
- [mmsp2comp](mmsp2comp.cpp) prints the compositions at every point in an MMSP grid.
- [mmsp2frac](mmsp2frac.cpp) computes the phase fractions from an MMSP grid.
37 changes: 22 additions & 15 deletions src/README.md
@@ -1,22 +1,25 @@
# CUDA precipitate-aging notes
# Precipitation Implementation Using CUDA

Due to the paraboloid free energy representation, we can leverage the
[HiPerC](https://github.com/usnistgov/hiperc) project to implement the
equations of motion on the GPU using CUDA.
equations of motion on the GPU using
[CUDA](https://developer.nvidia.com/cuda-downloads).

## Workflow

### `MMSP::generate()`

Initial conditions are generated using the existing MMSP code, and written to a
compressed MMSP checkpoint, with no work assigned to the GPU.
Initial conditions are generated using the existing MMSP code, and written
to a compressed MMSP checkpoint, with no work assigned to the GPU.

### Initialization

1. `main.cpp` was adapted from MMSP, rather than HiPerC.
2. The initial condition checkpoint gets read back into an MMSP::grid object.
2. The initial condition checkpoint gets read back into an `MMSP::grid`
object.
3. The Laplacian kernel gets written into const cache on the GPU.
4. 12 device arrays get allocated on the GPU: one old and one new for each field variable.
4. 12 device arrays get allocated on the GPU: one old and one new for each
field variable.
1. `x_Cr`
2. `x_Nb`
3. `phi_del`
Expand All @@ -29,26 +32,30 @@ compressed MMSP checkpoint, with no work assigned to the GPU.

#### Before timestepping:

1. Data gets read from the MMSP::grid into the host arrays.
1. Data gets read from the `MMSP::grid` into the host arrays.
2. Data gets copied from the host to device arrays.

#### For each iteration:

1. Boundary conditions get applied on each of the "old" device arrays.
2. Laplacian values gets computed and recorded in each of the "new" arrays.
3. Boundary conditions get applied on each of the "new" device arrays.
4. Updated field values get computed from the "old" and "new" device arrays.
5. Secondary phases are stochastically inserted into the "new" device arrays.
6. Fictitious matrix phase compositions get computed and written into the "new" device array.
4. Updated field values get computed from the "old" and "new" device
arrays.
5. Secondary phases are stochastically inserted into the "new" device
arrays.
6. Fictitious matrix phase compositions get computed and written into the
"new" device array.
7. Pointers to "old" and "new" arrays are swapped in the device.

#### After timestepping:

1. Data gets copied from the 6 "old" device arrays, holding the updated values,
into the "new" host arrays.
2. Data gets read from the host arrays into the MMSP::grid object.
3. The MMSP::grid object gets written to a compressed MMSP checkpoint.
1. Data gets copied from the 6 "old" device arrays, holding the updated
values, into the "new" host arrays.
2. Data gets read from the host arrays into the `MMSP::grid` object.
3. The `MMSP::grid` object gets written to a compressed MMSP checkpoint.

### Cleanup

Arrays gets freed from the host and device once the last checkpoint is written.
Arrays gets freed from the host and device once the last checkpoint is
written.

0 comments on commit 80b570d

Please sign in to comment.