Introduction

Natural convection is vital in various engineering applications, including heat transfer in electronic devices, energy-efficient building design, and thermal management in industrial processes. To design and optimize such systems, it is important to understand and predict the fluid flow and heat transfer properties in complex geometries1,2,3,4,5,6.

Several studies have focused on the influences of magnetic fields on heat transfer and fluid flow in square wavy cavities. Researchers have examined the influence of different parameters, for instance, magnetic field strength, orientation, and boundary conditions, on the convective heat transfer process. Sreedevi et al.7 examined the behavior of nanofluid in a square cavity considering magnetic field and thermal radiation. The finite difference approach was used to solve the governing equations. They found that the maximum average value of the Nusselt number can be obtained with higher values of the Rayleigh number. To study the natural convection in a cavity where an inclined oval heater is exposed to a magnetic field, Dogonchi et al.8 performed a numerical investigation using the CVFEM method. According to their findings, improving the Hartmann number reduced the average Nusselt at a constant Rayleigh number. Li et al.’s research9 concentrated on convective heat transfer in an alumina water nanofluid-filled square cavity that was angled toward the horizon. In addition to convective heat transfer, they also considered radiative heat transfer. The study also analyzed entropy production. A hot circular baffle was placed inside the cavity under a fixed horizontal magnetic field. They understood that with the increase of the Rayleigh number from 103 to 106, the pace of heat transfer improved 4.5 times, and the entropy produced also increased with the development of the Rayleigh number. Furthermore, as the magnetic field strength (Ha) increased, there was a notable decrease in both the average Nusselt number (Nu) and the amount of entropy generated. Specifically, the Nu decreased by 45%, while the generated entropy diminished by 35%. In order to study the entropy generation and heat transfer in a porous corrugated cavity filled with an integrated nanofluid under the influence of natural convection, Dogonchi et al.10 conducted a numerical study using the finite element method (FEM). This study shows that raising the Rayleigh number (Ra), and Darcy number (Da) is necessary to raise the thermal-natural convection rate. The results showed that complete irreversibility is established with Ra and Da, while it is reduced with Ha. Also, this analysis provides valuable insights into entropy production and convective heat transfer characteristics in such complex systems. Jalili et al. 11,12,13,14,15,16,17 did several works using the FEM method in this field. Mahmoudi 18 conducted theoretical and numerical research to investigate natural convection heat transfer in a porous cavity exposed to a magnetic field. This study used the scale analysis method to create a correlation to predict the heat transfer. A numerical study was also conducted using the Lattice Boltzmann method to validate the theoretical findings. The numerical simulations’ results were consistent with the theoretical predictions, indicating the proposed correlation’s correctness and reliability. This research contributes to a better understanding of heat transfer in porous cavities with magnetic field effects. Izadi et al. 19 examined the influence of two non-constant magnetic sources on the natural convection of a magnetic nanofluid in a porous medium. They discovered that as the intensity ratio between the two magnetic sources grew along with a rise in the Rayleigh (Ra) numbers, the Nusselt number initially dropped. This suggests that the convection rate decreases when the magnetic field strength becomes more asymmetric. It highlights the complex interaction between magnetic fields and natural convection in porous media and provides further insights into the behavior of such systems. Massoudi et al. 20 studied the physical properties of natural convection and radiation heat transfer in a nonagon cavity with a variable magnetic field length in a porous medium with nanofluid exposed to a uniform magnetic field. In order to find out how metal foam and rotation angle affected the natural convection of nanofluids in a hollow exposed to a magnetic field, Qi et al. 21 conducted an experiment. Their research demonstrated that a horizontal magnetic field lessens the cavity’s heat transfer, but a vertical direction improves it. The horizontal magnetic field with more force brings down the number of Nusselt, and the vertical magnetic field with higher strength enhances heat transfer, resulting in a larger Nusselt number. The numerical examination of natural convection in an F-shaped cavity with a horizontal periodic magnetic field containing non-Newtonian silver nanofluid in a porous medium was conducted by AK Hussein et al. 22. It was noticed that heat transfer improves with increasing solid volume fraction (φ), Darcy number (Da), and Rayleigh number (Ra). Izadi et al. 23 numerically studied nanofluid’s natural convection in a porous medium influenced by a nonuniform magnetic field. Buoyancy forces, Lorentz forces, and magnetism influence the hybrid nanofluid. They found that in a porous medium at high Da, the Nusselt number falls as the porosity coefficient rises, but the Nusselt number is unaffected by the porosity coefficient of the porous medium at low and high values of Da and Ra, respectively. At low Rayleigh numbers, with the change of porosity and permeability coefficient, natural convection heat transfer change is not noticeable. Hashemi et al. 24 studied the natural convection of micropolar copper–water nanofluid in a porous chamber that produces heat. Their investigation focused on the thermal and dynamic characteristics of the nanofluid in a square chamber, where heat is produced in both the fluid and solid phases of the porous medium. They employed the Galerkin finite element method with a nonuniform structured grid to solve the governing equations and the Darcy model to simulate the flow dynamics. Finally, they showed the effect of various dimensionless parameters on velocity, temperature, and rotation. Fenghua Li et al. 25 explored the flow behavior of hybrid nanomaterials inside a permeable cavity under the influence of magnetic force. They considered the effects of permeability and external force in the Navier–Stokes equations to simulate the free convection of hybrid nanomaterials. They also evaluated the effect of various factors such as Darcy number, Hartmann number, and radiation on the fluid flow. The steady-state flow of magnetized nanofluid in the wavy cavity with radiation was examined by Nong et al. 26. The control volume finite element (CVFE) technique is used to estimate numerical modeling. The behavior of streamlines, average Nusselt number, and isotherms was shown to be affected by magnetic force, Rayleigh number, porosity coefficient, and shape factors of nanoparticles according to them. The natural convection of a micropolar fluid was examined by Nikita et al. 27. They reviewed their study in the wave cavity. They discussed how the flow patterns, temperature fields, and average Nusselt number in the hot corrugated wall were affected by various characteristics, including the Rayleigh number, Prandtl number, wave number, and vortex viscosity parameter. Their work is based on partial differential equations constructed in non-dimensional variables and solved with second-order precision using a finite difference approach. Mahmoud et al. 28 focused on investigating fluid flow and heat transfer in a porous media when subjected to a magnetic field. They investigated the effect of different parameters such as Darcy number, porosity parameter, radiation parameter, and Richardson number on heat transfer and flow characteristics. They applied numerical techniques and the Galerkin weighted residual finite element approach to solve the governing equations. According to their findings, there is a positive correlation between these factors and heat transfer, while an increase in the slant angle of the magnetic field causes a slight increase in velocity. In an effort to improve heat transfer, Tusi et al. 29 examined the natural motion of a water fluid containing nanocopper particles in a square cavity that was partially filled with porous media. They utilized the Darcy-Brinkman-Forchheimer relationship for fluid flow via porous media and the two-phase mixture model for simulating nanofluid flow. Additionally, they looked into how fluid flow and heat transfer were affected by the concentration of nanoparticles, Rayleigh and Darcy numbers, and the thickness ratio of the porous layer. Geridonmez et al. 30,31,32 investigated the mathematical analysis of natural convection flow in a square cavity that is exposed to a constant magnetic field. The RBF method for spatial derivatives and the backward Euler method for time derivatives are used to discretize the governing dimensionless equations. The findings demonstrate that the Lorentz force significantly reduces fluid flow and heat transfer in the affected area. In summary, this study provides significant findings regarding the aforementioned aspects. Convective heat transfer is decreased, and fluid flows more slowly as the influence area grows because of the increase in Lorentz force. As they concluded, the applied magnetic field is capable of controlling fluid flow and heat transfer. In an effort to enhance heat transfer, Several investigations were carried out to examine a cavity under various circumstances when a magnetic field was present 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47. Alsabery et al. 48,49,50 did several works in the field of heat transfer inside the porous cavity.

This paper explores the natural convection in a square, wavy, porous cavity with a partial magnetic field. Our objective is to analyze the fluid flow patterns and heat transfer behavior within the cavity through numerical simulations and mathematical modeling. This study supports existing knowledge by providing information on the influence of external factors, such as magnetic fields and porous media, on natural convection phenomena.

Problem formulation

A cavity with porous material and a partially imposed magnetic field is being considered for a laminar, incompressible natural convection flow. The configuration of the problem can be seen in Fig. 1. The cavity’s top and bottom walls are thermally insulated, while the left wall is the heat source (T = Th), and the right wavy wall is the cold boundary (T = Tc). The cavity’s length (L) and height (H) are in unity. The values of the parameters related to the right wall are: a = 0.9, b = 0.1, and \(k{\prime}\) is the wave number. The porous material inside the cavity is uniform and has isotropic properties. The fluid and porous material reach a local thermal equilibrium. The current analysis does not account for the effects of radiation effects, viscous dissipation, Joule heating, or the induced magnetic field.

Figure 1
figure 1

Definition of problem geometry.

Darcy’s law alone may not be sufficient in various scenarios, such as when dealing with more porous materials, high velocities, or high Reynolds number effects. In 1901, Forchheimer introduced the concept of a quadratic drag term (also known as the inertial or Forchheimer term) to Darcy’s law. Later, Brinkmann further expanded on the model to incorporate larger porosity and account for viscous effects. It’s worth mentioning that this study excludes certain factors, such as induced magnetic fields and Joule heating.

