1 Introduction

Determinate the internal structure of the stars is a relevant topic mainly in the astrophysical point of view, involving different areas such as particle physics and gravitation [1,2,3,4,5,6]. One of the most relevant contributions in the understanding of the interior of the stars was developed by Chandrasekhar with his analysis of white dwarfs in hydrostatic equilibrium from the electron’s pressure degeneration resulting the called Chandrasekhar’s limit [7]. In the case of more compact such as neutron stars one more time we the Pauli’s exclusion principle, now applied to the neutrons, implies a limit in the mass of these kind of stars [5]. An other relevant fact is that if we assume a density of the order of nuclear density \(\rho \approx 10^{15} \text {g/cm}^3\) the matter can present anisotropy in the pressure [8, 9].

The most of the proposed models to describe this kind of objects require an analysis starting of an adequate gravitational theory, at these order the description of compact objects in hydrostatic equilibrium must be treated in a relativistic way, however, there are analysis made under the assumption of different gravitational theories [10,11,12]. In the case of the Einstein’s equations with a perfect fluid as the source of matter the Tolman Oppenheimer Volkof [13, 14] allows to determinate the mass, radio and central density of the stars from the state equation using numerical methods [15]. In the case of internal exact solutions the most of the previous efforts in this topic start from the condition that the radial and tangential pressures are the same [16,17,18], an analysis of a variety of solutions built show that very few of these solutions are physically acceptables [19] and just a few of them allow to describe stars with a compacity ratio associated to neutron or quarks stars. Because of the density order some models for these kind of stars are given from fluids with anisotropic pressures [20, 21] or with a charged perfect fluid [22,23,24,25].

Some of the anisotropic exact regular solutions which are physically acceptable were built from a regular solution of a perfect fluid with an additional anisotropic parameter which allows recover the solution for the perfect fluid [26,27,28], even though anisotropic solutions which has no similar for a perfect fluid exist [29,30,31].

A part of the effect of the anisotropy over the physical properties has been understood thanks to the constructed solutions [32]. However, the relevance of the anisotropy over the behavior of the density and pressure is not studied in a way that could provide a regular anisotropic model and physically acceptable but that in the absence of anisotropy the model of perfect fluid could be regular but not physically acceptable. In the present work we talk about this analysis, for that purpose we construct a regular solution with a perfect fluid as matter source but such as the density and the speed of sound are not both positive at the origin and generalizing this at the case of an anisotropic fluid. We show that the new solution is regular and compact. The report is organized as follows: in Sect. 2, we give the basic equations that describe the behavior of the static and spherically symmetric anisotropic stellar models and discuss the requirements for a system solution to be physically acceptable; in Sect. 3, consider a regular solution for the perfect fluid but that is not physically acceptable,which will be used in that same section for the construction of the physically acceptable anisotropic model; in Sect. 4 the consequences of the conditions stated are discussed; in Sect. 5 it is shown that the anisotropic model is applicable for compact stars; we finalized this work with the presentation of the conclusions in Sect. 6.

2 Basic equations

The main interest is focused in the construction of a model with matter distribution in statical equilibrium and spherically symmetric with a energy-momentum tensor given by an anisotropic fluid:

$$\begin{aligned} T_{\mu \nu }= (c^2\rho +{ P}_t ) u_{\mu }u_{\nu }+ { P}_t g_{\mu \nu }+({ P}_r-P_t) \chi _{\mu }\chi _{\nu } , \end{aligned}$$
(1)

where \(P_t\), \(P_r\) are the radial and tangential pressures respectively, \(\rho \) the density, \(u^\mu \) the component of the four-velocity of the fluid, \(\chi _\mu \) the unitary vector in the radial direction. The geometry of the configuration is statical and spherically symmetric, in our case we adopt the Schwarzschild coordinates for the metric [33]:

$$\begin{aligned} ds^2 = -y(r)^2dt^2+\frac{dr^2}{1- 2m(r)/r} +r^2 (d\theta ^2+\sin ^2{\theta }d\phi ^2), \nonumber \\ \end{aligned}$$
(2)

With the range of coordinates \((t, \theta ,\phi )\) in the usual form and \(r\le R\), where R represent the star radius. The geometry in the inside of the star and the distribution of matter are given by the solution of Einstein equations and the conservation of the energy-momentum tensor

