Introduction

Nanofluids have a lot of potential in different environments and conditions, which caused considerable importance in industries and the cooling of small-sized components. Magneto hydrodynamics (MHD) is a relatively new branch of fluid dynamics. This topic examines the interactions of fluids and electromagnetic fields. Research on the use of media with the goal of achieving optimal heat transfer rates has been considered by many researchers. The following is a brief overview of the carried out studies by the researchers in this topic. Biswas and Manna [1] enhanced convective heat transfer in lid-driven porous cavity with aspiration. They concluded that the upward-flow configuration yields the maximum heat transfer. Gibanov et al. [2] investigated the effects of uniform inclined magnetic field on mixed convection in a lid-driven cavity. They found that Nusselt number is a function of Darcy number and porous height. Chen et al. [3] investigated the influences of radiative characteristics on free convection in a saturated porous cavity. They found that the thermal radiation plays an important role on the fluid flow and heat transfer. Miroshnichenko et al. [4] investigated natural convection of Al2O3/H2O nanofluid in an open inclined cavity. They concluded that the nanoparticles do not allow intensifying the cooling process. Shi et al. [5] investigated the influences of thermophysical properties of Fe3O4/CNT nanofluid under magnetic field. They concluded that the increase in heat transfer depends on the direction of magnetic source. A study on natural convection was carried out by Miroshnichenko et al. [6]. They examined the effect of nanofluid on convection in a cavity. They found the heat transfer enhancement with nanoparticles concentration. Sheikholeslami and Rokni [7] simulated of nanofluid heat transfer in a porous enclosure in presence of radiation. Their results indicate that shape of nanoparticles can change the maximum rate of heat transfer. Kareem and Gao [8] studied the mixed convection of turbulent nanofluid flow in a three-dimensional lid-driven enclosure. Nonlinear increases in Nusselt number have been observed by using nanofluid. Chen et al. [9] studied conjugate natural convection in a square cavity filled with porous media. They found that thickness of porous layer influences the patterns of flow field and temperature field. Sheremet and Pop [10] investigated the effect of the size of the heat element on the heat transfer inside a porous cavity. They used LTNE and a two-phase model. They found the heat transfer enhancement with decreasing the distance between the heater and the cold vertical wall. The effect of MHD on free convection in a trapezoidal cavity containing nanofluid was studied by Selimefendigil and Öztop [11]. They observed that when the number of corrugation waves enhance, local and average heat transfer coefficients reduce. Sajjadi et al. [12] simulated the free convection of nanofluid in a cubic enclosure. They considered the distribution of temperature on one of the walls in a non-uniform way. They found that an increase in the intensity of the magnetic field reduced the heat transfer, but increasing the transfer of heat was observed with increasing Rayleigh number. Alsabery et al. [13] examined the combined convection in a cavity using a nanofluid. They used a two-phase model for analysis. They concluded that at high Richardson number, the addition of nanoparticles does not have a favorable effect on the heat transfer rate. Benos and Sarris [14] studied free convection in a shallow cavity. They considered the effects of MHD and internal heat generation. They found that although the addition of nanoparticles is a good factor in increasing heat transfer, it is important to consider the effect of MHD as a reducing agent in heat transfer. Kefayati [15] studied magneto hydrodynamic convection and entropy generation in an open cavity. They considered Soret and Dufour effects. They found that heat transfer enhancement depends on Dufour parameter and the mass transfer enhancement depends on Soret parameter increases. Hashim et al. [16] simulated natural convection in a wavy enclosure with Buongiorno’s two-phase model. They concluded that heat transfer inside the enclosure is increased by introducing nanoparticles as well as a selection of optimal number of oscillations. A study on the entropy generation in a cavity with various porous partitions was conducted by Gibanov et al. [17]. They found that an increase in the volume fraction caused a significant change in entropy generation. Ghasemi and Siavashi [18] examined magneto hydrodynamic convection and entropy generation in a square enclosure. They used a porous material with different permeability within the cavity. Hatami et al. [19] investigated the effect of using a variable field on fluid flow and heat dissipation in a half-annulus cavity. They showed that increasing the Hartmann number makes a decrease on the Nusselt number. Analysis of heat transfer and pumping power in a porous cavity was studied by Biswas et al. [20]. Using the DBF equations, they found that an increase in pumping power has a direct correlation with Reynolds’s increase. For further study on the application of nanofluids, Refs. [21,22,23,24] can be useful. In addition, for information on the application of porous media in heat transfer, Refs. [25,26,27] are suitable for study. In relation to the application of magneto hydrodynamics in heat transfer, Refs. [28,29,30] are recommended. Other studies including experimental and numerical approaches can be found in Refs. [31,32,33,34,35,36]. Those interested in simulation of heat transfer can follow Refs. [37,38,39]. Useful topics close to this paper can be found in Refs. [40,41,42,43,44].

In this study, the effects of the MHD and porous medium on mixed convection of Fe3O4-water nanofluid in a cavity with rotating cylinders in three different temperature cases with LTE and LTNE approaches are studied. The effect of the use of local thermal non-equilibrium model on streamlines and isotherm-lines has been investigated. The use of heat transfer enhancing mechanisms has been extensively investigated by many researchers. These mechanisms include nanofluids, porous media, magnetic fields, and various designs. But their composition in one system has been little studied by researchers. The idea of this research is to simultaneously apply the mentioned mechanisms to study the phenomena and effects of each mechanism on the system. The use of circular barriers with different thermal boundaries is another innovation of this study to improve or weaken heat transfer rates.

Problem statement

In this study, the effects of magnetic field and porous medium on mixed convection of Fe3O4-water nanofluid in a cavity with rotating cylinders are investigated numerically. The cavity is a square in size of L × L. Left and right walls of the cavity are arranged in hot and cold temperatures, respectively, and upper and lower walls are adiabatic. The geometry of the present work is shown in Fig. 1. Both cylinders are assumed to have the same radius of R. The cylinders are rotating at constant angular velocity (− ω). It should be noted that the cylinders are not solid but hollow and have different thermal boundary conditions. Inside the cavity is a nanofluid and filled porous material. The porous material is assumed to be homogeneous. It is also assumed that all porous cell cells are open completely. For the porous medium, local thermal equilibrium (LTE) and local thermal non-equilibrium (LTNE) models have been used. A magnetic field is applied continuously to the hot wall. The Richardson, Hartmann and Darcy numbers ranges are 1 ≤ Ri ≤ 100, 0 ≤ Ha ≤ 30, 0.001 ≤ Da ≤ 0.1, respectively. Also, the volume fraction of nanofluid is changed in the range of 0 ≤ φ ≤ 0.03.

Fig. 1
figure 1

Schematic of the problem

Governing equations

Continuity equation

$$ \frac{\partial u}{\partial x} + \frac{\partial v}{\partial y} = 0 $$
(1)

Momentum equations

(x-direction)

$$ \frac{{\rho_{\text{nf}} }}{{\varepsilon^{2} }}\left[ {u\frac{\partial u}{\partial x} + v\frac{\partial u}{\partial y}} \right] = - \frac{\partial p}{\partial x} + \frac{{\mu_{\text{nf}} }}{\varepsilon }\left[ {\frac{{\partial^{2} u}}{{\partial x^{2} }} + \frac{{\partial^{2} u}}{{\partial y^{2} }}} \right] - \frac{{\mu_{\text{nf}} }}{K}u $$
(2-a)

(y-direction)

$$ \frac{{\rho_{\text{nf}} }}{{\varepsilon^{2} }}\left[ {u\frac{\partial v}{\partial x} + v\frac{\partial v}{\partial y}} \right] = - \frac{\partial p}{\partial y} + \frac{{\mu_{\text{nf}} }}{\varepsilon }\left[ {\frac{{\partial^{2} v}}{{\partial x^{2} }} + \frac{{\partial^{2} v}}{{\partial y^{2} }}} \right] - \frac{{\mu_{\text{nf}} }}{K}u - \frac{{\sigma_{\text{nf}} }}{{\rho_{\text{nf}} }}B_{0}^{2} v + \left( {\rho \beta } \right)_{\text{nf}} g\left( {T - T_{\text{C}} } \right) $$
(2-b)

The generated Lorentz force by the magnetic field is calculated from the following equation. [45]:

$$ \vec{F} = \vec{J} \times \vec{B} $$
(3)

where

$$ \vec{J} = \sigma_{\text{nf}} \left( {\vec{V} \times \vec{B}} \right) $$
(4-a)

And,

$$ \vec{B} = \vec{B}_{0} + \vec{b} $$
(4-b)

On the other hand, \( \vec{J} \) is calculated according to the ampere’s law as follows:

$$ \vec{J} = \frac{1}{{\mu_{\text{nf}} }}\nabla \times \vec{B} $$
(5)

Maxwell’s equation is defined as follows:

$$ \nabla \cdot \vec{B} = 0 $$
(6)

By writing and rearranging Eqs. (4-a6), the magnetic induction equation is obtained as follows [45]:

$$ \left( {\vec{V} \cdot \nabla } \right)\vec{B} = \frac{1}{{\mu_{\text{nf}} \sigma_{\text{nf}} }}\nabla^{2} \vec{B} + \left( {\vec{B} \cdot \nabla } \right)\vec{V} $$
(7)

The current density will be obtained in each repetition by solving the magnetization equations.

Energy equation

$$ u\frac{\partial T}{\partial x} + v\frac{\partial T}{\partial y} = \alpha_{\text{nf}} \left[ {\frac{{\partial^{2} T}}{{\partial x^{2} }} + \frac{{\partial^{2} T}}{{\partial y^{2} }}} \right] $$
(8)

Equations (2-a) and (2-b) are valid for a magnetic field and for assuming a local thermal equilibrium (LTE) or a local thermal non-equilibrium (LTNE) models. Equation (8) also holds for the assumption of local thermal equilibrium model. When the local thermal non-equilibrium model is considered, two energy equations for solid and fluid phases are written as follows [46, 47]:

For fluid phase

$$ \left( {\rho C_{\text{p}} } \right)_{\text{nf}} \left[ {u\frac{{\partial T_{\text{nf}} }}{\partial x} + v\frac{{\partial T_{\text{nf}} }}{\partial y}} \right] = \varepsilon k_{\text{nf}} \left[ {u\frac{{\partial^{2} T_{\text{nf}} }}{{\partial x^{2} }} + v\frac{{\partial^{2} T_{\text{nf}} }}{{\partial y^{2} }}} \right] + h\left( {T_{\text{s}} - T_{\text{nf}} } \right) $$
(9)

For solid phase

$$ 0 = \left( {1 - \varepsilon } \right)k_{\text{s}} \left[ {u\frac{{\partial^{2} T_{\text{s}} }}{{\partial x^{2} }} + v\frac{{\partial^{2} T_{\text{s}} }}{{\partial y^{2} }}} \right] + h\left( {T_{\text{nf}} - T_{\text{s}} } \right) $$
(10)

The dimensionless forms of Eqs. (1), (2-a), (2-b), (7) and (8) are as follows [48]:

$$ \frac{\partial U}{\partial X} + \frac{\partial V}{\partial Y} = 0 $$
(11)
$$ \left[ {U\frac{\partial U}{\partial X} + V\frac{\partial U}{\partial Y}} \right] = - \varepsilon^{2} \frac{{\rho_{\text{f}} }}{{\rho_{\text{nf}} }}\frac{\partial P}{\partial X} + \frac{\varepsilon }{\text{Re}}\frac{{v_{\text{nf}} }}{{v_{\text{f}} }}\left[ {\frac{{\partial^{2} U}}{{\partial X^{2} }} + \frac{{\partial^{2} U}}{{\partial Y^{2} }}} \right] - \frac{{v_{\text{nf}} }}{{v_{\text{f}} }}\frac{1}{{\text{Re} \,{\text{Da}}}}U\varepsilon^{2} $$
(12-a)
$$ \left[ {U\frac{\partial V}{\partial X} + V\frac{\partial V}{\partial Y}} \right] = - \varepsilon^{2} \frac{{\rho_{\text{f}} }}{{\rho_{\text{nf}} }}\frac{\partial P}{\partial Y} + \frac{{v_{\text{nf}} }}{{v_{\text{f}} }}\frac{\varepsilon }{\text{Re}}\left[ {\frac{{\partial^{2} U}}{{\partial X^{2} }} + \frac{{\partial^{2} U}}{{\partial Y^{2} }}} \right] - \frac{{v_{\text{nf}} }}{{v_{\text{f}} }}\frac{1}{{\text{Re} \,{\text{Da}}}}V\varepsilon^{2} - \frac{{\sigma_{\text{nf}} \rho_{\text{f}} }}{{\sigma_{\text{f}} \rho_{\text{nf}} }}\frac{{{\text{Ha}}^{2} }}{\text{Re}}V\varepsilon^{2} + \frac{{\beta_{\text{nf}} \rho_{\text{nf}} }}{{\beta_{\text{f}} \rho_{\text{nf}} }}\frac{\text{Gr}}{{\text{Re}^{2} }}\theta \varepsilon^{2} $$
(12-b)
$$ U\frac{{\partial \theta_{\text{nf}} }}{\partial X} + V\frac{{\partial \theta_{\text{nf}} }}{\partial Y} = \frac{1}{{\text{Re} \,\Pr }}\left[ {\frac{{\partial^{2} \theta_{\text{nf}} }}{{\partial X^{2} }} + \frac{{\partial^{2} \theta_{\text{nf}} }}{{\partial Y^{2} }}} \right] $$
(13)

Equation (13) only exists under local thermal equilibrium (LTE) conditions. When the local thermal non-equilibrium model (LTNE) is considered, the energy equation for the fluid and solid phases is expressed as follows [46, 47]:

For fluid phase

$$ \frac{1}{\varepsilon }\left[ {U\frac{{\partial \theta_{\text{nf}} }}{\partial X} + V\frac{{\partial \theta_{\text{nf}} }}{\partial Y}} \right] = \Gamma \left[ {\frac{{\partial^{2} \theta_{\text{nf}} }}{{\partial X^{2} }} + \frac{{\partial^{2} \theta_{\text{nf}} }}{{\partial Y^{2} }}} \right] + \frac{{\rho C_{\text{pf}} }}{{\left( {\rho C_{\text{p}} } \right)_{\text{nf}} }}H\left( {\theta_{\text{s}} - \theta_{\text{nf}} } \right) $$
(14)

For solid phase

$$ 0 = \left[ {\frac{{\partial^{2} \theta_{\text{s}} }}{{\partial x^{2} }} + \frac{{\partial^{2} \theta_{\text{s}} }}{{\partial y^{2} }}} \right] + \gamma H\left( {\theta_{\text{nf}} - \theta_{\text{s}} } \right) $$
(15)

Dimensionless parameters are defined as follows [48,49,50,51]:

$$ \theta_{\text{nf}} = \frac{{T_{\text{nf}} - T_{\text{C}} }}{{T_{\text{H}} - T_{\text{C}} }} $$
(16)
$$ \theta_{\text{s}} = \frac{{T_{\text{s}} - T_{\text{C}} }}{{T_{\text{H}} - T_{\text{C}} }} $$
(17)
$$ \psi = \frac{{\Psi L}}{\alpha } $$
(18)
$$ {\text{Da}} = \frac{K}{{L^{2} }} $$
(19)
$$ {\text{Gr}} = \frac{{g\beta_{\text{f}} \Delta TL^{3} }}{{\nu_{\text{f}}^{2} }} $$
(20)
$$ H = \frac{{hL^{2} }}{{\varepsilon k_{\text{f}} }} $$
(21)
$$ {\text{Ha}} = B_{0} L\sqrt {\frac{{\sigma_{\text{nf}} }}{{\rho \nu_{\text{f}} }}} $$
(22)
$$ P = \frac{p}{{\rho_{\text{nf}} v_{0}^{2} }} $$
(23)
$$ \Pr = \frac{{v_{\text{f}} }}{{\alpha_{\text{f}} }} $$
(24)
$$ \text{Re} = \frac{{\rho_{\text{f}} v_{0} L}}{{\mu_{\text{f}} }} $$
(25)
$$ {\text{Ri}} = \frac{\text{Gr}}{{\text{Re}^{2} }} $$
(26)
$$ U = \frac{u}{{v_{0} }} $$
(27)
$$ V = \frac{v}{{v_{0} }} $$
(28)
$$ X = \frac{X}{L} $$
(29)
$$ Y = \frac{y}{L} $$
(30)
$$ \Gamma = \frac{{\alpha_{\text{nf}} }}{{\alpha_{\text{bf}} }} $$
(31)
$$ \Omega = \frac{ - \omega L}{{2v_{0} }} $$
(32)
$$ \gamma = \frac{{\varepsilon k_{\text{nf}} }}{{\left( {1 - \varepsilon } \right)k_{\text{s}} }} $$
(33)
$$ \theta = \frac{{T - T_{\text{C}} }}{{T_{\text{H}} - T_{\text{C}} }} $$
(34)

The thermophysical properties of nanofluid are expressed in terms of Eqs. (35)–(40), respectively [52,53,54,55,56].

$$ \rho_{\text{nf}} = \rho_{\text{f}} \left( {1 - \varphi } \right) + \rho_{\text{p}} \varphi $$
(35)
$$ \left( {\rho C_{\text{p}} } \right)_{\text{nf}} = \left( {\rho C_{\text{p}} } \right)_{\text{f}} \left( {1 - \varphi } \right) + \left( {\rho C_{\text{p}} } \right)_{\text{p}} \varphi $$
(36)
$$ \left( {\rho \beta } \right)_{\text{nf}} = \left( {\rho \beta } \right)_{\text{f}} \left( {1 - \varphi } \right) + \left( {\rho \beta } \right)_{\text{p}} \varphi $$
(37)
$$ k_{\text{nf}} = k_{\text{f}} \frac{{k_{\text{p}} + 2k_{\text{f}} + 2\varphi \left( {k_{\text{p}} - k_{\text{f}} } \right)}}{{k_{\text{p}} + 2k_{\text{f}} - \varphi \left( {k_{\text{p}} - k_{\text{f}} } \right)}} $$
(38)
$$ \mu_{\text{nf}} = \frac{{\mu_{\text{f}} }}{{\left( {1 - \varphi } \right)^{2.5} }} $$
(39)
$$ \sigma_{\text{nf}} = \sigma_{\text{f}} \left[ {1 + \frac{{3\left( {\frac{{\sigma_{\text{p}} }}{{\sigma_{\text{f}} }} - 1} \right)\varphi }}{{\left( {\frac{{\sigma_{\text{p}} }}{{\sigma_{\text{f}} }} + 2} \right) - \left( {\frac{{\sigma_{\text{p}} }}{{\sigma_{\text{f}} }} - 1} \right)\varphi }}} \right] $$
(40)

The local Nusselt number on the hot walls is defined as follows [47]:

$$ \begin{aligned} {\text{Nu}} & = \underbrace {{\left[ { - \left( {\frac{{k_{\text{nf}} }}{{k_{\text{f}} }}} \right)\frac{{\partial \theta_{\text{nf}} }}{\partial Y}} \right]_{{{\text{X}} = 0}} }}_{{{\text{Nu}}_{{{\text{hot}}\,{\text{wall}}}} }} + \underbrace {{\left[ { - \left( {\frac{{k_{\text{nf}} }}{{k_{\text{f}} }}} \right)\frac{{\partial \theta_{\text{nf}} }}{\partial n}} \right]_{\text{surface,UC}} }}_{{{\text{Nu}}_{\text{surface,UC}} }} + \underbrace {{\left[ { - \left( {\frac{{k_{\text{nf}} }}{{k_{\text{f}} }}} \right)\frac{{\partial \theta_{\text{nf}} }}{\partial n}} \right]_{\text{surface,LC}} }}_{{{\text{Nu}}_{\text{surface,LC}} }} \\ & = \left[ {\frac{{q^{\prime\prime}\left( y \right)L}}{{\Delta Tk_{\text{f}} }}} \right]_{{{\text{hot}}\,{\text{wall}}}} + \left[ {\frac{{q^{\prime\prime}D}}{{\Delta Tk_{\text{f}} }}} \right]_{\text{UC}} + \left[ {\frac{{q^{\prime\prime}D}}{{\Delta Tk_{\text{f}} }}} \right]_{\text{LC}} \\ \end{aligned} $$
(41)

The average Nusselt number on the hot walls is defined as follows [47]:

$$ {\text{Nu}}_{\text{ave}} = \mathop \int \limits_{0}^{1} \left. {{\text{Nu}}_{{{\text{hot}}\,{\text{wall}}}} {\text{d}}Y} \right|_{{{\text{X}} = 0}} + \int {{\text{Nu}}_{\text{surface,UC}} {\text{d}}S} + \int {{\text{Nu}}_{\text{surface,LC}} {\text{d}}S} $$
(42)

While considering the local thermal non-equilibrium model, two heat transfer parameters are generated by solving two energy equations. Hence, \( {\text{Nu}}_{\text{f}} \) and \( {\text{Nu}}_{\text{s}} \) are defined as follows [47]:

$$ {\text{Nu}}_{\text{f}} = - \left( {\frac{{k_{\text{nf}} }}{{k_{\text{f}} }}} \right)\frac{{\partial \theta_{\text{nf}} }}{\partial Y} = \frac{{q_{\text{f}}^{{\prime \prime }} \left( y \right)L}}{{\Delta Tk_{\text{f}} }} $$
(43)
$$ {\text{Nu}}_{s} = - \left( {\frac{{k_{\text{s}} }}{{k_{\text{f}} }}} \right)\frac{{\partial \theta_{\text{s}} }}{\partial Y} = \frac{{q_{s}^{{\prime \prime }} \left( y \right)L}}{{\Delta Tk_{\text{s}} }} $$
(44)

Boundary conditions

$$ \begin{aligned} & {{Top}}\;{{wall}}\;\left( {{Adiabatic}} \right)\;u = v = 0,\quad \frac{\partial T}{\partial y} = 0 \\ & {{Bottom}}\;{{wall}}\;\left( {{Adiabatic}} \right)\;u = y = 0,\quad \frac{\partial T}{\partial y} = 0 \\ & {{Right}}\;{{wall}}\; v = + v_{0} ,\quad T = T_{\text{c}} \\ & {{Left}}\;{{wall}}\;v = - v_{0} ,\quad T = T_{\text{h}} \\ & {{Adiabatic}}\;{{cylinders}}\;u = - \omega \left( {y - y_{0} } \right)\quad v = \omega \left( {x - x_{0} } \right),\quad \frac{\partial T}{\partial n} = 0 \\ & {{Isothermal}}\;{{cylinders}}\;\left( {{Cold}} \right)\;u = - \omega \left( {y - y_{0} } \right)\quad v = \omega \left( {x - x_{0} } \right),\quad T = T_{\text{c}} \\ & {{Isothermal}}\;{{cylinders}}\;\left( {{Hot}} \right)\;u = - \omega \left( {y - y_{0} } \right)\quad v = \omega \left( {x - x_{0} } \right),\quad T = T_{\text{H}} \\ \end{aligned} $$
(45)

The dimensionless forms of boundary conditions according to the dimensionless equations are written as follows:

$$ \begin{aligned} & {{Top}}\;{{wall}}\;\left( {{Adiabatic}} \right)\; U = V = 0\quad \frac{\partial \theta }{\partial Y} = 0\quad Y = 1\quad 0 < X < 1 \\ & {{Bottom}}\;{{wall}}\;\left( {{Adiabatic}} \right) \;U = V = 0\quad \frac{\partial \theta }{\partial Y} = 0\quad Y = 0\quad 0 < X < 1 \\ & {{Right}}\;{{wall}}\; U = \theta = 0\quad V = + 1\quad X = 1\quad 0 < Y < 1 \\ & {{Left}}\;{{wall}}\; U = 0, V = - 1\quad \theta = 1\quad X = 0\quad 0 < Y < 1 \\ & {{Adiabatic}}\;{{cylinders}}\; U = 2\Omega \left( {Y - Y_{0} } \right)\;\quad V = - 2\Omega \left( {X - X_{0} } \right),\quad \frac{\partial \theta }{\partial n} = 0 \\ & {{Isothermal}}\;{{cylinders}}\;\left( {{Cold}} \right) \;U = 2\Omega \left( {Y - Y_{0} } \right)\quad V = - 2\Omega \left( {X - X_{0} } \right),\quad \theta = 0 \\ & {{Isothermal}}\;{{cylinders}}\;\left( {{Hot}} \right)\;U = 2\Omega \left( {Y - Y_{0} } \right)\;\quad V = - 2\Omega \left( {X - X_{0} } \right),\quad \theta = 1 \\ \end{aligned} $$
(46)

