1 Introduction

The heat and mass transfer inside various shaped cavities is natural phenomenon, and it is known in engineering and has been the topic of many research engineering studies because of their occurrences and appearances in the various fields used in industrial applications like solar collectors, heat exchangers, electronic chips, and green buildings. Ismail et al. [1, 2] studied numerically the heat and mass transfer of the laminar, incompressible, steady, and viscous fluid inside the T-shaped cavity using a finite difference approximation. They assume the fluid flow is driven from the upper and lower walls once, and from upper wall another once. Sahi et al. [3] investigated numerically the magnetic field effect on the 2-D natural convection inside T-shaped cavity subjected to isothermal boundary conditions using the finite volume method. They investigated the free convective heat transfer due to the temperature difference between the upper cold flat wall and the bottom hot wall. In [4, 5], they studied numerically the mixed convection heat transfer of nanofluids inside a T-shaped lid-driven by finite element method. The nanofluids are considered in the cavity to augment the heat transfer rate such that the upper boundaries have low temperature but the bottom boundaries have high temperature. Esfe et al. [6] investigated numerically the natural convection of fluid flow and heat transfer inside T-shaped cavity filled with nanofluids by using finite volume method, they assumed that the cavity having six walls with high constant temperature and the horizontal top wall with low constant temperature but the bottom wall is kept thermally insulated. Almeshaal et al. [7] investigated numerically the natural convection of the three-dimensional, unsteady, laminar, and incompressible nanofluid inside the T-shaped cavity using control volume method, they assumed that the left side walls have hot temperature and the right side walls are assumed as cold temperature but the bottom and top walls are kept thermally insulated. Hussain et al. [8] investigated numerically the mixed convection and entropy generation rate inside T-shaped porous cavity that filled with nanofluid using finite element method, they assumed that the upper wall has low temperature and the bottom wall is sinusoidally heated, whereas all the other walls are adiabatic. In [9, 10] studied numerically free convection of nanofluid inside ┴ shaped cavity. Sarkar et al. [11] investigated numerically of MHD mixed convection in a lid-driven rectangular cavities with the wall wavy at the top and rectangular heaters at the bottom wall using finite element method, they assumed that the top of the cavity is driven by a wavy wall with low temperature, while the lower wall has three rectangular heaters with high temperature. Ma et al. [12,13,14] investigated numerically of natural convection and mixed convection of nanofluid in a U-shaped cavity in the presence of a magnetic field using lattice Boltzmann method (LBM). Selimefendigil and Öztop [15] investigated numerically of mixed convective nanofluid flow in an inclined L-shaped cavity by using the finite element method, they assumed that the cavity is driven from the upper wall with constant velocity, also the left and right walls are considered at high and low temperatures respectively, while the top and bottom walls are adiabatic. Sheremet et al. [16] investigated numerically of the mixed convection flow and heat transfer for micropolar fluid inside triangular cavity using finite element method, they assumed that the cavity is driven from the bottom wall with constant velocity and high-temperature wall, while the left and right walls are considered at low temperature. Ismail et al. [17] investigated numerically heat and mass transfer due to the steady, laminar, and incompressible MHD micropolar fluid flow in a rectangular duct with the slip flow and convective boundary conditions. Haq et al. [18] investigated numerically for heat transfer analysis of water functionalized Fe3O4 ferrofluid is performed along with the irreversibility process along a porous semi-annulus. Haq et al. [19] investigated numerically for thermal management of water-based single-wall carbon nanotubes (SWCNTs) inside the partially heated triangular cavity with heated cylindrical obstacle. Haq et al. [20] investigated numerically for heat transfer analysis is performed for Magnetohydrodynamic (MHD) water-based single-wall carbon nanotubes (SWCNTs) inside a C-shaped cavity that is partially heated along the left vertical wall in the presence of magnetic field. Haq et al. [21] investigated numerically for natural convection flow in a partially heated trapezoidal cavity containing non-Newtonian Casson fluid. A non-Newtonian model of Casson fluid is used to develop the governing flow equations.

Our effort in this paper is dedicated to study the heat and mass transfer inside a T-shaped cavity with two parallel walls in motion from the top and bottom walls under the effect of the external magnetic field.

2 Mathematical formulation

2.1 Physical description

Consider the steady, laminar, and incompressible viscous fluid is moved inside a T-shaped cavity under transverse external magnetic flux density (\(B_{0}\)) applied in Y-direction as shown in Fig. 1a. The cavity has a length (\(L\)) and can be divided into two parts, the upper part is called the head with length \(L\) and height (\(0.4 L\)), while the lower part is called the tail with length (\(0.4 L\)) and hight (\(0.6 L\)) as in Fig. 1a. The upper and the lower walls are moving with uniform horizontal velocity in X-direction (\(U = u_{0}\)) and are maintained at high temperature (\(T = T_{\text{h}}\)), while the other walls are maintained at low temperature (\(T = T_{\text{c}}\)). Figure 1b presents the locations of the vertices inside the cavity that formed due to the horizontal velocities and magnetic field effect. In this cavity, the upper and lower horizontal velocities are caused to form the primary and secondary primary vertices (C1) and (C6), respectively, that leads to form the secondary vertices (C3, C4, and C2) and tertiary vertices (C5 and C7). When the velocity is decreased, the primary vertex (C1) is divided into (C1L and C1R).

Fig. 1
figure 1

a Statement for T-shaped cavity, b the dimension of the cavity

2.2 Mathematical modeling

Assume the working fluid to be incompressible, electrically conducting, and Newtonian fluid. Two-dimensional MHD equations have been applied to the cavity. The flow of the fluid is assumed laminar and steady state with constant fluid properties. The fluid is movement inside the cavity under transverse external magnetic flux density (\(B_{0}\)) applied in Y-direction. Assume the walls are electrically insulated, so that it neglects the electrical field \(\left( E \right)\), and the magnetic permeability (\(\mu_{0}\)) of the fluid is low (low magnetic Reynolds number) so that it can neglect the induced magnetic field.

According to the assumptions stated above, the MHD equations that contain continuity, momentum, and energy [1, 2] under the effect of magnetic field for the present cavity can be written as:

$$\frac{\partial U}{\partial X} + \frac{\partial V}{\partial Y} = 0$$
(1)
$$\rho \left( { U\frac{\partial U}{\partial X} + V\frac{\partial U}{\partial Y}} \right) = - \frac{\partial P}{\partial X} + \mu \left( {\frac{{\partial^{2} U}}{{\partial X^{2} }} + \frac{{\partial^{2} U}}{{\partial Y^{2} }}} \right) - \sigma U B_{0}^{2}$$
(2)
$$\rho \left( { U\frac{\partial V}{\partial X} + V\frac{\partial V}{\partial Y}} \right) = - \frac{\partial P}{\partial Y} + \mu \left( {\frac{{\partial^{2} V}}{{\partial X^{2} }} + \frac{{\partial^{2} V}}{{\partial Y^{2} }}} \right)$$
(3)
$$\rho C_{P} \left( { U\frac{\partial T}{\partial X} + V\frac{\partial T}{\partial Y}} \right) = k\left( {\frac{{\partial^{2} T}}{{\partial X^{2} }} + \frac{{\partial^{2} T}}{{\partial Y^{2} }}} \right) + \sigma U^{2} B_{0}^{2}$$
(4)

The boundary conditions are classified as follows.

On the top and bottom walls (\(U = 1,\quad V = 0, \quad T = T_{\text{h}}\)), while on other walls (\(U = V = 0, \quad T = T_{\text{C}}\)).

Convenient the horizontal and velocities into the stream function and vorticity forms where;

$$U = \frac{{\partial \psi^{*} }}{\partial Y},\quad V = - \frac{{\partial \psi^{*} }}{\partial X},\quad \omega^{*} = \left( {\frac{\partial V}{\partial X} - \frac{\partial U}{\partial Y} } \right).$$
(5)

Applying the stream function and vorticity equation into governing equations we get;

