My thesis needs thousands of simulations of a laser melting metal, enough to train a model that predicts microstructure from process parameters. With finite elements, one part-scale laser scan took 189 hours. So, with Andreas Ntinos and Manas Upadhyay, I wrote a solver that does it in under an hour.
The plan of my Ph.D. is to learn the link between laser parameters and the microstructure they produce. A machine learning model can do that, but it needs data, a lot of it, and experiments alone are too slow and too expensive. High-fidelity simulations could fill the gap if they were cheap. They are not: a single scan can take days on a CPU.
The temperature is written as a sum of cosine modes of the block. In that basis, plain heat diffusion is exact: each mode just decays at its own rate, so there is no big linear system to solve at each time step. Everything that makes the problem hard (conductivity that changes with temperature, melting, evaporation, the laser itself) goes into a forcing term that is updated by fixed-point iterations.
Moving between the modes and the grid is a discrete cosine transform. cuFFT does not provide one, so on the GPU I built it from CuPy's real FFT and a few custom CUDA kernels. Laser paths are read straight from G-code.
Every cosine mode has zero heat flux at the boundary. Our first intuition was therefore that this basis could never represent the laser heating the top surface, and that we needed a different one. That intuition was wrong. In the Galerkin formulation the surface flux enters through the boundary term, and the series still converges to the right temperature; it just needs more modes near the surface. Accepting that, and understanding why, was the most interesting part of the project for me.
On a single-pass laser scan, the solver stays within 0.67% of a fine finite element reference. On one core of a Ryzen 9 5900X, the finite element run took 189 hours; ours took 30.6 hours with ten times more degrees of freedom (25 million). On an NVIDIA Quadro RTX 5000 it took 50 minutes.
Then we ran something finite elements could not reasonably do: a whole plate of 6 × 6 cm, 1 mm thick, scanned island by island with 2,500 laser tracks of 0.5 cm. That is 20.8 seconds of scanning, and it took 3.82 hours on a single GPU. Including evaporation and latent heat more than halved a temperature-uniformity metric from the literature, so these effects cannot be left out when choosing scan strategies.
The code, the documentation and the examples are open source. These thermal histories are now the input for the microstructure models of my thesis.