Brinkman-Forchheimer-extended Darcy’s model is utilized in this study to analyze the porous material within the cavity. The problem’s configuration involves a laminar, incompressible natural convection flow with a partially applied magnetic field. This study’s governing equations are the continuity, momentum, and energy expressed in the u-v-p-T form. These nonlinear equations capture the complex dynamics of the system and provide insights into the fluid flow, pressure distribution, and temperature distribution within the porous material-filled cavity, as follows 31:

$$\nabla .\mathbf{u}=0,$$
(1)
$$\frac{{\mu }_{e}}{{\rho }_{f}{\epsilon }_{p}}{\nabla }^{2}u=\frac{1}{{\epsilon }_{p}}\frac{\partial u}{\partial t}+\frac{1}{{{\epsilon }_{p}}^{2}}\left(u\frac{\partial u}{\partial x}+v\frac{\partial u}{\partial y}\right)+\frac{1}{{\rho }_{f}}\frac{\partial p}{\partial x}+\frac{\mu }{{\rho }_{f}\mathsf{K}}u+\frac{{c}_{F}}{\sqrt{\mathsf{K}}}\left|\mathbf{u}\right|u,$$
(2)
$$\frac{{\mu }_{e}}{{\rho }_{f}{\epsilon }_{p}}{\nabla }^{2}v=\frac{1}{{\epsilon }_{p}}\frac{\partial v}{\partial t}+\frac{1}{{{\epsilon }_{p}}^{2}}\left(u\frac{\partial v}{\partial x}+v\frac{\partial v}{\partial y}\right)+\frac{1}{{\rho }_{f}}\frac{\partial p}{\partial y}+\frac{\mu }{{\rho }_{f}k}v+\frac{{c}_{F}}{\sqrt{\mathsf{K}}}\left|\mathbf{u}\right|v-g\beta \left(T-{T}_{c}\right)+{\updelta }_{B}\frac{\upsigma {{B}_{0}}^{2}}{{\rho }_{f}}v,$$
(3)
$${{\alpha }}_{e}{\nabla }^{2}T={\upsigma }_{h}\frac{\partial T}{\partial t}+\mathbf{u}.\nabla T.$$
(4)

