Skip to main content
Log in

Multiscale finite element calculations in Python using SfePy

  • Published:
Advances in Computational Mathematics Aims and scope Submit manuscript

Abstract

SfePy (simple finite elements in Python) is a software for solving various kinds of problems described by partial differential equations in one, two, or three spatial dimensions by the finite element method. Its source code is mostly (85%) Python and relies on fast vectorized operations provided by the NumPy package. For a particular problem, two interfaces can be used: a declarative application programming interface (API), where problem description/definition files (Python modules) are used to define a calculation, and an imperative API, that can be used for interactive commands, or in scripts and libraries. After outlining the SfePy package development, the paper introduces its implementation, structure, and general features. The components for defining a partial differential equation are described using an example of a simple heat conduction problem. Specifically, the declarative API of SfePy is presented in the example. To illustrate one of SfePy’s main assets, the framework for implementing complex multiscale models based on the theory of homogenization, an example of a two-scale piezoelastic model is presented, showing both the mathematical description of the problem and the corresponding code.

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

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Abdulle, A., Nonnenmacher, A.: A short and versatile finite element multiscale code for homogenization problems. Comput. Methods Appl. Mech. Eng. 198(37), 2839–2859 (2009). https://doi.org/10.1016/j.cma.2009.03.019

    Article  MathSciNet  MATH  Google Scholar 

  2. Allaire, G.: Homogenization and two-scale convergence. SIAM J. Math. Anal. 23, 1482–1518 (1992). https://doi.org/10.1137/0523084

    Article  MathSciNet  MATH  Google Scholar 

  3. Alnaes, M.S., Blechta, J., Hake, J., Johansson, A., Kehlet, B., Logg, A., Richardson, C., Ring, J., Rognes, M.E., Wells, G.N.: The FEniCS project version 1.5. Arch. Numer. Softw. 3, 9–23. https://doi.org/10.11588/ans.2015.100.20553 (2015)

  4. Alowayyed, S., Groen, D., Coveney, P.V., Hoekstra, A.G.: Multiscale computing in the exascale era. J. Comput. Sci. 22, 15–25 (2017). https://doi.org/10.1016/j.jocs.2017.07.004

    Article  Google Scholar 

  5. Amaya, M., Morten, J.P., Boman, L.: A low-rank approximation for large-scale 3D controlled-source electromagnetic gauss-newton inversion. Geophysics 81(3), 211–225. https://doi.org/10.1190/geo2015-0079.1 (2016)

  6. Balay, S., Abhyankar, S., Adams, M., Brown, J., Brune, P., Buschelman, K., Dalcin, L., Dener, A., Eijkhout, V., Gropp, W., Kaushik, D., Knepley, M., May, D., Curfman McInnes, L., Mills, R., Munson, T., Rupp, K., Sanan, P., Smith, B., Zampini, S., Zhang, H., Zhang, H.: PETSc users manual. Tech. Rep. ANL-95/11 - Revision 3.10, Argonne National Laboratory. http://www.mcs.anl.gov/petsc, accessed 25 September 2018 (2018)

  7. Balzani, D., Gandhi, A., Klawonn, A., Lanser, M., Rheinbach, O., Schröder, J: One-way and fully-coupled FE2 methods for heterogeneous elasticity and plasticity problems: parallel scalability and an application to thermo-elastoplasticity of dual-phase steels. In: Bungartz, H.J., Neumann, P., Nagel, W.E. (eds.) Software for Exascale Computing - SPPEXA 2013-2015, Springer International Publishing, Lecture Notes in Computational Science and Engineering, pp 91–112 (2016)

  8. Borden, M.J., Scott, M.A., Evans, J.A., Hughes, T.J.R.: Isogeometric finite element data structures based on Bezier extraction of NURBS. Int. J. Numer. Meth. Eng. 87, 15–47 (2011). https://doi.org/10.1002/nme.2968

    Article  MATH  Google Scholar 

  9. Borgdorff, J., Mamonski, M., Bosak, B., Kurowski, K., Ben Belgacem, M., Chopard, B., Groen, D., Coveney, P.V., Hoekstra, A.G.: Distributed multiscale computing with muscle 2, the multiscale coupling library and environment. J. Comput. Sci. 5(5), 719–731 (2014). https://doi.org/10.1016/j.jocs.2014.04.004

    Article  Google Scholar 

  10. Bradshaw, R., Behnel, S., Seljebotn, D.S., Ewing, G., et al.: The Cython compiler. http://cython.org, Accessed 25 September 2018 (2018)

  11. Brough, D.B., Wheeler, D., Kalidindi, S.R.: Materials knowledge systems in python—a data science framework for accelerated development of hierarchical materials. Integ. Mater. Manuf. Innov. 6(1), 36–53 (2017). https://doi.org/10.1007/s40192-017-0089-0

    Article  Google Scholar 

  12. Chopard, B., Borgdorff, J., Hoekstra, A.G.: A framework for multi-scale modelling. Philos. Trans. R. Soc. A Math. Phys. Eng. Sci. 372(2021), 20130378 (2014). https://doi.org/10.1098/rsta.2013.0378

    Article  Google Scholar 

  13. Cimrman, R.: Enhancing sfepy with isogeometric analysis. arXiv:http://arXiv.org/abs/1412.6407 (2014)

  14. Cimrman, R., Lukeš, V.: SfePy 2018.3 sources and heat conduction examples demonstrating declarative and imperative APIs of SfePy. https://zenodo.org/record/1434071. https://doi.org/10.5281/zenodo.1434071 (2018)

  15. Cimrman, R., Rohan, E.: On modelling the parallel diffusion flow in deforming porous media. Math. Comput. Simul. 76(1–3), 34–43 (2007). https://doi.org/10.1016/j.matcom.2007.01.034

    Article  MathSciNet  MATH  Google Scholar 

  16. Cimrman, R., Rohan, E.: Two-scale modeling of tissue perfusion problem using homogenization of dual porous media. Int. J. Multiscale. Com. 8(1), 81–102 (2010). https://doi.org/10.1615/IntJMultCompEng.v8.i1.70

    Article  Google Scholar 

  17. Cimrman, R., Novák, M., Kolman, R., Tůma, M., Plešek, P., Vackář, J.: Convergence study of isogeometric analysis based on Bézier extraction in electronic structure calculations. Appl. Math. Comput. 319, 138–152 (2018a). https://doi.org/10.1016/j.amc.2017.02.023

    MathSciNet  MATH  Google Scholar 

  18. Cimrman, R., Novák, M., Kolman, R., Tůma, M., Vackář, J.: Isogeometric analysis in electronic structure calculations. Math. Comput. Simulat. 145, 125–135 (2018b). https://doi.org/10.1016/j.matcom.2016.05.011

    Article  MathSciNet  MATH  Google Scholar 

  19. Cioranescu, D., Donato, P.: An introduction to homogenization. No. 17 in Oxford Lecture Series in mathematics and its applications. Oxford University Press, Oxford (1999)

    Google Scholar 

  20. Cioranescu, D., Damlamian, A., Griso, G.: The periodic unfolding method in homogenization. SIAM J. Math. Anal. 40(4), 1585–1620 (2008). https://doi.org/10.1137/080713148

    Article  MathSciNet  MATH  Google Scholar 

  21. Cottrell, J.A., Hughes, T.J.R., Bazilevs, Y.: Isogeometric analysis: toward integration of CAD and FEA. New York, Wiley (2009)

    Book  MATH  Google Scholar 

  22. Dalcin, L., Paz, R., Kler, P., Cosimo, A.: Parallel distributed computing using Python. Adv. Water Resour. 34(9), 1124–1139 (2011a). https://doi.org/10.1016/j.advwatres.2011.04.013

    Article  Google Scholar 

  23. Dalcin, L., Collier, N., Vignal, P., Cortes, A., Calo, V.: Petiga: a framework for high-performance isogeometric analysis. Comput. Method Appl. M, 308(C), 151–181. https://doi.org/10.1016/j.cma.2016.05.011 (2016)

  24. Dalcin, L.D., Paz, R.R., Kler, P.A., Cosimo, A.: Parallel distributed computing using Python. Adv. Water Resour. 34(9), 1124–1139 (2011b). https://doi.org/10.1016/j.advwatres.2011.04.013

    Article  Google Scholar 

  25. Davis, T.A.: Algorithm 832: UMFPACK, an unsymmetric-pattern multifrontal method. ACM T Math. Softw. 30(2), 196–199 (2004). https://doi.org/10.1145/992200.992206

    Article  MathSciNet  MATH  Google Scholar 

  26. Falcone, J.L., Chopard, B., Hoekstra, A.: MML: towards a multiscale modeling language. Procedia Comput. Sci. 1(1), 819–826 (2010). https://doi.org/10.1016/j.procs.2010.04.089

    Article  Google Scholar 

  27. Geers, M.G.D., Kouznetsova, V.G., Matouš, K., Yvonnet, J.: Homogenization Methods and Multiscale Modeling: Nonlinear Problems, Wiley, Ltd, p. 1–34. https://doi.org/10.1002/9781119176817.ecm2107 (2017)

  28. Geus, R., Wheeler, D., Orban, D.: Pysparse documentation. http://pysparse.sourceforge.net, Accessed 25 September 2018 (2018)

  29. de Geus, T.W.J., Vondřejc, J., Zeman, J., Peerlings, R.H.J., Geers, M.G.D.: Finite strain fft-based non-linear solvers made simple. Comput. Methods Appl. Mech. Eng. 318, 412–430 (2017). https://doi.org/10.1016/j.cma.2016.12.032

    Article  MathSciNet  Google Scholar 

  30. git: The git project web site. https://git-scm.com, Accessed 25 September 2018 (2018)

  31. github: Github web site. https://github.com, Accessed 25 September 2018 (2018)

  32. Group TH: Hierarchical data format version 5. http://www.hdfgroup.org/HDF5, Accessed 25 September 2018 (2018)

  33. Henderson, A.: ParaView guide, a parallel visualization application. Kitware Inc, New York (2007)

    Google Scholar 

  34. Hunter, J.D.: Matplotlib: A 2D graphics environment. Comput. Sci. Eng. 9 (3), 90–95 (2007). https://doi.org/10.1109/MCSE.2007.55

    Article  Google Scholar 

  35. Jones, E., Oliphant, T.E., Peterson, P., et al.: SciPy: open source scientific tools for Python. http://www.scipy.org, Accessed 25 September 2018 (2018)

  36. Kitware, Inc: The Visualization Toolkit User’s Guide. Kitware, Inc. Publishers., iSBN 1-930934-18-1 (2010)

  37. Kochová, P., Cimrman, R., Stengl, M., Ošťádal, B., Tonar, Z.: A mathematical model of the carp heart ventricle during the cardiac cycle. J. Theor. Bio. 373, 12–25 (2015). https://doi.org/10.1016/j.jtbi.2015.03.014

    Article  MathSciNet  MATH  Google Scholar 

  38. Kondov, I., Surmann, G. (eds.): Multiscale modelling methods for applications in materials science: CECAM tutorial, 16 - 20 September 2013, Forschungszentrum Jülich; lecture notes. Schriften des Forschungszentrums Jülich IAS series, Forschungszentrum, Zentralbibliothek (2013)

  39. Logg, A.: Efficient representation of computational meshes. Int. J. Comput. Sci. Eng. 4(4), 283–295 (2009). https://doi.org/10.1504/IJCSE.2009.029164

    Google Scholar 

  40. Matouš, K., Geers, M.G., Kouznetsova, V.G., Gillman, A.: A review of predictive nonlinear theories for multiscale modeling of heterogeneous materials. J. Comput. Phys. 330, 192–220 (2017). https://doi.org/10.1016/j.jcp.2016.10.070

    Article  MathSciNet  Google Scholar 

  41. Meurer, A., Smith, C.P., Paprocki, M., Čertík, O., Kirpichev, S.B., Rocklin, M., Kumar, A., Ivanov, S., Moore, J.K., Singh, S., Rathnayake, T., Vig, S., Granger, B.E., Muller, R.P., Bonazzi, F., Gupta, H., Vats, S., Johansson, F., Pedregosa, F., Curry, M.J., Terrel, A.R., Roučka, Š., Saboo, A., Fernando, I., Kulal, S., Cimrman, R., Scopatz, A.: Sympy: symbolic computing in Python. Peer J. Comput. Sci. 3, e103 (2017). https://doi.org/10.7717/peerj-cs.103

    Article  Google Scholar 

  42. Miller, R.E., Tadmor, E.B.: A unified framework and performance benchmark of fourteen multiscale atomistic/continuum coupling methods. Model. Simul. Mater. Sci. Eng. 17(5), 053001 (2009). https://doi.org/10.1088/0965-0393/17/5/053001

    Article  Google Scholar 

  43. Mosby, M., Matouš, K.: Hierarchically parallel coupled finite strain multiscale solver for modeling heterogeneous layers: hierarchically parallel multiscale solver. Int. J. Numer. Methods Eng. 102(3–4), 748–765 (2015). https://doi.org/10.1002/nme.4755

    Article  MATH  Google Scholar 

  44. Moulinec, H., Suquet, P.: A fast numerical method for computing the linear and nonlinear mechanical properties of composites. Comptes Rendus de l’Académie des Sciences 318(11), 1417–1423 (1994). série II, Mécanique, physique, chimie, astronomie

    MATH  Google Scholar 

  45. Muntean, A., Chalupecky, V.: Homogenization Method and Multiscale Modeling MI Lecture Note Series, Faculty of Mathematics, Kyushu University (2011)

  46. Oliphant, T.E.: Python for scientific computing. Comput. Sci. Eng. 9(3), 10–20 (2007)

    Article  Google Scholar 

  47. Patzák, B., Rypl, D., Kruis, J.: Mupif – a distributed multi-physics integration tool. Adv. Eng. Softw. 60–61, 89–97 (2013). https://doi.org/10.1016/j.advengsoft.2012.09.005

    Article  Google Scholar 

  48. pytables: Pytables web site. https://www.pytables.org, Accessed 25 September 2018 (2018)

  49. Ramachandran, P., Varoquaux, G.: Mayavi: 3d visualization of scientific data. Comput. Sci. Eng. 13(2), 40–51 (2011). https://doi.org/10.1109/MCSE.2011.35

    Article  Google Scholar 

  50. Rathgeber, F., Ham, D., Mitchell, L., Lange, M., Luporini, F., Mcrae, A., Bercea, G.T., Markall, G., Kelly, P.: Firedrake: automating the finite element method by composing abstractions. ACM T Math. Softw. 43(3), 24:1–24:27 (2016). https://doi.org/10.1145/2998441

    Article  MathSciNet  MATH  Google Scholar 

  51. Rohan, E., Cimrman, R.: Multiscale FE simulation of diffusion-deformation processes in homogenized dual-porous media. Math Comput. Simul. 82 (10), 1744–1772 (2012). https://doi.org/10.1016/j.matcom.2011.02.011

    Article  MathSciNet  MATH  Google Scholar 

  52. Rohan, E., Lukeš, V.: Homogenization of the vibro–acoustic transmission on perforated plates. arXiv:http://arXiv.org/abs/1901.00202 [physics.comp-ph] (2019)

  53. Rohan, E., Lukeš, V.: Homogenization of the acoustic transmission through a perforated layer. J. Comput. Appl. Math 234(6), 1876–1885 (2010). https://doi.org/10.1016/j.cam.2009.08.059

    Article  MathSciNet  MATH  Google Scholar 

  54. Rohan, E., Lukeš, V.: Homogenization of the fluid-saturated piezoelectric porous media. Int. J. Solids Struct. 147, 110–125 (2018). https://doi.org/10.1016/j.ijsolstr.2018.05.017

    Article  Google Scholar 

  55. Rohan, E., Miara, B.: Band gaps and vibration of strongly heterogeneous Reissner-Mindlin elastic plates. C R Math 349(13–14), 777–781 (2011). https://doi.org/10.1016/j.crma.2011.05.013

    Article  MathSciNet  MATH  Google Scholar 

  56. Rohan, E., Cimrman, R., Lukeš, V.: Numerical modelling and homogenized constitutive law of large deforming fluid saturated heterogeneous solids. Comput. Struct. 84(17–18), 1095–1114 (2006). https://doi.org/10.1016/j.compstruc.2006.01.008

    Article  MathSciNet  Google Scholar 

  57. Rohan, E., Cimrman, R., Naili, S., Lemaire, T.: Multiscale modelling of compact bone based on homogenization of double porous medium. In: Computational plasticity x - fundamentals and applications (2009a)

  58. Rohan, E., Miara, B., Seifrt, F.: Numerical simulation of acoustic band gaps in homogenized elastic composites. Int. J. Eng. Sci. 47(4), 573–594 (2009b). https://doi.org/10.1016/j.ijengsci.2008.12.003

    Article  MATH  Google Scholar 

  59. Rohan, E., Naili, S., Cimrman, R., Lemaire, T.: Hierarchical homogenization of fluid saturated porous solid with multiple porosity scales. C R Mecanique 340(10), 688–694 (2012a). https://doi.org/10.1016/j.crme.2012.10.022

    Article  Google Scholar 

  60. Rohan, E., Naili, S., Cimrman, R., Lemaire, T.: Multiscale modeling of a fluid saturated medium with double porosity: relevance to the compact bone. J. Mech. Phys. Solids 60(5), 857–881 (2012b). https://doi.org/10.1016/j.jmps.2012.01.013

    Article  MathSciNet  Google Scholar 

  61. Schneider, M., Ospald, F., Kabel, M.: Computational homogenization of elasticity on a staggered grid. Int. J. Numer. Methods Eng. 105(9), 693–720 (2016). https://doi.org/10.1002/nme.5008

    Article  MathSciNet  Google Scholar 

  62. scikit-umfpack: skikit-umfpack web site. https://github.com/scikit-umfpack/scikit-umfpack, Accessed 25 September 2018 (2018)

  63. sfepy: The SfePy project web site. http://sfepy.org, Accessed 25 September 2018 (2018)

  64. Solin, P., Segeth, K., Dolezel, I.: Higher-order finite element methods. CRC Press, Boca Raton (2003)

    Book  Google Scholar 

  65. sphinx: Sphinx web site. http://www.sphinx-doc.org, Accessed 25 September 2018 (2018)

  66. Talebi, H., Silani, M., Bordas, S.P.A., Kerfriden, P., Rabczuk, T.: A computational library for multiscale modeling of material failure. Comput. Mech. 53(5), 1047–1071 (2014). https://doi.org/10.1007/s00466-013-0948-2

    Article  MathSciNet  Google Scholar 

  67. travis-ci: Travis-ci web site. https://travis-ci.org, Accessed 25 September 2018 (2018)

  68. Vackář, J., Čertík, O., Cimrman, R., Novák, M., Šipr, O., Plešek, J.: Advances in the Theory of Quantum Systems in Chemistry and Physics. Prog. T. Chem, vol. 22, Springer, chap Finite Element Method in Density Functional Theory Electronic Structure Calculations, pp. 199–217. https://doi.org/10.1007/978-94-007-2076-3_12 (2011)

  69. Wang, K., Sun, W.: A multiscale multi-permeability poroplasticity model linked by recursive homogenizations and deep learning. Comput. Methods Appl. Mech. Eng. 334, 337–380 (2018). https://doi.org/10.1016/j.cma.2018.01.036

    Article  MathSciNet  Google Scholar 

  70. Weinan, E., Engquist, B.: The heterogeneous multi-scale method for homogenization problems. In: Engquist, B., Runborg, O., Lötstedt, P. (eds.) Multiscale Methods in Science and Engineering, Springer Berlin Heidelberg, Lecture Notes in Computational Science and Engineering, pp 89–110 (2005)

  71. Wheeler, D., Brough, D., Fast, T., Kalidindi, S., Reid, A.: PYMKS: materials knowledge system in Python. https://doi.org/10.6084/m9.figshare.1015761.v2. https://figshare.com/articles/pymks/1015761 (2014)

  72. Wu, B., Du, X., Tan, H.: A three-dimensional FE nonlinear analysis of membranes. Comput. Struct. 59(4), 601–605 (1996). https://doi.org/10.1016/0045-7949(95)00283-9

    Article  MATH  Google Scholar 

  73. Zeman, J., de Geus, T.W.J., Vondřejc, J., Peerlings, R.H.J., Geers, M.G.D.: A finite element perspective on nonlinear FFT-based micromechanical simulations. Int. J. Numer. Methods Eng. 111(10), 903–926 (2017). https://doi.org/10.1002/nme.5481

    Article  MathSciNet  Google Scholar 

  74. Zemčík, R., Rolfes, R., Rose, M., Tessmer, J.: High-performance 4-node shell element with piezoelectric coupling. Mech. Adv. Mater Struct. 13 (5), 393–401 (2006). https://doi.org/10.1080/15376490600777657

    Article  MATH  Google Scholar 

Download references

Funding

This work was supported by the projects GA17-12925S (the first author) and GA19-04956S (the second author) of the Czech Science Foundation and by the project LO1506 of the Czech Ministry of Education, Youth and Sports (the third author).

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Robert Cimrman.

Additional information

Communicated by: Pavel Solin

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Cimrman, R., Lukeš, V. & Rohan, E. Multiscale finite element calculations in Python using SfePy. Adv Comput Math 45, 1897–1921 (2019). https://doi.org/10.1007/s10444-019-09666-0

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10444-019-09666-0

Keywords

Mathematics Subject Classification (2010)

Navigation