1 Introduction

Stellar evolution predicts that when the nuclear fuel gets exhausted, the stars turn into highly dense compact objects such as white dwarf, neutron star or back hole. Massive stars undergoing the supernova explosion turn into neutron star and black hole. For neutron star, the main idea is that the gravitational collapse is supported by the neutron degeneracy pressure. The general perception is that for high densities at the core, nucleons have to converted to hyperons or either form condensates. Some studies predict that these nucleons could form Cooper pairs and can be in superfluid state. Based on the MIT bag model, Witten [1] provides the existence of strange quark matter, which indicates that the quarks inside the compact objects might not be in a confined hadronic state. At the high densities and pressures they could form a larger colorless region with equal part of up, down and strange quarks. Consequently, the composition of the core region of compact objects is still an open subject in relativistic astrophysics.

When densities of compact stars are greater than the nuclear matter density, it expects the appearance of unequal principal stresses, called anisotropic effect. This usually means that the radial pressure component \(p_r\) is not equal to the transverse component \(p_t\). The presence of anisotropy was first predicted for self-gravitating objects in Newtonian regime by Jeans [2]. Later, Lemaitre [3] considered the local anisotropy effect in the context of general relativity and showed that the presence of anisotropy can change the upper limits on the maximum value of the surface gravitational potential. Ruderman [4] showed that a compact star with matter density \((\rho > 10^{15} \text{ g } \text{ cm}^{-3})\), where the nuclear interaction become relativistic in nature, is likely to be anisotropic. Herrera [5] presented the evidence on the appearance of local anisotropy in self gravitating systems in both Newtonian and general relativistic context. Since then, a lot of investigations have been carried out in finding new exact solutions with anisotropy feature.

For half of century, the theory of anisotropic compact stars in General Relativity has been developed. Bower and liang [6] provided the generalization of Tolman–Oppenheimer–Volkov equation in presence of anisotropy. The stability of a stellar model can be enhanced by a presence of a repulsive anisotropic force when \( \Delta =p_t - p_r > 0 \). This feature leads to more compact stable configurations compare to the isotropic case as pointed out by Ivanov [7]. The work of Ivanov [7] gives general bounds on the redshift for any anisotropic compact objects. Cosenza et al. [8] developed a heuristic way for the modeling of stars with anisotropic fluid distribution. Herrera et al. [9] formulated governing equations with anisotropic stress for self-gravitating spherically symmetric distributions. Herrera and Barreto [10, 11] described a new way to study stability of polytropic models by means of Tolman-mass. Errehymy and Daoud [12] obtained analytical solution using dark-energy (DE), which is characterized by a equation of state (EoS) of the type \(p_r = (\gamma -1)\rho \). Singh et al. [13] presented the anisotropic stars by taking a modified polytropic equation of state in the framework of the Korkina-Orlyanskii spacetime. In the background of the conformal motion and under Karmarkar condition [14], several researchers studied the model of compact stars in presence of anisotropy which can be found in refs. [15,16,17,18,19,20,21,22,23]. The anisotropic compact star models have also been studied in the context of modified gravity. Zubair and Abbas [24] explored charged anisotropic compact stars in f(T) gravity based on the diagonal form of tetrad field for static spacetime. Biswas and his collaborators [25] used metric potentials given by Krori–Barua [26] and established a new model for highly compact anisotropic strange system in the context of \(f(R,\,T)\) gravity. Zubair et al [27] obtained anisotropic compact star models in f(T) gravity with Tolman–Kuchowicz spacetime. Bhar [28] explored a charged model of compact star in \(f(R,\,T)\) gravity admitting chaplygin equation of state. Rej and Bhar [29] obtained charged strange star in \(f (R,\,T )\) gravity with linear equation of state. In the framework of Teleparallel Gravity, Nashed et al. [30] derived a charged non-vacuum solution for a physically symmetric tetrad field with two unknown functions of radial coordinate. Singh et al. [31] explored exact solutions free from any physical and geometrical singularities, as well as the existence of compact stellar systems throughout linear and Starobinsky f(RT) gravity theory. More details about the anisotropic models of compact stars can be found in some of these Refs. [32,33,34,35,36,37,38,39,40,41,42,43].

Now-a-days it is a concern of famed interest to obtain the models of early mentioned small sized heavily dense stellar objects to advocate the regime of strictly coupled gravitational fields, since long time, general relativity (GR) theory is a handy tool to understand the behavior of these heavily compact objects. With considerable observationally and experimentally subsidized support, Will [44] explained its gravitational consequences and interactions in four dimensional metric-space in admissible manners. Compact stars are normally understood as spherically symmetric and isotropic highly-dense objects. However anisotropy favors the heterogeneous pressure conditions and generalizes the isotropic conditions. In this study we use the Tolman spacetime [45] as spherically symmetry to explore the anisotropy of the heavenly objects named as compact stars. Several authors mentioned in the refs. [46,47,48,49,50] used this spacetime to investigate the structures of compact stars in their research articles. Tolman–Kuchowiz spacetime [45, 51] have already been used by the authors [52,53,54,55] to discuss the anisotropic manners of fluid in compact star formation.

