Implementation and verification of a two-dimensional CFD solver in Python for diffusive problems and laminar forced flows

Authors

  • Edgard Elohim Canche Cauich Universidad Autónoma de Campeche, Calle, Av. Agustín Melgar s/n, Buenavista, 24039 San Francisco de Campeche, Campeche, México https://orcid.org/0009-0005-4298-6562
    Competing Interests

    No conflict of interest declared

  • Felipe Noh-Pat Universidad Autónoma de Campeche, Calle, Av. Agustín Melgar s/n, Buenavista, 24039 San Francisco de Campeche, Campeche, México image/svg+xml https://orcid.org/0000-0003-1981-8323
    Competing Interests

    No conflict of interest declared

  • Miguel Angel Gijón Rivera Tecnológico de Monterrey, Av. Eugenio Garza Sada #2501 Sur, Col. Tecnológico, C.P. 64849, Monterrey, Nuevo León, México image/svg+xml https://orcid.org/0000-0003-2462-2499
    Competing Interests

    No conflict of interest declared

  • Manuel Jesús Rodríguez-Pérez Universidad Autónoma de Campeche, Calle, Av. Agustín Melgar s/n, Buenavista, 24039 San Francisco de Campeche, Campeche, México image/svg+xml https://orcid.org/0000-0003-1531-9180
    Competing Interests

    None

  • Mauricio Iván Huchin-Miss Universidad Autónoma de Campeche, Calle, Av. Agustín Melgar s/n, Buenavista, 24039 San Francisco de Campeche, Campeche, México https://orcid.org/0000-0002-5669-9098
    Competing Interests

    No conflict of interest declared

DOI:

https://doi.org/10.37636/recit.v9n3e460

Keywords:

Computational fluid dynamics, Finite volume method, ADI-SIMPLE algorithms

Abstract

Computational Fluid Dynamics (CFD) enables the prediction of the behavior of physical phenomena in a wide range of systems. In Mexico, its application has gained relevance in the study of energy-efficient buildings in response to the impacts of global warming. The objective of this work is to develop and verify a two-dimensional CFD solver implemented in the Python programming language, based on the finite volume method, capable of solving diffusive equations and the Navier-Stokes equations under laminar flow conditions, as well as to evaluate its computational performance. The numerical solution of the discretized governing equations is carried out using an Alternating Direction Implicit (ADI) method based on line Gauss-Seidel (LGS-ADI). The first case study corresponds to the solution of the steady-state heat conduction equation in a solid block. The second case consists of the simulation of laminar airflow in a square cavity filled with air, driven by a prescribed velocity at the top lid, with a Reynolds number of 1000. In this case, the SIMPLE algorithm is implemented for pressure-velocity coupling, and staggered grids are employed for the velocity field. The simulations are performed on a uniform 150x150 cell grid, initially using a first-order upwind scheme and subsequently a hybrid differencing scheme to reduce numerical diffusion. The results reproduce the characteristic flow structures, such as the formation of two vortices in the lower corners of the cavity, and show good agreement with the reference solution. The relative errors obtained in the verification cases are below 4.70%. Compared with a solver based on the classical Gauss-Seidel method, the ADI algorithm combined with the Thomas method reduces the computational time by 61.92% for the diffusive problem and by 15.04% for the forced flow problem, a difference attributed to the nonlinear nature of the latter. This work contributes to the development of an in-house code for numerical modeling using CFD.   

Downloads

Download data is not yet available.

References

[1] J. Xamán y M. Gijón-Rivera, Dinámica de Fluidos Computacional para Ingenieros. Ciudad de México, 2016.

[2] The OpenFOAM Foundation Ltd., “OpenFOAM.” Accessed: Jun. 19, 2025. [Online]. Available: https://openfoam.org/

[3] G. Materano, C. Araujo, and A. A. V. Ochoa, “A new OpenFOAM proposal for the solution of diffusion problems,” Thermal Science and Engineering Progress, vol. 25, p. 100982, Oct. 2021, doi: 10.1016/j.tsep.2021.100982 DOI: https://doi.org/10.1016/j.tsep.2021.100982

[4] T. Välikangas, Conjugate heat transfer in OpenFOAM. In Proceedings of CFD with OpenSource software, 2016, edited by Nilsson. H. 2016. Accessed: May 31, 2025. [Online]. Available: https://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2016/TuroValikangas/Report_Turo.pdf

[5] G. Vijaya Kumar, M. Kampili, S. Kelm, K. Arul Prakash, and H.-J. Allelein, “CFD modelling of buoyancy-driven flows in enclosures with relevance to nuclear reactor safety,” Nuclear Engineering and Design, vol. 365, p. 110682, Aug. 2020, doi: 10.1016/j.nucengdes.2020.110682 DOI: https://doi.org/10.1016/j.nucengdes.2020.110682

[6] J. S. Piña et al., “Development of a boundary-coupled CFD model for collimated-diffusive radiation,” Int. J. Heat Mass Transf., vol. 248, p. 127170, Sep. 2025, doi: 10.1016/j.ijheatmasstransfer.2025.127170 DOI: https://doi.org/10.1016/j.ijheatmasstransfer.2025.127170

[7] R. Manceau, “Industrial codes for CFD. Master,” Poitiers, France, 2026.

[8] J. Carlier and M. V. Papalexandris, “An efficient tracking method of evaporative and flat free surfaces for turbulent convection,” Comput. Fluids, vol. 257, p. 105882, May 2023, doi: 10.1016/j.compfluid.2023.105882 DOI: https://doi.org/10.1016/j.compfluid.2023.105882

[9] A. Labihi et al., “Effect of phase change material wall on natural convection heat transfer inside an air filled enclosure,” Appl. Therm. Eng., vol. 126, 2017, doi: 10.1016/j.applthermaleng.2017.07.112 DOI: https://doi.org/10.1016/j.applthermaleng.2017.07.112

[10] J. Ríos-Arriola, E. Gómez-Arias, I. Zavala-Guillén, N. Velázquez-Limón, G. Bojórquez-Morales, and J. E. López-Velázquez, “Numerical modeling of soil temperature variation under an extreme desert climate,” Geothermics, vol. 112, 2023, doi: 10.1016/j.geothermics.2023.102731 DOI: https://doi.org/10.1016/j.geothermics.2023.102731

[11] S. Sena, R. Goyal, and S. K. Tyagi, “Numerical modelling for improved prediction of ground temperature in seasonal snow-cover regions,” Cold Reg. Sci. Technol., vol. 239, p. 104578, Nov. 2025, doi: 10.1016/j.coldregions.2025.104578 DOI: https://doi.org/10.1016/j.coldregions.2025.104578

[12] Secretaría de Medio Ambiente y Recursos Naturales, Plan de Acción en Enfriamiento, México. Refrigerantes con Bajo Potencial de Calentamiento Global y Eficiencia Energética en Equipos de Refrigeración y Aire Acondicionado. México. Semarnat, 2022.

[13] Y. Olazo-Gómez, I. Hernández-López, I. Zavala-Guillén, I. Hernández-Pérez, and D. García-Pérez, “Numerical study of a cool roof and double-glazing window coupled to an air-cavity under a tropical Mexican climate”, Case Studies in Thermal Engineering, vol. 73, p. 106372, Sep. 2025, doi: 10.1016/j.csite.2025.106372 DOI: https://doi.org/10.1016/j.csite.2025.106372

[14] J. Uriarte, Análisis Térmico de una Habitación con Techo de Geometría Irregular y Cubiertas Reflectivas. Cuernavaca, México, 2022. Accessed: Mar. 29, 2026. [Online]. Available: https://rinacional.tecnm.mx/bitstream/TecNM/4141/4/DM_Javier_Uriarte_Flores_2022.pdf