$$\omega^{*} = - \left( {\frac{{\partial^{2} \psi^{*} }}{{\partial X^{2} }} + \frac{{\partial^{2} \psi^{*} }}{{\partial Y^{2} }}} \right)$$
(6)
$$\rho \left( {\frac{{\partial \psi^{*} }}{\partial Y} \frac{{\partial \omega^{*} }}{\partial X} - \frac{{\partial \psi^{*} }}{\partial X} \frac{{\partial \omega^{*} }}{\partial Y}} \right) = \mu \left[ {\frac{{\partial^{2} \omega^{*} }}{{\partial X^{2} }} + \frac{{\partial^{2} \omega^{*} }}{{\partial Y^{2} }}} \right] + \sigma B_{0}^{2} \frac{{\partial^{2} \psi^{*} }}{{\partial Y^{2} }}$$
(7)
$$\rho C_{\text{P}} \left( {\frac{{\partial \psi^{*} }}{\partial Y} \frac{\partial T}{\partial X} - \frac{{\partial \psi^{*} }}{\partial X} \frac{\partial T}{\partial Y}} \right) = k\left[ {\frac{{\partial^{2} T}}{{\partial X^{2} }} + \frac{{\partial^{2} T}}{{\partial Y^{2} }}} \right] + \sigma B_{0}^{2} \left( {\frac{{\partial \psi^{*} }}{\partial Y}} \right)^{2}$$
(8)

It is convenient the governing equations into non-dimensional forms by using the scale parameters as following;

$$\left( {x,y} \right) = \frac{{\left( {X,Y} \right)}}{L}, \quad \left( {u,v} \right) = \frac{{\left( {U,V} \right)}}{{u_{0} }} , \quad \psi = \frac{{\psi^{*} }}{{u_{0} L}},\quad \omega = \frac{{\omega^{*} L}}{{u_{0} }}, \quad \theta = \frac{{T - T_{\text{c}} }}{{T_{\text{h}} - T_{\text{c}} }}$$
(9)

By applying the scale parameters into Eqs. (68), we get;

$$\omega = - \left( {\frac{{\partial^{2} \psi }}{{\partial x^{2} }} + \frac{{\partial^{2} \psi }}{{\partial y^{2} }}} \right)$$
(10)
$$\left( {\frac{\partial \psi }{\partial y} \frac{\partial \omega }{\partial x} - \frac{\partial \psi }{\partial x} \frac{\partial \omega }{\partial y}} \right) = \frac{1}{\text{Re}}\left[ {\frac{{\partial^{2} \omega }}{{\partial x^{2} }} + \frac{{\partial^{2} \omega }}{{\partial y^{2} }}} \right] + \frac{{{\text{Ha}}^{2} }}{\text{Re}} \frac{{\partial^{2} \psi }}{{\partial y^{2} }}$$
(11)
$$\left( {\frac{\partial \psi }{\partial y} \frac{\partial \theta }{\partial x} - \frac{\partial \psi }{\partial x} \frac{\partial \theta }{\partial y}} \right) = \frac{1}{{{ \Pr } {\text{Re}}}}\left[ {\frac{{\partial^{2} \theta }}{{\partial x^{2} }} + \frac{{\partial^{2} \theta }}{{\partial y^{2} }}} \right] + \frac{{{\text{Ha}}^{2} {\text{Ec}}}}{\text{Re}} \left( {\frac{\partial \psi }{\partial y}} \right)^{2}$$
(12)
$$u = \frac{\partial \psi }{\partial y} , v = - \frac{\partial \psi }{\partial x}$$
(13)

where Reynolds number (\({\text{Re}} = \rho u_{0} L /\mu\)), Hartmann number (\({\text{Ha}} = B_{0} L\sqrt {\sigma /\mu }\)), Prandtl number (\({ \Pr } = C_{\text{P}} \mu /k\)), and Eckert number (\({\text{Ec}} = u_{0}^{2} /C_{\text{P}} ( {T_{\text{h}} - T_{\text{c}} } )\)).

The non-dimensional boundary conditions are classified as follows;

  • On all horizontal walls \(\left( {\frac{\partial \psi }{\partial x} = 0,\quad \omega = - \frac{{\partial^{2} \psi }}{{\partial y^{2} }}} \right)\), while on all vertical walls \(\left( {\frac{\partial \psi }{\partial y} = 0,\quad \omega = - \frac{{\partial^{2} \psi }}{{\partial x^{2} }}} \right)\).

  • On the top and bottom walls \(\left( {\theta = 1} \right)\), while on other walls \(\left( {\theta = 0} \right)\).

  • On the top and bottom walls \(\left( {u = 1, v = 0} \right)\), while on other walls \(\left( {u = v = 0} \right)\).