In which \(\mu \) corresponds to the dynamic viscosity of the fluid, the effective dynamic viscosity is \({\mu }_{e}\), the fluid’s density is \({\rho }_{f}\), the norm of the velocity vector \(\sqrt{({u}^{2}+{v}^{2})}\) is \(\left|\mathbf{u}\right|\), \(g\) is the gravitational acceleration, the thermal expansion coefficient is \(\beta \), the pressure is defined by \(p\), the porosity of a porous medium is measured by \({\epsilon }_{p}\), the magnitude of the applied magnetic field is referred to as \({B}_{0}\), the fluid’s electrical conductivity is defined as σ, the effective thermal diffusivity is \({{\alpha }}_{e}=\frac{{k}_{e}}{{({\rho }_{f}{c}_{p})}_{f}}\), the effective thermal conductivity is \({k}_{e}={\epsilon }_{p}{k}_{f}+(1-{\epsilon }_{p}){k}_{s}\), the specific heat at constant pressure is \({c}_{p}\), the coefficient of form is \({c}_{F}=\frac{1.75(1-{\epsilon }_{p})}{{d}_{p}{{\epsilon }_{p}}^{3}}\), \(K=\frac{{{d}_{p}}^{2}{{\epsilon }_{p}}^{3}}{150{(1-{\epsilon }_{p})}^{2}}\) refers to the permeability of the porous medium, \({d}_{p}\) is the size of a solid particle in a porous medium, and the heat capacity ratio \({\upsigma }_{h}=\frac{{\epsilon }_{p}{({\rho }_{f}{c}_{p})}_{f} +(1-{\epsilon }_{p}){({\rho }_{f}{c}_{p})}_{s}}{{({\rho }_{f}{c}_{p})}_{f}}\) , is considered one in this model. Additionally, the fluid \((f)\) and solid \((s)\) are assumed to have the same thermal conductivity and thermal diffusivity. That means, \({k}_{e}={k}_{f}={k}_{s}\) and \({\alpha }_{e}={\alpha }_{f}=\alpha \). In addition, \({\mu }_{e}=\mu \) is assumed. Air fluid was used for the present work. The physical properties of air are given in Table 1.

Table 1 Physical properties of air at 20c.

The boundary conditions are outlined below:

$$u=v=0, \frac{\partial T}{\partial y}=0 at y=\text{0,1} , 0<x<1,$$
(5a)
$$u=v=0, T={T}_{h} at x=0 , 0<y<1,$$
(5b)
$$u=v=0, T={T}_{c} at x=a+bcos(2k\pi y) , 0<y<1.$$
(5c)

The dimensionless quantities are defined below:

$${x}{\prime}=\frac{x}{L} , {y}{\prime}=\frac{y}{L} , {u}{\prime}=\frac{uL}{\alpha } , {v}{\prime}=\frac{vL}{\alpha } ,$$
(6a)
$${p}{\prime}=\frac{p{L}^{2}}{{\rho }_{f}{\alpha }^{2}} ,{ t}{\prime}=\frac{t\alpha }{{L}^{2}} , \theta =\frac{T-{T}_{c}}{{T}_{h}-{T}_{c}}.$$
(6b)

With the help of non-dimensional quantities, they are replaced in the original Eqs. (1)-(4), and assuming the elimination of prime symbols, the following dimensionless equations are obtained.

$$\frac{\partial u}{\partial x}+\frac{\partial v}{\partial y}=0,$$
(7)
$$\frac{Pr}{{\epsilon }_{p}}{\nabla }^{2}u=\frac{1}{{\epsilon }_{p}}\frac{\partial u}{\partial t}+\frac{1}{{{\epsilon }_{p}}^{2}}\left(u\frac{\partial u}{\partial x}+v\frac{\partial u}{\partial y}\right)+\frac{\partial p}{\partial x}+\frac{Pr}{Da}u+{c}_{g}\frac{\left|\mathbf{u}\right|}{\sqrt{Da}}u,$$
(8)
$$\frac{Pr}{{\epsilon }_{p}}{\nabla }^{2}v=\frac{1}{{\epsilon }_{p}}\frac{\partial v}{\partial t}+\frac{1}{{{\epsilon }_{p}}^{2}}\left(u\frac{\partial v}{\partial x}+v\frac{\partial v}{\partial y}\right)+\frac{\partial p}{\partial y}+\frac{Pr}{Da}v+{c}_{g}\frac{\left|\mathbf{u}\right|}{\sqrt{Da}}v-RaPr\theta +{\updelta }_{B}{Ha}^{2}Prv,$$
(9)
$${\nabla }^{2}\theta =\frac{\partial \theta }{\partial t}+u\frac{\partial \theta }{\partial x}+v\frac{\partial \theta }{\partial y}.$$
(10)

