Lettuce: PyTorch-Based Lattice Boltzmann Framework | SpringerLink
Skip to main content

Lettuce: PyTorch-Based Lattice Boltzmann Framework

  • Conference paper
  • First Online:
High Performance Computing (ISC High Performance 2021)

Abstract

The lattice Boltzmann method (LBM) is an efficient simulation technique for computational fluid mechanics and beyond. It is based on a simple stream-and-collide algorithm on Cartesian grids, which is easily compatible with modern machine learning architectures. While it is becoming increasingly clear that deep learning can provide a decisive stimulus for classical simulation techniques, recent studies have not addressed possible connections between machine learning and LBM. Here, we introduce Lettuce, a PyTorch-based LBM code with a threefold aim. Lettuce enables GPU accelerated calculations with minimal source code, facilitates rapid prototyping of LBM models, and enables integrating LBM simulations with PyTorch’s deep learning and automatic differentiation facility. As a proof of concept for combining machine learning with the LBM, a neural collision model is developed, trained on a doubly periodic shear layer and then transferred to a different flow, a decaying turbulence. We also exemplify the added benefit of PyTorch’s automatic differentiation framework in flow control and optimization. To this end, the spectrum of a forced isotropic turbulence is maintained without further constraining the velocity field. The source code is freely available from https://github.com/lettucecfd/lettuce.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
¥17,985 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
JPY 3498
Price includes VAT (Japan)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
JPY 11439
Price includes VAT (Japan)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
JPY 14299
Price includes VAT (Japan)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