Thermophysical properties of the nanofluid and solving method

The thermophysical properties of the nanofluid and base fluid are presented in Table 1.

Table 1 Thermophysical properties of nanoparticles and base fluid [55, 57]

The finite element method (FVM) has been used to solving equations. A commercial software package (ANSYS-FLUENT) is used for geometry drawing, meshing and analysis processes. A uniform grid is used. The second-order upwind scheme has been used to solve fundamental equations. SIMPLE algorithm has been used for pressure–velocity coupling. Guess-Seidel method is used for to solve numerical equations. V-Cycle and F-Cycle methods are used for coupling momentum and energy equations. Under-relaxation factors (URF) for pressure, momentum, energy and magnetic induction equations are 0.3, 0.7, 1 and 0.9, respectively. The convergence criterion is considered 10−6. The features of the system are: CPU core i7 4500U (1.8 GHz), RAM 8 GB DDR3 and Win. 10.

Grid independency and validation

Two parameters of steam function and heat transfer rate (ψ and Nu) have been used to stabilize the output parameters. As shown in Table 2, the third grid is an appropriate choice for the simulation.

Table 2 Grid independency for Da = 0.001, Ri = 1, Ha = 0 and φ = 0.03

In order to ensure that the numerical solution is applied, the present work is compared with the various references. A numerical comparison (Fig. 2a, b) was performed with results of Ref. [56]. Ghasemi et al. [56] investigated the effect of convection heat transfer in a cavity filled by a nanofluid numerically. In order to increase or decrease the heat transfer rate, they used a uniform magnetic field. Their simulation was done for a cavity with two insulating walls in the top and bottom of the cavity and two hot and cold walls in the left side and right side of the cavity, respectively. As can be seen, there is a good agreement between the present work and the Ref. [56].

Fig. 2
figure 2

a Validation for streamlines with Ref. [56], b Validation for isotherm-lines with Ref. [56]

The second validation involves another numerical study. Santhosh Kumar et al. [58] studied mixed convection in a porous cavity. They considered a wide range of Darcy, Reynolds, and Grashof numbers. They used the SIMPLE algorithm and the QUICK method for discretization of equations. Figure 3 shows the comparison between the obtained results and the numerical results [58]. As can be seen, a perfectly acceptable match for the streamlines and isotherm-lines can be seen.

Fig. 3
figure 3

Validation for streamlines (left) and isotherm-lines (right) with Ref. [58]. (Da = 10−3, Gr = 102 and Ri = 10−2)

In order to be more assured of the numerical method employed, the present study is validated with the experimental [59] and the numerical [60] results. In the experimental reference, the alumina-water nanofluid was used in three square-shaped cavities. Natural convection and migration of nanoparticles were investigated in the experimental reference. Figure 4 shows the comparison of the present work with experimental and numerical references. As can be seen, an acceptable match can be obtained with experimental results. It is worth mentioning that the reason for the difference in numerical with the experimental results is due to the distribution of nanoparticles in the cavity. Also, the present study is validated with Motlagh and Soltanipour [60], which is very well suited to numerical reference.

Fig. 4
figure 4

Comparison between the present work with Refs. [59, 60]

Results and discussion

This section describes the results obtained from the simulation. First, the streamlines and isotherm-lines are shown and the effect of different parameters on them is examined. After that, the effect of different parameters and various boundary conditions on heat transfer in the graph format is given.

Figure 5 shows the contours of the streamlines and isotherm-lines for different Hartmann numbers in the constant Richardson and Darcy numbers for different temperature conditions. As can be seen, in all three cases, there are two strong vortexes in the proximity of the cylinders. Two vortexes are generated due to the rotation of the cylinders. Of course, the generated vortex by the right-hand cylinder is larger than the generated vortex by the left-handed cylinder. This is due to the fact that the direction of the wall movement and the right cylinder rotation empowers the vortex and ultimately forms a larger vortex. In all three cases, the increase in the Hartmann number leads to a decrease in the flow function. This is due to the fact that the Lorentz force acts as a current inhibitor. When the cylinders are insulated, in the left wall, small vortexes arise from the wall movement, which, with increasing magnetic field intensity, these vortexes fade away and a uniform area of the flow is created in the cavity. However, when the cylinders are isotherm with a cold or hot wall, in the absence of a magnetic field, the flow in this area is almost uniform, which can clearly be seen when the cylinders are cold. In the presence of the magnetic field, the flow in this region is suddenly changed, which is due to the isothermally of the cylinders with cold and hot walls. By increasing the intensity of the magnetic field, although the power of the vortexes decreases, the small vortexes generated at Ha = 10 are converted to larger vortexes with less power due to the complementary effect of the cylinders. The minimization and maximization of the flow function happened in the case of cold cylinders. In all cases, at the bottom of the left-hand cylinder there is a region at which the velocity is minimal, which means that the rotation of the cylinders causes the fluid flow to the upstream of the cavity. Considering that, three different conditions are considered for the boundary condition of the cylinders, contour of isotherm-lines will have different states for each mode. When the cylinders are insulated, the increase in the Hartmann number causes more heat diffusion to the cavity, in a way that, the heat diffusion is carried out in the lower part of the cavity. In fact, with the reduction in the flow velocity due to the Lorentz force, the fluid has a lower chance of heat dissipation, and it is expected that in this condition the heat transfer will decrease. When the cylinders are cold, most of the cavity is at a cold region. In this case, as the Hartmann number increases, the heat diffusion is slowly happened from the bottom of the left cylinder and continues to the right cylinder. Nevertheless, the point is that in the absence of a magnetic field, the heat diffusion in the left upstream is maximal. As the intensity of the magnetic field increases, the intensity of the penetration decreases and due to the contrast between the Buoyancy force and the Lorentz force, the heat is drained downward and eventually transmitted to the middle of the cavity. When the cylinders are heated, a large portion of the cavity is in the heat region. In this case, as the Hartman number increases, the heat diffusion in the cavity increases. As it can be seen, the heat diffusion is done from the proximity cylinder to the top.

Fig. 5
figure 5figure 5figure 5

Streamlines (left) and isotherm-lines (right) contours for various Hartmann numbers and \( \gamma = 9 \)

The contours of the streamlines and isotherm-lines for various Darcy numbers in the Richardson numbers are shown for different temperature conditions in Fig. 6. As can be seen, in all three modes (whether in the presence or absence of a magnetic field), the flow function increases with increasing the Darcy number. In fact, increasing the permeability increases the velocity of the fluid flow into the cavity and eventually increases the flow function. When the cylinders are insulated, and in the absence of a magnetic field, the increase in permeability leads to the elongation of the vortexes. This effect is such that in the proximity of the right cylinder, with the increase in the Darcy number, the flow is transferred to the top of the cavity and increases the circulation of fluid in the cavity. In this case, with the increase in the Darcy number, in the region where the flow function is minimal, the vortexes generated from the cylinder movement are merged into each other and created a single vortex proximate to the left cylinder. Increasing the permeability and impact of the cylinder’s rotational velocity is such that a major vortex is created at the corners of the cavity. The same behavior is observed for cylinders that are cold or hot. With the difference that when the cylinders are cold, a larger vortex with a greater power is formed proximate to the cold wall. In addition, a large vortex, a combination of two vortexes generated by the cylinders, is created in the center of the cavity. Therefore, in this case, the flow function for the cold wall will be maximized. In the case of hot cylinders, the same condition is observed, with the difference that the amount of the flow function is minimal. In all three modes, in the presence of the magnetic field, the flow function increases with the increase in the Darcy number. This suggests that the role of the porous medium is stronger than the role of the magnetic field. In the presence of a magnetic field, with the increase in the Darcy number, the vortex elongation happened in the left cylinder, and thus the flow strengthening happened. In the proximity of the right cylinder, there is a decrease in the flow velocity and, as a result, a weakening of the vortex happened. Since the increase in permeability increases the flow velocity and consequently creates a larger gradient, in the upstream of the left cylinder due to the contrast between the convection force and the Lorentz, the result reversed and the flow amplified and ultimately leads to increased vorticity. In the proximity of the right cylinder, due to the location of the cylinder in the cavity, the presence of the magnetic force reduces the flow velocity and ultimately weakens the vortex. In all three cases, by increasing the Darcy number, the heat diffusion in cavity increases. When the cylinders are insulated, the heat diffusion starts from the hot zone and the center of the cavity, and empowers by the rotation of the cylinders and the heat is transferred to the cold wall. When the cylinders are cold, the heat is slowly flowing from the center of the hot wall and transfers to the center of the cavity. Because the flow function is the minimum in this area, starting and continuing the heat transfer takes place from this area. In the case of hot cylinders, the same behavior is observed and a large part of the heat transfer occurs near the cold wall. Of course, for all three modes, the sudden variations of the heat transfer from Da = 0.001 to Da = 0.01 are slightly more than Da = 0.01 to Da = 0.1. This can contribute to the role of porous environment in the amount of heat penetration. On the other hand, when the magnetic field is applied, the heat transfer in the cavity is greater than that of the absence of the magnetic field. Since the magnetic field reduces the flow velocity of the fluid, the presence of Lorentz force is considered as a factor in enhancing heat transfer.

Fig. 6
figure 6figure 6figure 6figure 6figure 6

Streamlines (left) and isotherm-lines (right) contours for various Darcy numbers and \( \gamma = 9 \)

In Fig. 7, contours of the streamlines and isotherm-lines for different Richardson numbers in their fixed Darcy number are given. As can be seen, in all three cases (in the presence or absence of a magnetic field), by increasing the Richardson number, the flow function decreases. In fact, the increase in the Richardson number leads to a weakening of the forced convection and the dominance of the buoyancy force and ultimately reduces the flow function. As can be seen, the convection force weakening will result in the separation of the fringes generated in the cavity, especially in the vicinity of the cylinders, so that in Ri = 100 the generated vortexes in the upstream and downstream of the left and right cylinders are small and weakened. The highest value of the flow function for Ri = 1 occurs in the absence of a magnetic field and for the case where the cylinders are cold, and the lowest value of the flow function for Ri = 100 occurs in the presence of a magnetic field for the case where the cylinders are insulated. Therefore, the more the flow function increases, the more powerful vortexes appear in their own realm. In all three cases, in the absence of a magnetic field, by increasing the Richardson number, the isotherm-lines pattern will become uniform, while when the magnetic field is existed, the flow pattern will be uniform due to the decreasing velocity than in the absence of the magnetic field. In this case, the heat diffusion in the cavity is mostly due to the magnetic field, but since the decrease in velocity is directly related to the decrease in forced convection power, so in a fixed Hartmann number, with the increase in the Richardson number, the heat diffusion in the cavity becomes less frequent.

Fig. 7
figure 7figure 7figure 7figure 7figure 7

Streamlines (left) and isotherm-lines (right) contours for various Richardson numbers and \( \gamma = 9 \)

The effect of dimensionless thermal conductivity and its variations on the streamlines and isotherm-lines for the Richardson and Darcy number is shown in Fig. 8. As can be seen, since the thermal conductivity is only in the energy equation, in all three cases no significant change can be seen in the pattern of streamlines due to the changes in the dimensionless thermal conductivity coefficient. But since the device of the governing equations is solved together, these changes appear slightly in the flow function and streamlines. Therefore, as it is observed, the most changes are related to the contours of the isotherm-lines. The thermal equilibrium model assumes that in each location the solid phase temperature is approximately equal to the temperature of the fluid phase. In fact, in this model, \( T_{\text{s}} = T_{\text{nf}} = T \), which \( T_{\text{s}} \) is the solid phase temperature and \( T_{\text{nf}} \) is the fluid temperature at each point. This assumption is theoretically and numerically simple. Assuming not to use local thermal equilibrium, in a given porosity, by decreasing the dimensionless thermal conductivity, the isotherm-lines behavior will be softer. In fact, reducing the thermal conductivity leads to increase the solids thermal conductivity coefficient, and finally, the isotherm-lines show more gentle behavior. In the case of γ = 9, the thermal conductivity of the solid phase and the fluid phase is equal and it can be concluded that the contribution of both fluid and solid phase in heat diffusion is the same. In the case of assuming the thermal equilibrium, since an overall energy equation for fluid and solid phase is solved, therefore, by reducing the dimensionless thermal conductivity coefficient, the thermal conductivity of the fluid cannot be functioning in heat transfer. In addition, as what previously have been stated about the contours of the isotherm-lines, in this section, isotherm-lines patterns follow the rules stated in the previous sections for all three modes. Moreover, by decreasing the dimensionless thermal conductivity coefficient, the heat transfer is increased due to the increase in the thermal conductivity of the solid phase. The presence of the magnetic field, coupled with the reduction in the dimensionless thermal conductivity, leads to increase the density of the isotherm-lines, which means that diffusing the heat in the cavity is completely continuous.

Fig. 8
figure 8figure 8figure 8figure 8figure 8

Streamlines (left) and isotherm-lines (right) contours for various dimensionless thermal conductivity

The effect of the dimensionless inter-phase heat transfer coefficient on the streamlines and isotherm-lines in Darcy and Richardson numbers is shown in Fig. 9. As can be seen, in all three cases, with increasing inter-phase heat transfer coefficient, no appreciable change in the contour of the streamlines is observed. Since the dimensionless inter-phase heat transfer coefficient is a function of porosity percent, in a given volume fraction and a constant porosity, with an increase in inter-phase heat transfer coefficient, only amount of heat transfer is changed, and no change occurs in fluid content. Therefore, as flow contours of the streamlines are also known, the change in the flow pattern does not occur with increasing H, and we can ignore the variations of the flow function with increasing H. Since it is in the state of local thermal non-equilibrium \( T_{\text{s}} \ne T_{\text{nf}} \), two energy equations are solved for fluid and solid phases. Therefore, as it is observed, there will be two contours for isotherm-lines. In the case of H = 0.1, the difference between the phases of the fluid phase and the solid phase is observed. As the H increases, the solid-state phase contour isotherm-lines are more affected by fluctuations. This is due to the low thermal resistance of the solid phase relative to the fluid phase. Therefore, in this case, most of the heat is transmitted through the conduction mechanism in the porous medium (solid phase), so the difference in isotherm-lines for solid and liquid phases is high. By increasing H, the pattern of the solid phase isotherm-lines varies and becomes close to isotherm-lines of fluid phase, in this case the heat transfer from the solid phase has increased, indicating that the fluid phase dominates the solid phase. When H is maximal, the pattern of isotherm-lines of fluid and solid phase is very similar to each other.

Fig. 9
figure 9figure 9figure 9figure 9figure 9

Streamlines (left), isotherm-lines (right and bottom) contours for various dimensionless inter-phase heat transfer coefficient

Therefore, with respect to the contours of isotherm-lines, it can be state that in this condition a thermal equilibrium has occurred with a good approximation. It can be concluded that due to the increase in thermal resistance of the solid phase, the effect of the fluid phase and its properties overcame on solid phase.

The average Nusselt number diagrams in terms of the Hartmann number for three different temperature cases in a constant Richardson number are shown in Fig. 10. On a constant Hartmann number with increasing the Darcy number, the heat transfer increases. Increasing the Darcy number leads to increased permeability, and the fluid has the potential for penetration in the porous medium, and this issue caused to increase the heat transfer. Of course, a significant increase in the heat transfer from Da = 0.001 to Da = 0.01 is observed. However, the increase in heat transfer from Da = 0.01 to Da = 0.1 compared with Da = 0.01 to Da = 0.01 is low. Therefore, it can be said that although the maximum heat transfer for the Da = 0.1 occurs, but Darcy 0.01 has the most effective and highest rate of heat transfer. Because of this, it can be related to the inherent property of the porous medium. The intrinsic property of the porous medium acts in such a way that, in the case of minimum permeability, in all three cases, with the increase in the Hartmann number, the heat transfer is increased. As the Darcy number increases, the behavior of the Nusselt number varies with the changes in the Hartmann number; in the case of cylinders that are insulated or cold, the maximum heat transfer rate is within the Ha = 10 range and, if cylinders are hot, a contradictory behavior is observed in the case of Da = 0.001. Since the Nusselt number behavior is different in the high permeability, it can be concluded that the behavior of the porous medium is influenced by the effect of the temperature of the system (the temperature conditions is related to the cylinders); although the presence of the magnetic field results in reducing the flow rate, factors such as the degree of permeability and temperature boundary conditions can greatly affect the increase or decrease in heat transfer.

Fig. 10
figure 10

Nusselt number versus Hartmann number for various Darcy numbers

In Fig. 11, the mean Nusselt number in terms of the Richardson number for three different temperature cases for different Darcy numbers in the presence and absence of a magnetic field is indicated. The variations in the Nusselt number follow almost the same behavior in all three different temperatures. In all three graphs, for the Ri = 0, the highest heat transfer rate is observed. In addition, the variation of the Nusselt number with the Richardson number is L-shaped. This means that when the Richardson number is minimal, forced convection completely fits in the cavity, and so the Nusselt number is maximal. In Richardson’s maximum, there is a dominant buoyancy force in the cavity and therefore the least heat transfer is observed. In the case of the Richardson maximum, the buoyancy force of the system is strongly dependent on the temperature of the cylinders. As the cylinders are hot, the Nusselt number is less than 1. Since there is no limitation on the Nusselt number and the heat transfer rate, it is possible to receive heat transfer through the conduction mechanism. Even with tenfold increase in forced convection when the cylinders are hot, the heat transfer is still dominated by conduction mechanism, and in the upper permeability, the Nusselt number is less than that of the Ri = 100. While when the cylinders are cold or insulated, the above conditions do not happen. Therefore, the temperature conditions of the cylinders play an essential role in predicting the heat transfer rate, especially in cases where the buoyancy force is dominant. As mentioned earlier, the combination of the magnetic field and the porous medium can increase or decrease the heat transfer rate that is because of the inherent nature of the porous medium.

