1 Introduction

Gravity is fundamentally and obviously present in our daily life, yet it still remains the force most difficult to understand and interpret as an interaction compared to all the other interactions. The gravitational force is most easily studied, without any sophisticated and deep knowledge, and was the first one to be tested experimentally due to its nature and the apparatus needed [1].

A lot of work has been done [2,3,4] to explore the dynamical aspects of stars without finding the exact solutions in f(RT) gravity. The f(RT) theory of gravity has been introduced by Harko et al. [5]; for the formulation of this theory they have modified the Lagrangian of general relativity as a general function of R (Ricci scalar) and T (trace of the stress-energy tensor). They have formulated the equations of motion by using the metric approach instead of the Palatini approach. It has been investigated that the importance of T in the theory may be prominently observed by the exotic form of matter or phenomenological aspects of quantum gravity. The f(RT) theory is an explicit generalization of f(R) theory, in which many cosmological and astrophysical results have been discussed so far [7]. But, there is a still room to study some cosmological and astronomical processes in f(RT) theory which have not yet been studied. In our present work the f(RT) model will be selected in the following form:

$$\begin{aligned} f(R,T)=f_{1}(R)+f_{2}(T). \end{aligned}$$
(1)

Here, we take \(f_{1}(R)=R\) and \(f_{2}(T) =2\lambda T\) where R is the Ricci scalar, \(\lambda \) is some positive constant and T is the trace of the stress-energy tensor, as already mentioned.

Recently, Zubair et al. [6] analyzed the dynamical stability of a cylindrically symmetric collapsing object with locally anisotropic fluid in f(RT) theory. Alves et al. [8] investigated the existence of spacetime fluctuations in f(RT) and \(f(R, T^{\phi })\) theories of gravity. The study of collapse and dynamics of collisionless self-gravitating systems has been carried out by the coupled collisions using the Boltzmann and Poisson equations in f(RT) gravity [9, 10]. Chakraborty [11] has proved that the unknown generalized function f(RT) can be evaluated in closed form if this theory obeys the conservation of the stress-energy tensor. Sharif and Zubair [12] derived the energy conditions in f(RT) gravity, which correspond to the results of f(R) gravity. Houndjo et al. [13] investigated some little rip model in f(RT) gravity using the standard reconstruction approach. Also, they remarked that the second law of thermodynamics remains valid for the little rip model if the temperature inside the horizon is the same that of the apparent horizon.

Oppenheimer and Snyder [14] investigated the process of collapse in 1939; they observed the contraction of an inhomogeneous spherically symmetric dust cloud. This study involves the exterior and interior regions as Schwarzschild and Friedman like solutions, respectively. It has been investigated in [15] that when massive stars collapse by the force of their own gravity, the final fate of such gravitational collapse is a white dwarf, neutron star, a black hole or a naked singularity. Misner and Sharp [16, 17] studied a perfect fluid in spherically symmetric collapse and also some authors [18,19,20,21,22,23,24,25,26,27,28,29,30,31,32] have discussed the phenomenon of gravitational collapse using the dissipative and viscous fluid in general relativity. It has been shown that one can go beyond the general relativity; the more one has chances of admitting an uncovered singularity [33]. In fact most modified gravity theories go out of their way to avoid making any changes to gravity near massive objects. The reason for this is that there is no evidence of any odd gravitational behavior near massive objects, so all of the modified gravity theories are designed to match the standard gravity at short non-galactic distances. There are also a large number of modified gravity theories that attempt to deal with dark energy, i.e. they explain the observations that lead us to think dark energy exists as a modified gravity in a similar fashion to how modified Newtonian dynamics is supposed to do away with the need for dark matter. As far as it has proposed a modified gravity theory that consistently accounts for all observational data, it might work really well for galaxies as well as for cosmology. That being said, the current dark energy and dark matter model for the universe is not completely without its own problems, so modified gravity remains a possibility, albeit less likely on current evidence than the current model.

2 f(RT) theory of gravity