where, \({c}_{g}=\frac{ 1.75}{\sqrt{150}{{\epsilon }_{p}}^{3/2}}\). The dimensionless parameters Prandtl, Darcy, Rayleigh, and Hartmann numbers are as follows:

$$ \Pr = {\raise0.7ex\hbox{$\mu $} \!\mathord{\left/ {\vphantom {\mu {\alpha \rho _{f} }}}\right.\kern-\nulldelimiterspace} \!\lower0.7ex\hbox{${\alpha \rho _{f} }$}},\,\,\,\,Da = {\raise0.7ex\hbox{$K$} \!\mathord{\left/ {\vphantom {K {L^{2} }}}\right.\kern-\nulldelimiterspace} \!\lower0.7ex\hbox{${L^{2} }$}},\,\,\,\,Ra = {\raise0.7ex\hbox{${g\beta \Delta T\rho _{f} L^{3} }$} \!\mathord{\left/ {\vphantom {{g\beta \Delta T\rho _{f} L^{3} } {\mu \alpha }}}\right.\kern-\nulldelimiterspace} \!\lower0.7ex\hbox{${\mu \alpha }$}},\,\,\,\,Ha = B_{0} L\sqrt {{\raise0.7ex\hbox{$\sigma $} \!\mathord{\left/ {\vphantom {\sigma \mu }}\right.\kern-\nulldelimiterspace} \!\lower0.7ex\hbox{$\mu $}}} . $$
(11)

where \(\Delta T={T}_{h}-{T}_{c}\). By setting the stream function \(\psi \) as \(u=\partial \psi /\partial y, v=-\partial \psi /\partial x\), it eliminates the continuity equation due to satisfying the continuity condition, and the pressure term is removed by using the vorticity definition \(\omega =\nabla \times \mathbf{u}\) in the momentum equations. Non-dimension equations are deduced from the effects of stream and vorticity functions:

$${\nabla }^{2}\psi =\omega ,$$
(12)
$${\nabla }^{2}\omega =\frac{1}{Pr}\frac{\partial \omega }{\partial t}+\frac{1}{Pr{\epsilon }_{p}}\left(u\frac{\partial \omega }{\partial x}+v\frac{\partial \omega }{\partial y}\right)+\frac{{\epsilon }_{p}}{Da}\omega +\frac{{c}_{g}{\epsilon }_{p}}{Pr\sqrt{Da}}\left[v\frac{\partial \left|\mathbf{u}\right|}{\partial x}-u\frac{\partial \left|\mathbf{u}\right|}{\partial y}+\left|\mathbf{u}\right|\omega \right]-{\epsilon }_{p}Ra\frac{\partial \theta }{\partial x}+{\epsilon }_{p}{\updelta }_{B}{Ha}^{2}\frac{\partial v}{\partial x},$$
(13)
$${\nabla }^{2}\theta =\frac{\partial \theta }{\partial t}+u\frac{\partial \theta }{\partial x}+v\frac{\partial \theta }{\partial y}.$$
(14)

In the case of the incoming magnetic field, \({\delta }_{B}\) , is defined as:

$${\delta }_{B}=\left\{\begin{array}{c}0, 0\le y<1-{L}_{B}\\ 1, 1-{L}_{B}\le y<1.\end{array}\right.$$
(15)

The reduced boundary conditions are as follows:

$$\psi =0, \frac{\partial \theta }{\partial y}=0 at y=\text{0,1} , 0<x<1,$$
(16a)
$$\psi =0, \theta =1 at x=0 , 0<y<1,$$
(16b)
$$\psi =0, \theta =0 at x=a+bcos(2k\pi y) , 0<y<1,$$
(16c)

The average Nusselt number for the warm wall is determined as follows:

$$\overline{Nu }=\frac{1}{H}{\int }_{0}^{H}-\frac{\partial \theta }{\partial x}dy.$$
(17)

Method of solution and numerical results

The Eqs. (12)-(14) have been solved using the Finite Element Method with boundary conditions (16). The reliability of this method is a result of its high strength and flexibility. Once the initial meshing is done, the solution continues continuously. To achieve acceptable accuracy, it may also alter the mesh structure. This process continues until the convergence condition is met. The convergence condition for the present work is to reach 10–5 accuracy. The Finite Element Method (FEM) operates on a fundamental principle: breaking down a complex problem domain into discrete sub-regions that are called finite elements. Each of these elements possesses a distinct geometry and is characterized mathematically through a set of equations that describe the behavior of the system within that particular section. This approach simplifies the solution of complex governing equations, which would be arduous or nearly impossible to solve manually. Shape functions are used in FEM to interpolate element-level solutions based on nodal values. In this study, FEM serves as a numerical tool for solving the governing equations related to fluid flow and heat transfer due to natural convection of a square wavy cavity with a magnetic field and porous media. To improve understanding of the numerical solution technique, Fig. 2 displays the flowchart of the numerical method. Through FEM, a more precise and detailed solution for the natural convection of a square wavy cavity with a magnetic field and porous media can be obtained. Figure 3 shows a good match between the streamlines and isotherm lines compared to the work of Geridonmez et al. 31.

Figure 2
figure 2

The flowchart of the numerical method.

Figure 3
figure 3

Comparison of streamlines (on the left) and isotherm lines (on the right) at Ra = 105, Da = 0.01, ϵp = 0.9, Ha = 50, LB = 0.7.

In order to obtain a mesh-independent solution, mesh independence is investigated. The grid-independent solution was examined by providing a solution for natural convection in a square cavity with one side having a cosine wave with a magnetic field applied to a portion of the square side. Five of the grids have been tested. As can be seen in Table 2, with the number of cells 3006, the solution becomes independent and reaches an accuracy of 10–5. The optimal mesh is shown in Fig. 4.

Table 2 Mesh independent review with Ra = 105, Da = 0.01, ϵp = 0.9, Ha = 50, LB = 0.5, \(k{\prime}\) = 2.
Figure 4
figure 4

Grid of geometry.

Results and discussions

Figure 5 shows the impact of the entranced magnetic field length on the left wall. As the magnetic field length increases, the main vortex is compressed towards the lower left nook of the cavity, but the upper part of the vortex is stretched towards the upper right nook of the cavity because of the increased Lorentz force area introduced by the magnetic field. The vortex’s strength decreases with the magnetic field’s length. On the other hand, the buoyancy force slows down. The temperature difference in the isotherms decreases. In addition, the isotherm lines tend to flatten, indicating the magnetic force’s inhibition of natural convection.

Figure 5
figure 5

Impact of magnetic field length on streamlines and isotherm lines with Ra = 105, Da = 0.01, ϵp = 0.9, Ha = 50, \(k{\prime}\)= 2; from top to bottom Nu = 5.127, 4.245, 3.247, respectively.

The velocity and temperature distribution based on the variable magnetic field length can be seen in Fig. 6. It is concluded that by raising the magnetic field length, the velocity decreases, and the temperature increases from the bottom of the cavity to its center, but this process is the opposite for the upper half. The maximum velocity u belongs to LB = 0.5.

Figure 6
figure 6

Velocity and temperature distribution based on magnetic field length change with Ra = 105, Da = 0.01, ϵp = 0.9, Ha = 50, \(k{\prime}\) = 2; (a) u at y = 0.5, (b) v at x = 0.5, (c) θ at x = 0.5.

Figure 7 shows the effect of the Rayleigh number on streamlines and isothermal lines. LB = 0.5, as defined, means that the magnetic field affects the left wall of the cavity from the top to the center. Therefore, the streamlines show the natural convection at the bottom of the cavity, while the upper part of the cavity shows the lagging impact of the Lorentz force. Because of the dominance of Lorentz force over the buoyancy force, the second vortex is seen in the streamlines at Ra = 104, while it is not observed at Ra = 105 or 106 due to the high buoyancy force. The isotherm lines are approximately 90 degrees to the upper wall for Ra = 104, 105. With the increase of Rayleigh, the isotherm lines tend to bend more from the flat state, and heat penetrates more in the upper half.

Figure 7
figure 7

Influence of Rayleigh number on streamlines and isotherm lines with Da = 0.01, ϵp = 0.9, Ha = 100, LB = 0.5, \(k{\prime}\) = 2; from top to bottom Nu = 1.465, 3.6, 8.944, respectively.

The velocity and temperature distribution based on the Rayleigh number change can be seen in Fig. 8. Raising the Rayleigh number lowered the temperature in the cavity’s lower region while increasing the maximum velocity, but this trend changes for the upper part of the cavity, and the temperature increases.

Figure 8
figure 8

Velocity and temperature distribution based on Rayleigh number change with Da = 0.01, ϵp = 0.9, Ha = 100, LB = 0.5, \(k{\prime}\) = 2; (a) u at y = 0.5, (b) v at x = 0.5, (c) θ at x = 0.5.

Figure 9 shows the effect of the Hartmann number on streamlines and isothermal lines. In case there’s no magnetic field due to the non-existence of Lorentz force delay, the streamlines show natural convection in all parts of the cavity. With the augmentation of the Hartmann number, the vortex tends to the lower side of the cavity. Also, the increase in Hartmann reduces the strength of the vortex.

Figure 9
figure 9

Impact of Hartmann number on streamlines and isotherm lines with Da = 0.01, ϵp = 0.9, Ra = 105, LB = 0.5, \(k{\prime}\) = 2; from top to bottom Nu = 5.973, 3.6, 3.342, respectively.

The isotherm lines are almost perpendicular to the top wall for Ra = 105, 106. As the Rayleigh increases, the isotherm lines tend to bend less from the flat state, and heat penetrates less in the upper half, indicating that the magnetic field was controlling the heat transfer and fluid flow.

The velocity and temperature distribution due to the Hartmann number change is shown in Fig. 10. In the absence of a magnetic field, u has the lowest value, and with the augmentation of the Hartmann number, u and v decrease. With increasing the Hartmann number, the temperature trend for the cavity’s lower half increases, but this trend is reversed for the upper half, and the temperature decreases.

Figure 10
figure 10

Velocity and temperature distribution based on Hartmann number change with Da = 0.01, ϵp = 0.9, Ra = 105, LB = 0.5, \(k{\prime}\) = 2; (a) u at y = 0.5, (b) v at x = 0.5, (c) θ at x = 0.5.

The influence of Darcy number on streamlines and isotherm lines was examined, and it is shown as a contour in Fig. 11. At the Darcy number close to zero, the vorticity tends to the center, and the isothermal lines are almost parallel to each other because the Lorentz force loses its effect at a low Darcy number. With the increase of Darcy, the penetration of heat increases, and as a result, the fluid moves at a higher speed, and the vortex is transferred downwards.

Figure 11
figure 11

Impact of Darcy number on streamlines and isotherm lines with Ra = 105, ϵp = 0.9, Ha = 50, LB = 0.5, \(k{\prime}\) = 2; from top to bottom Nu = 1.234, 2.404, 4.245, respectively.

The velocity and temperature distribution due to the Darcy number change can be seen in Fig. 12. With increasing the Darcy number, the magnitude of u and v increase, and it can be said that the temperature also has an increasing trend, and in Darcy 10–4, the temperature changes are insignificant.

Figure 12
figure 12

Velocity and temperature distribution based on Darcy number change with Ra = 105, Ha = 50, ϵp = 0.9, LB = 0.5, \(k{\prime}\)= 2; (a) u at y = 0.5, (b) v at x = 0.5, (c) θ at x = 0.5.

The impact of wave number on streamlines and isotherm lines was studied, and the outcomes are shown in Fig. 13. As the wave number increases, the eddy tends to rise less, and the fluid moves with a higher partial velocity. The number of waves has no noticeable effect on isothermal lines. Nonetheless, there is a certain increase in the Nusselt number as the wave number rises. The behavior of velocity in horizontal and vertical, as well as temperature distribution in the vertical case, is shown. See Fig. 14 for better understanding.

Figure 13
figure 13

Impact of wave number on streamlines and isotherm lines with Ra = 105, Da = 0.01, ϵp = 0.9, Ha = 50, LB = 0.5; from top to bottom Nu = 3.978, 4.093, 4.245, 4.243, respectively.

Figure 14
figure 14

Velocity and temperature distribution based on Wave number change with Ra = 105, Ha = 50, Da = 0.01, ϵp = 0.9, LB = 0.5; a) u at y = 0.5, b) v at x = 0.5, c) θ at x = 0.5.

