Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Computational materials science in Python: crystal lattices, diffraction, elasticity, phase diagrams, phase-field models and kinetics

School of Engineering, Nazarbayev University

A material followed from its unit cell to its microstructure and its selection for a design, with every method written out in NumPy and checked against an exact result.

The properties of a material are set at several length scales, and this book treats each by computing with it, in five parts. The first part starts from the unit cell: its metric tensor gives bond lengths, densities and packing fractions, its reciprocal lattice gives the spacing of planes, and the structure factor gives the powder diffraction pattern and the broadening of its peaks. The second part treats the elastic constants of cubic crystals and of polycrystals, crystals held together by a pair potential, vacancies and the stress needed to move a dislocation. The third part builds phase diagrams from models of the Gibbs energy and follows an alloy through solidification. The fourth part solves the Cahn–Hilliard and Allen–Cahn equations for the separation of a solution into two phases and for the motion of a boundary. The fifth part treats diffusion, the kinetics of transformations, creep life and the selection of materials, and closes with a project that connects the modules on a model alloy.

Each lecture is an executed Jupyter notebook of about one hour. It states the principle and its equations, works through four short demonstrations, and then repeats by hand the calculation of a function of the package that it has used. The notebooks share a small Python package, engmaterials, written to be read as much as to be used; its core needs NumPy alone. Each lecture has two numbered figures and ends with three exercises: one that verifies a result, one that looks for a way in which the method fails, and one that asks the reader to write a function. A worked solution to every exercise is given in the Worked solutions part of the book.

The material properties in the package are representative values typed in for the examples and are not reference data. Parameters of the models are labelled as assumed, and data that stand for measurements are synthetic: they are generated in the notebooks from stated laws, so that the answer is known and a method can be judged against it. The alloy of the closing project is a teaching model and not a real material.

The level is that of the final undergraduate year or the first year of graduate study in materials, chemical or mechanical engineering. The lectures assume calculus, linear algebra, a first course in thermodynamics, and Python with NumPy. Symbols are collected in Notation and conventions, a plan for a semester in the syllabus, the checks of the package in the validation report, and original papers and books for further study in Suggested references.

Part I. Crystal geometry, reciprocal space and X-ray diffraction

LectureTopics
0. Units, crystal densities and the element tableångström, electron volt and molar units; density and molar volume from the unit cell; the table of 14 elements; thermal expansion and density
1. Bravais lattices, metric tensors and packing fractionscubic and hexagonal cells; the metric tensor; neighbour shells and packing fractions; HCP away from the ideal axial ratio
2. Reciprocal lattices, Miller planes and Brillouin zonesreciprocal basis vectors; plane spacings in any lattice; the Brillouin zone of a hexagonal lattice; strain along one axis
3. X-ray diffraction, structure factors and systematic absencesBragg’s law; the structure factor; systematic absences of BCC, FCC, diamond and HCP; computed powder patterns; the choice of wavelength
4. Peak broadening: the Scherrer equation and the Williamson–Hall plotsize and strain broadening; why the single-peak Scherrer estimate is biased; the Williamson–Hall plot; instrumental broadening

Part II. Elasticity, pair potentials and defects

LectureTopics
5. Elasticity of cubic single crystals and the Zener ratiostiffness and compliance of a cubic crystal; Born stability; the Zener ratio; Young’s modulus as a function of direction
6. Polycrystals: Voigt–Reuss–Hill averages and the Pugh ratioVoigt, Reuss and Hill averages; the universal anisotropy index; the Pugh ratio and the Cauchy pressure
7. Pair potentials, lattice sums and the Cauchy relationLennard-Jones and Morse potentials; shifted-force cutoff; lattice sums for FCC, BCC and SC; elastic constants from lattice sums; the Cauchy relation
8. Vacancies and the Peierls–Nabarro stressequilibrium vacancy fraction; differential dilatometry on synthetic data; ideal shear strength; the Peierls–Nabarro stress and the choice of slip plane

Part III. Solution thermodynamics and solidification

LectureTopics
9. Regular and Redlich–Kister solutions and the spinodalregular solutions; Redlich–Kister terms; chemical potentials; the critical temperature and the spinodal
10. Common tangents, binodals and binary phase diagramsequality of chemical potentials; the common tangent as a lower convex hull; binodal and spinodal; liquidus and solidus of an ideal isomorphous system
11. The lever rule, eutectics and Scheil–Gulliver solidificationthe lever rule; primary and eutectic constituents; Scheil–Gulliver solidification; homogenization time

Part IV. Phase-field models of microstructure

LectureTopics
12. Diffuse interfaces and the linear theory of spinodal decompositionthe gradient-energy functional; the equilibrium interface profile and its energy; growth rate of a composition wave; explicit and semi-implicit time stepping
13. Spinodal decomposition and coarsening in two dimensionsa two-dimensional Cahn–Hilliard solver; interpenetrating domains and droplets; bulk and gradient energy; the domain size from the structure factor
14. The Allen–Cahn equation and motion by curvaturethe Allen–Cahn equation; motion by curvature; a shrinking circle; conserved against non-conserved coarsening

Part V. Diffusion, transformation kinetics and materials selection

LectureTopics
15. Carburization, the Crank–Nicolson method and Boltzmann–Matano analysisdiffusivities of carbon and iron in austenite (assumed Arrhenius parameters); the error-function profile; the Crank–Nicolson method; Boltzmann–Matano analysis
16. Transformation kinetics, creep life and materials selectionJMAK kinetics and the Avrami plot; a time–temperature–transformation curve; the Larson–Miller parameter; performance indices and a Pareto front
17. Project: a model alloy from lattice constant to Pareto fronta model alloy with assumed parameters followed from lattice constant to density, moduli, spinodal ageing, a yield-strength model and a Pareto front

Where to start

If you are…Read
reading a powder diffraction patternLectures 1 to 4
working with elastic constantsLectures 5 and 6
starting molecular simulation of solidsLectures 7 and 8
computing a phase diagramLectures 9 to 11
starting phase-field modellingLectures 12 to 14
short of timeLectures 3, 6, 10, 13 and 15

Companion books

Author and licence

Yanwei Wang, Department of Chemical and Materials Engineering, School of Engineering, Nazarbayev University, Astana, Kazakhstan (yanwei.wang@nu.edu.kz, ORCID 0000-0002-8488-9833). The code is under the MIT licence; the text, figures and notebook outputs are under CC BY 4.0. The source is at github.com/ktwyw/engmaterials.