Harko et al. [5, 33] proposed a generalization of the f(R) theories, namely f(RT) gravity. It depends on a general function of R (Ricci scalar) and T (the trace of the tensor \(T_{\mu \nu }\)) but in f(R) theories the action depends on just the Ricci scalar R. According to the authors, the dependence of the theory on T arises from quantum mechanical aspects which are usually neglected in f(R) or GR theories, for instance. The full action of f(RT) gravity is in [5] as follows:

$$\begin{aligned} S=\int {d^{4}x\sqrt{-g}}(f(R,T)+L_\mathrm{m}), \end{aligned}$$
(2)

where \(L_\mathrm{m}\) is the matter Lagrangian and g is the determinant of the metric \(g_{ab}\). Here, we choose \(L_\mathrm{m}=\rho ,\) and the above action yields

$$\begin{aligned} G_{\mu \nu }= & {} \frac{1}{f_{R}}\left[ (f_{T}+1)T^{(m)}_{\mu \nu }-\rho g_{\mu \nu }f_{T}\right. \nonumber \\&\left. +\frac{f-R f_{R}}{2} g_{\mu \nu }+(\nabla _{\mu }\nabla _\nu -g_{\mu \nu }\square )f_{R}\right] , \end{aligned}$$
(3)

where \(T^{(m)}_{\mu \nu }\) is the matter stress-energy tensor. The spacetime in this case has the following form:

$$\begin{aligned} \mathrm{d}s^{2}&=W^{2}(t,r)\mathrm{d}t^{2}-X^{2}(t,r)\mathrm{d}r^{2}\nonumber \\&\quad -Y^{2}(t,r)(\mathrm{d}\theta ^{2}+sin^{2}\theta \mathrm{d}\phi ^{2}). \end{aligned}$$
(4)

The stress-energy tensor for the anisotropic source is

$$\begin{aligned} {T_{uv}}^{(m)}=(\rho +P_\bot )V_{u} V_{v}-P_\bot g_{uv}+(P_r-P_\bot )X_{u} X_{v}. \end{aligned}$$
(5)

Here \(\rho \), \(V_{u}\), \(X_{u}\), \(P_r,~P_\bot \) are the energy density of matter, co-moving four-velocity of the source fluid, radial four-vector, and radial and tangential pressures, respectively. Also, for the given line element the quantities appearing in \({T_{uv}}^{(m)}\) must satisfy

$$\begin{aligned} V^{u}=W^{-1}\delta _{0}^u, \quad V^{u}V_{u}=1,\quad X^{u}=X^{-1}\delta _{1}^u,\quad X^{u}X_{u}=-1.\nonumber \\ \end{aligned}$$
(6)

The volumetric rate of expansion \(\Theta \) is

$$\begin{aligned} \Theta =\frac{1}{WXY}\left( {\dot{X}Y}+{2{X}\dot{Y}}\right) , \end{aligned}$$
(7)