Average Nusselt is influenced by magnetic field length, Rayleigh, Hartmann, and Darcy number, as shown in Fig. 15. The average Nusselt is proportional to the Rayleigh and Darcy numbers and increases with the increase of Rayleigh and Darcy. At the same time, it has an inverse relationship with the Hartmann number and the length of the magnetic field. Figures 16 and 17 show the simultaneous effect of magnetic field length, Rayleigh number, and Hartmann and Darcy numbers on the average Nusselt. The average Nusselt number reached its highest point when there was no magnetic field, and the Rayleigh and Darcy numbers were high.

Figure 15
figure 15

Impact of magnetic field length, Rayleigh, Hartmann, and Darcy numbers on Average Nusselt with Ra = 105, Da = 0.01, ϵp = 0.9, Ha = 50, LB = 0.5, \(k {\prime}\)= 2.

Figure 16
figure 16

Simultaneous effect of magnetic field length and Rayleigh number on average Nusselt number with Da = 0.01, ϵp = 0.9, Ha = 50, \(k\) = 2.

Figure 17
figure 17

Simultaneous impact of Hartmann and Darcy numbers on average Nusselt number with Ra = 105, ϵp = 0.9, LB = 0.5, \(k\) = 2.

In summary, the set of average Nusselt number and maximum psi value is given in Table 3.