Fig. 11
figure 11

Average Nusselt number versus Richardson number for various Darcy numbers

Figure 12 shows the diagram of the local Nusselt number on the hot wall in three different temperature cases and in the local thermal non-equilibrium. The behavior of the graph for the Nusselt number of the fluid phase shows an exponential behavior. As the length of the cavity increases, the local Nusslet number also increases. Since there are two cylinders in the cavity and the position of the cylinders can play an important role in predicting the flow and heat pattern, therefore according to the schematic of the problem geometry, the presence of the left cylinder near the hot wall and at the top of the cavity increases the flow circulation and amplification of the thermal gradients and the velocity gradients are heated in the vicinity of the wall, and therefore the local Nusselt number is higher in this part than the lower cavity. In addition, the local Nusselt number and the mean Nusselt number for cold and warm cylinders are maximum and minimum, respectively. Coldness of cylinders increases the velocity of fluid flow and increases the heat transfer rate. In a fixed fluid/solid heat transfer coefficient, an increase in the dimensionless thermal conductivity coefficient leads to an increase in the thermal transfer coefficient of the solid phase and, consequently, to an increase in the Nusselt number. This issue can be seen in the local Nusselt number diagram for the solid phase. Therefore, for the mean Nusselt number, and local Nusselt number, maximum and minimum heat transfer rates occur for the maximum and minimum dimensionless thermal conductivity coefficients, respectively.

Fig. 12
figure 12

Local Nusselt number versus dimensionless length of cavity for various γ

Figure 13 shows the local Nusselt number diagram on a hot wall in three different temperature cases and in the condition of local thermal non-equilibrium. The behavior of the graphs is similar to that described in Fig. 12. In the case of a fixed dimensionless thermal conductivity, the increase in the fluid/solid heat transfer coefficient increases the local Nusselt number and ultimately leads to an increase in the mean Nusselt number. Because the fluid/solid dimensionless heat transfer coefficient expresses the convection ratio at the interface between solid and fluid phases to thermal conductivity, so the heat transfer increases with increasing H due to the increase in the heat transfer coefficient of the fluid and solid phase interface. In other words, the smallness of H indicates a higher thermal conductivity and, with increasing H, the difference between the temperature and the solid phase becomes lesser, and hence the Nusselt number increases. As a result, H increases the system’s local thermal equilibrium. Comparing the behavior of the Nusselt solid case diagrams, it can be seen that in all three temperature cases, for H = 10, the behavior of the graph with the behavior of the Nusselt number diagram for the fluid phase is the same. This indicates that the system is reaching or approaching the local thermal equilibrium. The above factors are true for the solid phase Nusselt number diagram. Because in the case of local thermal non-equilibrium, two energy equations are solved, so increasing the parameter H directly affects the heat transfer of solid and liquid phases.

Fig. 13
figure 13

Local Nusselt number versus dimensionless length of cavity for various H

Figure 14 shows the general changes of all three basic parameters (Darcy number, Hartmann number and volume fraction) for the temperature cases of the rotating cylinders. In all cases (all the permeability and temperature cases of the cylinders), and in the absence of magnetic field with increasing volume fraction, the heat transfer increases due to an increase in the thermal conductivity of the fluid. In the case of a magnetic field, for a given Hartmann number, in almost all cases, the volume fraction of the heat transfer increases. However, in general, the increase in the Hartmann number reduces the flow velocity of the fluid, but in a Hartmann number, the effect of the thermal conductivity coefficient is greater than that of Lorentz force. However, obviously there are exceptions in this case. In all permeability, with the maximum number of Hartmann, and in the case of warm cylinders, the heat transfer rate is reduced by increasing the volume fraction. Since the heat of the cylinders has the lowest heat transfer rate, in fact, the warmth of the cylinders in the Hartmann number maximizes the ability of the nanofluid to function well, and thus does not show a steady increase in behavior. For Da = 0.001, the curve surface shows a calm and soft behavior in three different temperature cases. This is because in low permeability, the current flow decreases, and this decrease leads to reduction in the velocity and heat gradients. Reducing the current flow causes the cylinder temperatures to fail to play an effective role in heat transfer, so the surface of the graph shows a soft and effective behavior. As the permeability increases, the fluid content also increases and the surface of the graph shows a more rigid and non-uniform behavior. Therefore, in extreme permeability, especially in the case of cold cylinders, there is a violent behavior in the variation of the Nusselt number. The cooling of the cylinders further exacerbates the heating gradients near the hot wall and helps more heat dissipation. Indeed, in high permeability and especially in the case of cold cylinders, the contrast between the Lorentz force and the convection force is clearly seen, so that there is a decreasing behavior in the heat transfer rate. Therefore, the presence of the magnetic field can be a useful factor, but of course it can be said that the magnetic field can be used to control the flow of fluid.

Fig. 14
figure 14figure 14

3D diagram of variations of three basic parameters (Hartmann number, volume fraction and Darcy number) with Nusselt number

Conclusions

In this paper, comprehensive study of the use of porous medium and magnetic field along with nanofluid in a cavity with spinning obstacles was investigated. Summarize the results as follows:

  • In the absence of MHD, the use of porous media can lead to increased heat transfer.

  • The combination of the porous medium and the magnetic field can increase or decrease the transfer rate, but the use of a magnetic field to control the flow of fluid inside the cavity is desirable.

  • In each of the three different temperatures cases considered for cylinders, cold cylinders give the highest heat transfer rates in all states. Hot cylinders give the lowest heat transfer rate.

  • In a given Hartmann number, in most cases, the heat transfer is increased by increasing the volume fraction. But when the cylinders are hot and at a maximum of Hartmann numbers, the heat transfer is reduced slightly by increasing the volume fraction of nanoparticles.