where \(\cdot =\partial _t\) and \('=\partial _r\). The dimensionless anisotropy is

$$\begin{aligned} \Delta {a}=\frac{P_{r}-P_{\bot }}{P_{r}}. \end{aligned}$$
(8)

For the given line element and stress-energy tensor the set of field equations is

$$\begin{aligned} G_{00}= & {} \frac{W^2}{f_{R}}\left[ \rho +\frac{f-R f_{R}}{2}+\frac{f^{{\prime \prime }}_{R}}{X^2}\right. \nonumber \\&\left. - {\dot{{f_{R}}}}\left( \frac{\dot{X}}{X}-\frac{2\dot{Y}}{Y}\right) \frac{1}{W^2}-\frac{{f_{R}^\prime }}{X^2}\left( \frac{X^\prime }{X} -\frac{2Y^\prime }{Y}\right) \right] \end{aligned}$$
(9)
$$\begin{aligned} G_{01}= & {} \frac{\dot{f}_{R}^\prime }{f_{R}}\left[ 1-\frac{W^\prime }{W}\frac{\dot{f}_{R}}{\dot{f}_{R}^\prime }-\frac{\dot{X}}{X}\frac{f_{R}{^\prime }}{\dot{f}_{R}^\prime }\right] , \end{aligned}$$
(10)
$$\begin{aligned} \nonumber G_{11}= & {} \frac{X^2}{f_{R}}\left[ P_r+(\rho +P_r)f_{T}-\frac{f-f_{R}}{2}\right. \nonumber \\&\left. -\frac{\dot{f_{R}}}{YWX^2}\left( {Y\dot{W}}-{2W\dot{Y}}\right) \right. \nonumber \\&\left. -\frac{f_{R}^\prime }{YWX^2}\left( {W^\prime }{Y}+{2Y^\prime }{W}\right) \right] , \end{aligned}$$
(11)
$$\begin{aligned} G_{22}= & {} \frac{Y^2}{f_{R}}\left[ p_{\bot }+(\rho +P_{\bot })f_{T}-\frac{f}{2}+\frac{R f_{R}}{2}+\frac{\ddot{f_{R}}}{W^2}-\frac{f''_{R}}{X^2}\right. \nonumber \\&\left. -\frac{\dot{f_{R}}}{W^2}\left( \frac{\dot{W}}{W}-\frac{\dot{X}}{X}-\frac{\dot{Y}}{Y}\right) \right. \nonumber \\&-\left. \frac{f_{R}^{\prime \prime }}{X^2}\left( \frac{W^\prime }{W}-\frac{X^\prime }{X}-\frac{Y^\prime }{Y}\right) \right] . \end{aligned}$$
(12)

The Misner and Sharp mass is [17]

$$\begin{aligned} m(t,r)=\frac{Y}{2X^2W^2}\left( X^2{W^2}+{X^2\dot{Y^2}}-{{W^2}Y^{\prime 2}}\right) . \end{aligned}$$
(13)

By using the f(RT) gravity model defined by Eq. (1), in Eqs. (9)–(12), we get the system of equations in the following form:

$$\begin{aligned}&(1+\lambda )\rho -\lambda P_r-2\lambda P_{\bot } =\frac{1}{X^2}\left( 2\frac{X^\prime }{X}\frac{Y^\prime }{Y}-\frac{Y^{\prime 2}}{Y^2}-2\frac{Y^{\prime \prime }}{Y}\right) \nonumber \\&\qquad +\frac{1}{Y^2}+ \frac{1}{W^2}\left( 2\frac{\dot{X}}{X}\frac{\dot{Y}}{Y}+\frac{\dot{Y^2}}{Y^2}\right) ,\end{aligned}$$
(14)
$$\begin{aligned}&G_{01}=0=\frac{\dot{Y^\prime }}{Y}-\frac{\dot{Y}}{Y}\frac{W^\prime }{W}-\frac{\dot{X}}{X}\frac{Y^\prime }{Y}, \end{aligned}$$
(15)
$$\begin{aligned}&\lambda \rho +(1+3\lambda )P_r+2\lambda P_{\bot } =\frac{1}{X^2}\left( 2\frac{Y^\prime }{Y}\frac{W^\prime }{W}+\frac{Y^{\prime 2}}{Y^2}\right) -\frac{1}{Y^2}\nonumber \\&\qquad +\frac{1}{W^2}\left( 2\frac{\dot{Y}}{Y}\frac{\dot{W}}{W}-\frac{\dot{Y^2}}{Y^2}-2\frac{\ddot{Y}}{Y}\right) \end{aligned}$$
(16)
$$\begin{aligned}&\lambda \rho +\lambda P_r+(1+4\lambda )P_{\bot }\nonumber \\&\quad =\frac{1}{X^2}\left( \frac{W^{\prime \prime }}{W}+\frac{Y^{\prime \prime }}{Y}+\frac{Y^\prime }{Y}\frac{W^\prime }{W} -\frac{X^\prime }{X}\frac{Y^\prime }{Y}-\frac{X^\prime }{X}\frac{W^\prime }{W}\right) ,\nonumber \\&\qquad +\frac{1}{W^2}\left( \frac{\dot{X}}{X}\frac{\dot{W}}{W}+\frac{\dot{Y}}{Y}\frac{\dot{W}}{W}-\frac{\dot{X}}{X}\frac{\dot{Y}}{Y} -\frac{Y^{\prime \prime }}{Y}-\frac{X^{\prime \prime }}{X}\right) . \end{aligned}$$
(17)
Fig. 1
figure 1

The variation of \(\rho \) with respect to r for the various values of \(\lambda \) and \(h_{1}(t)\) = 1

The auxiliary solution of Eq. (15) is

$$\begin{aligned} W=\frac{\dot{Y}}{Y},\quad X=Y^\alpha , \end{aligned}$$
(18)

where \(\alpha \) is arbitrary constant. Now using Eq. (7), we have the following form for the expansion scalar:

$$\begin{aligned} \Theta =(2+\alpha )Y^{(\alpha -1)}. \end{aligned}$$
(19)

For \(\alpha >-2\) and \(\alpha <-2\), we have expanding and collapsing solutions. With the help of Eq. (18) the mass function is given by

$$\begin{aligned} \frac{2m(t,r)}{Y}-1=Y^{2\alpha }-\frac{Y^{\prime 2}}{Y^{2\alpha }}. \end{aligned}$$
(20)

When \(Y^\prime = Y^{2\alpha }\), there exists a trapped surface at \(Y =2m\), hence \(Y^\prime = Y^{2\alpha }\) is the trapping condition. The trapping condition \(Y^\prime = Y^{2\alpha }\) has the integral

$$\begin{aligned} Y^{(1-2\alpha )}_\mathrm{trap}=r(1-2\alpha )+H(t), \end{aligned}$$
(21)

where H(t) appears as the integration function. Using Eqs. (18) and (21), we get the following explicit form of the source variables:

$$\begin{aligned} \rho= & {} \frac{\left( H(t)+(r-2 \alpha r)^{\frac{1}{1-2 \alpha }}\right) ^{-2}}{(1+2\lambda )(12\lambda ^2+6\lambda +1)}+\frac{2\alpha \left( H(t)+(r-2 \alpha r)^{\frac{1}{1-2 \alpha }}\right) ^{-2(1+\alpha )}}{(r-2\alpha r)^{2}(1+2\lambda )(12\lambda ^2+6\lambda +1)}\nonumber \nonumber \\&-\frac{(r-2r\alpha )^{\frac{{4\alpha }}{1-2\alpha }}\left( H(t)+(r-2 \alpha r)^{\frac{1}{1-2 \alpha }}\right) ^{-2(1+\alpha )}}{(1+2\lambda )}\nonumber \\&+\frac{(r-2\alpha r)^{\frac{-1+4\alpha }{1+2\alpha }}\left( H(t)+(r-2 \alpha r)^{\frac{1}{1-2 \alpha }}\right) ^{-2(1+\alpha )}(4\alpha \lambda ^2-18\lambda ^2+\alpha \lambda -7\lambda -1)}{(1+2\lambda )(12\lambda ^2+6\lambda +1)}\nonumber \\&+\frac{(1+2\alpha )\left( H(t)+(r-2 \alpha r)^{\frac{1}{1-2 \alpha }}\right) ^{4\alpha }(8\alpha \lambda ^2+12\lambda ^2+2\alpha \lambda +6\lambda +1)}{(1+2\lambda )(12\lambda ^2+6\lambda +1)}, \end{aligned}$$
(22)
$$\begin{aligned} P_r= & {} \frac{\left( H(t)+(r-2 \alpha r)^{\frac{1}{1-2 \alpha }}\right) ^{2(-1+\alpha )}(1+2\alpha )(12\lambda ^2-2\alpha \lambda +6\lambda +1)}{(1+2\lambda )(12\lambda ^2+6\lambda +1)}\nonumber \\&+\frac{\left( H(t)+(r-2 \alpha r)^{\frac{1}{1-2 \alpha }}\right) ^{-2(1+\alpha )}(r-2 \alpha r)^{\frac{2}{1-2 \alpha }}(6\lambda ^2+5\lambda +1)}{(1+2\lambda )(12\lambda ^2+6\lambda +1)r^2(-1+2\alpha )}\nonumber \\&+\frac{(r-2\alpha r)^{\frac{-1+4\alpha }{1-2\alpha }}\left( H(t)+(r-2 \alpha r)^{\frac{1}{1-2 \alpha }}\right) ^{-2(1+\alpha )}(r-2\alpha r)^{\frac{-1+4\alpha }{1-2\alpha }}}{(1+2\lambda )(12\lambda ^2+6\lambda +1)}\nonumber \\&\times \left[ -4(\alpha ^2\lambda +6\alpha \lambda ^2)-(r-2 \alpha r)^{\frac{1}{1-2 \alpha }}(12\alpha \lambda +6\lambda +1)\right] +\frac{\left( H(t)+(r-2 \alpha r)^{\frac{1}{1-2 \alpha }}\right) ^{-2}}{(1+2\lambda )}, \end{aligned}$$
(23)
$$\begin{aligned} P_{\bot }= & {} \frac{\alpha (1-2 \lambda ) (r-2 \alpha r)^{\frac{4 \alpha }{1-2 \alpha }} \left( H(t)+(r-2 \alpha r)^{\frac{1}{1-2 \alpha }}\right) ^{-2 (\alpha +1)}}{12 \lambda ^2+6 \lambda +1}\nonumber \\&-\frac{(1-2 \alpha )^2 (2 \alpha +1) (2 \lambda +1) r^2 \left( H(t)+(r-2 \alpha r)^{\frac{1}{1-2 \alpha }}\right) ^{2 (\alpha -1)}}{\left( 12 \lambda ^2+6 \lambda +1\right) (r-2 \alpha r)^2}. \end{aligned}$$
(24)

3 Generating solutions

For various possible values of \(\alpha \), we now discuss the nature of solutions.

3.1 Collapse solution \(\alpha =-\frac{5}{2}\)

When the value of the expansion scalar is negative, we have gravitational collapse, so Eq. (19) implies that \(\Theta <0\), if \(\alpha <-2\), for convenience we take \(\alpha =-\frac{5}{2}\) and the condition \(Y^\prime =Y^{2\alpha }\) leads to \(Y^\prime =Y^{-5}\), which further is integrated to

$$\begin{aligned} Y_\mathrm{trap}=\left( 6r+h_{1}(t)\right) ^\frac{1}{6}. \end{aligned}$$
(25)

Here \(h_1(t)\) is the integration function. Using Eqs. (18), (25) in Eqs. (14)–(17), with some tedious algebra, we obtain the following explicit form of the matter variables:

$$\begin{aligned} \mathfrak {}\rho= & {} -\frac{5\lambda (1+4\lambda )}{\left( 6r+h_{1}(t)\right) ^\frac{7}{6}(1+2\lambda )(12\lambda ^2+6\lambda +1)}\end{aligned}$$
(26)
$$\begin{aligned} \nonumber&+\frac{1}{\left( 6r+h_{1}(t)\right) ^\frac{1}{3}(1+2\lambda )},\\ P_r= & {} -\frac{5 \lambda }{\left( 24 \lambda ^3+24 \lambda ^2+8 \lambda +1\right) (6r+h_{1}(t))^{7/6}}\end{aligned}$$
(27)
$$\begin{aligned} \nonumber&-\frac{1}{(2 \lambda +1) \root 3 \of {6r+h_{1}(t)}},\\ P_{\bot }= & {} -\frac{5(1+2\lambda )}{2\left( 6r+h_{1}(t)\right) ^\frac{7}{6}(12\lambda ^2+6\lambda +1)}. \end{aligned}$$
(28)

The mass function given in Eq. (19) becomes

$$\begin{aligned} m_{1}(r,t)=\frac{1}{2} \root 6 \of {6r+h_{1}(t)}. \end{aligned}$$
(29)

The dimensionless parameter \(\Delta {a}\) from Eq. (8) takes the form

$$\begin{aligned} \Delta {a}= & {} \frac{-5-10\lambda (1+2\lambda )+\left( 6r+h_{1}(t)\right) ^\frac{5}{6}(2+6\lambda +12\lambda ^2)}{10\lambda +2\left( 6r+h_{1}(t)\right) ^\frac{5}{6}(1+6\lambda +12\lambda ^2)}.\nonumber \\ \end{aligned}$$
(30)
Fig. 2
figure 2

The variation of \(P_r\) with respect to r for the various values of \(\lambda \) and \(h_{1}(t)\) = 1

Fig. 3
figure 3

The variation of \(P_{\bot }\) with respect to r for the various values of \(\lambda \) and \(h_{1}(t)\) = 1

Fig. 4
figure 4

The variation of \(\triangle a\) with respect to r for the various values of \(\lambda \) and \(h_{1}(t)\) = 1

In the above expressions \(h_{1}(t)\) is an arbitrary function of time t; by taking \(h_{1}(t)=1\), we have analyzed the results. By choosing \(\alpha = -\frac{5}{2}\), we get \(\Theta <0\) and the energy density remains a positive and decreasing function of r. The graphical behavior of \(\rho \) with various values of \(\lambda \) is shown in Fig. 1. The radial pressure increases first and then decreases continuously with respect to radius at different values of \(\lambda \) as shown in Fig. 2, but the transverse pressure is decreasing with respect to radius as shown in Fig. 3. To account for this we can say the pressure is minimum when the value of \(\lambda \) is minimum, as shown in Figs. 2 and 3. The maximum value of the anisotropy occurs near the center of the sphere, so the anisotropy parameter \(\Delta a\) attains a maximum value near the center and its value decreases when r increases with various values of \(\lambda \); see Fig. 4.

3.2 Expansion with \(\alpha =\frac{3}{2}\)

When the expansion scalar attains positive values, we have an expanding solution, so Eq. (19), implies that \(\Theta >0\), if \(\alpha >-2\), for convenience we take \(\alpha =\frac{3}{2}\) and assume that

$$\begin{aligned} Y=(r^2+r^{2}_{0})^{-1}+h_{2}(t), \end{aligned}$$
(31)

where \(h_{2}(t)\) is an integration function and \(r_{0}>0\). For simplicity, we take \(F(t,r)=1+h_{2}(t)(r^2+r^{2}_{0})\) and \(Y=\frac{F}{(r^2+r^{2}_{0})}\), then using Eqs. (18), (31) with Eqs. (14)–(17), with simplification, we obtain the following explicit form of the matter variables:

$$\begin{aligned} \rho= & {} \frac{14\lambda ^2+7\lambda +1}{(1+2\lambda )(12\lambda ^2+6\lambda +1)}\left[ -\frac{8r^2(r^2+r^{2}_{0})}{F^5}\right. \nonumber \\&\left. +\frac{4(3r^2-r^{2}_{0})}{F^4}-\frac{4F}{(r^2+r^{2}_{0})}-\frac{(r^2+r^{2}_{0})^2}{F^2}\right] \nonumber \\ \nonumber&+\frac{8\lambda ^2+2\lambda }{(1+2\lambda )(12\lambda ^2+6\lambda +1)} \left[ \frac{6}{(r^2+r^{2}_{0})F}\right. \\&\left. -\frac{12r^2(r^2+r^{2}_{0})}{F^5}+\frac{(3r^2-r^{2}_{0})(r^2-r^{2}_{0})}{F^4}\right] \nonumber \\&+\frac{\lambda }{(12\lambda ^2+6\lambda +1)}\left[ \frac{8r^2(r^2+r^{2}_{0})}{F^5}\right. \nonumber \\&\left. +\frac{(r^2+r^{2}_{0})^2}{F^2}+\frac{4F}{(r^2+r^{2}_{0})}\right] , \end{aligned}$$
(32)
$$\begin{aligned} P_r= & {} \frac{\lambda (1+6\lambda )}{(1+2\lambda )(12\lambda ^2+6\lambda +1)}\left[ \frac{8r^2(r^2+r^{2}_{0})}{F^5}\right. \nonumber \\&\left. +\frac{4(3r^2-r^{2}_{0})(r^2+r^{2}_{0})}{F^4}+\frac{(r^2+r^{2}_{0})^2}{F^2}+\frac{4F}{r^2+r^{2}_{0}}\right] \nonumber \\ \nonumber&+\frac{6\lambda ^2+5\lambda +1}{(1+2\lambda )(12\lambda ^2+6\lambda +1)}\\&\times \left[ \frac{8r^2(r^2+r^{2}_{0})}{F^5}++\frac{(r^2+r^{2}_{0})^2}{F^2}+\frac{4F}{r^2+r^{2}_{0}}\right] \nonumber \\&-\frac{2\lambda }{(1+2\lambda )(12\lambda ^2+6\lambda +1)}\nonumber \\&\times \left[ \frac{(r^2+r^{2}_{0})^2\left( 3r^4-r^{2}_{0}(1+r^{2}_{0})+r^2(2r^{2}_{0}-9)\right) }{F^5}\right. \nonumber \\&\left. +\frac{6F}{(r^2+r^{2}_{0})}\right] , \end{aligned}$$
(33)
$$\begin{aligned} P_{\bot }= & {} \frac{\lambda }{(12\lambda ^2+6\lambda +1)}\left[ \frac{8r^2(r^2+r^{2}_{0})}{F^5}\right. \nonumber \\&\left. -\frac{4(3r^2-r^{2}_{0})(r^2+r^{2}_{0})}{F^4}+\frac{4F}{(r^2+r^{2}_{0})}+\frac{(r^2+r^{2}_{0})^2}{F^2}\right] \nonumber \\ \nonumber&-\frac{1}{(12\lambda ^2+6\lambda +1)}\left[ \frac{6}{(r^2+r^{2}_{0})F}\right. \nonumber \\&\left. -\frac{12r^(-4+F)(r^2+r^{2}_{0})}{F^5}-\frac{r^{2}_{0}(r^2+r^{2}_{0})}{F^4}\right] \nonumber \\&-\frac{1+2\lambda }{(12\lambda ^2+6\lambda +1)}\left[ \frac{8r^2(r^2+r^{2}_{0})}{F^5}+\frac{(r^2+r^{2}_{0})^2}{F^2}\right. \nonumber \\&\left. +\frac{4F}{(r^2+r^{2}_{0})}\right] . \end{aligned}$$
(34)

The anisotropy parameter and mass function are given by

$$\begin{aligned} \triangle a= & {} \frac{4\lambda ^2\left( \frac{8r^2(r^2+r^{2}_{0})}{F}-4(3r^2-r^{2}_{0})(r^2+r^{2}_{0})+(r^2+r^{2}_{0})F^2+4F^5\right) }{(1+2\lambda )\left( 4(3r^2-r^{2}_{0})(r^2+r^{2}_{0})\lambda +\frac{6(1+2\lambda )F^5}{(r^2+r^{2}_{0})}+\frac{r^2(r^2+r^{2}_{0})(2r^{2}_{0}-9)(1+2\lambda )}{F}\right) }\nonumber \\&+\frac{(r^2+r^{2}_{0})(4\lambda ^2+2\lambda +1)\left( \frac{3r^4-r^{2}_{0}(1+r^{2}_{0})}{F}+\frac{6F^5}{(r^2+r^{2}_{0})^2}+\frac{r^2(2r^{2}_{0})-9}{F}\right) }{(1+2\lambda )\left( 4(3r^2-r^{2}_{0})(r^2+r^{2}_{0})\lambda +\frac{6(1+2\lambda )F^5}{(r^2+r^{2}_{0})}+\frac{r^2(r^2+r^{2}_{0})(2r^{2}_{0}-9)(1+2\lambda )}{F}\right) }\nonumber \\&+\frac{(8\lambda ^2+6\lambda +1)\left( \frac{8r^2(r^2+r^{2}_{0})}{F}+(r^2+r^{2}_{0})F^2+4F^5\right) }{(1+2\lambda )\left( 4(3r^2-r^{2}_{0})(r^2+r^{2}_{0})\lambda +\frac{6(1+2\lambda )F^5}{(r^2+r^{2}_{0})}+\frac{r^2(r^2+r^{2}_{0})(2r^{2}_{0}-9)(1+2\lambda )}{F}\right) }, \end{aligned}$$
(35)
$$\begin{aligned} m_{2}(t,r)= & {} \frac{1}{2}\left( \frac{F}{(r^2+r^{2}_{0})}-\frac{4r^2}{(r^2+r^{2}_{0})^4F^4}+\frac{F^4}{(r^2+r^{2}_{0})^4}\right) .\nonumber \\ \end{aligned}$$
(36)
Fig. 5
figure 5

The variation of \(\rho \) with respect to r for the various values of \(\lambda \) and \(h_{2}(t)\) = 1

Fig. 6
figure 6

The variation of \(P_r\) with respect to r for the various values of \(\lambda \) and \(h_{2}(t)\) = 1

Fig. 7
figure 7

The variation of \(P_{\bot }\) with respect to r for the various values of \(\lambda \) and \(h_{2}(t)\) = 1

Fig. 8
figure 8

The variation of \(\triangle a\) with respect to r for the various values of \(\lambda \) and \(h_{2}(t)\) = 1

In this case, when \(\alpha = \frac{3}{2}\) we get \(\Theta >0\) and the energy density remains finitely positive for the selected arbitrary time profile t; by fixing the values of \(\alpha \), the variation is given by \(\lambda \) and under such restrictions the density \(\rho \) can be observed to be a decreasing function, as shown in Fig. 5. The radial pressure decreases continuously with respect to radius at different values of \(\lambda \), but the transverse pressure is increasing with respect to radius as shown in Figs. 6 and 7, respectively. To account for this we can say the pressure has reverse effects to the effects observed in the previous case. It is observed that the anisotropy is an increasing function of r but with respect to the value of \(\lambda \) the anisotropy is going to be maximum as the value of \(\lambda \) is being increased, as shown in Fig. 8.

4 Conclusion

Motivated by the f(RT) theory of gravity formulated by Harko et al. [5], a lot of work related to cosmology and stability of the dynamics of a collapsing stellar system has been done in recent years [34,35,36,37,38,39,40,41,42,43,44,45,46,47,48]. This theory has a wide range of cosmological and astrophysical applications in modern physics. According to the available observation data, our universe is in the phase of accelerating expansion, and to explain the physical significance of this phenomenon a number of modifications to GR have been proposed. The f(RT) theory of gravity is one that has been at the center of attention of researchers in the current era; this type of theories seems to provide a capacity of working successfully for dark matter. The conformal relation of f(RT) to GR with a self-interacting scalar field has been discussed by Zubair et al. [49].

Here, we have developed the generating solutions to collapse and expansion of fluid sphere in f(R,T) theory of gravity. For the interior matter distribution, the collapse solution yields a unique trapped surface. It has been investigated that during gravitational contraction, the phase transition would occur for the massive stellar system, for instance most of the condensed matter configuration transits to a \(\pi \)-meson condensed state. The gravitational collapse is a highly dissipative process and a great amount of heat energy is released during gravitational collapse according to Herrera et al. [50]. In order to model the inhomogeneous cosmological solutions Collins [51] has explored the non-static expanding solutions. Also, the inclusion of anisotropic stress in the fluid source is very important, and the influence of the non-zero anisotropy parameter \(\delta a\) on the late time evaluation of the universe with non-homogeneous background has been explored by Barrow et al. [52]. Due to the valid selection of R(tr) and \(\alpha \), one can obtain an anisotropy interconnection which collapses or expands as studied by Glass [53]. In this paper, we extend the work of Glass [53] to the f(RT) theory of gravity.

In this paper interior solutions for anisotropic fluids have been discussed in detail, which are being used in modeling of anisotropic stars in the context of the modified theory of gravity based on f(RT). Using the auxiliary form of the metric functions, we have determined the trapping conditions for a fluid sphere in f(RT) gravity. The resulting solutions have been classified as collapsing and expanding, depending on the nature of the scalar expansion. The matter density, radial and transverse pressures, anisotropy parameter and mass function have been calculated in the context of the f(RT) theory of gravity. For the collapse solution when \(\alpha = -\frac{5}{2}\) the density decreases as the value of \(\lambda \) increases, as shown in Fig. 1. The radial pressure \(P_r\) and the matter density \(\rho \) have maximum values at center and they decrease from center to the surface of star. It has been observed that the anisotropy will be directed outward when \(P_r>P_{\bot }\); this gives \(\triangle a >0\) as observed graphically in Figs. 4 and 8. It is found in Fig. 4 that the anisotropy decreases with the increase in radius.

Further, the expansion of the gravitating source would occur when \(\alpha = \frac{3}{2}\), and \(\Theta \), the expansion scalar, is positive. In this case the matter density decreases as shown in Fig. 5. The radial/transverse pressures and the anisotropy parameter with various values of \(\lambda \) have a reverse behavior as compared to the case of gravitational collapse.