Table 3 The values of average Nusselt number and maximum psi with Ra = 105, Da = 0.01, ϵp = 0.9, Ha = 50, LB = 0.5, \(k{\prime}\) = 2.

Conclusion

This paper presents the results of a numerical study on natural convection in a square wavy cavity in the presence of a partial magnetic field under effective factors such as magnetic field length (LB), Rayleigh number (Ra), Hartmann number (Ha), Darcy number (Da) and wave number (\(k{\prime}\)). The effective parameters were investigated in LB = 0.3–0.7, Ra = 104–106, Da = 0.0001–0.01, \(k{\prime}\) = 0–3 intervals. In addition, the distribution of temperature, average Nusselt, streamlines, and isotherm lines were shown for the cavity. The most important results obtained are as follows:

  1. 1.

    As the magnetic field’s length increases, heat transfer decreases. As the length of the magnetic field increases from 0.3 to 0.7, the Nusselt number decreases by 36.6%, and the value of maximum psi decreases by 34%.

  2. 2.

    As the Rayleigh number increases, the Nusselt number also increases. In fact, with the increase of the Rayleigh number, the buoyancy force increases, and the buoyancy force increases the heat transfer and fluid velocity. As the Rayleigh number increases from 104 to 106, the Nusselt number increases more than five times, and the value of maximum psi increases more than seven times.

  3. 3.

    In the lower Rayleigh, the second vortex is formed due to the dominance of the Lorentz force over the buoyancy force.

  4. 4.

    The effect of Lorentz force on fluid flow and heat transfer increases at a high Rayleigh number.

  5. 5.

    Nusselt number decreases with increasing Hartmann number. As the Hartmann number increases, the Lorentz force increases. Lorentz force reduces heat transfer and fluid velocity. As the Hartmann number increases from 0 to 200, the Nusselt number decreases by 44%, and the value of maximum psi decreases by 38.8%.

  6. 6.

    By increasing the permeability in the porous medium, heat transfer is improved. As the Darcy number increases from 0.0001 to 0.01, the Nusselt number increases more than two times, and the value of maximum psi increases more than nine times.

  7. 7.

    At low Darcy numbers, the magnetic field becomes ineffective.

  8. 8.

    As the wave number of the right wall increases, the Nusselt number increases due to the increase of the heat transfer area. As the wave number increases from 0 to 2, the Nusselt number increases by 6.71%, and the value of maximum psi increases by 1.3%.