[15] J. Xamán, A. Rodriguez-Ake, I. Zavala-Guillén, I. Hernández-Pérez, J. Arce, and D. Sauceda, “Thermal performance analysis of a roof with a PCM-layer under Mexican weather conditions,” Renew. Energy, vol. 149, pp. 773–785, Apr. 2020, doi: 10.1016/j.renene.2019.12.084 DOI: https://doi.org/10.1016/j.renene.2019.12.084

[16] J. Xamán, C. Jiménez-Xamán, G. Álvarez, I. Zavala-Guillén, I. Hernández-Pérez, and J. O. Aguilar, “Thermal performance of a double pane window with a solar control coating for warm climate of Mexico,” Appl. Therm. Eng., vol. 106, pp. 257–265, Aug. 2016, doi: 10.1016/j.applthermaleng.2016.06.011 DOI: https://doi.org/10.1016/j.applthermaleng.2016.06.011

[17] I. Zavala-Guillén, D. Barrera-Román, F. Noh-Pat, M. Sidón, D. García-Pérez, and A. Rodriguez-Ake, “Thermal analysis of multi-layered glazed window under Mexican climate,” Energy Build., vol. 329, p. 115259, Feb. 2025, doi: 10.1016/j.enbuild.2024.115259 DOI: https://doi.org/10.1016/j.enbuild.2024.115259

[18] F. Noh-Pat, M. Gijón-Rivera, C. I. Rivera-Solorio, and M. Jiménez-Xamán, “Numerical analysis of the thermal performance of a lightweight insulating roof integrated with a phase change material,” Case Studies in Thermal Engineering, vol. 77, p. 107634, Jan. 2026, doi: 10.1016/j.csite.2025.107634 DOI: https://doi.org/10.1016/j.csite.2025.107634

[19] N. Rodrigues Marques Sakiyama, J. Frick, T. Bejat, and H. Garrecht, “Using CFD to Evaluate Natural Ventilation through a 3D Parametric Modeling Approach,” Energies (Basel)., vol. 14, no. 8, p. 2197, Apr. 2021, doi: 10.3390/en14082197 DOI: https://doi.org/10.3390/en14082197

[20] B. LeMesurier, Introduction to Numerical Methods and Analysis with Python. 2024. https://lemesurierb.people.charleston.edu/introduction-to-numerical-methods-and-analysis-python.pdf. Consultado abril de 2026.

[21] L. Barba and G. Forsyth, “CFD Python: the 12 steps to Navier-Stokes equations,” Journal of Open-Source Education, vol. 1, no. 9, p. 21, Nov. 2018, doi: 10.21105/jose.00021 DOI: https://doi.org/10.21105/jose.00021

[22] S. Pawar and O. San, “CFD Julia: A Learning Module Structuring an Introductory Course on Computational Fluid Dynamics,” Fluids, vol. 4, no. 3, p. 159, Aug. 2019, doi: 10.3390/fluids4030159 DOI: https://doi.org/10.3390/fluids4030159

[23] B. Kumar, W. Liu, and W. Hao, “GPU Accelerated Computational Methods using Python and CUDA,” Sweden, 2025.

[24] U. Ghia, K. N. Ghia, and C. T. Shin, “High-Re solutions for incompressible flow using the Navier-Stokes equations and a multigrid method,” J. Comput. Phys., vol. 48, no. 3, pp. 387–411, Dec. 1982, doi: 10.1016/0021-9991(82)90058-4 DOI: https://doi.org/10.1016/0021-9991(82)90058-4

[25] T. Bergman, A. Lavine, F. Incropera, and D. DeWitt, Introduction to Heat Transfer, 6th ed. New York, United States of America, 2011.

[26] C. J. Greenshields and H. G. Weller, Notes on Computational Fluid Dynamics: General Principles. Reading, UK: CFD Direct Ltd, 2022.

[27] J. Anderson, Computational Fluid Dynamics. New York: McGraw-Hill, 1995.