In this work, we have investigated the physical stability and viability of anisotropic model of compact stars in the background of the Tolman spacetime. We use the physical requirements for acceptability of the model to imply constraints on the maximum allowed compactness and redshift. We further use pulsars observational data of total mass and radius to test the model validity under a certain boundary conditions. We have considered the following compact stars whose observational mass and radius are given in the bracket: Vela X -1 [mass=(\(1.77 \pm 0.08)M_{\odot }\); radius=\(9.56_{-0.08}^{+0.08}\) km] [56], radius= \(8.301_{- 0.2}^{+0.2}\) km [Mass=(\(1.04 \pm 0.09)M_{\odot }\); radius= \(8.301_{-0.2}^{+0.02}\) km] [56], 4U \(1608 - 52\) [mass=(\(1.74 \pm 0.14)M_{\odot }\); radius= \(9.528_{-0.15}^{+0.15}\) km] [57], PSR J\(1614 - 2230\) [mass=\((1.97 \pm 0.04)M_{\odot }\); radius= \(9.69_{-0.2}^{+0.2}\) km] [58], EXO \(1785 - 248\) [mass= (\(1.3 \pm 0.2) M_{\odot }\); radius=\(8.849_{-0.4}^{+0.4}\)] [59] and from our present work, we have successfully estimated their masses and radii.

The outline of our paper is as follows: In Sect. 2 we have described the basic field equations and their solutions. We picked the Tolman ansatz for one metric coefficient \(W=1+ar^2+br^4\) and calculated the relation of other components by employing the role of anisotropy factor. Some basic physical properties of the model are also discussed including the density, pressure, energy conditions and mass-radius relation. Section 3 deals with the exterior spacetime and smooth matching conditions. We have calculated unknown constants using the matching conditions and results are given in Table 1. The relationship between the matter density and pressure have been discussed in Sect. 4. It is worthwhile to mention that we here obtain the nonlinear EoS which contains the attributes of modified Chaplygin gas. The next section gives an idea about the stability and equilibrium condition of our model under different forces. Here, we probe the viability of our results under the Harrison–Zeldovich–Novikov stability criterion, causality condition and cracking, realistic adiabatic index and TOV equation. The final Sect. 6 briefly summarizes this manuscript and highlights the major conclusions drawn.

2 Interior spacetime

2.1 Basic field equations

To describe the interior of a compact star model, let us assume that the matter within the star is anisotropic in nature and therefore, the corresponding energy-momentum tensor is given as,

$$\begin{aligned} T_{\nu }^{\mu }=(\rho c^2+p_t)~\xi ^{\mu }\xi _{\nu }-p_t g_{\nu }^{\mu }+(p_r-p_t)~\zeta ^{\mu }\zeta _{\nu }, \end{aligned}$$
(1)

with \( \xi ^{i}\xi _{j} =-\zeta ^{i}\zeta _j = 1 \) and \(\xi ^{i}\zeta _j= 0\). Here the vector \(\zeta ^{i}\) is the space-like vector and \(\xi _i\) is the fluid 4-velocity and which is orthogonal to \(\zeta ^{i}\), \(\rho \) is the matter density, \(p_t\) and \(p_r\) are respectively the transverse and radial pressure components of the fluid and these two pressures act orthogonally to each other.

In (3+1)-dimension, in Schwarzschild coordinates \(x^{\mu } = (t,\,r,\,\theta ,\,\phi )\), a static and spherically symmetry spacetime is described by the line element,

$$\begin{aligned} ds^{2}=-V^{2}dt^{2}+W^{2} dr^{2}+r^{2}(d\theta ^{2}+\sin ^{2}\theta d\phi ^{2}), \end{aligned}$$
(2)

where the metrics V and W are functions of the radial coordinate ‘r’ and do not depend on the time ‘t’ i.e., they are static. The asymptotic flatness implies \(\lim _{r\rightarrow \infty }V(r)~=0=~\lim _{r\rightarrow \infty }W(r)\) and the regularity at the center imposes the condition \(V(0)=\) constant and \(W(0)=1\) [60].

The Einstein field equations for our present anisotropic model of compact star using the energy momentum tensor (1) are described by,

$$\begin{aligned} G_{\nu }^{\mu }= & {} R_{\nu }^{\mu }-\frac{1}{2}g_{\nu }^{\mu }R=\frac{8\pi G}{c^4} T_{\nu }^{\mu }, \end{aligned}$$
(3)

Here \(G_{\nu }^{\mu }\) is the Einstein tensor, G and c are respectively the universal gravitational constant and speed of the light.

Using (3) and assuming \(G=1=c\), the Einstein field equations can be expressed as the following system of ordinary differential equations:

$$\begin{aligned} \kappa \rho= & {} \frac{1}{r^2}\left( 1-\frac{1}{W^2}\right) +\frac{2W'}{W^3r}, \end{aligned}$$
(4)
$$\begin{aligned} \kappa p_r= & {} \frac{1}{W^2}\left( \frac{1}{r^2}+\frac{2V'}{Vr}\right) -\frac{1}{r^2}, \end{aligned}$$
(5)
$$\begin{aligned} \kappa p_t= & {} \frac{V''}{VW^2}-\frac{V'W'}{VW^3}+\frac{1}{W^3rV}(V'W-W'V), \end{aligned}$$
(6)

where \(\kappa =8\pi \) and ‘prime’ denotes ‘r’ derivative.

The mass function, m(r), within the radius ‘r’ is introduced by,

$$\begin{aligned} \frac{1}{W^2}= & {} 1-\frac{2m(r)}{r}, \end{aligned}$$
(7)

Using (7), from (4) to (6) one can get,

$$\begin{aligned} m(r)= & {} 4\pi \int _0^{r}\omega ^{2}\rho (\omega )d\omega , \end{aligned}$$
(8)
$$\begin{aligned} \frac{2V'}{V}= & {} \frac{\kappa r p_r+\frac{2m}{r^2}}{1-\frac{2m}{r}}, \end{aligned}$$
(9)
$$\begin{aligned} \frac{dp_r}{dr}= & {} -(\rho +p_r)\frac{V'}{V}+\frac{2}{r}(p_t-p_r), \end{aligned}$$
(10)

Combining (9) and (10), one can finally obtain :

$$\begin{aligned} \frac{dp_r}{dr}= & {} -\frac{\rho +p_r}{2}\frac{\left( \kappa r p_r+\frac{2m}{r^2}\right) }{\left( 1-\frac{2m}{r}\right) }+\frac{2}{r}(p_t-p_r). \end{aligned}$$
(11)

The Eq. (11) is called the Tolman–Oppenheimer– Volkoff (TOV) equation of a hydrostatic equilibrium for the anisotropic stellar configuration.

Our goal is to generate an exact solution by solving the field equations which does not suffer from any kind of singularities. The following metric provides a singularity free model which will be described in the next sections. To solve the above set of Eqs. (4)–(6), instead of solving the equations. for any prescribed equation of state, we are rather interested in solving Eqs. (4)–(6) with the help of the following ansatz

$$\begin{aligned} W^2=1+ar^2+br^4, \end{aligned}$$
(12)

The choice (12) was proposed in [45], where ‘\(a,\,b\)’ are constants of having units length\(^{-2}\) and length\(^{-4}\) respectively and can be obtained from the boundary conditions which has been discussed in details in Sect. 3. The above metric potential was used earlier by several researchers in the background of General relativity as well as in modified gravity. Jasim et al. [52] studied a singularity-free model for the spherically symmetric anisotropic strange stars under Einstein’s general theory of relativity in presence of the cosmological constant \(\Lambda \) which depends on radial co-ordinate r. Biswas et al. [61] used this metric potential along with the MIT Bag model equation of state to obtain strange star model. Bhar et al. [62] successfully obtained a new relativistic compact stellar model by using the above ansatz in General relativity. Patwardhan and Vaidya [63], Mehra [64] also used this ansatz earlier. Singh et al. [65] also used the same metric potential to obtained the compact star model in embedding class I spacetime. On the other hand, we now discuss about the use of this metric potential in the context of modified gravity. This metric potential was used earlier by Bhar et al. [54] to model compact object in Einstein–Gauss–Bonnet gravity and Javed et al. [66] used this metric potential to model anisotropic spheres in f(RG) modified gravity, Biswas et al. [67] obtained an anisotropic strange star with f(RT) gravity, Majid and Sharif [68] obtained quark stars in massive Brans–Dicke gravity, Naz and Shamir [69] found the stellar model in f(G) gravity, Farasat Shamir and Fayyaz [70] obtained the model of charged compact star in f(R) gravity, Rej et al. [71] studied the charged compact star in the context of \(f(R,\,T)\) gravity. Since one can obtain the results in the background of GR as a limiting case of the result in different modified theories of gravity, one can conclude that all the obtained results in modified gravity are also consistent in the background of GR. One can note that this metric potential successfully produces the model of compact star which is singularity free and satisfies all the requirements to be physically acceptable. Therefore, inspired by all the previous works done mentioned earlier in GR as well as in modified gravity, we choose the metric potential in Eq. (12) in our present paper.

Using Eqs. (5)–(6) and the definition of anisotropy \(\Delta =p_t-p_r\), we obtain the following expression

$$\begin{aligned} \kappa \Delta= & {} \frac{1}{W^2}\left( \frac{V''}{V}-\frac{V'}{Vr}\right) -\frac{W'}{W^3}\left( \frac{V'}{V}-\frac{1}{r} \right) \nonumber \\&- \frac{1}{W^2 r^2} +\frac{1}{r^2}, \end{aligned}$$
(13)

By making following transformation \(\frac{1}{W^{2}}=T\), equation (13) becomes

$$\begin{aligned} \kappa \Delta -\frac{1}{r^2}= & {} T\left( \frac{V''}{V}-\frac{V'}{Vr}- \frac{1}{ r^2}\right) +\frac{T'}{2}\left( \frac{V'}{V}+\frac{1}{r}\right) . \end{aligned}$$
(14)

The above equation (14) can also be written as,

$$\begin{aligned} \frac{V''}{V}+P(r)\frac{V'}{V}+Q(r)=0 \end{aligned}$$
(15)

where

$$\begin{aligned} P(r)= \frac{T'}{2T}-\frac{1}{r},\, Q(r)= \frac{T'}{2Tr}-\frac{1}{r^2}-\frac{\chi }{T},\, \chi =\kappa \Delta -\frac{1}{r^2}. \end{aligned}$$

Equation (15) is a second order ordinary differential equation (ODE) in V. An algorithm was presented by Herrera et al. [32] that shows that all static spherically symmetric anisotropic solutions of Einstein’s field equations may be generated from Eq. (15) by two generating functions \(\Delta \) and V. If one can obtain the metric potential V, the other physical variables may be expressed in terms of the functions \(\chi \) and V.

2.2 Solution of field equations and pressure anisotropy

From Eq. (15), it is clear that once we assume the anisotropic factor \(\Delta \), we can easily solve the second order ODE and consequently obtained the expression for V. The anisotropy \(\Delta \) should be chosen in such manner that

  • it should vanish at the center of the star,

  • it does not suffer from any kind of singularities,

  • \(\Delta \) is positive inside the stellar interior and finally

  • the field equation can be integrated easily with this choice of \(\Delta \).

To obtain the model of compact star, Dey et al. [72], Maharaj et al. [73] choose a physically reasonable choice of \(\Delta \) to find the exact solutions for the Einstein–Maxwell equations. Murad and Fatema [74] obtained relativistic anisotropic charged fluid spheres by solving the Einstein–Maxwell field equations with a preferred form of one of the metric potentials, and suitable forms of electric charge distribution and pressure anisotropy functions as,

$$\begin{aligned} V^2= & {} B_N(1 + Cr^2)^N,\\ \Delta= & {} \delta Cr^2(1 - 2aCr^2)(1 + Cr^2)^{1-N} \\&\times \big (1 + (1 + N)Cr^2\big )^\frac{N-1}{N+1},\\ \frac{2q^2}{Cr^4}= & {} K (Cr^2)^{n+1}(1+Cr^2)^{1-N} (1+mCr^2)^p\\&\times \big (1+(1+N)Cr^2\big )^\frac{N-1}{N+1}, \end{aligned}$$

where \(K,\,\delta \ge 0\), n is a nonnegative integer, and \(m,\, p,\, a\) are any real numbers.

For our present model, we assume the anisotropic factor as,

$$\begin{aligned} \Delta =\frac{\left[ (a + b r^2)^2-b\right] r^2}{\kappa (1 + a r^2 + b r^4)^2}. \end{aligned}$$
(16)

One can choose the anisotropic factor in such a way that these allow us to integrate Eq. (15) and satisfies the physically acceptable conditions mentioned earlier. Thus this choice may be physically reasonable and useful in the study of the gravitational behavior of anisotropic stellar objects. By looking at the expression of (16) and we can easily found that \(\Delta (0)=0\). The above choice of \(\Delta \) produces a non-negative anisotropic factor inside the stellar interior which will be discussed in the coming section.

Using Eqs. (12) and (16) in (15), we get the following second order ODE in V as,

$$\begin{aligned} V''=V'\frac{1+2ar^2+3br^4}{r(1+ar^2+br^4)}, \end{aligned}$$
(17)

In Eq. (17), we have a second order differential equation for V which on solving provides the expression of the metric coefficient for V as,

(18)

In the expression of \(V^2\) mentioned above \(C,\,D\) are constants of integration, which can be obtained from the boundary conditions.

With the help of (18), the matter variable, radial and transverse pressure for the new solution are obtained as,

$$\begin{aligned} \kappa \rho= & {} \frac{3 a + (a^2 + 5 b) r^2 + 2 a b r^4 + b^2 r^6}{(1 + a r^2 + b r^4)^2}, \end{aligned}$$
(19)
$$\begin{aligned} \kappa p_r= & {} \frac{32 b^{3/2} C}{\Psi \big [2 \sqrt{ b} \big (8 b D + a C \Psi + 2 b C r^2 \Psi \big ) - \Omega \big ]}\nonumber \\&-\frac{a + b r^2}{\Psi ^2}, \end{aligned}$$
(20)
$$\begin{aligned} \kappa p_t= & {} \frac{32 b^{3/2} C}{\Psi \big [2 \sqrt{ b} \big (8 b D + a C \Psi + 2 b C r^2 \Psi \big ) - \Omega \big ]}\nonumber \\&-\frac{a+2br^2}{\Psi ^4}. \end{aligned}$$
(21)

where, \(\Psi ,\,\Omega \) are functions of r and its expression is given as,

$$\begin{aligned}\Psi \!=\!\sqrt{1 \!+\! a r^2 \!+\! b r^4},\, \Omega \!=\!(a^2 \!-\! 4 b) C \log \left[ a \!+\! 2 b r^2 \!+\! 2 \sqrt{b} \Psi \right] . \end{aligned}$$

2.3 Physical attributes of the present model

2.3.1 Regularity of the metric coefficients

To avoid the singularity, the metric potentials should take finite and positive values at the center. Now \(V|_{r=0}=\frac{2 \sqrt{b} (a C + 8 b D)+(4 b-a^2) C \log {a + 2 \sqrt{b}}}{16 b^{ 3/2}}>0\) and \(W|_{r=0}=1\). We have drawn the profiles of the metric co-efficients for the compact star against r in Fig. 1. Now, \((V^2)'=\frac{C (r + a r^3 + b r^5) \big (2 \sqrt{ b} (8 b D + a C \Psi + 2 b C r^2 \Psi ) - \Omega \big )}{8 b^{3/2} \Psi },\) and \((W^2)'=2 r (a + 2 b r^2)\). We also note that \((V^2)'\) and \((W^2)'\) both vanishes at the center of the star.

2.3.2 Nature of the density and pressure

The central pressure (\(p_c\)) and central density (\(\rho _c\)) should be nonzero and positive valued inside the stellar interior, on the other hand \(p_r\) should vanish at the boundary of the star \(r=r_b\). The central pressures and the density can be written as

$$\begin{aligned} \kappa p_c= & {} \frac{32 b^{3/2} C}{ 2 \sqrt{b} (a C + 8 b D) - (a^2 - 4 b) C \log [a + 2 \sqrt{b}]}-a, \nonumber \\ \end{aligned}$$
(22)
$$\begin{aligned} \kappa \rho _c= & {} 3a, \end{aligned}$$
(23)

Again from the Zeldovich’s condition [75] \(p_c/\rho _c<1\) gives the following inequality:

$$\begin{aligned} a - \frac{8 b^{3/2} C}{ 2 \sqrt{b} (a C + 8 b D) - (a^2 - 4 b) C \log (a + 2 \sqrt{b})}>0, \nonumber \\ \end{aligned}$$
(24)

Equation (23) gives, \(a>0\) where as, (22) and (24) together implies,

$$\begin{aligned} \frac{4b-a^2}{8ab}+E~<\frac{D}{C}~<\frac{16b-a^2}{8ab}+E, \end{aligned}$$
(25)

where,

$$\begin{aligned} E=\frac{a^2-4b}{16 b^{\frac{3}{2}}}\log (a + 2 \sqrt{b}). \end{aligned}$$

The surface density \(\rho _s\) of the compact star model is obtained as,

$$\begin{aligned} \kappa \rho _s= & {} \frac{3 a + (a^2 + 5 b) r_b^2 + 2 a b r_b^4 + b^2 r_b^6}{(1 + a r_b^2 + b r_b^4)^2}. \end{aligned}$$
(26)

We have calculated the numerical values of the central density and surface density for different compact star in Table 2.

The behavior of the matter density (\(\rho \)), radial and transverse pressure \(p_r\) and \(p_t\) inside the stellar interior are shown in Figs. 1 and 2 respectively.

The density and pressure gradient of our present model are obtained by performing differentiation of the density and pressure with respect to the radial co-ordinate as,

$$\begin{aligned} \kappa \rho '= & {} -\frac{2r}{\Psi ^6}\Bigg [5 a^2 - 5 b + a (a^2 + 13 b) r^2 \nonumber \\&+ 3 b (a^2 + 4 b) r^4 + 3 a b^2 r^6 + b^3 r^8\Bigg ], \end{aligned}$$
(27)
$$\begin{aligned} \kappa p_r'= & {} 2 r \Bigg [\frac{(a + b r^2) (a + 2 b r^2)}{\Psi ^4} -\frac{b}{\Psi ^2}\nonumber \\&- \frac{ 16 b^{3/2} C (a + 2 b r^2)}{\Psi ^3 \Phi } + \frac{ 256 b^3 C^2}{\Phi ^2}\Bigg ],\end{aligned}$$
(28)
$$\begin{aligned} \kappa p_t'= & {} \kappa p_r'+\kappa \Delta ',\nonumber \\= & {} \kappa p_r'-\frac{1}{\Psi ^6}\Bigg [2 r (-a^2 + b + a (a^2 - 5 b) r^2 \nonumber \\&+ 3 (a^2 - 2 b) b r^4 + 3 a b^2 r^6 + b^3 r^8)\Bigg ]. \end{aligned}$$
(29)

where,

$$\begin{aligned} \Phi= & {} 2 \sqrt{ b} (8 b D + a C \Psi + 2 b C r^2 \Psi ) \\&- (a^2 - 4 b) C \log ( a + 2 b r^2 + 2 \sqrt{b} \Psi ). \end{aligned}$$

The profiles of density and pressure gradients are shown in Fig. 3. We check that both the density and pressure gradients are negative and it verifies the monotonic decreasing nature of both density and pressures with respect to ‘r’.

Fig. 1
figure 1

(Left) The metric potentials and (right) the matter density \(\rho \) are plotted against r inside the stellar interior for the compact star PSR J1903+327

Fig. 2
figure 2

The radial pressure \(p_r\) (left) and transverse pressure \(p_t\) (right) are plotted against r inside the stellar interior for the compact star PSR J1903+327

Fig. 3
figure 3

(Left) The anisotropic factor \(\Delta \) and (right) the density and pressure gradients are plotted against r inside the stellar interior for the compact star PSR J1903+327

The variation of anisotropy \((\Delta =p_t -p_r)\) throughout the star is regular and free of singularity. More importantly, the anisotropy vanishes at the centre and remain positive inside the star as required. The anisotropy profile in Fig. 3 shows that \(\Delta >0\) is repulsive, allowing the construction of more compact structures.

Fig. 4
figure 4

Energy conditions are plotted against r inside the stellar interior for the compact star PSR J1903+327

2.3.3 Energy conditions

It is well known that for a compact star model, the energy conditions should be satisfied and in this section we are interested to study about it. For an anisotropic compact star, all the energy conditions namely Weak Energy Condition (WEC), Null Energy Condition (NEC) and Strong Energy Condition (SEC) are satisfied if and only if the following inequalities hold simultaneously for every points inside the stellar configuration.

$$\begin{aligned} WEC&:&T_{\mu \nu }\alpha ^\mu \alpha ^\nu \ge 0~\Rightarrow ~ \rho \ge 0,~\rho +p_r \ge 0,\,\rho +p_t \ge 0 \nonumber \\ \end{aligned}$$
(30)
$$\begin{aligned} NEC&:&T_{\mu \nu }\beta ^\mu \beta ^\nu \ge 0~\Rightarrow ~ \rho +p_r \ge 0,\,\rho +p_t \ge 0\end{aligned}$$
(31)
$$\begin{aligned} DEC&:&T_{\mu \nu }\alpha ^\mu \alpha ^\nu \ge 0 ~\Rightarrow ~ \rho \ge |p_r|,\, \rho \ge |p_t| \end{aligned}$$
(32)
$$\begin{aligned} SEC&:&T_{\mu \nu }\alpha ^\mu \alpha ^\nu - {1 \over 2} T^\lambda _\lambda \alpha ^\sigma \alpha _\sigma \ge 0 ~\Rightarrow ~ \rho +p_r+2p_t \ge 0. \nonumber \\ \end{aligned}$$
(33)

Where \(~\alpha ^\mu \) and \(\beta ^\mu \) are time-like vector and null vector respectively and \(T_{\mu \nu }\alpha ^{\mu } \) is nonspace-like vector. To check all the inequality stated above we have drawn the profiles of energy conditions of (30)–(33) in Fig. 4 in the interior of the compact star and this figure indicates that all the energy conditions are well satisfied by our model.

Fig. 5
figure 5

(Left) The mass function and (right) the gravitational redshift are plotted against r inside the stellar interior for the compact star PSR J1903+327

2.3.4 Mass-radius relation and redshift

The mass function of the present model can be obtained from the formula, \(m(r)=\int _0^r 4\pi \rho r^2 dr\), which implies,

$$\begin{aligned} m(r)=\frac{r^3}{2}\frac{a+br^2}{1+ar^2+br^4}, \end{aligned}$$

The compactness factor, i.e., the ratio of mass to the radius of a compact star for our present model is obtained from the formula, \(u=\frac{m(r)}{r}\), and consequently the surface redshift is obtained as,

$$\begin{aligned} z_s= & {} \frac{1}{\sqrt{1-2u(r_b)}}-1=\sqrt{\frac{1+ar_b^2+br_b^4}{r_b^3\left( a+br_b^2\right) }} -1. \end{aligned}$$

A familiar result is that if the wavelength of a photon emitted at the surface of the star is \(\lambda _e\), and the wavelength of the same photon observed at infinity is \(\lambda _o\), the gravitational red-shift z is defined to be the fractional variation of the wavelength \(z=\frac{\lambda _o-\lambda _e}{\lambda _e}\), which consequently gives, \(z=\frac{1}{V(r)}-1\). The central value of the gravitational redshift is obtained as,

Table 1 The values of the constants \(a,\,C\) and D of few well known compact star candidates

3 Exterior spacetime and boundary conditions

In this section we match our interior solution to the exterior solution smoothly at the boundary \(r=r_b\) in order to find the constants \(a,\,b,\,C\) and D. The exterior spacetime is represented by Schwarzschild vacuum solution which is given by,

$$\begin{aligned} ds_{+}^2= & {} -f(r)dt^2+[f(r)]^{-1}dr^2+ r^2(d\theta ^2+\sin ^2 \theta d\phi ^2),\nonumber \\ \end{aligned}$$
(34)

corresponding to our interior line element that matches exactly with the interior solution at the boundary of the star \(r=r_b\), where, \(f(r)=\left( 1-{2M \over r}\right) \). For a smooth matching of the metric potentials across the boundary, i.e., at \(r=r_b\),

$$\begin{aligned} g_{rr}^+=g_{rr}^-,~g_{tt}^+=g_{tt}^-, \end{aligned}$$
(35)

and

$$\begin{aligned} p_r(r_b)=0. \end{aligned}$$
(36)

Equation (35) gives,

$$\begin{aligned} \sqrt{1-{2M \over r_b}}= & {} D + \frac{C \left( 2 \sqrt{b} (a + 2 b r_b^2)\Psi (r_b) - \Omega (r_b)\right) }{16 b^{3/2}},\nonumber \\ \end{aligned}$$
(37)
$$\begin{aligned} \left( 1-{2M \over r_b}\right) ^{-1}= & {} 1+ar_b^2+br_b^4, \end{aligned}$$
(38)

and (36) gives,

$$\begin{aligned} 32 b^{3/2} C\Psi (r_b)= & {} (a + b r_b^2)\nonumber \\&\times \Big \{2 \sqrt{ b} \big (8 b D + a C \Psi (r_b)+ 2 b C r_b^2 \Psi (r_b)\big )-\Omega (r_b)\Big \}\nonumber \\ \end{aligned}$$
(39)

Solving the three Eqs. (37)–(39) the constants can be obtained as,

$$\begin{aligned} a= & {} \frac{1}{r_b^2} \left[ \left( 1 - \frac{2M}{r_b}\right) ^{-1} - 1 - br_b^4\right] , \end{aligned}$$
(40)
$$\begin{aligned} C= & {} \frac{\sqrt{\left( 1 - \frac{2M}{r_b}\right) } (a + b r_b^2)}{2 \sqrt{1 + a r_b^2 + b r_b^4}},\end{aligned}$$
(41)
$$\begin{aligned} D= & {} \frac{C}{16 b^{ 3/2} (a + b r_b^2) \Psi (r_b)}\nonumber \\&\times \left[ -2 \sqrt{ b} (\Psi (r_b))^2 \big (a^2 + 3 a b r_b^2 + 2 b (-8 + b r_b^4)\big )\right. \nonumber \\&\left. + (a^2 - 4 b)(a + b r_b^2) \Psi (r_b) \log \left( a + 2 b r_b^2 + 2 \sqrt{b} \Psi (r_b)\right) \right] .\nonumber \\ \end{aligned}$$
(42)

From Eqs. (40)–(42), it is noted that if we fix the value of b, we obtain the values of \(a,\,C\) and D. The values of \(a,\,C\) and D for different compact stars are obtained in Table 1.

4 Equation of state

Physical feature in a relativistic stellar model requires an equation of state relating the radial pressure \(p_r\) to the energy density \(\rho \). Solving Eq.  (19) in term of r and using Taylor series expansion, we get the expression

$$\begin{aligned} r^2\approx & {} \frac{1}{\rho }+ \alpha \rho , \end{aligned}$$
(43)

where

$$\begin{aligned} \alpha= & {} \frac{3b^2(24 \sqrt{3} a^4 b^4 -291 \sqrt{3}a^2 b^5 +1500 \sqrt{3} b^6 + 2a^3 \beta +9ab\beta )}{\beta (2a^3b^3+9ab^4 +3\sqrt{3}\beta )},\nonumber \\ \end{aligned}$$
(44)
$$\begin{aligned} \beta= & {} \sqrt{b^7(8 a^4 -97 a^2 b+500 b^2)} \end{aligned}$$
(45)

Using the expression (43) in the Eq. (20), we get the equation of the form

$$\begin{aligned} p_r= & {} -\frac{a+b\left( \frac{1}{\rho }+\alpha \rho \right) }{J^2} +\frac{16b^3 C}{H(2\sqrt{b}(8b D+a C H+I)-J)}, \end{aligned}$$
(46)

where

$$\begin{aligned} H= & {} \sqrt{1+a(\frac{1}{\rho } +\alpha \rho ) +b(\frac{1}{\rho } +\alpha \rho )^2},\, I=2b C H\left( \frac{1}{\rho }+\alpha \rho \right) ,\\ J= & {} (a^2-4b) C \times \log {\left( a+\sqrt{b}H+2b\left( \frac{1}{\rho }+\alpha \rho \right) \right) }. \end{aligned}$$

The equation of state (46) is derived from the Einstein field equations, where we rewrite the pressure in term of density. It describes a macroscopic physics features of a general relativistic gravitating compact object. It is interesting to point out, the nonlinear equation of state (46) contains the modified Chaplygin equation of state which has been extensively utilize in different studies. For instance, in the case of charged anisotropic fluid spheres [76,77,78,79] and in the framework of f(T) gravity theory [80, 81]. The Chaplygin modified equation of state has proven to be adaptable tools to investigate many open problems at the theoretical level.

The variations of radial and transverse pressure with respect to the matter density are shown in Fig. 6.

5 Stability and equilibrium condition

It is very important to check the stability of the present model. Bondi [82] developed an idea for stability analysis of neutral stars. Herrera et al. [83] proposed a new way for the analysis of spherical symmetric models by means of cracking (overturning), which described the behavior of fluid distribution just after equilibrium state has been perturbed through density perturbation and this result was further extended by Gonzalez et al. [84] by introducing local density perturbation. In this section we want to discuss the stability of the present model via (1) Harrison–Zeldovich–Novikov condition, (2) causality condition and Herrera’s method of cracking and (3) relativistic adiabatic index.

5.1 Stability due to Harrison–Zeldovich–Novikov

Harrison et al. [85] and Zeldovich–Novikov [86] proposed a stability condition for the model of compact star which depends on the mass and central density and it gives us information on the stability of the gaseous stellar configuration in relation to radial pulsations. They proved that a stellar configuration will be stable if \(\frac{\partial M}{\partial \rho _c}>0\), where \(M=m(\rho _c)\). For our present model,

$$\begin{aligned} \frac{\partial M}{\partial \rho _c}=\frac{24 \pi r^3}{2(3+3\pi \rho _c r^2+3 b r^4)^2}. \end{aligned}$$
(47)

It is very clear from the above expression that \(\frac{\partial M}{\partial \rho _c}>0\) and therefore the stability condition is well satisfied.

5.2 Causality condition and cracking

Next we are interested to check the subliminal velocity of sound for our present model. Since we are dealing with the anisotropic fluid, the square of the radial and transverse velocity of sound \(V_r^2\) and \(V_t^2\) respectively should obey some bounds. According to Le Chatelier’s principle, speed of sound must be positive i.e., \(V_r>0,\,V_t>0\). At the same time, for anisotropic compact star model, both the radial and transverse velocity of sound should be less than 1 which is known as causality conditions. Combining the above two inequalities one can obtain, \(0<V_r^2,\,V_t^2<1\). For our present model,

$$\begin{aligned} V_r=\sqrt{\frac{dp_r}{d\rho }}=\sqrt{\frac{p_r'}{\rho '}},\, V_t=\sqrt{\frac{dp_t}{d\rho }}=\sqrt{\frac{p_t'}{\rho '}}. \end{aligned}$$
(48)
Table 2 The numerical values of the central density (\(\rho _c\)), surface density (\(\rho _s\)), central pressure (\(p_c\)), compactness factor and surface redshift of few well known compact star candidates

The profile of radial and transverse velocity of sound are shown in Fig. 7.

5.3 Relativistic Adiabatic index

In this section we want to check the stability of our present model via relativistic adiabatic index. The adiabatic index \(\Gamma \) is the ratio of the two specific heat and its expression can be obtained from the following formula:

$$\begin{aligned} \Gamma= & {} \frac{\rho +p_r}{p_r}V_r^2, \end{aligned}$$
(49)
Fig. 6
figure 6

The variations of radial and transverse pressure with respect to density are plotted for the compact star PSR J1903+327

Fig. 7
figure 7

(Left) The variations of the square of sound velocities (\(V_r^2,\,V_t^2\)) and (right) the variation of \(V_t^2-V_r^2\) against r are shown inside the stellar interior for the compact star PSR J1903+327

Now for a newtonian isotropic sphere the stability condition is given by \(\Gamma >\frac{4}{3}\) and for an anisotropic collapsing stellar configuration, the condition is quite difficult and it changes to [82]

$$\begin{aligned} \Gamma > {4\over 3}+\left[ {4\over 3}~{p_{ti}-p_{ri} \over r|p'_{ri}|}+{8\pi r \over 3}~{\rho _i p_{ri} \over |p'_{ri}|}\right] _{max} \end{aligned}$$
(50)

here \(p_{ri}, ~p_{ti}\) and \(\rho _i\) are initial values of radial pressure, transverse pressure and density respectively. From eqn. (50), it is clear that for a stable anisotropic configuration, the limit on adiabatic index depends upon the types of anisotropy. In our present case, we have plotted the profile of \(\Gamma \) and we see that it is always greater than \(\frac{4}{3}\) and hence we get stable configuration from Fig. 8.

5.4 Equilibrium condition

To check the static stability condition of our model under three different forces, the generalized Tolman-Oppenheimer-Volkov (TOV) equation has been considered which is represented by the equation

$$\begin{aligned} -\frac{M_g(\rho +p_r)}{r^{2}}\frac{W}{V}-\frac{dp_r}{dr}+\frac{2}{r}(p_t-p_r)=0. \end{aligned}$$
(51)
Fig. 8
figure 8

(Left) The adiabatic index \(\Gamma \) and (right) the forces acting on the system are shown against r inside the stellar interior for the compact star PSR J1903+327

The above expression of \(M_g(r)\) can be derived from Tolman-Whittaker mass formula and Einstein’s field equation defined by

$$\begin{aligned} M_g(r)= & {} 4\pi \int _0^{r}(T_t^t-T_r^r-T_{\theta }^{\theta }-T_{\phi }^{\phi })r^2 VW, \end{aligned}$$
(52)

which further simplifies to,

$$\begin{aligned} M_g(r)=r^{2}\frac{V'}{W}, \end{aligned}$$
(53)

. Using the expression of equation (53) in (51) we obtain the modified TOV equation as,

$$\begin{aligned} F_g+F_h+F_a=0 \end{aligned}$$
(54)

Where the expression of the three forces are given by,

$$\begin{aligned} F_g=-\frac{V'}{V}(\rho +p_r),\, F_h=-\frac{dp_r}{dr},\, F_a= & {} \frac{2}{r}(p_t-p_r).\nonumber \\ \end{aligned}$$
(55)

\(F_g\), \(F_h\) and \(F_a\) are known as gravitational, hydro-statics and anisotropic forces respectively. The profile of the above three forces for our model of compact star is shown in Fig. 8, which verifies that present system is in static equilibrium under these three forces.

6 Discussion and concluding remarks

In this paper, we have presented a model of Einstein’s field equations for a spherically symmetric stellar object with anisotropic pressures. For this particular motive we have selected the Tolman-spacetime as interior geometry, and it has been traditionally matched with the Exterior Schwarzschild geometry to evaluate unknown parameters present in the model. For the plotting of the different physical model parameters we have considered the compact star PSR \(J1903+0327\) with mass \(1.66~M_{\odot }\) and radius 10.4 km [87]. From the matching conditions we obtain \(a=0.00816742\), \(C=0.00278563\) and \(D=0.261086\). PSR \(J1903+0327\) is a millisecond pulsar in a highly eccentric binary orbit and it lies in the categories of stars whose masses have been found accurately [87]. The pulse period is 2.15 ms, or 465.1 times per second. These stars are composed of the densest material exist in this universe. The radii of these stars depend upon the equation of state (EoS) i.e., how physical variables are related to each other [88]. Following points summarize our concluding remarks:

  • As, if one analyze the results from left panel of Fig. 1, it is well clear that both the metric gravitational potentials have positive and regular behavior inside the stellar interior. The study of compact stars requires the metric gravitational components must behave positively (i.e. \(V,\,W>0\)) when graphes against radial coordinate ‘r’.

  • Energy progression as shown in the right panel of Fig. 1 promises the real formation of stellar body by having positive advancement all over the matter distribution along radial direction and shows smooth decline from inward to outward direction.

  • Congruent to density, the behavior of pressure components in left and right panel of the Fig. 2 declares the realistic formation of compact object as one can assess that \(p_t>0\) and \(p_r\) approaches to zero exactly at the boundary \(r=R\). Both the pressures are positive, continuous and do not suffer from any kind of singularities inside the stellar interior.

  • Out spread of anisotropic factor (\(\Delta \ge 0\)) Shown in the left panel of Fig. 3 ensures the existence of repulsive forces allowing the more compact formation by escaping the stellar collapsing to point singularity. Right panel in the Fig. 3 depicts the negative trend (Propagating from zero to negative from center to boundary) in gradient components which strengthen the equilibrium of the system by counterbalancing the forces inside the stellar body.

  • The model analysis shows that the null, weak, dominant and strong energy conditions are satisfied throughout the stellar structure as shown in Fig. 4. For the complexity of the expressions of density and pressures we have taken the help of graphical representations which ensures about the well behaved nature of all the energy conditions.

  • The mass function and gravitational redshift are plotted in Fig. 5. The figure shows that mass function is monotonic increasing function of ‘r’ and regular at the center of the star. On the other hand the gravitational redshift is monotonic decreasing. The mass and gravitational redshift values are in agreement with required physical conditions as one can examine from Fig. 5. For a spherical object, in the absence of a cosmological constant, Buchdahl [89] has proposed the upper bound for surface redshift as, \(z_s \le 2\) which was generalized by Böhmer and Harko [90] for an anisotropic spherical object in the presence of a cosmological constant \(\Lambda \) as \(z_s \le 5\). Later this bound was modified by Ivanov [7] who demonstrated that the most extreme admissible value could be as high as \(z_s = 5.211\). In our present study we have obtained the surface redshift for different compact star models presented in Table 2, which indicates that \(z_s\) lies in the reasonable bound.

  • The variation of radial and transverse pressures with respect to the density has been pointed in Fig. 6. The figure indicates that both the pressures obeys a non-linear equation of state with respect to matter density.

  • Sound speeds and Herrera’s cracking conditions are plotted in Fig. 7 versus radial direction, both the sound speeds are within the stable range of compact star i.e. \(0<V_r^2,\,V_t^2<1\). Herrera’s cracking condition [83] \(V^2_{t}-V^2_{r}<0\) is also justified to ensure the potentially stability of the system.

  • As TOV forces are also in good balance to declare the equilibrium state of the stellar model of our case study as shown in right panel of Fig. 8. Left panel of Fig. 8 shows the stability of the system of stellar objects under adiabatic index \(\Gamma >\frac{4}{3}\).

The model is potentially stable and regular and more details numerical features of our solution can be found in Tables  1 and 2. The masses and radii of some pulsars obtained from our model are roughly equal to the observed stars such Vela X -1, LMC X -4, 4U 1608 - 52, PSR J1614 - 2230, EXO 1785 - 248. Through analytical, graphical and numerical analysis, all the features of the model are well described. Finally, if we summarize our discussion, we collectively convinced by the calculated results which says that the system under discussion is physically admissible and viably stable.