3 Results and discussion

In this study, the Magnetohydrodynamic flow and heat transfer for the fluid through T-shaped cavity have been solved numerically by using the finite difference approximation with 51 × 51 mesh points [1, 2] where the number of grids \(\left( {N_{x} = 51} \right)\) and \(\left( {N_{y} = 51} \right)\) in (\(i\) and \(j\)) directions, respectively, as in Fig. 2.

Fig. 2
figure 2

Grid generation for T-shaped cavity

Using Mathematical software for plotting the velocity vector profiles, streamline profiles, vorticity profiles, and temperature distribution profiles inside the cavity. The governing equations are approximation at \(\left( {{ \Pr } = 1.69} \right)\) and \(\left( {{\text{Ec}} = 1} \right)\) with various Reynolds and Hartmann numbers (\({\text{Re}} = 1, \,100, \,800, \,1200, \,2000\, {\text{and}}\, {\text{Ha}} = 0, \,10, \,25, \,50\)).

Figures 3a and 4a show the dimensionless velocity vector and streamlines profiles at \(\left( {{\text{Re}} = 1} \right)\) and \(\left( {{\text{Ha}} = 0} \right)\), respectively. It presents the primary vertex \(\left( {{\text{C}}1} \right)\) is rotated in clockwise, while the secondary vertices \(\left( {{\text{C}}2, {\text{C}}3, {\text{C}}4} \right)\) and secondary primary vertex \(\left( {{\text{C}}6} \right)\) are rotated in a counterclockwise direction as in [1]. When Hartmann numbers increase as in Figs. 3b–d and 4b–d, the vertexes \(\left( {{\text{C}}2,\,{\text{C}}3\,{\text{and}}\, {\text{C}}4} \right)\) are hidden and \(\left( {{\text{C}}1} \right)\) is divided into two vertices: \(\left( {{\text{C}}1{\text{L}}} \right)\) and \(\left( {{\text{C}}1{\text{R}}} \right)\). When the Reynolds number increases as in Figs. 7, 8, 11, and 12, other vertexes appear as the tertiary vertexes \(\left( {{\text{C}}5 {\text{and}} {\text{C}}7} \right)\) and rotate in clockwise direction. Figures 5, 6, 9, 10, 13, and 14 show the vorticity and temperature profiles at \(\left( {{\text{Re}} = 1, 800, 2000} \right)\) and \(\left( {{\text{Ha}} = 0, 10, 25, 50} \right)\). It observes the temperature increase with increasing the Reynolds and Hartmann numbers.

Fig. 3
figure 3

The velocity vector profile at \({\text{Re}}\) = 1 and a \({\text{Ha}}\) = 0, b \({\text{Ha}}\) = 10, c \({\text{Ha}}\) = 25, d \({\text{Ha}}\) = 50

Fig. 4
figure 4

The streamlines profile at \({\text{Re}}\) = 1 and a \({\text{Ha}}\) = 0, b \({\text{Ha}}\) = 10, c \({\text{Ha}}\) = 25, d \({\text{Ha}}\) = 50

Fig. 5
figure 5

The vorticity profile at \({\text{Re}}\) = 1 and a \({\text{Ha}}\) = 0, b \({\text{Ha}}\) = 10, c \({\text{Ha}}\) = 25, d \({\text{Ha}}\) = 50

Fig. 6
figure 6

The temperature profile at \({\text{Re}}\) = 1 and a \({\text{Ha}}\) = 0, b \({\text{Ha}}\) = 10, c \({\text{Ha}}\) = 25, d \({\text{Ha}}\) = 50

Fig. 7
figure 7

The velocity vector profile at \({\text{Re}}\) = 800 and a \({\text{Ha}}\) = 0, b \({\text{Ha}}\) = 10, c \({\text{Ha}}\) = 25, d \({\text{Ha}}\) = 50

Fig. 8
figure 8

The streamlines profile at \({\text{Re}}\) = 800 and a \({\text{Ha}}\) = 0, b \({\text{Ha}}\) = 10, c \({\text{Ha}}\) = 25, d \({\text{Ha}}\) = 50