$$\begin{aligned} G_{\mu \nu }=kT_{\mu \nu },\qquad \quad \nabla ^\mu T_{\mu \nu }=0, \end{aligned}$$
(3)

with \(k =8\pi G/c^4\), where G is the universal gravitational constant and c is the light speed. From (1)–(2) we get the non zero components of the Eq. (3) which are:

$$\begin{aligned} kc^2\rho= & {} \frac{2m'}{r^2}, \end{aligned}$$
(4)
$$\begin{aligned} k{ P_r}= & {} \left( 1-{\frac{2m }{r}} \right) \frac{2y'}{ry } -\frac{2m}{{r}^{3}}, \end{aligned}$$
(5)
$$\begin{aligned} k{ P_t}= & {} {\frac{( r-2m)( ry''+y') }{y{r}^{2}}}- {\frac{( y'r+y)(m'r-m)}{{r}^{3}y}}\qquad \end{aligned}$$
(6)
$$\begin{aligned} { P_r}'= & {} -{\frac{ \left( { P_r} +c^2\rho \right) y'}{y }}+\frac{2}{r}(P_t-P_r), \end{aligned}$$
(7)

where \('\) denotes the derivate respect to the r coordinate. From these four equations only three are independent, for example the equation that comes from conservation of the momentum-energy tensor (Eq. (7)) we can obtain derivating the Eq. (5) and replacing the derivate of the mass function in (4) and the second derivate of y in (6). We consider the system conformed by the three Eqs. (4)–(6), and if \(P_t=P_r=P\) with the four functions \((y,m,P,\rho )\) that need to be determinate, “(in the anisotropic case we get the five function \((y, m, P_r,P_t,\rho )\))”. Because we have one function more than the number of equations is necessary the assignation of an additional equation or fix one of the functions, in particular we give a form of the redshift factor y [33] which allows us integrate the system. Finding solutions for the equation system (4)–(6) does not implies that these are physically acceptables, minimal conditions over the metric functions are required and over the density and pressures also in order to get a viable model [19, 34,35,36,37]:

  1. 1.

    There must exist a value \(r=R\) identified as the frontier of the star where the pressure is null, i.e., \( P_r (R) = 0. \)

  2. 2.

    At the surface of the frontier of the star \(r = R\) the interior solution (2) should match continuously to the exterior Schwarzschild solution:

    $$\begin{aligned} ds^2= & {} -\left( 1- \frac{2GM}{c^2r}\right) dt^2+\left( 1- \frac{2GM}{c^2r}\right) ^{-1}dr^2 \nonumber \\&\quad + r^2 \;(d\theta ^2+\sin ^2{\theta }d\phi ^2),\quad r\le R. \end{aligned}$$
    (8)
  3. 3.

    The metric functions must be finite and non zero \( y(r)^2 > 0 \), \(1- \frac{2m}{r}> 0 \) for \( 0 \le r \le R \).

  4. 4.

    The density and pressures must be positive functions \(\rho (r)\ge 0\), \(P_r\ge 0\), \(P_t\ge 0\) for \(0\le r \le R\).

  5. 5.

    The density must be a monotonic decrescent functions, \(\frac{d\rho }{d r}< 0\), with a maximal value at the origin \( \left. \frac{d\rho }{d r}\right| _{r=0}=0, \) \( \left. \frac{d^2 \rho }{d r^2}\right| _{r=0} < 0. \)

  6. 6.

    The pressure must be a monotonic decrescent function, \(\frac{dp_r}{d r}< 0\), para \( 0 < r \le R\), with maximal value at the origin: \( \left. \frac{dp_r}{d r}\right| _{r=0}=0, \) \( \left. \frac{d^2 p_r}{d r^2}\right| _{r=0} < 0. \)

  7. 7.

    For the anisotropic fluid configuration, the energy condition like null energy condition (NEC), the dominant energy condition (DEC), the strong energy condition (SEC) must be satisfied throughout the interior region, i.e., \(\rho \ge 0\); \(c^2\rho \pm P_r \ge 0\); \(c^2\rho \pm P_t \ge 0\); ; \(c^2\rho +P_r+2P_t \ge 0\).

  8. 8.

    Inside of the star the causality condition must be satisfied, i.e. the tangential and radial speed of sound must be lower than the light speed.

    $$\begin{aligned} 0<v_r^2\equiv \frac{d p_r}{d\rho }<c^2,\quad 0<v_\perp ^2\equiv \frac{d p_t}{d\rho }<c^2. \end{aligned}$$
  9. 9.

    The radial and tangential pressure at the origin must be the same \( P_r(0) = P_t(0) \).

  10. 10.

    The anisotropic model is potentially stable if \( -1 \le v_\perp ^2 - v_r^2 \le 0\), [38]. This last condition is required only for a potentially stable model.

Another property, that in some cases is imposed, is on the behavior of the speed of sound. It is required that the speed of sound is a decreasing monotonic function as a function of the radius [28]. However, this is not a generality [19, 39, 40], a simple example is the MIT Bag equation of state \(P=\frac{1}{3}(c^2\rho -4B_{g})\) applicable for quarks stars, in this case the speed of sound, \(v^2=c^2/3\), is constant [41]. So we will only consider the non-violation of causality, although in the Sect. 5 we show that the solution admits situations for which the speed of sound is monotone decreasing.

3 The solution

3.1 Perfect fluid

When we considered a perfect fluid the radial and tangential pressure are the same, so equating (5) and (6) we obtain:

$$\begin{aligned} \left( r-{2m}\right) r^2y'' -\left( rm'-3m \right) (ry' +y)- r^2y'=0 \end{aligned}$$
(9)

If one of the Einstein equations solutions with a perfect fluid in a static and spherically symmetric space time is regular at the center, It is a requirement that [42]:

$$\begin{aligned} y^2(r)= a_0+a_1 r^2+\cdots \end{aligned}$$
(10)

Other condition is that \(m(r)=\alpha r^3+O(r^4)\) when \(r\rightarrow 0\). However the solution at the origin is not guarantes that the solution is physically acceptable. In this section we assume a form of the magnitude of the Killing vector [33] like:

$$\begin{aligned} {y}^{2}(r)=C{\frac{3+a{r}^{2}}{1-a{r}^{2}}}\approx C \left[ 3+4\,a{r}^{2}+4\,{a}^{2}{r}^{4}+O({r}^{6})\right] \end{aligned}$$
(11)

where \(C>0\), this function satisfies the condition (10) and can be constructed a solution to the Einstein equations with a perfect fluid don’t generate a physically acceptable solution. The differential equation that we get is:

$$\begin{aligned}&(9-a^2{r}^{4} )( 1-a^2{r}^{4})rm' -3( 1+a{r}^{2})\left[ {\frac{}{}} 9\right. -17a{r}^{2} \nonumber \\&\quad \left. -9\,{a}^{2}{r}^{4}+{a}^{3}{r}^{6}{\frac{}{}}\right] m -16 ( 2+a{r}^{2} ){a}^{2}{r}^{5} =0, \end{aligned}$$
(12)

after the integration the result is:

$$\begin{aligned} m(r)= & {} \frac{8a( 1-a{r}^{2} ) ^{3}(3+ a{r}^{2}){r}^{3}}{ \left( 3 -a{r}^{2} \right) ^{4}} \left[ A+\ln \left( {\frac{1+a{r}^{2}}{1-a{r}^{2}}} \right) \right] \nonumber \\&+\frac{4a \left( 15-16\,a{r}^{2}-{a}^{2}{r}^{4} + 4\,{a}^{3}{r}^{6} \right) {r}^{3}}{ \left( 3-a{r}^{2} \right) ^{4}}. \end{aligned}$$
(13)

Now we do the analysis of the conditions numerated in the section II that need to be satisfied by the pressure, density and the speed of sound in order to have a model physically acceptable. We are giving only the relevant conditions in the analysis, the first is \(k(c^2\rho (0) + 3P(0) ) = 8a > 0\) this condition will be considerated in the following inequalities:

$$\begin{aligned} k\Pr \left( 0 \right)= & {} -{\frac{16\,a \left( A-2 \right) }{27}}>0 \quad \Rightarrow \quad A < 2. \end{aligned}$$
(14)
$$\begin{aligned} k{c}^{2}\rho \left( 0 \right)= & {} {\frac{8\,a \left( 2\,A+5 \right) }{9} }>0 \quad \Rightarrow \quad -5/2<A. \end{aligned}$$
(15)
$$\begin{aligned} k{c}^{2}\left. \frac{d^2\rho }{dr^2}\right| _0= & {} -{\frac{640\,{a}^{ 2} \left( A-2\right) }{81}}<0 \quad \Rightarrow \quad A>2. \end{aligned}$$
(16)
$$\begin{aligned} 0\le \frac{{ v_r^2} \left( 0 \right) }{c^2}= & {} {\frac{4\,A+19}{20(\,A-2)}} \le 1, \end{aligned}$$
(17)

as the pressure can not be negative, (14) and (16) implies that if the pressure is negative, the density would be monotonic decrescent function in a neighborhood of the origin. Considering the positivity of the speed of sound and the pressure we get to \(A<-19/4\) adding up this with the density at the origin we get that is not possible satisfy both inequalities, in other words, the density and the speed of sound can not be positive at the origin at the same time, so this solution is not physically acceptable.

3.2 Anisotropic model

A diversity of anisotropic models physically acceptables have been constructed as a generalization of models that are physically acceptables with matter of a perfect fluid [43, 44], one of the reasons of the generalizations is that the anisotropic models can describe stars with a bigger compactness ratio. However, the effect of the anisotropy over the plausibility of generalize a not physically acceptable regular model in to a model that is physically acceptable has not been addressed. In this section we focus in the construction of an anisotropic model that generalize the one constructed in the last section which is physically acceptable. The system of equations that we have is similar to the previous but the Eq. (9) is not satisfied because the pressures are not the same, so now we have

$$\begin{aligned} P_t(r)=P_r(r)+\varDelta (r). \end{aligned}$$
(18)

If the radial pressure in the frontier must be null and the tangential pressure must be no negative, we will get the anisotropic factor in the frontier must be positive and is related with the metric functions by

$$\begin{aligned} \left( r-{2m}\right) r^2y'' -\left( rm'-3m \right) (ry)'- r^2(y'-kr y\varDelta )=0. \end{aligned}$$
(19)

The proposal is to take the same form of the redshift factor, equivalently the same function y(r), meanwhile we choose the factor of anisotropy so that at the origin is null in order to get a regular solution. Different forms of \(\varDelta \) with this characteristics can be choose and not necessarily this generate anisotropic solutions physically acceptable, here we give a form of the function that generate a physically acceptable model.

$$\begin{aligned} k\varDelta \left( r \right) =32\,{\frac{ \left( 1-n \right) \left( 1 -a{r}^{2} \right) {a}^{2}{r}^{2}}{ \left( 3-a{r}^{2} \right) ^{3}}}, \qquad n\le 1. \end{aligned}$$
(20)

The restriction of \(n\le 1\) is due to the null radial pressure at the frontier, so the tangential pressure at the surface would be given by \(P_t(R)=\varDelta (R)\) and it is positive only if this satisfies the restriction. Replacing in (19) the form of the shift function (11) and the anisotropy given by (20) we get to the differential equation

$$\begin{aligned}&(9-a^2{r}^{4} )( 1-a^2{r}^{4})rm' -3( 1+a{r}^{2})\left[ {\frac{}{}} 9\right. -17a{r}^{2} \nonumber \\&\left. -\,9{a}^{2}{r}^{4}+{a}^{3}{r}^{6}{\frac{}{}}\right] m -16\, ( 2+a{r}^{2} )\,{a}^{2}{r}^{5}\nonumber \\&+\,\frac{32\left( 1-n \right) {a}^{2}{r}^{5} \left( 3+a{r}^{2} \right) ^{2} \left( 1-a{ r}^{2} \right) ^{3} }{ \left( 3-a{r}^{2} \right) ^{ 3}} =0, \end{aligned}$$
(21)

after the integration we get

$$\begin{aligned} m(r)= & {} \frac{8a( 1-a{r}^{2} ) ^{3}(3+ a{r}^{2}){r}^{3}}{ \left( 3 -a{r}^{2} \right) ^{4}} \left[ A+n\ln \left( {\frac{1+a{r}^{2}}{1-a{r}^{2}}} \right) \right] \nonumber \\&+\frac{4a \left( 15-16\,a{r}^{2}-{a}^{2}{r}^{4} + 4\,{a}^{3}{r}^{6} \right) {r}^{3}}{ \left( 3-a{r}^{2} \right) ^{4}}. \end{aligned}$$
(22)

From Eq. (5) with the form of (11) and the mass function (22) we obtain the radial pressure

$$\begin{aligned} kP_r(r)= & {} -\frac{ 16a( 3+6 a{r}^{2}-{a}^{2}{r}^{4}) (1 - a{r}^{2} ) ^{2}}{ (3 -a{r}^{2}) ^{4}} \left[ n\ln \!\left( {\frac{1+a{r}^{2}}{1-a{r}^{2}}} \right) + A\right] \nonumber \\&+\frac{16a\! \left( 6-21a{r}^{2}+16{a}^{2 }{r}^{4} -2{a}^{3}{r}^{6} \right) }{(3 -a{r}^{2}) ^{4}}. \nonumber \\ \end{aligned}$$
(23)

The density is determinate from (4) replacing the mass function (22):

$$\begin{aligned} k{c}^{2}\rho (r)= & {} \frac{48a \left( 1 -a{r}^{2}\right) ^{2} \left( 9-17a{r}^{2}-9{a}^{2}{r}^{4}+ {a}^{3}{r}^{6} \right) }{ \left( 3-a{r}^{2} \right) ^{5}} \nonumber \\&\times \left[ A + n\ln \left( {\frac{1+a{r}^{2}}{1-a{r}^{2} }} \right) \right] +\frac{64 \left( 3+ a{r}^{2}\right) \left( 1-a{r}^{2} \right) ^{2}n{a}^{2}{r}^{2}}{ \left( 3-a{r}^{2} \right) ^{4} \left( 1+a{r}^{2}\right) }\nonumber \\&+\frac{8a \left( 135-165a{r}^{2}-69{a}^{2}{r}^{4}+107{a}^{3}{r}^{6 }-4{a}^{4}{r}^{8} \right) }{ \left( 3-a{r}^{2} \right) ^{5}}.\; \nonumber \\ \end{aligned}$$
(24)

The tangential pressure is obtained from (18) when we replace the form of the radial pressure (23) and the anisotropy function (20). The expressions for the radial and tangential speeds of sound are a little bit longer just as the first and second derivatives of the density and pressures, so we have omitted them.

4 Analysis of the solution

The conditions over the core of the star generates the following set of inequalities:

$$\begin{aligned} kP_r \left( 0 \right) =-{\frac{16\,a \left( A-2 \right) }{27}}>0. \quad k{c}^{2}\rho \left( 0 \right) ={\frac{8\,a \left( 2\,A+5 \right) }{9}}>0. \end{aligned}$$

Applying the conditions for the density and pressures to be monotonic decrescent functions we get

$$\begin{aligned} k\left. {\frac{ { { \mathrm d}^{2} P_r } }{{ \mathrm{d} } {r}^{2}}} \right| _{r=0}= & {} -{\frac{32\,{a}^{2} \left( 4\,A+13+6\,n \right) }{81}}<0.\\ k\left. {\frac{ { { \mathrm d}^{2} P_t } }{{ \mathrm{d} } {r}^{2}}} \right| _{r=0}= & {} -{\frac{32\,{a}^{2} \left( 4\,A+7+12\,n \right) }{81}}<0.\\ k{c}^{2}\left. {\frac{ { { \mathrm d}^{2} \rho } }{{ \mathrm{d} } {r}^{2}}} \right| _{r=0}= & {} -{\frac{320\,{a}^{2} \left( -1-3\,n+2\,A \right) }{81}}<0. \end{aligned}$$

The condition over the speed of sound leads us to

$$\begin{aligned} 0\le \frac{ {v_{r}}^2( 0)}{c^2}= & {} \frac{13+6\,n+4\,A}{10(-1-3\,n+2\,A)}\le 1.\\ 0\le \frac{ {v_{\perp }}^2( 0)}{c^2}= & {} \frac{7+12\,n+4\,A}{10(-1-3\,n+2\,A)}\le 1. \end{aligned}$$

Besides the shape of the anisotropy function \( \varDelta (0)=0\), so \(P_t(0)=P_r(0)\). Forming the expression

$$\begin{aligned} k \left( \rho \left( 0 \right) {c}^{2}+3\,\Pr \left( 0 \right) \right) =8a \quad \Rightarrow \quad a>0. \end{aligned}$$

Moreover the set of inequalities we get the following two regions for the interval of A depending on the value of n

$$\begin{aligned} -\frac{13}{4}-\frac{3}{2}n< A < 2\quad \text{ if }\quad n\in \left[ -\frac{7}{2}, -\frac{5}{4}\right) , \end{aligned}$$
(25)

and

$$\begin{aligned} \frac{23}{16}+\frac{9}{4}n< A < 2\quad \text{ if }\quad n\in \left[ -\frac{5}{4}, \frac{1}{4}\right] , \end{aligned}$$
(26)

In the other side the constant of integration A is obtained by imposing the null value of the pressure function at the surface, leading us to

$$\begin{aligned} A=-n\ln \left( {\frac{1+w}{1-w}} \right) +{\frac{6-21w+16w^{2}-2y^{3}}{ \left( 3+6w-w^{2}\right) \left( 1-w\right) ^{2}}}. \end{aligned}$$
(27)

Where \(w=aR^2\) is positive because of \(a>0\). This form of A as function of n and w added up to the intervals (25) and (26) allows us to have inequalities between n and w, additionally to the form of A we note that \(w<1\) even though this is not the upper limit. From the previous relations we have shown the solution permit intervals for the constants that make it physically acceptable at the center, which did not happen in the case of the perfect fluid (\(n=1\)). At this point, starting from the conditions at the center ant the frontier, we have obtained intervals for n and A related each other. It is necessary to verify the solution have adequate conditions inside and at the frontier.

5 Compact stars

The anisotropic solution constructed depends of two parameters (nw) which intervals is determinated for the relations (25) and (26) with A given by (27). The specific values of these parameters fix the type of compact object that represent and this is given by the compacity ratio that can be determinated considering the form known for A and imposing the metric that must be continuous at the frontier, we get the the compactness ratios

$$\begin{aligned} 1-\frac{2m(R)}{R}=1-\frac{2GM}{c^2R}\equiv 1-2u,\quad u= \frac{4w}{3+6\,w- {w}^{2}}, \end{aligned}$$
(28)

furthermore the value of the constant C in equation (11) is obtained of the continuity of

$$\begin{aligned} y(R)^2=C{\frac{3+w}{1-w} }=1-\frac{2GM}{c^2R}\quad \Rightarrow \quad C=\frac{(1-w)^2}{3+6w-w^2}, \end{aligned}$$

then all the constants have been determined. In the interval \(w\in (0,1)\) the compactness is a monotonic decrescent function and \(u(1)=1/2\), so one more time note that \(w<1\). Now we apply the model to represent compact stars with different values of compactness, the way to proceed is give a new value of compactness \(u=u_0\), from the equation (28) we get its value associated for \(w=w_0\) which allows us to get an interval for n with that fixed value of \(w_0\). A plausible interval for n is obtained from the relations (25)–(27) however, the final interval is a subset of this one because at the interior the speed of sound for this interval is not lower than the light speed or positive for every case. The model allow us to represent compact stars with compactness values of \(u=0.316022\) or lower which is characteristic of quark stars, for this value \(w=0.423669443\) and the interval for \(n\in ( -0.721033970\), \(-0.5)\). This interval is obtained making a graphic analysis. The Fig. 1 shows that the minimal value of n is determinated by the tangential speed of sound because inside it gets a minimal value which is posistive if \(n\ge -0.721033970\) (lower curve). The maximal value of n is fixed by the radial speed of sound in as much inside this has a maximal value and this is lower than the light speed if \(n\le -0.5\) (upper curve). The behavior of the speed of sound for other values of n in this interval is shown in the figures, in which the radial speed of sound is always bigger than the tangential speed of sound, both positive and lower than the speed of light and consequently \(-1\le v_t^2(r)-v_r^2(r) \le 0\) this implies that the solution is potentially stable [38, 46]. Furthermore the density and the radial and tangential pressure are finite positive and monotonic decrescent functions. If we consider a value for the compacity lower \(u = 0.207345059\) we get \(w=0.222\), in this case both speeds of sound, radial and tangential, are monotonic decrescent functions and the interval for \(n\in [ -0.771108398\), \(-0.231572621 ]\), Fig. 2. In the same way than the previous one, for a fixed n, the tangential speed of sound is lower than the radial speed of sound, satisfying \(-1\le v_t^2(r)-v_r^2(r) \le 0\) in this interval the solution is potentially stable [38, 46]. The analysis of the stability was raised through the concept of cracking [38] that allows us to determine the region of stability through a simple comparison between the radial and tangential speeds. Of course, stability can be considered from different approaches and stability with respect to one type of perturbation does not imply stability with respect to another perturbation. In particular with respect to radial oscillations the system may not be stable and this may be developed in future investigations [47]. Even though in each case the proposed value for the compacity does not change because it does not depend of the parameter n associated with the anisotropy, the density, pressures and speeds of sound if those have a certain dependency on the value of n. The Fig. 3 shows how the changes in the radial and tangential pressure depending on the parameter of the anisotropy n for the case \(u = 0.207345059 \) the radial pressure inside is bigger as the value of n gets bigger. The tangential pressure in the center is high for bigger values of n, even though in the surface it gets lower when the values of n increase. Even if we only consider this two possible values of u, a similar situation is shown for other values. The Fig. 4 shows that the behavior of the density for different values of n where we get that the central density is bigger for lower values of n even though in the frontier happens in the inverse way. From the Fig. 2 for the speed of sound it is observed that its behavior is similar to that of radial pressure, that is, its value increases if the parameter of anisotropy increases. An analysis of the energy conditions shows that these are satisfied for all the values of compactness \( u \le 0.316022598\). In particular, it can be noticed from the graphs of the Figs. 3 and 4 that even the density at the border (region where the density is minimum) is greater than the central pressure (region where the pressure is maximum), furthermore

$$\begin{aligned} c^2\rho (r)+P_r(r)+2P_t(r)>c^2\rho (R)+2P_t(R)>0 \end{aligned}$$

in this inequalities we have used that density and pressures are decreasing monotonous functions (Figs. 3, 4).

Fig. 1
figure 1

Graphical representation of the radial and tangential speed of sound behavior for (\(w=0.423669443\))

Fig. 2
figure 2

Graphical representation of the radial and tangential speed of sound for \(w=0.222\)

Fig. 3
figure 3

Graphical representation of radial and tangential pressure behavior

Fig. 4
figure 4

Graphical representation of the radial and tangential pressure

As we mentioned above, the model is physically acceptable for values of compactness \( u <0.316022\), this allows having results for the case of massive stars with small radius. So we first take the pulsar J1614-2230 since it has radius 13km and mass \(1.97 M_\odot \) [48], then \(u=0.2237\). The model for this data is physically acceptable and stable for \(n\in (-0.7659883, -0.2677099)\) and for \(n\in (-0.5488255, -0.2677099)\) the speed of sound radial and tangential are monotonically decrescent. The interval for the central density is \(\rho _c \in [4.6529,5.0042] 10^{17}\,{\text {Kg}}/{\text {m}^3} \) and for the surface density \(\rho _b\in [3.7955,3.9545] 10^{17}\,{\text {kg}}/{\text {m}^3} \). While for the pulsar \(\hbox {J}0348+0432\), \(u=0.2283\) since this has mass 2.01 and approximate radius of \(13\,\text {km}\) [49]. Once again the model admits two physically acceptable intervals, for \(n\in ( -0.7661832,\) \(-0.5027961)\) the speed of sound is monotonous decreasing in a region of the interio, and for \(n\in [-0.5027961,\) \(-0.2777563)\) the speed of sound is monotonous decreasing in all the interior. And the intervals for the central density and surface density are \(\rho _c \in [4.7582, 5.1237]\) \(10^{17}\,{\text {Kg}}/{\text {m}^3}\) and \(\rho _b\in [3.8634, 4.0266 ]\) \(10^{17}\,{\text {Kg}}/{\text {m}^3} \) respectively. The density for this case is slightly higher than the previous case as a result of the mass being slightly bigger. On the other hand, the density values obtained from the models, in both cases are higher than the nuclear densities which are consistent with what is expected for this type of compact objects.

6 Conclusions

We have shown, by construction of a model, that the effect of the anisotropic pressures is important when we consider models that represent compact stars. The absence of the anisotropy in the pressures will lead to solutions which are not physically acceptable meanwhile the anisotropy allow models that are potentially stables, this shows the relevance of the presence of anisotropic pressures. The model constructed not only shows the impact of the anisotropic pressure but can be applied to compact objects. In a complementary way it have been shown, for a specific value of compactness , that the orders of magnitude of the density are characteristic of compact objects. The proposal gives rise to some interesting questions, such as: (a) Is the model stable with respect to radial oscillations or some other disturbance? (b) Is the characteristic behavior of the current model or does it happen with other models?. (c) Which are the conditions that must satisfy the anisotropy function, so that a solution with a perfect fluid, that is not physically acceptable, can be generalized in a physically acceptable anisotropic model?, (d) Is it possible that the effect of the anisotropy allows to generate physically acceptable models from singular solutions with perfect fluid? (e) Is there an analog for charged objects?. Questions that can be discussed in future works.