[28] M. Sahin and R. G. Owens, “A novel fully implicit finite volume method applied to the lid‐driven cavity problem—Part I: High Reynolds number flow calculations,” Int. J. Numer. Methods Fluids, vol. 42, no. 1, pp. 57–77, May 2003, doi: 10.1002/fld.442 DOI: https://doi.org/10.1002/fld.442

[29] L. Davidson, “Lecture Notes on Computational Fluid Dynamics of Turbulent Flow, chapter 6.” Accessed: Mar. 26, 2026. [Online]. Available: https://www.cfd-sweden.se/lada/comp_fluid_dynamics/postscript_files/chapter_6.pdf

[30] WolfDynamics, “Tips and tricks in OpenFOAM.” Accessed: Mar. 29, 2026. [Online]. Available: https://www.wolfdynamics.com/wiki/tipsandtricks.pdf

[31] OpenCFD Ltd, “Solution and algorithm control,” OpenFOAM User Guide, sec. 6.3. Accessed: Mar. 29, 2026. [Online]. Available: https://www.openfoam.com/documentation/user-guide/6-solving/6.3-solution-and-algorithm-control

[32] E. E. Canche-Cauich, F. Noh-Pat, M. A. Jiménez-Torres, F. R. Lezama-Zárraga, and B. Cortazar-Miranda, “Efecto de la conducción de calor en una ventana de vidrio doble. Memorias XXI Congreso Internacional, XXVII Congreso Nacional de Ciencias Ambientales y VIII Iberoamericano de Física y Química Ambiental,” Revista Internacional de Contaminación Ambiental, vol. 40, Oct. 2024, doi: 10.20937/RICA.2024.40.ANCA DOI: https://doi.org/10.20937/RICA.2024.40.ANCA

[33] T. A. AbdelMigid, K. M. Saqr, M. A. Kotb, and A. A. Aboelfarag, “Revisiting the lid-driven cavity flow problem: Review and new steady state benchmarking results using GPU accelerated code,” Alexandria Engineering Journal, vol. 56, no. 1, pp. 123–135, Mar. 2017, doi: 10.1016/j.aej.2016.09.013 DOI: https://doi.org/10.1016/j.aej.2016.09.013

[34] M. R. Patel, J. U. Pandya, and V. K. Patel, “Numerical Analysis of Fluid Flow Behaviour in Four-Sided Square Lid-Driven Cavity Using the Finite Volume Technique,” Int. J. Appl. Comput. Math., vol. 8, no. 4, p. 153, Aug. 2022, doi: 10.1007/s40819-022-01353-x DOI: https://doi.org/10.1007/s40819-022-01353-x

[35] Numba, “Numba: A High-Performance Python Compiler.” Accessed: Mar. 29, 2026. [Online]. Available: https://numba.pydata.org/

[36] P. Virtanen et al., “Author Correction: SciPy 1.0: fundamental algorithms for scientific computing in Python,” Nat. Methods, vol. 17, no. 3, pp. 352–352, Mar. 2020, doi: 10.1038/s41592-020-0772-5 DOI: https://doi.org/10.1038/s41592-020-0772-5

[37] N. Bell, L. N. Olson, and J. Schroder, “PyAMG: Algebraic Multigrid Solvers in Python,” J. Open Source Softw., vol. 7, no. 72, p. 4142, Apr. 2022, doi: 10.21105/joss.04142 DOI: https://doi.org/10.21105/joss.04142

Figure abstract

Published

2026-07-04

Data Availability Statement

The data from this study are available upon request from the corresponding author.

How to Cite

Canche Cauich, E. E., Noh Pat, F., Gijón Rivera , M. A., Rodríguez Pérez, M. J. ., & Huchin-Miss, M. I. (2026). Implementation and verification of a two-dimensional CFD solver in Python for diffusive problems and laminar forced flows. Revista De Ciencias Tecnológicas, 9(3), 1-25. https://doi.org/10.37636/recit.v9n3e460

Similar Articles

1-10 of 207

You may also start an advanced similarity search for this article.

Most read articles by the same author(s)