Fig. 9
figure 9

The vorticity profile at \({\text{Re}}\) = 800 and a \({\text{Ha}}\) = 0, b \({\text{Ha}}\) = 10, c \({\text{Ha}}\) = 25, d \({\text{Ha}}\) = 50

Fig. 10
figure 10

The temperature profile at \({\text{Re}}\) = 800 and a \({\text{Ha}}\) = 0, b \({\text{Ha}}\) = 10, c \({\text{Ha}}\) = 25, d \({\text{Ha}}\) = 50

Fig. 11
figure 11

The velocity vector profile at \({\text{Re}}\) = 2000 and a \({\text{Ha}}\) = 0, b \({\text{Ha}}\) = 10, c \({\text{Ha}}\) = 25, d \({\text{Ha}}\) = 50

Fig. 12
figure 12

The streamlines profile at \({\text{Re}}\) = 2000 and a \({\text{Ha}}\) = 0, b \({\text{Ha}}\) = 10, c \({\text{Ha}}\) = 25, d \({\text{Ha}}\) = 50

Fig. 13
figure 13

The vorticity profile at \({\text{Re}}\) = 2000 and a \({\text{Ha}}\) = 0, b \({\text{Ha}}\) = 10, c \({\text{Ha}}\) = 25, d \({\text{Ha}}\) = 50

Fig. 14
figure 14

The temperature profile at \({\text{Re}}\) = 2000 and a \({\text{Ha}}\) = 0, b \({\text{Ha}}\) = 10, c \({\text{Ha}}\) = 25, d \({\text{Ha}}\) = 50

Table 1 presents the simulation of primary vertexes \(\left( {{\text{C}}1, {\text{C}}1{\text{L and C}}1{\text{R}}} \right)\) at the head part under various Reynolds and Hartmann numbers. It presents the location of the primary vertexes and the stream function. The stream function has a negative sign, this means that the vortices rotating clockwise about z-axis as in [1]. Table 2 presents the simulation of secondary vertexes \(\left( {{\text{C}}3 {\text{and C}}4} \right)\) at the head part under various Reynolds and Hartmann numbers. The stream function in this table has a positive sign, so that the vertexes rotating counterclockwise about z-axis. Table 3 presents the simulation of second primary vertex \(\left( {{\text{C}}6} \right)\) at the tail part under various Reynolds and Hartmann numbers. The stream function has a positive sign, so that the vortices rotating counterclockwise about z-axis. Table 4 presents the simulation of tertiary vertexes \(\left( {{\text{C}}5} \right)\) and \(\left( {{\text{C}}7} \right)\) at the tail part under various and Hartmann numbers. The stream function has a negative sign, so that the vertexes rotating in clockwise about z-axis. Table 5 presents the simulation of secondary vertex \(\left( {{\text{C}}2} \right)\) at the tail part under various Reynolds and Hartmann numbers. The stream has a positive sign, this means that the vortices rotating counterclockwise about z-axis.

Table 1 Simulation of vertex “\({\text{C}}1, {\text{C}}1{\text{L and C}}1{\text{R}}\)“ under the various of Reynolds and Hartmann numbers
Table 2 Simulation of vertex “\({\text{C}}3 {\text{and C}}4\)“ under the various of Reynolds and Hartmann numbers
Table 3 Simulation of vertex “\({\text{C}}6\)“ under the various of Reynolds and Hartmann numbers
Table 4 Simulation of vertex “\({\text{C}}7 {\text{and C}}5\)“ under the various of Reynolds and Hartmann numbers
Table 5 Simulation of vertex “\({\text{C}}2\)“ under the various of Reynolds and Hartmann numbers

4 Conclusion

In this paper, we presented the effects of Reynolds and Hartmann numbers into the mass and heat transfer of steady, laminar and incompressible MHD fluid inside a T-shaped cavity under the effect of the external magnetic field. It assumed the cavity is driven by the two horizontal velocities from the top and bottom walls of the cavity. The results are presented in graphs and tables. Based on the obtained results, we can conclude that:

  • When the Reynolds number increases, the locations of vertexes vorticity are changing and increased, also the temperature is increased.

  • When the Hartmann number increases, the locations of vertexes vorticity are changing and decreased, also the temperature is increased.