References

  1. Bauer, M., et al.: waLBerla: a block-structured high-performance framework for multiphysics simulations. Comput. Math. with Appl. 81, 478–501 (2021)

    Article  MathSciNet  Google Scholar 

  2. Bhatnagar, P.L., Gross, E.P., Krook, M.: A model for collision processes in gases. I. Small amplitude processes in charged and neutral one-component systems. Phys. Rev. 94(3), 511–525 (1954)

    Article  Google Scholar 

  3. Brachet, M.E., Meiron, D.I., Orszag, S.A., Nickel, B., Morf, R.H., Frisch, U.: Small-scale structure of the Taylor-green vortex. J. Fluid Mech. 130, 411–452 (1983)

    Article  Google Scholar 

  4. Brown, D.L.: Performance of under-resolved two-dimensional incompressible flow simulations. J. Comput. Phys. 122(1), 165–183 (1995)

    Article  MathSciNet  Google Scholar 

  5. Chen, T., Wen, X., Wang, L.P., Guo, Z., Wang, J., Chen, S.: Simulation of three-dimensional compressible decaying isotropic turbulence using a redesigned discrete unified gas kinetic scheme. Phys. Fluids 32(12), 125104 (2020)

    Article  Google Scholar 

  6. Coreixas, C., Latt, J.: Compressible lattice Boltzmann methods with adaptive velocity stencils: an interpolation-free formulation. Phys. Fluids 32(11), 116102 (2020)

    Article  Google Scholar 

  7. Dellar, P.J.: Incompressible limits of lattice Boltzmann equations using multiple relaxation times. J. Comput. Phys. 190(2), 351–370 (2003)

    Article  MathSciNet  Google Scholar 

  8. Diwan, S.S., Ravichandran, S., Govindarajan, R., Narasimha, R.: Understanding transmission dynamics of Covid-19-type infections by direct numerical simulations of cough/sneeze flows. Trans. Indian Natl. Acad. Eng. 5, 255–261 (2020)

    Article  Google Scholar 

  9. Fabregat, A., Gisbert, F., Vernet, A., Dutta, S., Mittal, K., Pallarès, J.: Direct numerical simulation of the turbulent flow generated during a violent expiratory event. Phys. Fluids 33(3), 035122 (2021)

    Article  Google Scholar 

  10. Font, B., Weymouth, G.D., Nguyen, V.T., Tutty, O.R.: Deep learning of the spanwise-averaged Navier-Stokes equations. J. Comput. Phys. 434, 110199 (2021)

    Article  MathSciNet  Google Scholar 

  11. Frapolli, N., Chikatamarla, S.S., Karlin, I.V.: Entropic lattice Boltzmann model for compressible flows. Phys. Rev. E Stat. Nonlinear Soft Matter Phys. 92(6), 061301 (2015)

    Article  Google Scholar 

  12. Geier, M., Pasquali, A., Schönherr, M.: Parametrization of the cumulant lattice Boltzmann method for fourth order accurate diffusion. Part I: Derivation and validation. J. Comput. Phys. 348, 862–888 (2017)

    Article  MathSciNet  Google Scholar 

  13. Ginzburg, I., Verhaeghe, F., D’Humières, D.: Two-relaxation-time Lattice Boltzmann scheme: about parametrization, velocity, pressure and mixed boundary conditions. Commun. Comput. Phys. 3(2), 427–478 (2008)

    MathSciNet  Google Scholar 

  14. Godenschwager, C., Schornbaum, F., Bauer, M., Köstler, H., Rüde, U.: A framework for hybrid parallel flow simulations with a trillion cells in complex geometries. In: Proceedings of the International Conference for High Performance Computing, Networking, Storage and Analysis - SC 2013, New York, NY, USA, pp. 1–12. ACM Press (2013)

    Google Scholar 

  15. Hennigh, O.: Lat-Net: compressing lattice Boltzmann flow simulations using deep neural networks. arXiv preprint arXiv:1705.09036 (2017)

  16. Herrera, P.: pyevtk 1.2.0. PyPI (2021). https://pypi.org/project/pyevtk/

  17. Heuveline, V., Krause, M.J.: OpenLB: towards an efficient parallel open source library for lattice Boltzmann fluid flow simulations. In: International Workshop on State-of-the-Art in Scientific and Parallel Computing, PARA, vol. 9 (2010)

    Google Scholar 

  18. Karlin, I.V., Bösch, F., Chikatamarla, S.: Gibbs’ principle for the lattice-kinetic theory of fluid dynamics. Phys. Rev. E Stat. Nonlinear Soft Matter Phys. 90(3), 1–5 (2014)

    Article  Google Scholar 

  19. Kochkov, D., Smith, J.A., Alieva, A., Wang, Q., Brenner, M.P., Hoyer, S.: Machine learning accelerated computational fluid dynamics. Proc. Nat. Acad. Sci. 118(21), e2101784118 (2021).

    Google Scholar 

  20. Krämer, A., Wilde, D., Küllmer, K., Reith, D., Foysi, H.: Pseudoentropic derivation of the regularized lattice Boltzmann method. Phys. Rev. E 100(2), 023302 (2019)

    Article  Google Scholar 

  21. Krüger, T., Kusumaatmaja, H., Kuzmin, A., Shardt, O., Silva, G., Viggen, E.M.: The Lattice Boltzmann Method: Principles and Practice. Springer, Heidelberg (2017)

    Book  Google Scholar 

  22. Lallemand, P., Luo, L.S.: Theory of the lattice Boltzmann method: dispersion, dissipation, isotropy, Galilean invariance, and stability. Phys. Rev. E Stat. Phys. Plasmas Fluids Relat. Interdiscip. Top. 61(6), 6546–6562 (2000)

    MathSciNet  Google Scholar 

  23. Latt, J., Chopard, B.: Lattice Boltzmann method with regularized pre-collision distribution functions. Math. Comput. Simul. 72(2–6), 165–168 (2006)

    Article  MathSciNet  Google Scholar 

  24. Latt, J., Coreixas, C., Beny, J., Parmigiani, A.: Efficient supersonic flow simulations using lattice Boltzmann methods based on numerical equilibria. Philos. Trans. R. Soc. A Math. Phys. Eng. Sci. 378(2175), 20190559 (2020)

    Article  MathSciNet  Google Scholar 

  25. Latt, J., et al.: Palabos: parallel lattice Boltzmann solver. Comput. Math. Appl. 81, 334–350 (2021)

    Article  MathSciNet  Google Scholar 

  26. Lenz, S., et al.: Towards real-time simulation of turbulent air flow over a resolved urban canopy using the cumulant lattice Boltzmann method on a GPGPU. J. Wind Eng. Ind. Aerodyn. 189, 151–162 (2019)

    Article  Google Scholar 

  27. McNamara, G.R., Zanetti, G.: Use of the Boltzmann equation to simulate lattice-gas automata. Phys. Rev. Lett. 61(20), 2332–2335 (1988)

    Article  Google Scholar 

  28. Mora, P., Morra, G., Yuen, D.A.: A concise python implementation of the lattice Boltzmann method on HPC for geo-fluid flow. Geophys. J. Int. 220(1), 682–702 (2020)

    Article  Google Scholar 

  29. Obrecht, C., Kuznik, F., Tourancheau, B., Roux, J.J.: Scalable lattice Boltzmann solvers for CUDA GPU clusters. Parallel Comput. 39(6), 259–270 (2013)

    Article  MathSciNet  Google Scholar 

  30. Pastewka, L., Greiner, A.: HPC with python: an MPI-parallel implementation of the lattice Boltzmann method. In: Proceedings of the 5th bwHPC Symposium (2019)

    Google Scholar 

  31. Paszke, A., et al.: PyTorch: an imperative style, high-performance deep learning library. In: Wallach, H., Larochelle, H., Beygelzimer, A., D’Alché-Buc, F., Fox, E., Garnett, R. (eds.) Advances in Neural Information Processing Systems 32, pp. 8024–8035. Curran Associates, Inc. (2019)

    Google Scholar 

  32. Porté-Agel, F., Bastankhah, M., Shamsoddin, S.: Wind-turbine and wind-farm flows: a review. Boundary Layer Meteorol. 174(1), 1–59 (2020)

    Article  Google Scholar 

  33. Rüttgers, M., Koh, S.-R., Jitsev, J., Schröder, W., Lintermann, A.: Prediction of acoustic fields using a lattice-Boltzmann method and deep learning. In: Jagode, H., Anzt, H., Juckeland, G., Ltaief, H. (eds.) ISC High Performance 2020. LNCS, vol. 12321, pp. 81–101. Springer, Cham (2020)

    Chapter  Google Scholar 

  34. Saadat, M.H., Hosseini, S.A., Dorschner, B., Karlin, I.V.: Extended lattice Boltzmann model for gas dynamics. Phys. Fluids 33(4), 046104 (2021)

    Article  Google Scholar 

  35. Saadat, M.H., Bösch, F., Karlin, I.V.: Lattice Boltzmann model for compressible flows on standard lattices: variable Prandtl number and adiabatic exponent. Phys. Rev. E 99(1), 013306 (2019)

    Article  MathSciNet  Google Scholar 

  36. Sagaut, P.: Large Eddy Simulation for Incompressible Flows. An Introduction. Springer, Heidelberg (2006)

    MATH  Google Scholar 

  37. Samtaney, R., Pullin, D.I., Kosović, B.: Direct numerical simulation of decaying compressible turbulence and shocklet statistics. Phys. Fluids 13(5), 1415–1430 (2001)

    Article  Google Scholar 

  38. Schmieschek, S., et al.: LB3D: a parallel implementation of the lattice-Boltzmann method for simulation of interacting amphiphilic fluids. Comput. Phys. Commun. 217, 149–161 (2017)

    Article  MathSciNet  Google Scholar 

  39. Brunton, S.L., Noack, B.R., Koumoutsakos, P.: Machine learning for fluid mechanics. Annu. Rev. Fluid Mech. 52, 477–508 (2020)

    Article  Google Scholar 

  40. Um, K., Fei, Y.R., Holl, P., Brand, R., Thuerey, N.: Solver-in-the-loop: learning from differentiable physics to interact with iterative PDE-solvers. In: 34th Conference on Neural Information Processing Systems (NeurIPS 2020), Vancouver, Canada, vol. 1, no. c, pp. 1–37 (2020)

    Google Scholar 

  41. Wichmann, K.R., Kronbichler, M., Löhner, R., Wall, W.A.: A runtime based comparison of highly tuned lattice Boltzmann and finite difference solvers. Int. J. High Perform. Comput. Appl. (2021).

    Google Scholar 

  42. Wilcox, D.C.: Turbulence Modeling for CFD. DCW Industries, CA (1993)

    Google Scholar 

  43. Wilde, D., Krämer, A., Bedrunka, M., Reith, D., Foysi, H.: Cubature rules for weakly and fully compressible off-lattice Boltzmann methods. J. Comput. Sci. 51, 101355 (2021)

    Article  MathSciNet  Google Scholar 

  44. Wilde, D., Krämer, A., Reith, D., Foysi, H.: Semi-Lagrangian lattice Boltzmann method for compressible flows. Phys. Rev. E 101(5), 53306 (2020)

    Article  MathSciNet  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Andreas Krämer .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Bedrunka, M.C., Wilde, D., Kliemank, M., Reith, D., Foysi, H., Krämer, A. (2021). Lettuce: PyTorch-Based Lattice Boltzmann Framework. In: Jagode, H., Anzt, H., Ltaief, H., Luszczek, P. (eds) High Performance Computing. ISC High Performance 2021. Lecture Notes in Computer Science(), vol 12761. Springer, Cham. https://doi.org/10.1007/978-3-030-90539-2_3

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-90539-2_3

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-90538-5

  • Online ISBN: 978-3-030-90539-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics