1 Introduction

The study of exact solutions of Einstein’s field equations is an important part of the theory of general relativity. This importance is not only concerned with more formal mathematical aspects associated with the theory (e.g. the classification of spacetimes) but also with the growing importance of the application of general relativity to astrophysical phenomena. For example, exact solutions may offer physical insights that numerical solutions cannot. The present time trend of analyzing different aspects of black hole (BH) solutions did lead us to direct our interests to cleaner \(2+1\)-dimensional gravity. The discovery of BTZ BH [1] ignited the light first. Through this \(2+1\)-dimensional model if we need to explore the foundations of classical and quantum gravity we would not find any Newtonian limit and no propagating degrees of freedom will arise. In the literature, very easy-to-find works in this aspect comprise the study of quasi-normal modes of charged dilaton BHs in \(2+1\)-dimensional solutions in low energy string theory with asymptotic anti-de Sitter spacetimes [2]. Hawking radiation from covariant anomalies in \(2+1\)-dimensional BHs [3] is another beautiful example. Lastly, we must also point out the study of branes with naked singularities analogous to linear or planar defects in crystals and showing that zero branes in AdS spacetimes are ‘negative mass BHs!’ [4]. Taking charged gravastars as an alternative to charged BHs in \((2+1)\) AdS spacetimes has already been investigated [5]. Extensions of BTZ BH solutions with charge are also available in the literature. These are obtained by employing nonlinear Born–Infield electrodynamics to eliminate the inner singularity [6]. The non-static charged BTZ like BHs in \((N+1)\) dimensions have also been studied [7] which in its static limit, for \(N=2\), reduces to \((2+1)\) BTZ BH solutions.

The study of interior solutions in \((2+1)\) dimensions [8] shows that even the noncommutative-geometry-inspired BTZ BH is not free from any singularity. The study of interior solutions is rarely found in the literature. For example, solutions of Wolf [9] and Yazadjiev [10], solutions in the framework of the Brans–Dicke theory of gravity by Kozyrev [11] and a new class of solutions corresponding to BTZ exterior spacetime by Sharma et al. [12], which is regular at the center and it satisfies all the physical requirements except at the boundary where the authors propose a thin ring of matter content with negative energy density so as to prevent collapsing. The discontinuity of the affine connections at the boundary surface provide the above matter confined to the ring. Such a stress-energy tensor is not ruled out from the consideration of the Casimir effect for massless fields.

The purpose of the present work is to find exact interior solutions for a perfect fluid model both with and without cosmological constant, \(\Lambda \). The motivation for doing so is provided by the fact that the assumption of the equation of state (EoS) is \(p=m\rho \), which seems to be very reasonable for describing the matter distribution in the study of relativistic objects like stars [13, 14], wormholes [15, 16] and gravastars [5, 17].

The structure of our work is as follows: In Sect. 2, we derive the required Einstein equations. Section  3 contains different interior solutions for various cases of the EoS. Lastly, in Sect. 4 a brief conclusion is provided.

2 Einstein field equations in \((2 + 1)\) dimensions

We take the static metric to describe the interior region of a \(2+1\)-dimensional spacetime as follows:

$$\begin{aligned} ds^{2} = -e^{2\nu (r)}dt^{2}+ e^{2\mu (r)}dr^{2} + r^{2} d\theta ^{2}, \end{aligned}$$
(1)

where \(\nu (r)\) and \(\mu (r)\) are the two unknown metric functions. We take the perfect fluid form of the energy momentum tensor,

$$\begin{aligned} T_{ij}= \mathrm{diag}(-\rho ,p,p), \end{aligned}$$
(2)

where \(\rho \) is the energy density and \(p\) is the pressure. Einstein’s field equations with a cosmological constant, \(\Lambda \), for the spacetime metric (see (1)) together with the energy momentum tensor given in (2) may be written as

$$\begin{aligned}&\!\!\!2\pi \rho +\Lambda = \mu ^{\prime }e^{-2\mu (r)}/r,\end{aligned}$$
(3)
$$\begin{aligned}&\!\!\!2\pi p -\Lambda = \nu ^{\prime }e^{-2\mu (r)}/r,\end{aligned}$$
(4)
$$\begin{aligned}&\!\!\!2\pi p -\Lambda = e^{-2\mu }\left( {\nu ^{\prime \prime }}+{\nu ^ {\prime 2}}-\nu ^{\prime }\mu ^{\prime }\right) . \end{aligned}$$
(5)

Here the superscript ‘\(\prime \)’ denotes the derivative with respect to \(r\). Assuming \(G=c=1\), the generalized Tolman–Oppenheimer–Volkov (TOV) equation may be written as

$$\begin{aligned} \left( \rho +p\right) \nu ^{\prime }+{p^{\prime }} =0, \end{aligned}$$
(6)

which represents conservation equations in \((2+1)\) dimensions.

We take the EoS of the form

$$\begin{aligned} p =m \rho , \end{aligned}$$
(7)

where \(m\) is EoS parameter.

3 Interior solutions

We first obtain interior solutions without any cosmological constant, thereby taking \(\Lambda =0\). Later on, we generalize our study to non-zero value of \(\Lambda \). We choose various cases of the EoS parameter for both choices of \(\Lambda \).

3.1 No cosmological constant (\(\Lambda =0\))

3.1.1 \(~0~< m~< ~1~\)

For \(\Lambda = 0\), the field equations (3)–(6) become

$$\begin{aligned} 2 \pi \rho&= \mu 'e^{-2\mu }/r, \end{aligned}$$
(8)
$$\begin{aligned} 2 \pi m\rho&= \nu 'e^{-2\mu }/r, \end{aligned}$$
(9)
$$\begin{aligned} 2 \pi m\rho&= e^{-2\mu }(\nu '^{2}+\nu ''-\mu '\nu '). \end{aligned}$$
(10)

The TOV equation (11) takes the form

$$\begin{aligned} (\rho +m \rho )\nu '+m \rho '=0, \end{aligned}$$
(11)

Equation (11) yields

$$\begin{aligned} \rho ^{m}e^{(1+m)\nu }=C. \end{aligned}$$
(12)

Solving (8) and (9), we get

$$\begin{aligned} \nu =m\mu +A. \end{aligned}$$
(13)

Equating (9) with (10), we get

$$\begin{aligned} e^{\mu }=e^{\nu }\nu '/r. \end{aligned}$$
(14)

Now, solving (13) and (14), we obtain

$$\begin{aligned} \nu&= \frac{A}{1-m}-\frac{m}{1-m}ln\left\{ \frac{1-m}{m}\left( B-\frac{r^{2}}{2} \right) \right\} ,\end{aligned}$$
(15)
$$\begin{aligned} \mu&= \frac{1}{1-m}\left[ A-ln\left\{ \frac{1-m}{m}\left( B-\frac{r^{2}}{2} \right) \right\} \right] ,\end{aligned}$$
(16)
$$\begin{aligned} \rho&= \frac{1}{2 \pi m} e^{-\frac{2A}{1-m}}\left[ \frac{1-m}{m}\left( B-\frac{r^{2}}{2} \right) \right] ^{\frac{1+m}{1-m}}. \end{aligned}$$
(17)

Here \(C\), \(A\), and \(B\) are integration constants.

For consistency of the solutions, the constants should follow the constraint equation,

$$\begin{aligned} A=m \ln (2 \pi m)+\ln C. \end{aligned}$$
(18)

These solutions are regular at the center. The central density is given by

$$\begin{aligned} \rho _c= 1/(2 \pi m) e^{-\frac{2A}{1-m}}\left[ B(1-m)/m \right] ^{\frac{1+m}{1-m}}. \end{aligned}$$
(19)

The interior solution is valid up to the radius \(r<\sqrt{2B}\). For a physically meaningful solution the radial and tangential pressure should be a decreasing function of r. From (17), we find

$$\begin{aligned} \frac{d\rho }{dr}=\frac{1}{m} \frac{dp}{dr} < 0, \end{aligned}$$
(20)

which gives the density and the pressure as decreasing functions of r. At \(r=0\), one can get

$$\begin{aligned} \frac{dp}{dr}=0,\quad \frac{d\rho }{dr}=0 \quad \mathrm{and}\quad \frac{d^2\rho }{dr^2}=\left[ \frac{(1-m)B}{m}\right] ^{\frac{2m}{1-m}} <0,\nonumber \\ \end{aligned}$$
(21)

which support maximality of the central density and the radial central pressure. Here, the density and the pressure decrease radially outward as shown in Fig. 1.

Fig. 1
figure 1

Variation of the energy density (\(\rho \)) in the interior region. The description of the curves is as follows: The red, brown, and black colors represent \(m=1/3\), \(m=1/2\), and \(m=2/3\), respectively. For all these, solid, dashed, and chain lines represent \(C=0.25\), 0.5, and 0.75, respectively. Thin, thick, and thickest lines correspond to \(B=5, 10\), and \(20\), respectively

The above TOV (11) may be re-written as

$$\begin{aligned} \frac{M_G\left( \rho +p\right) }{r}e^{\frac{\mu -\nu }{2}}+\frac{dp}{dr} =0, \end{aligned}$$
(22)

where \(M_G=M_G(r)\) is the gravitational mass inside a sphere of radius \(r\) and is given by the Tolman–Whittaker formula, which may be derived from the field equations,

$$\begin{aligned} M_G(r)=re^{\frac{\nu -\mu }{2}}\nu ^{\prime }. \end{aligned}$$
(23)

This modified form of the TOV equation indicates the equilibrium condition for the fluid sphere subject to the gravitational and hydrostatic forces,

$$\begin{aligned} F_g+ F_h =0, \end{aligned}$$
(24)

where

$$\begin{aligned} F_g&= \nu ^{\prime }\left( \rho +p\right) \nonumber \\&= r\frac{1+m}{2\pi m}e^{-\frac{2A}{1-m}}\left[ \frac{1-m}{m}\left( B-\frac{r^{2}}{2}\right) \right] ^{\frac{2m}{1-m}}, \end{aligned}$$
(25)
$$\begin{aligned} F_h&= \frac{dp}{dr}=-F_g. \end{aligned}$$
(26)

The profiles of \(F_g\) and \(F_h\) for the specific values of the parameters are shown in Fig. 2, which provides information as regards the static equilibrium due to the combined effect of the gravitational and hydrostatic forces.

Fig. 2
figure 2

Variation of compactness (\(u=\frac{M(r)}{r}\)) in the interior region. The description of the curves is the same as in Fig. 1

The mass, \(M(r)\), within a radius \(r\), is calculated as

$$\begin{aligned} M(r)&= \int \limits _0^r 2\pi \rho \tilde{r}d\tilde{r} = \frac{1}{2}e^{-\frac{2A}{1-m}}\left[ B\left( \frac{1-m}{m}\right) \right] ^{\frac{2}{1-m}} \nonumber \\&\quad -\frac{1}{2}e^{-\frac{2A}{1-m}}\left[ \left( B-\frac{r^{2}}{2}\right) \left( \frac{1-m}{m}\right) \right] ^{\frac{2}{1-m}}. \end{aligned}$$
(27)

The compactness of the fluid sphere, \(u(r)\), is thus defined as

$$\begin{aligned} u(r)= M(r)/r. \end{aligned}$$
(28)

This is an increasing function of the radial parameter (see Fig. 3). Correspondingly, the surface redshift (\(Z_s\)) is given by

$$\begin{aligned} Z_s(r)= ( 1-2 u(r))^{-\frac{1}{2}} - 1. \end{aligned}$$
(29)

Figure 4 provides the variation of \(Z_s\) against r for different values of the parameters.

Fig. 3
figure 3

Variation of the forces in the interior region. The description of the curves is the same as in Fig. 1

Fig. 4
figure 4

Variation of redshift in the interior region. The description of the curves is the same as in Fig. 1

In (2\(+\)1)-dimensional spacetime, the vacuum solution does not exist without cosmological constant. Thus it is not possible to match our interior solution with the BTZ black hole as it is the vacuum solution with non-zero \(\Lambda \). However, if one takes B as large as possible, then the solution is valid for the infinitely large fluid sphere. This means that we do not have the vacuum region left.

3.1.2 \(~m=1~\)

For a stiff fluid model, \(p=\rho \), and with \(\Lambda = 0\), the field equations (3)–(6) yield the following solutions:

$$\begin{aligned} \nu&= e^{-D}(r^{2}/2)+E, \end{aligned}$$
(30)
$$\begin{aligned} \mu&= -D + e^{-D}(r^{2}/2) + E, \end{aligned}$$
(31)
$$\begin{aligned} \rho&= F e^{-2E-r^{2}e^{-D}}. \end{aligned}$$
(32)

Here \(D\), \(E\), and \(F\) are integration constants.

For the consistency of the solutions, the constants should follow the following constraint equation:

$$\begin{aligned} D= \ln (2 \pi F). \end{aligned}$$
(33)

This ensures that \(F>0\). The solutions are regular at the center and are valid for infinite large sphere. The central density is \(\rho _c= F e^{-2E}\).

From (32), we find at \(r=0\)

$$\begin{aligned} \frac{dp}{dr}=0,~~ \frac{d\rho }{dr} = 0~~\mathrm{and}~~ \frac{d^{2}\rho }{dr^{2}}=\frac{1}{\pi }\left[ -e^{-2E}\right] <0. \end{aligned}$$
(34)

Thus the central density is maximum.

The mass, \(M(r)\), within a radial distance \(r\) is given by

$$\begin{aligned} M(r)=e^{D}\left[ e^{D-2E}-e^{D-2E-r^{2}e^{-D}}\right] /2. \end{aligned}$$
(35)

The compactness of the fluid sphere is, thus, \(u(r)= M(r)/r\). Having \(u\), the \(Z_s\) is determined using (29). The important physical characteristics such as density, compactness, and redshift are shown in Figs. 5, 6, and 7.

Fig. 5
figure 5

Variation of the energy density (\(\rho \)) in the interior region for \(m=1\). The description of the curves is as follows: \(F=1,2,4,6\), and \(8\) correspond to black, brown, blue, orange, and red colors, respectively. \(E=0, -1, -2\), and \(-3\) correspond to solid, dotted, dashed, and dot-dashed lines, respectively. For \( E\ge 0\) the values are too small

Fig. 6
figure 6

Variation of compactness (\(u=\frac{M(r)}{r}\)) in the interior region. The description of the curves is the same as in Fig. 5

Fig. 7
figure 7

Variation of redshift in the interior region. The description of the curves is the same as in Fig. 4

The TOV equation yields

$$\begin{aligned} F_g+ F_h =0, \end{aligned}$$
(36)

where

$$\begin{aligned} F_g=-F_h=(r/\pi )e^{-2E-r^{2}e^{-D}}. \end{aligned}$$
(37)

The profiles of \(F_g\) and \(F_h\) for the specific values of parameters are shown in Fig. 8, which provides information as regards the static equilibrium due to gravitational and hydrostatic forces combined. As before, we cannot match our interior solution with the BTZ exterior vacuum solution.

Fig. 8
figure 8

Variation of the forces in the interior region for \(m=1\). The description of the curves is the same as in Fig. 4

3.1.3 \(~m=-1~\)

The equation of state of the kind \(p =-\rho \) is related to the \(\Lambda -dark \,\, energy\), an agent responsible for the second phase of the inflation of hot big bang theory. Using the equation of state of the kind \(p =-\rho \), and with \(\Lambda = 0\), the field equations (3)–(6) yield the following solutions:

$$\begin{aligned} \rho&= -p = J,\end{aligned}$$
(38)
$$\begin{aligned} \nu&= \left[ H+ \ln (r^{2}+K)\right] /2,\end{aligned}$$
(39)
$$\begin{aligned} \mu&= \left[ H- \ln (r^{2}+K)\right] /2. \end{aligned}$$
(40)

Here \(J\), \(K\), and \(H\) are integration constants. Solutions hold good for the following constraint equation:

$$\begin{aligned} 2 \pi J + e^{-H}=0. \end{aligned}$$
(41)

These are regular at the center if \(K\) is positive and the solution is valid for an infinitely large fluid sphere. However, for \(K<0\), the solution is valid for \(r>\sqrt{-K}\) up to infinitely large radius.

3.1.4 \(~m=0~\)

For the dust case, i.e. when \(p=0\) and \(\rho \ne 0\), the field equations (3)–(6) reduce to

$$\begin{aligned} \nu = \nu _0 \end{aligned}$$
(42)

and

$$\begin{aligned} e^{-2\mu } = \mu _0 - \int 4 \pi r \rho dr. \end{aligned}$$
(43)

Here, \(\nu _0 \) and \( \mu _0\) are integration constants.

Unless specifying the energy density, one cannot get an exact analytical solution of the field equations. Thus a dust model in (2\(+\)1)-dimensional spacetime is possible for known energy density.

3.2 With cosmological constant \((\Lambda \ne 0)\)

3.2.1 \(~m=-1~\)

As before for the equation of state of the kind \(p =-\rho \) with non-zero \(\Lambda \), the field equations (3)–(6) yield \(\rho = c_4\). The metric coefficients may be obtained as

$$\begin{aligned} \nu = \ln (r^{2}+B_5)/2+D_5 \end{aligned}$$
(44)

and

$$\begin{aligned} \mu = -\ln (r^{2}+B_5)/2 -D_5 +A_4. \end{aligned}$$
(45)

Here, \(c_4\), \(A_4\), \(B_5\), and \(D_5\) are integration constants.

These solutions are consistent if

$$\begin{aligned} 2 \pi c_4 +\Lambda + e^{2D_5-2A_4}=0. \end{aligned}$$
(46)

These solutions are regular at the center if \(B_5\) is positive and the solution is valid for the infinitely large fluid sphere. However, for \( B_5 <0\), the solution is valid for \(r>\sqrt{-B_5}\) up to infinitely large radius. The nature of the solutions of the metric potentials is independent of the sign of \(\Lambda \). However, the sign of \(\Lambda \) plays a crucial role to get a positive energy density. For positivity of the energy density, one should take a negative \(\Lambda \).

Note that without any loss of generality, we can take \(D_5 =0\) as it can be absorbed by re-scaling the coordinates. We match the interior solution to the exterior BTZ BH metric,

$$\begin{aligned} ds^{2}=-(-M_0-\Lambda r^{2})dt^{2}+(-M_0-\Lambda r^{2})^{-1}dr^{2}+r^{2}d\theta ^{2}, \end{aligned}$$

at the boundary \(r=R\), which yields

$$\begin{aligned} (-M_0-\Lambda R^{2})=R^2 +B_5 \end{aligned}$$
(47)

and

$$\begin{aligned} (-M_0-\Lambda R^{2})^{-1}=e^{2A_4}(R^2 +B_5)^{-1} \end{aligned}$$
(48)

Solving the above two equations we get,

$$\begin{aligned} A_4=0 \quad \mathrm{and}\quad B_5= -M_0-(\Lambda +1)R^{2} \end{aligned}$$
(49)

The consistency relation assumes the form

$$\begin{aligned} 2 \pi c_4 +\Lambda + 1=0. \end{aligned}$$
(50)

3.2.2 \(0<m\le 1\)

From the field equations (3)–(6) after some manipulation, we arrive at

$$\begin{aligned} 2 \pi (1+m)A_1 e^{\frac{m-1}{m}\nu }\nu '^{3}=2r\nu '^{2}+r\nu ''-\nu '. \end{aligned}$$
(51)

One can observe that \(\nu '=0\) will be a particular solution of this equation. This yields \(\nu =constant\). Equation (4) implies \(p = \Lambda /2 \pi \). Finally, we get the following solution for \(\mu \):

$$\begin{aligned} \mu =-\ln \left[ A_5-Nr^2\right] /2. \end{aligned}$$
(52)

Here, \(N=\Lambda (1+m)/m\), and \(A_5\) is an integration constant.

For positivity of the energy density, one should take a positive \(\Lambda \). The solutions are regular at the center if \(A_5>0\) and valid up to \(r< \sqrt{A_5/N}\). In this case, we cannot match the interior solution to the exterior BTZ BH metric, which is a vacuum solution with negative \(\Lambda \).

3.2.3 \(~m=0~\)

For the dust case, i.e. when \(p=0\) and \(\rho \ne 0\), one cannot obtain the exact analytical solution of the field equations. Thus, the dust model in \(2+1\)-dimensional spacetime with non-zero \(\Lambda \) is not possible.

4 Conclusion

In this paper we have obtained a new class of exact interior solution of Einstein field equation in \(2+1\)-dimensional spacetime assuming the equation of state \(p=m \rho \) (where \(m\) is the equation of state parameter). The interior solutions obtained without cosmological constant, \(\Lambda \), are physically acceptable for the following reasons:

  1. (i)

    the solutions are regular at the origin,

  2. (ii)

    both the pressure (\(p\)) and the energy density (\(\rho \)) are positive definite at the origin,

  3. (iii)

    the pressure reduces to zero at some finite boundary radius \(r_b > 0\),

  4. (iv)

    both the pressure and the energy density are monotonically decreasing to the boundary,

  5. (v)

    the subluminal sound speed obeys \(v^2_s =\frac{ dp }{d \rho } = m \le 1\),

  6. (vi)

    and the Ricci scalar is non-zero, i.e. spacetime is non-flat.

It is to be noted that at very high densities the adiabatic sound speed may not equal the actual propagation speed of the signal. By studying the TOV equation, we have shown that the equilibrium stage of the interior region without \(\Lambda \) can be achieved due to the combined effect of gravitational and hydrostatic forces. We know that the BTZ exterior vacuum solution in (2 \(+\) 1) dimensions is valid only for non-zero \(\Lambda \). Therefore, it is not possible to match our interior solution (without \(\Lambda \)) with the BTZ spacetime at some boundary. We emphasize the fact that any interior solution in four-dimensional space made with a perfect fluid must be glued with an exterior vacuum solution only at a regular surface \(p = 0\) (this is a consequence of the well-known Israel matching conditions for the related problem). For a barotropic equation of state the configurations present \(p=0\) surfaces at the same location where \(\rho = 0\). For the solutions ([15])–([17]) with \(0 < m < 1\) this occurs at \(r = \sqrt{2B}\). However, the metric coefficients are singular at the same locus, in fact, there is a curvature singularity at \(r = \sqrt{2B}\). Hence, this is not a regular region where spacetime can be continuously glued with another spacetime. Hence, one should take B as large as possible, so that the solution is valid for the infinitely large fluid sphere and we do not have the vacuum region left. For the \(m=1\) case, there does not exist any radius for which p or \(\rho =0\), hence, the Israel matching condition does not occur.

While finding an interior solution with non-zero \(\Lambda \), we note that the density and the pressure remain constant. Interestingly, we observe that it is not possible to get the dust model in \(2+1\)-dimensional spacetime with non-zero \(\Lambda \). Investigation on a full collapsing model of a \(2+1\)-dimensional configuration will be a future project.