1 Introduction

The stellar structure topic has been developed over many years either in Newtonian gravity or later in General Relativity (GR) since the firstly obtained exterior/interior solution of a spherically symmetric object [1, 2]. Motivated by the claim that pressure at core of the compact star model could have anisotropic structure where the density exceeds the nuclear density \(\sim 10^{15}\) \(\hbox {g/cm}^{3}\), many models have been developed imposing the anisotropic pressure concept (assuming radial and tangential pressures are different) to derive realistic stellar models within the GR context [3] (see also [4,5,6,7,8,9,10,11,12,13,14,15]) and in modified gravity as well [16,17,18,19,20,21,22,23,24,25,26]. Possible sources of anisotropy of ultra-compact stars could be due to solidification [27], superfluidity [28], strong magnetic fields [29], hyperons [30], pion-condesation [31] and strong interactions [32]. Local anisotropy and its consequences on the stability and the gravitational collapse of self-gravitating systems has been investigated by Herrera and Santos [33] (see also [34,35,36,37]).

The GR theory has been proven to be a successful theory of gravity on solar system scales (spacetime curvature is weak) by many observational tests, c.f. [38], and also on black hole scales (spacetime curvature is extremely strong) using black hole shadows observations by Event Horizon Telescope [39] not to mention the perfect predictions of the gravitational waves due to binary black holes merging [40,41,42]. On the cosmological scales, however, the GR does not provide answers for explaining the late accelerated expansion [43,44,45,46]. Even in presence of a cosmological constant \(\varLambda \), the discrepancy of the current Hubble parameter \(H_0\) value, between early universe observations by Planck satellite and late universe measurements by distance ladder or strong lensing, may point out the need to modify the GR theory [47], see also [48,49,50].

Many efforts have been done to generalize GR theory by using general function in Einstein–Hilbert action instead of the Ricci invariant, e.g. f(R), f(G), f(T) and mimetic gravity [48, 49, 51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71]. In fact, these modified theories kept the fundamental assumption that the covariant divergence of the energy-momentum vanishes, i.e. \({\mathcal {T}}^{\alpha }{_{\beta ; \alpha }}=0\) where the semicolon denotes the Levi–Civita covariant derivative. On the contrary, Rastall attempted to modify GR by dropping this assumption replacing it by setting \({\mathcal {T}}^{\alpha }{_{\beta ; \alpha }}=a_{\beta }\) where \(a_{\beta }\) vanishes in flat spacetime (vacuum) and recovers GR, otherwise it does not [72, 73]. Rastall showed that \(a_{\beta } \propto \partial _\beta {\mathcal {R}}\) is a reasonable choice which reflects the non-minimal coupling between matter and geometry. Interestingly, some cosmological models have been constructed using RT [74,75,76] as well as black hole solutions [77,78,79,80,81]. Moreover, shadows of rotating black holes have been investigated within RT by Kumar et al. [82] and Heydarzade and Darabi [77]. Furthermore, the effects of the non-minimal coupling between matter and geometry on thermodynamics of black holes in RT has been investigated in comparison with the GR theory [79, 83,84,85].

Recently, Vissar claimed that RT is completely equivalent to GR [86]. On the contrary, Darabi et al. investigated Visser’s claim but they concluded that Visser misinterpreted the matter-geometry coupling term which led him to wrong conclusion [87]. In addition, they showed that by applying Visser’s approach to f(R) theory one may conclude that it is equivalent to GR as well which is not true. Different studies have proven that RT is not equivalent to GR [88,89,90,91]. Visser’s conclusion is correct when Ricci scalar vanishes for black holes in general, otherwise the claim is incorrect and both theories are not equivalent. One of the good examples which may reveal the contribution of the matter-geometry coupling in RT in contrast to GR is the stellar models when the presence of matter plays a crucial role. It is the aim of the present study to derive a anisotropic static spherically symmetric interior solution using RT and confront it with pulsars observations.

The arrangement of this study is as follows: In Sect. 2 we briefly review the main assumptions and features of the non-conservative theory of Rastall’s gravity. In Sect. 3, we apply Rastall’s field equations to a spherically symmetrical object in presence of anisotropic matter source. The system consists of three non-linear differential equations in five unknown functions (two metric potentials in addition to the energy-density, radial and tangential pressures). Therefore, two constraints have been imposed to close the system without using equation of state (EoS): We assumed a specific form of one of the metric potential, \(g_{rr}\) as usually done in interior solutions, additionally we made the metric potential \(g_{tt}\) contribution to the anisotropy to vanish. Consequently, we derive the analytic form of energy-density, radial, and tangential pressures which satisfy Rastall field equations. In Sect. 4, we list the necessary and sufficient physical conditions that any stellar model must fulfill to be compatible with a realistic compact star. In Sect. 5, we investigated the viability of the obtained solution with the conditions listed in Sect. 4. In Sect. 6, we matched our model with the exterior vacuum solution (Schwarzschild solution) fixing the model parameters and constants. The pulsar \(\textit{Her X-1 }\), with mass \(M= 0.85 \pm 0.15\, M_\odot ,\) and radius \(R= 8.1 \pm 0.41\) km [92] is used to determine the constants of the model. In Sect. 7, we investigated the stability of the model using a modified version of Tolman–Oppenheimer–Volkoff (TOV) equation of hydrostatic equilibrium and the adiabatic indices. In Sect. 8 we use other observational mass-radius constraints of twenty pulsars’ data to test the viability of the model. Also we plot the mass-radius profile of the model for different surface densities compatible with neutron core pulsars to show the maximum masses allowed by the model. Finally, we summarize and conclude in Sect. 9.

2 Rastall gravitational theory

In Riemann geometry, by making use of the contracted Bianchi Identity on one hand and the minimal coupling procedure on the other hand,

$$\begin{aligned} {\mathcal {G}}_{\alpha \beta ;\alpha }= ({\mathcal {R}}_{\alpha \beta }-\frac{1}{2}g_{\alpha \beta }{\mathcal {R}})_{;\alpha }\equiv 0, \qquad \qquad {\mathcal {T}}_{\alpha \beta ;\alpha }=0, \end{aligned}$$
(1)

this led Einstein to formulate the consistent field equations of GR

$$\begin{aligned} {\mathcal {G}}_{\alpha \beta }=\chi {\mathcal {T}}_{\alpha \beta }, \end{aligned}$$
(2)

where \(\chi =8\pi G_N/c^4\) where \(G_N\) is the Newtonian gravitational constant and c is the speed of light, \({\mathcal {G}}_{\alpha \beta }\) denotes Einstein tensor, \({\mathcal {R}}_{\alpha \beta }\) denotes Ricci tensor and \({\mathcal {R}}=g^{\alpha \beta }{\mathcal {R}}_{\alpha \beta }\) denotes Ricci invariant. Rastall, however, dropped the minimal coupling procedure assuming non-divergence-free energy-momentum in curved spacetime [72, 73]

$$\begin{aligned} {\mathcal {T}}^\alpha {}_{\beta ;\alpha }\ne 0, \qquad {\mathcal {T}}^\alpha {}_{\beta ;\alpha }=a_{\beta }={\tilde{\epsilon }}\, \partial _{\beta } {\mathcal {R}}, \end{aligned}$$
(3)

where the constant of proportionality \({\tilde{\epsilon }}\) measures how much the conservation law is locally violated. According to this assumption Rastall obtained a consistent set of field equations

$$\begin{aligned} {\mathcal {G}}_{\alpha \beta }={\mathcal {R}}_{\alpha \beta }-\frac{1}{2}g_{\alpha \beta }{\mathcal {R}} =\chi ({\mathcal {T}}_{\alpha \beta }-{\tilde{\epsilon }} g_{\alpha \beta }{\mathcal {R}}). \end{aligned}$$
(4)

Obviously Rastall gravity reflects non-minimal coupling features of matter and geometry whereas Einstein’s field equations are recovered when the spacetime is flat. Alternatively, Eq. (4) can be rewritten as

$$\begin{aligned} {\mathcal {R}}_{\alpha \beta }-\left( \frac{1}{2}-\chi {\tilde{\epsilon }}\right) g_{\alpha \beta }{\mathcal {R}}=\chi {\mathcal {T}}_{\alpha \beta }. \end{aligned}$$
(5)

Contracting the above equation gives

$$\begin{aligned} (1-4\chi {\tilde{\epsilon }}){\mathcal {R}}=-\chi {\mathcal {T}}, \end{aligned}$$
(6)

where \({\mathcal {T}}=g^{\alpha \beta }{\mathcal {T}}_{\alpha \beta }\) is the trace of the energy-momentum tensor. Thus the field equations of RT read

$$\begin{aligned} {\mathcal {G}}_{\alpha \beta }=\chi \widetilde{{\mathcal {T}}}_{\alpha \beta }. \end{aligned}$$
(7)

where

$$\begin{aligned} \widetilde{{\mathcal {T}}}_{\alpha \beta }={\mathcal {T}}_{\alpha \beta }+\frac{\chi {\tilde{\epsilon }}}{1-4\chi {\tilde{\epsilon }}}g_{\alpha \beta }{\mathcal {T}}, \qquad 1-4\chi {\tilde{\epsilon }}\ne 0. \end{aligned}$$
(8)

It proves convenient to use a dimensionless Rastall’s parameter \(\epsilon = {\tilde{\epsilon }} \chi \), c.f. [93]. Then, Eq. (5) becomes

$$\begin{aligned} {\mathcal {R}}_{\alpha \beta }-\left( \frac{1}{2}-\epsilon \right) { g}_{\alpha \beta }{\mathcal {R}}=\chi {\mathcal {T}}_{\alpha \beta }, \end{aligned}$$
(9)

and the tensor \(\widetilde{{\mathcal {T}}}_{\alpha \beta }\) in Eq. (7) reads

$$\begin{aligned} \widetilde{{\mathcal {T}}}_{\alpha \beta }= {\mathcal {T}}_{\alpha \beta }+\frac{\epsilon }{1-4\epsilon } g_{\alpha \beta } {\mathcal {T}}, \qquad \epsilon \ne \frac{1}{4}. \end{aligned}$$
(10)

For \(\epsilon =0\) case, the conservation law is restored and the GR version of gravity is recovered. In this sense, RT generalizes Einstein’s one by assuming a local violation of conservation law in curved spacetime due to non-minimal coupling between matter and geometry. Otherwise, flat spacetime, both theories are equivalent. Therefore, one of the important applications, which differentiate both theories, is stellar structure models when presence of the matter sector plays a crucial role in interior solutions.

3 Spherically symmetric interior solution

Providing that the static spherically symmetrical spacetime is given by the following metricFootnote 1

$$\begin{aligned} ds^2=-F(r)dt^2+G(r)\,dr^2+r^2(d\theta ^2+\sin ^2{\theta }\, d\phi ^2)\,,\nonumber \\ \end{aligned}$$
(11)

where F(r) and G(r) are unknown functions. For the spacetime metric (11), we obtain the non-vanishing components of Levi–Civita connection

$$\begin{aligned}&{\varGamma _{tt}}^r=\frac{F'}{2G}, \qquad {\varGamma _{tr}}^t=\frac{F'}{2F} , \qquad {\varGamma _{rr}}^r=\frac{G'}{2G} ,\nonumber \\&{\varGamma _{r\theta }}^\theta ={\varGamma _{r\phi }}^\phi =\frac{1}{r} ,\quad {\varGamma _{\theta \theta }}^r=-\frac{r}{G} , \qquad {\varGamma _{\theta \phi }}^\phi =\cot \theta ,\nonumber \\&{\varGamma _{\phi \phi }}^r=-\frac{r \sin ^2\theta }{G},\quad {\varGamma _{\phi \phi }}^\theta =-\sin \theta \, \cos \theta , \end{aligned}$$
(12)

where prime (double prime) denotes first (second) derivative with respect to the radial coordinate. We write the Ricci invariant

$$\begin{aligned}&{\mathcal {R}}(r)\nonumber \\&\quad ={-2F''G F r^2+F'^2 G r^2+r F F' (r G'-4G)+4 F^2 [r G' + G(G-1)] \over 2F^2 G^2 r^2}\,.\nonumber \\ \end{aligned}$$
(13)

We assume the energy-momentum tensor for a anisotropic fluid with spherical symmetry, i.e.

$$\begin{aligned} {\mathcal {T}}{^\alpha }{_\beta }=(p_{t}+\rho )u{^\alpha }u{_\beta }+p_{t} \delta ^\alpha _\beta + (p_{r}-p_{t})\zeta {^\alpha }\zeta {_\beta }, \end{aligned}$$
(14)

where \(\rho =\rho (r)\) is the fluid energy density, \(p_{r}=p_{r}(r)\) its radial pressure (in the direction the time-like four-velocity \(u_\alpha \)), \(p_{t}=p_{t}(r)\) its tangential pressure (perpendicular to \(u_\alpha \)) and \(\zeta {^\alpha }\) is the unit space-like vector in the radial direction. Then, the energy-momentum tensor takes the diagonal form \({\mathcal {T}}{^\alpha }{_\beta }=diag(-\rho ,\,p_{r},\,p_{t},\,p_{t})\).

Applying Rastall’s field equations (7) to the spacetime (11) where the matter sector is as given by (14) we obtain, respectively, the components \(t\,t\), \(r\,r\) and \(\theta \,\theta \) (\(= \phi \,\phi \)) as follows:

$$\begin{aligned} \rho= & {} {r G' +G(G-1) \over G^2 r^2}-{\epsilon \over 1-4\epsilon }(\rho -p_r-2p_t)\,,\nonumber \\ p_r= & {} {F' r- F(G-1) \over F G r^2}+{\epsilon \over 1-4\epsilon }(\rho -p_r-2p_t)\,,\nonumber \\ p_t= & {} {F[2G(F''r+F')-G' F' r]-2 G' F^2-F'^2 G r \over 4 F^2 G^2 r}\nonumber \\&+{\epsilon \over 1-4\epsilon }(\rho -p_r-2p_t)\,. \end{aligned}$$
(15)

Additionally, we define the anisotropy of the system (15) using the parameter

$$\begin{aligned} \varDelta (r)= & {} p_t-p_r ={2F'' G F r^2-F'^2 G r^2 - r F F' (r G'+2 G)-2 F^2 [r G' -2 G (G-1)] \over 4 F^2 G^2 r^2}\,. \end{aligned}$$
(16)

We note that the Rastall parameter quantitatively contributes in the radial and the tangential pressures by equal amount, i.e. Rastall parameter has no contribution in the anisotropy parameter, and this conclusion is valid for any spherically symmetric interior solution. For the \(\epsilon =0\) case, the differential equations (15) coincide with Einstein field equations of an interior spherically symmetrical spacetime [94, 95]. The system (15) consists of three independent non-linear differential equations in five unknowns G, F, \(\rho \), \(p_r\) and \(p_t\). Therefore, two conditions need to be imposed to close the above system. We follow the ansatz given in [96] (also used in [95]). First, we assume the metric potential G to have the form

$$\begin{aligned} G(r)=\frac{1}{\left( 1-\frac{a_2^2 r^2}{R^2}\right) ^4}\,, \end{aligned}$$
(17)

with \(a_2\) is a dimensionless constant to be determined by boundary condition and R is the radius at the star boundary. We note that the above ansatz is regular everywhere inside the star, i.e. \(0\le r\le R\), where \(|a_2|<1\). Substituting (17) in the anisotropy parameter (16), we get

$$\begin{aligned} \varDelta (r)={a_2^4 r^2 (6R^4-8R^2 a_2^2 r^2+3 a_2^4 r^4)\over R^8} +{{(R^2-a_2^2 r^2)^3} [r (2F F'' - F'^2) (R^2-a_2^2 r^2)-2F F' (R^2+3a_2^2 r^2)]\over 4 r F^2 R^8}\,.\nonumber \\ \end{aligned}$$
(18)

Now, we impose the second condition by assuming that the component \(g_{tt}\) has no contribution on the anisotropy parameter, i.e.

$$\begin{aligned} \varDelta (r)={a_2^4 r^2 (6R^4-8R^2 a_2^2 r^2+3 a_2^4 r^4)\over R^8}\,. \end{aligned}$$
(19)

This choice clearly gives no anisotropy at the center, \(r=0\), which is physically a reasonable feature [96], see the physical conditions in Sect. 4. Using Eqs. (18) and (19) and by solving for the metric potential F, we obtain:

$$\begin{aligned} F(r)={[a_0 R^2+2 a_1 a_2^2 (R^2-a_2^2 r^2)]^2 \over 8 a_2^4 (R^2-a_2^2 r^2)^2}\,, \end{aligned}$$
(20)

where the constants of integration \(a_0\) and \(a_1\) are dimensionless to be fixed by matching conditions. Up to this step the obtained results are the same as given by [96]. However, the matching conditions with the exterior solution give the set of constants {\(a_0\), \(a_1\), \(a_2\)} in terms of Rastall parameter \(\epsilon \). Therefore, any deviation from the GR in the following results should be related to the assumed matter-geometry coupling in Rastall field equations (15), i.e. Rastall parameter \(\epsilon \).

Substituting the metric potentials (17) and (20) into the system (15), we get the energy-density, radial and tangential pressures in the form

$$\begin{aligned} \rho&= \frac{12 a_2^2}{R^8[2a_1 a_2^2 (a_2^2 r^2-R^2) -a_0 R^2]}\Bigg \{ {\frac{3a_1 a_2^{10}}{2} (2\epsilon -1)}r^8 \nonumber \\&\quad - \frac{a_2^6}{2}{\left[ \frac{a_1 a_2^2}{3}(74\epsilon -37)+\frac{a_0}{2}(2\epsilon -3)\right] }R^2 r^6 \nonumber \\&\quad +\frac{a_2^4}{3}{\left[ a_1 a_2^2(58\epsilon -29)+a_0 (5\epsilon -7)\right] }R^4 r^4 \nonumber \\&\quad -2 a_2^2{\left[ \frac{7a_1 a_2^2}{2} (2\epsilon -1)+\frac{a_0}{4}(4\epsilon -5)\right] }R^6 r^2 \nonumber \\&\quad +{\left[ (4a_1 a_2^2+a_0)\epsilon -(2a_1 a_2^2+a_0)\right] }R^8 \Bigg \}\,, \nonumber \\ p_r&=\frac{12 a_2^2}{R^8[2a_1 a_2^2 (R^2-a_2^2 r^2)+ a_0 R^2]}\Bigg \{ {\frac{a_1 a_2^{10}}{6} (18\epsilon -1)}r^8 \nonumber \\&\quad - \frac{a_2^6}{2}{\left[ \frac{a_1 a_2^2}{3}(74\epsilon -5)+\frac{a_0}{2}(2\epsilon +1)\right] }R^2 r^6 \nonumber \\&\quad +\frac{a_2^4}{3}{\left[ a_1 a_2^2(58\epsilon -5)+a_0 (5\epsilon +2)\right] }R^4 r^4 \nonumber \\&\quad -2 a_2^2{\left[ \frac{a_1 a_2^2}{6} (42\epsilon -5)+\frac{a_0}{4}(4\epsilon +1)\right] }R^6 r^2 \nonumber \\&\quad +{\left[ (4a_1 a_2^2+a_0)\epsilon -\frac{2}{3}a_1 a_2^2\right] }R^8 \Bigg \}\,, \nonumber \\ p_t&=\frac{12 a_2^2}{R^8[2a_1 a_2^2 (R^2-a_2^2 r^2)+ a_0 R^2]}\Bigg \{ {\frac{a_1 a_2^{10}}{3} (9\epsilon -2)}r^8 \nonumber \\&\quad - \frac{a_2^6}{2}{\left[ \frac{2a_1 a_2^2}{3}(74\epsilon -8)+a_0\epsilon \right] }R^2 r^6 \nonumber \\&\quad +\frac{a_2^4}{3}{\left[ a_1 a_2^2(58\epsilon -12)+5 a_0 \epsilon \right] }R^4 r^4 \nonumber \\&\quad -2 a_2^2{\left[ \frac{a_1 a_2^2}{3} (42\epsilon -4)+a_0\epsilon \right] }R^6 r^2 \nonumber \\&\quad +{\left[ (4a_1 a_2^2+a_0)\epsilon -\frac{2}{3}a_1 a_2^2\right] }R^8 \Bigg \}\,, \end{aligned}$$
(21)

Equation (21) coincide with the GR version when Rastall parameter \(\epsilon \) vanishes [94]. It is to be mentioned that the anisotropic force, \(F_{a}=\frac{2\varDelta }{r}\), becomes attractive if \(p_t-p_r<0\) and repulsive if \(p_t-p_r>0\). The mass contained within a radius r of the sphere is defined as

$$\begin{aligned} M(r)=4\pi \int _0^r \rho (\zeta ) \zeta ^2 d\zeta \,. \end{aligned}$$
(22)

Using the energy-density as defined in Eqs. (21) and the above equation (22), we get

$$\begin{aligned} M(r)&=\frac{-3\pi }{a_1^4 a_2^{10} R^8\aleph }\Bigg \{\frac{\sqrt{2}a_0 R^9 \epsilon }{2}(a_0+2a_1 a_2^2)\tanh ^{-1}\left( \frac{\sqrt{2}a_1 a_2^2 r}{R \aleph }\right) \nonumber \\&\quad +a_2^2 \aleph r \left[ \frac{256 a_1^4 a_2^{10} r^2}{3} (2\epsilon -1) \left( 2R^2-a_2^2 r^2\right) \left( 2R^4 \right. \right. \nonumber \\&\quad \left. +a_2^4 r^4-2a_2^2 R^2 r^2\right) +a_0 R^2 \epsilon \left( a_0^3 R^6+\frac{2 r^2 a_1 a_2^4}{8} (4 a_1^2 a_2^4\right. \nonumber \\&\quad -2 a_1 a_2^2 a_0+a_0^2) R^4+\frac{4 a_1^2 a_2^8 r^4}{5} (a_0 -4 a_1 a_2^2) R^2\nonumber \\&\quad \left. \left. +\frac{8a_1^3 a_2^{12} r^6 }{7} \right) \right] \Bigg \},\qquad \end{aligned}$$
(23)

where \(\aleph =\sqrt{(a_0+2a_1a_2^2)a_1}\). It proves convenient to use the compactness parameter [97, 98] of a spherically symmetric source with radius r,

$$\begin{aligned}&u(r)=\frac{2M(r)}{r}, \end{aligned}$$
(24)

to study the stability of compact objects. Similarly we use the gravitational red-shift parameter Z which is related to the metric potential as

$$\begin{aligned} 1+Z=\frac{1}{\sqrt{-g_{tt}}}. \end{aligned}$$
(25)

These parameters will be used later in Sec 6. In the next section, however, we are going to discuss the physical requirements to derive viable stellar structures in order to test the viability of the obtained model.

4 Physical conditions for a stellar model

For a stellar model to be physically well behaved, it needs to satisfy the following conditions:

(i) For the geometric sector, the metric potentials F and G should be free from coordinate and physical singularities within the interior region of the star \(0\le r\le R\), where the center (boundary) is at \(r=0\) (\(r=R\)) respectively.

(ii) The metric potentials of the interior solution and the exteriorFootnote 2 should match smoothly at the boundary.

(iii) For the matter sector, the fluid density, radial and the tangential pressures should be free from coordinate or physical singularities within the interior region of the star. In addition, they should be maximum at the center of the star and monotonically decrease towards the boundary of the star. i.e.

  1. a.

    \(\rho (r=0)>0\), \(\rho '(r=0)=0\), \(\rho ''(r=0)<0\) and \(\rho '(0< r \le R)< 0\),

  2. b.

    \(p_r(r=0)>0\), \(p_r'(r=0)=0\), \(p_r''(r=0)<0\) and \(p_r'(0< r \le R)< 0\),

  3. c.

    \(p_t(r=0)>0\), \(p_t'(r=0)=0\), \(p_t''(r=0)<0\) and \(p_t'(0< r \le R)< 0\).

(iv) At the center of the star (\(r=0\)), the anisotropy parameter \(\varDelta \) should vanish, i.e. \(p_r(r=0)=p_t(r=0)\), and increasing toward the boundary, i.e. \(\varDelta '(0 \le r\le R)>0\).

(v) At the boundary of the star (\(r=R\)), the radial pressure should vanish, i.e. \(p_r(r=R)=0\). However, the tangential pressure at the boundary should not necessarily vanish.

(vi) Within the star (\(0< r < R\)), the density, radial and tangential pressures should be positive, i.e. \(\rho (0< r < R)>0\), \(p_r(0< r < R)>0\) and \(p_t(0< r < R)>0\).

(vii) The fluid density, radial and tangential pressures should fulfill the following energy conditions:

  1. a.

    Null energy condition (NEC): \(\rho c^2+ p_t > 0\), \(\rho > 0\),

  2. b.

    Weak energy condition (WEC): \(\rho c^2+p_r > 0\), \(\rho > 0\),

  3. c.

    Dominant energy conditions (DEC): \(\rho c^2 \ge |p_r|\) and \(\rho c^2\ge |p_t|\),

  4. d.

    Strong energy condition (SEC): \(\rho c^2+p_r > 0\), \(\rho c^2+p_t > 0\), \(\rho c^2-p_r-2p_t > 0\).

(viii) The causality condition should be satisfied, that is the speed of sound should be smaller than unity everywhere inside the star and monotonically decrease toward the boundary, i.e. for the radial velocity \(0\le v_r/c=\frac{1}{c}\sqrt{\frac{dp_r}{d\rho }}\le 1\) and \(v'_r{^2}<0\), and for the tangential velocity \(0\le v_t/c=\frac{1}{c}\sqrt{\frac{dp_t}{d\rho }}\le 1\) and \(v'_t{^2}<0\).

(ix) The stability condition should be satisfied, i.e. \(-1< (v_t^2-v_r^2)/c^2 < 0\) within the star [99].

(x) The gravitational red-shift should be finite and positive everywhere inside the star and decreases monotonically toward the boundary, i.e. \(Z>0\) and \(Z'<0\).

(xi) The adiabatic index stability condition for anisotropic star should be fulfilled, i.e. the adiabatic index \(\varGamma > \gamma \) where \(\gamma =4/3\) is the adiabatic index corresponds to the isotropic case.

We note that the stellar model which fulfills the above mentioned conditions is physically viable and well behaved. In the following sections we are going to examine the model at hand with these conditions investigating possible roles of Rastall parameter.

5 Physical properties of the model

We test the model showing that the metric potentials (17) and (20), and the solution (21) are free from physical or geometric singularities. Then we derive some physical quantities which will be used later in Sect. 6 to examine the viability of the present model. In addition, we use the matching conditions at the boundary surface of the star to set the constraining equations on the model parameters {\(\epsilon , a_0, a_1, a_2\)}.

5.1 Non singular model

From Eqs. (17) and (20) one finds that the metric potentials at the center read

$$\begin{aligned} F(r=0)={(a_0+2a_1 a_2^2)^2 \over 16 a_2^4}\quad \hbox {and}\quad G(r=0)=1. \end{aligned}$$
(26)

This ensures that the gravitational potentials are finite at the center of the star. Moreover, the derivatives of these potentials are finite at the center, i.e. \(F'(r=0)=G'(r=0)=0\). Equation (26) ensures that the metric is regular at the center. This satisfies condition (i) in Sect. 4.

From Eqs. (21) one finds that the density, radial and tangential pressures at the center are

$$\begin{aligned}&\rho (r=0)={-12 a_2^2 [a_0(\epsilon -1)+2a_1 a_2^2(2\epsilon -1)] \over R^2(a_0+2a_1 a_2^2)}\,,\nonumber \\&p_{r}(r=0)=p_{t}(r=0)={12 a_2^2 [a_0 \epsilon +\frac{2}{3}a_1 a_2^2 (6\epsilon -1)] \over R^2(a_0+2a_1 a_2^2)}. \end{aligned}$$
(27)

These ensure that the anisotropy parameter has a vanishing value at the center as stated in condition (iv) on Sect. 4. The density and the pressures should be positive at the center which sets two constraints on the model parameters/constants. Additionally, the Zeldovich condition [100] states that the radial pressure must be less than or equal to the density at the center, i.e. \(\frac{p_r(0)}{\rho (0)}\le 1\), i.e.

$$\begin{aligned} {-3(a_0+4a_1 a_2^2)\epsilon +2a_1 a_2^2 \over 3(a_0+4a_1 a_2^2)\epsilon -3(a_0+2a_1 a2^2)}\le 1. \end{aligned}$$
(28)

Using Eqs. (21) we give the derivative of energy density, radial and tangential pressures, respectively, as follows

$$\begin{aligned} \rho '&=\frac{2r{a_2}^{4} }{{R}^{8} \left( a_0{R}^{2}+2\,a_1{a_2}^{2}{R}^{2}-2a_1{a_2}^{4}{r}^{2} \right) ^{2}}\nonumber \\&\quad \times \biggl \{ 216{r}^{8}{a_1}^{2}{a_2}^{12}\epsilon -108\,{r}^{8}{a_1}^{2}{a_2 }^{12}\nonumber \\&\quad +440{r}^{6}{ R}^{2}{a_1}^{2}{a_2}^{10}-880{r}^{6}{R}^{2}{a_1}^{2}{ a_2}^{10}\epsilon \nonumber \\&\quad -676\,{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8} +1352\,{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\epsilon \nonumber \\&\quad -168\,{r}^{6} {R}^{2}a_1\,{a_2}^{8}a_0\,\epsilon \nonumber \\&\quad +108\,{r}^{6}{R}^{2}a_1\,{a_2}^{8}a_0\nonumber \\&\quad +464\,{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6}-928\,{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6} \epsilon \nonumber \\&\quad + 520\,{r}^{4}{R}^{4}a_1\,{a_2}^{6}a_0\,\epsilon -332\,{r} ^{4}{R}^{4}a_1\,{a_2}^{6}a_0\nonumber \\&\quad -120\,{R}^{8}{a_2}^{4} {a_1}^{2}\nonumber \\&\quad +240\,{R}^{8}{a_2}^{4}{a_1}^{2}\epsilon -544\,x { R}^{6}{a_2}^{4}{r}^{2}a_0\,a_1\,\epsilon \nonumber \\&\quad +344\,{R}^{6}{a_2}^{4}{r}^{2}a_0\,a_1\nonumber \\&\quad -27\,{R}^{4}{a_2}^{4}{r}^{4} {a_0}^{2}+18\,{R}^{4}{a_2}^{4}{r}^{4}{a_0}^{2}\epsilon \nonumber \\&\quad - 120\,a_0\,{R}^{8}{a_2}^{2}a_1\nonumber \\&\quad +192\,a_0\,{R}^{8}{a_2}^{2}a_1\,\epsilon +56\,{a_0}^{2}{R}^{6}{a_2}^{2} {r}^{2}\nonumber \\&\quad -40\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}\epsilon -30\,{a_0}^{2}{R}^{8}\nonumber \\&\quad +24\,{a_0}^{2}{R}^{8}\epsilon \biggr \}\,, \end{aligned}$$
(29)
$$\begin{aligned} p'_r&=\frac{-2r{a_2}^{4}}{{R}^{8} \left( a_0\,{R}^{2}+2\,a_1\,{a_2}^{2}{R}^{2}-2\,a_1\,{a_2}^{4}{r}^{2} \right) ^{2}}\nonumber \\&\quad \times \biggl \{ 216\,{r}^{8}{a_1}^{2}{a_2}^{12}\epsilon -12\,{r}^{8}{a_1}^{2}a_2^{12}+56\,{r}^{6}{R }^{2}{a_1}^{2}{a_2}^{10}\nonumber \\&\quad -880\,{r}^{6}{R}^{2}{a_1}^{2}{a_2}^{10}\epsilon \nonumber \\&\quad +1352\,{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8} \epsilon -100\,{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\nonumber \\&\quad -168\,{r}^{6}{ R}^{2}a_1\,{a_2}^{8}a_0\,\epsilon -4\,{r}^{6}{R}^{2}a_1\,{a_2}^{8}a_0 \nonumber \\&\quad +80\,{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6}-928\,{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6}\epsilon \nonumber \\&\quad +520\, {r}^{4}{R}^{4}a_1\,{a_2}^{6}a_0\,\epsilon +4\,{r}^{4}{R} ^{4}a_1\,{a_2}^{6}a_0\nonumber \\&\quad +240\,{R}^{8}{a_2}^{4}{a_1}^{2}\epsilon \nonumber \\&\quad -24\,{R}^{8}{a_2}^{4}{a_1}^{2}-544\,{R}^{6}{ a_2}^{4}{r}^{2}a_0\,a_1\,\epsilon \nonumber \\&\quad +8\,{R}^{6}{a_2}^ {4}{r}^{2}a_0\,a_1\nonumber \\&\quad +9\,{R}^{4}{a_2}^{4}{r}^{4}{a_0} ^{2}+18\,{R}^{4}{a_2}^{4}{r}^{4}{a_0}^{2}\epsilon -8\,a_0\,{R}^{8}{a_2}^{2}a_1\nonumber \\&\quad +192\,a_0\,{R}^{8}{a_2}^{2}a_1\,\epsilon -16\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}\nonumber \\&\quad -40\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}\epsilon +6\,{a_0}^{2}{R} ^{8}\nonumber \\&\quad +24\,{a_0}^{2}{R}^{8}\epsilon \biggr \}\,, \end{aligned}$$
(30)
$$\begin{aligned} p'_t&=\frac{-4r{a_2}^{4}}{{R}^{8} \left( a_0{R}^{2}+2a_1{a_2}^{2}{R}^{2}-2a_1{a_2}^{4}{r}^{2} \right) ^{2}} \nonumber \\&\quad \times \biggl \{ 108{r }^{8}{a_1}^{2}{a_2}^{12}\epsilon -24{r}^{8}{a_1}^{2}{a_2}^{12}+96{r}^{6}{R}^{2}{a_1 }^{2}{a_2}^{10}\nonumber \\&\quad -440{r}^{6}{R}^{2}{a_1}^{2}{a_2}^{10} \epsilon -144 {r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\nonumber \\&\quad +676{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\epsilon -84{r}^{6}{R}^{2}a_1 {a_2}^{8}a_0\epsilon \nonumber \\&\quad +16{r}^{6}{R}^{2}a_1{a_2}^{8}a_0-464{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6} \epsilon \nonumber \\&\quad +96{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6}+260{r}^{4}{R }^{4}a_1{a_2}^{6}a_0\epsilon +12{a_0}^{2}{R}^{8}\epsilon \nonumber \\&\quad -48\,{r}^{4}{R}^{4}a_1\,{a_2}^{6}a_0-24\,{R}^{8}{a_2}^{4}{a_1}^{2 }+120\,{R}^{8}{a_2}^{4}{a_1}^{2}\epsilon \nonumber \\&\quad -272\,{R}^{6}{a_2}^{4}{r}^{2}a_0\,a_1\,\epsilon +48\,{R}^{6}{a_2}^{4}{ r}^{2}a_0\,a_1\nonumber \\&\quad +9\,{R}^{4}{a_2}^{4}{r}^{4}{a_0}^{2} \epsilon -16\,a_0\,{R}^{8}{a_2}^{2}a_1\nonumber \\&\quad +96\,a_0\,{R} ^{8}{a_2}^{2}a_1\,\epsilon \nonumber \\&\quad -20\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}\epsilon \biggr \}\,. \end{aligned}$$
(31)

We use Eqs. (29)–(31) to show that the gradients of the energy-density, radial and tangential pressures are negative later in Sect. 6.

The radial and tangential sound velocities are given

$$\begin{aligned} v_r^2&=\frac{dp_r}{d\rho }=- \biggl \{216\,{r}^{8 }{a_1}^{2}{a_2}^{12}\epsilon \nonumber \\&\quad -12\,{r}^{8}{a_1}^{2}{a_2}^{12}+56\,{r}^{6}{R}^{2}{a_1}^{2 }{a_2}^{10}\nonumber \\&\quad -880\,{r}^{6}{R}^{2}{a_1}^{2}{a_2}^{10} \epsilon +1352\,{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\epsilon \nonumber \\&\quad -100 \,{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\nonumber \\&\quad -168\,{r}^{6}{R}^{2}a_1\,{a_2}^{8}a_0\,\epsilon -4\,{r}^{6}{R}^{2}a_1\,{a_2}^{8}a_0 \nonumber \\&\quad +80\,{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6}- 928\,{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6}\epsilon \nonumber \\&\quad +520\,{r}^{4}{R }^{4}a_1\,{a_2}^{6}a_0\,\epsilon +4\,{r}^{4}{R}^{4}a_1\,{a_2}^{6}a_0\nonumber \\&\quad +240\,{R}^{8}{a_2}^{4}{a_1}^{2} \epsilon -24\,{R}^{8}{a_2}^{4}{a_1}^{2}\nonumber \\&\quad -544\,{R}^{6}{a_2 }^{4}{r}^{2}a_0\,a_1\,\epsilon \nonumber \\&\quad +8\,{R}^{6}{a_2}^{4}{r}^{ 2}a_0\,a_1+9\,{R}^{4}{a_2}^{4}{r}^{4}{a_0}^{2}\nonumber \\&\quad +18 \,{R}^{4}{a_2}^{4}{r}^{4}{a_0}^{2}\epsilon \nonumber \\&\quad -8\,a_0\,{R}^ {8}{a_2}^{2}a_1+192\,a_0\,{R}^{8}{a_2}^{2}a_1 \,\epsilon -16\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}\nonumber \\&\quad -40\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}\epsilon +6\,{a_0}^{2}{R}^{8}\nonumber \\&\quad +24 \,{a_0}^{2}{R}^{8}\epsilon \biggr \} \biggl \{216\,{r}^{8}{a_1}^{2}{a_2}^{12} \epsilon \nonumber \\&\quad -108\,{r}^{8}{a_1}^{2}{a_2}^{12}+440\,{r}^{6}{R}^{2}{a_1}^{2}{a_2}^{10}\nonumber \\&\quad -880\,{r}^{6} {R}^{2}{a_1}^{2}{a_2}^{10}\epsilon -676\,{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\nonumber \\&\quad +1352\,{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8 }\epsilon \nonumber \\&\quad -168\,{r}^{6}{R}^{2}a_1\,{a_2}^{8}a_0\, \epsilon \nonumber \\&\quad +108\,{r}^{6}{R}^{2}a_1\,{a_2}^{8}a_0+464\,{r}^ {2}{R}^{6}{a_1}^{2}{a_2}^{6}\nonumber \\&\quad -928\,{r}^{2}{R}^{6}{a_1}^{ 2}{a_2}^{6}\epsilon \nonumber \\&\quad +520\,{r}^{4}{R}^{4}a_1\,{a_2}^{6}a_0\,\epsilon -332\,{r}^{4}{R}^{4}a_1\,{a_2}^{6}a_0\nonumber \\&\quad - 120\,{R}^{8}{a_2}^{4}{a_1}^{2}\nonumber \\&\quad +240\,{R}^{8}{a_2}^{4}{a_1}^{2}\epsilon -544\,{R}^{6}{a_2}^{4}{r}^{2}a_0\,a_1\,\epsilon \nonumber \\&\quad +344\,{R}^{6}{a_2}^{4}{r}^{2}a_0\,a_1-27\, {R}^{4}{a_2}^{4}{r}^{4}{a_0}^{2}\nonumber \\&\quad +18\,{R}^{4}{a_2}^{4}{r }^{4}{a_0}^{2}\epsilon -120\,a_0\,{R}^{8}{a_2}^{2}a_1\nonumber \\&\quad +192\,a_0\,{R}^{8}{a_2}^{2}a_1\,\epsilon +56\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}\nonumber \\&\quad -40\, {a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}\epsilon -30\,{a_0}^{2}{R}^{8}\nonumber \\&\quad +24\,{a_0}^{2}{R}^ {8}\epsilon \biggr \}^{-1}\,, \end{aligned}$$
(32)
$$\begin{aligned} v_t^2&=\frac{dp_t}{d\rho }=-2 \,\biggl \{108\,{r} ^{8}{a_1}^{2}{a_2}^{12}\epsilon -24\,{r}^{8}{a_1}^{2}{a_2}^{12}\nonumber \\&\quad +96\,{r}^{6}R^{2}{a_1} ^{2}{a_2}^{10}\nonumber \\&\quad -440\,{r}^{6}R^{2}{a_1}^{2}{a_2}^{10} \epsilon +676\,{r}^{4}R^{4}{a_1}^{2}{a_2}^{8}\epsilon \nonumber \\&\quad -144\, {r}^{4}R^{4}{a_1}^{2}{a_2}^{8}\nonumber \\&\quad -84\,{r}^{6}R^{2}a_1 \,{a_2}^{8}a_0\,\epsilon +16\,{r}^{6}R^{2}a_1\,{a_2}^{8}a_0\nonumber \\&\quad -464\,{r}^{2}R^{6}{a_1}^{2}{a_2}^{6} \epsilon \nonumber \\&\quad +96\,{r}^{2}R^{6}{a_1}^{2}{a_2}^{6}\nonumber \\&\quad +260\,{r}^{4}{R }^{4}a_1\,{a_2}^{6}a_0\,\epsilon -48\,{r}^{4}R^{4}a_1\,{a_2}^{6}a_0\nonumber \\&\quad -24\,R^{8}{a_2}^{4}{a_1}^{2 }+120\,R^{8}{a_2}^{4}{a_1}^{2}\epsilon \nonumber \\&\quad -272\,R^{6}{a_2}^{4}{r}^{2}a_0\,a_1\,\epsilon \nonumber \\&\quad +48\,R^{6}{a_2}^{4}{ r}^{2}a_0\,a_1+9\,R^{4}{a_2}^{4}{r}^{4}{a_0}^{2} \epsilon -16\,a_0\,R^{8}{a_2}^{2}a_1\nonumber \\&\quad +96\,a_0\,R ^{8}{a_2}^{2}a_1\,\epsilon \nonumber \\&\quad -20\,{a_0}^{2}R^{6}{a_2}^{2}{r}^{2}\epsilon +12\,{a_0}^{2}R^{8}\epsilon \biggr \}\biggl \{-108\,{r}^{8}{a_1}^{2}{a_2}^{12}\nonumber \\&\quad +216\,{r}^{8}{a_1}^{ 2}{a_2}^{12}\epsilon +440\,{r}^{6}R^{2}{a_1}^{2}{a_2}^ {10}\nonumber \\&\quad -880\,{r}^{6}R^{2}{a_1}^{2}{a_2}^{10}\epsilon -676\,{r} ^{4}R^{4}{a_1}^{2}{a_2}^{8}\nonumber \\&\quad +1352\,{r}^{4}R^{4}{a_1} ^{2}{a_2}^{8}\epsilon -168\,{r}^{6}R^{2}a_1\,{a_2}^{8} a_0\,\epsilon \nonumber \\&\quad +108\,{r}^{6}R^{2}a_1\,{a_2}^{8}a_0\nonumber \\&\quad +464\,{r}^{2}R^{6}{a_1}^{2}{a_2}^{6}-928\,{r}^{2}R^{6}{a_1}^{2}{a_2}^{6}\epsilon \nonumber \\&+520\,{r}^{4}R^{4}a_1\,{a_2}^{6}a_0\,\epsilon \nonumber \\&\quad -332\,{r}^{4}R^{4}a_1\,{a_2}^{6} a_0-120\,R^{8}{a_2}^{4}{a_1}^{2}\nonumber \\&\quad +240\,R^{8}{a_2}^{4}{a_1}^{2}\epsilon \nonumber \\&\quad -544\,R^{6}{a_2}^{4}{r}^{2}a_0 \,a_1\,\epsilon +344\,R^{6}{a_2}^{4}{r}^{2}a_0\,a_1\nonumber \\&\quad -27\,R^{4}{a_2}^{4}{r}^{4}{a_0}^{2}\nonumber \\&\quad +18\,R^{4}{a_2}^{4}{r}^{4}{a_0}^{2}\epsilon -120\,a_0\,R^{8}{a_2}^{ 2}a_1\nonumber \\&\quad +192\,a_0\,R^{8}{a_2}^{2}a_1\,\epsilon \nonumber \\&\quad +56\, {a_0}^{2}R^{6}{a_2}^{2}{r}^{2}-40\,{a_0}^{2}R^{6}{a_2}^{2}{r}^{2}\epsilon \nonumber \\&\quad -30\,{a_0}^{2}R^{8}+24\,{a_0}^{ 2}R^{8}\epsilon \biggr \}^{-1}\,. \end{aligned}$$
(33)

We use Eqs. (32) and (33) to show that the sound speeds satisfy the causality and the stability conditions later in Sect. 6.

5.2 Matching conditions

We note that the exterior spacetime of a static spherically symmetric star is the same for both GR and RT, since the exterior region is vacuum. Thus no reason to expect any solution rather the exterior Schwarzschild one for Rastall’s theory, that is

$$\begin{aligned} ds^2&= -\Big (1-\frac{2M}{r}\Big ) dt^2\nonumber \\&\quad +\Big (1-\frac{2M}{r}\Big )^{-1}dr^2+r^2(d\theta ^2+d\phi ^2), \end{aligned}$$
(34)

where M is the total mass \(r>2M\). We are going to match the interior spacetime metrics (17) and (20) and the exterior Schwarzschild spacetime metric (34) at the boundary of the star \(r =R\). Therefore, the continuity of the metric functions, as stated by condition (ii) in Sect. 4, across the boundary gives the conditions

$$\begin{aligned}&F(r=R)={[a_0-2a_1 a_2^2 (a^2-1)]^2 \over 12 a_2^4 (a_2^2-1)^2}=\left( 1-\frac{2M}{R}\right) ,\nonumber \\&G(r=R)=(a_2^2-1)^4=\left( 1-\frac{2M}{R}\right) . \end{aligned}$$
(35)

In addition, the radial pressure (21) approaches zero at the star boundary, \(p_{r|r=R}= 0\), which reads

$$\begin{aligned}&2a_1a_0^{10}-10a_1a_0^8+(20a_1+3a_0)a_0^6\nonumber \\&\quad -4(5a_1+2a_0)a_0^4+2(4a_1+3a_0)a_0^2 \nonumber \\&\quad -\left[ 36a_1a_2^{10}-148a_1a_2^8+2(116 a_1-3a_0)a_2^6\right. \nonumber \\&\quad \left. -4(42a_1-5a_0)a_2^4+24(2a_1-a_0)a_2^2-12a_0\right] \epsilon =0\,\nonumber \\ \end{aligned}$$
(36)

The above constraint ensures that condition (v) in Sect. 4 is fulfilled. From the above conditions, namely (35) and (36), we get the constraints on the set os constants \(\{a_0,~ a_1,~ a_2\}\) in terms of the start mass M, radius R in addition to the Rastall parameter \(\epsilon \). Using observational pulsars data, knowing the observed values of M and R, we obtain the corresponding numerical values for a particular choice of \(\epsilon \).

6 Astrophysical observational constraints

We convert back to physical standard units in order to correctly determine the numerical values of the model parameters. Using masses and radii of observed pulsars along with the physical conditions mentioned in the previous section, one can determine the constant parameters of the obtained model (21) and test its viability. We use the observational constraints of the particular pulsar Her X-1, whose mass \(M = 0.85\pm 0.15 M_\odot \) and radius \(R = 8.1\pm 0.41\) km

[101], where \(M_\odot \) (\(=1.989\times 10^{30}\) kg) denotes the solar mass. Then, the boundary conditions (35) and (36) are adopted to determine the dimensionless constants in terms of the Rastall parameter \(\epsilon \)

$$\begin{aligned}&a_0={2.564\, \epsilon - 0.4694 \over 4.542\, \epsilon -1.514},\, a_1=-6.192\, a_0 +1.661\, \text {and}\,\\&a_2=0.298. \end{aligned}$$

Noting that we select \(a_2<1\) which is required by the regularity condition of ansatz (17). Substituting the above expressions into Zeldovich condition (28), keeping in mind that the RT predictions are not expected to be far from GR ones (i.e. \(\epsilon \) should be small), we obtain the following constraints on Rastall parameter \(-1.880 \lesssim \epsilon \lesssim 0.259\).

Fig. 1
figure 1

Plots of the density, radial and tangential pressures given by (21) versus the radial coordinate r in km of the pulsar Her X-1 (\(M = 0.85\pm 0.15 M_\odot \), \(R = 8.1\pm 0.41\) km). We set \(\epsilon =-0.1\), \(a_0 \approx 0.369\), \(a_1\approx -0.622\) and \(a_2\approx 0.298\)

Fig. 2
figure 2

Plot of the anisotropy parameter (19), anisotropic force \(F_a=2\varDelta /r\). We note that the Rastall parameter has no contribution in the anisotropy, therefore GR and RT predicts same anisotropy in the case of spherical symmetry as discussed after (16). For \(\epsilon =0\) and \(\epsilon \ne 0\), the gradients of the density, tangential and radial pressures given by Eqs. (29)–(31) versus the radial coordinate r in km of the pulsar Her X-1

Next, we use the above expressions to plot some physical quantities for \(\epsilon =0\) (GR case) and \(\epsilon \ne 0\) (RT case) which enable us to test the model viability and investigate the role of Rastall parameter. We note that one should be careful for the choice of Rastall parameter in order to satisfy the physical conditions in Sect. 4 with a particular compact object. In agreement with Oliveira et al. [93] we confirm that the present model is physically stable whereas the Rastall parameter \(\epsilon \) is negativeFootnote 3. For the particular pulsar Her X-1, setting \(\epsilon =-0.1\), we determine the set of constants \(a_0 \approx 0.369\), \(a_1\approx -0.622\) and \(a_2\approx 0.298\), which clearly satisfies Zeldovich condition (28).

Fig. 3
figure 3

The radial and tangential sound speeds (30) versus the radial coordinate r in km for the pulsar Her X-1. The plots confirm that the model fulfill the causality and the stability conditions (viii) and (ix) in Sect. 4

Fig. 4
figure 4

The weak, null, strong and dominant energy conditions, using Eqs. (21), versus the radial coordinate r in km for the pulsar Her X-1. The plots show that the model fulfill the energy conditions (vii) in Sect. 4

In Fig. 1a, b, recalling condition (iii) in Sect. 4, we represent the behavior of energy-density, radial and tangential pressures for the pulsar Her X-1 from its center to the boundary surface. This shows that the density, radial and tangential pressures are positive as required for realistic stellar configuration with maximal finite values at the center decrease monotonically towards the surface. Also, as Fig. 1a shows, the surface density is above \(7\times 10^{14}\) \(\hbox {g/cm}^3\) while the central density is comparable to the nuclear density \(\sim 10^{15}\) \(\hbox {g/cm}^3\) which indicate that the pulsar Her X-1 may has no neutron core but quark-gluon one. This will be revisited in Sect. 8. In addition, Fig. 1b shows that the radial pressure at the surface is null in agreement with condition (v) in Sect. 4.

In Fig. 2a, recalling condition (iv) in Sect. 4, we show that the anisotropy parameter (19) is null at the center and increases monotonically toward the surface of the star. Also, it shows that the anisotropic force \(F_a=\frac{2\varDelta }{r}\) is positive reflecting the repulsive behaviour of the force as \(p_t-p_r>0\). Recalling Eq. (16) we verify that the Rastall parameter has no contribution to the anisotropy parameter so both GR (\(\epsilon =0\)) and RT (\(\epsilon \ne 0\)) cases coincide. However, this is not the case with other ingredients. For the GR (\(\epsilon =0\)) and RT (\(\epsilon \ne 0\)) cases, Fig. 2b, c respectively confirm that the gradients of energy-density, radial and tangential pressures, given by Eqs. (29)–(31), are negative everywhere inside the star as required by condition (iii) in Sect. 4.

Recalling the causality and stability conditions (viii) and (ix) in Sect. 4, in Fig. 3, for GR (\(\epsilon =0\)) and RT (\(\epsilon \ne 0\)) cases, we plot the radial and tangential sound speeds (30) where both have positive values less than one. This result confirms that the obtained stellar model is fulfilling the causality condition. In addition, we investigated the energy conditions as visualized in Fig. 4. The plots of Fig. 4a–d, for \(\epsilon \ne 0\), prove that the model satisfies the WEC, NEC, SEC and DEC since the graphs are always obtained in positive energy regions. This confirms the fulfillment of the energy conditions (vii) in Sect. 4.

In Fig. 5a, c, for \(\epsilon =0\) and \(\epsilon \ne 0\) cases, we plot the evolution of the radial and the tangential EoS parameters, i.e. \(w_r(r)=p_r/\rho \) and \(w_t(r)=p_t/\rho \), respectively, verses the radial distance from the center. The plots show that the EoS parameters slightly vary from maximum at the center with a monotonically decreasing behavior toward the surface whereas \(w_r\) drops to zero at the surface as expected. We note that the variation of the EoS parameters is more severe in RT than GR, which should be understood as an effect of the matter-geometry coupling. On the other hand, we remind that there are no EoS are preassumed in the model setup, Fig. 5b, d, however, prove that the EoS \(p(\rho )\) in both radial and tangential directions is in well fit with linear patterns, whereas the best fit are given by \(p_r=0.414\,\rho -27.6\) and \(p_t=0.223\, \rho -11.8\) for the pulsar Her X-1. Notably the slopes of the fitted lines \(dp_r/d\rho =0.414=v_r^2\) and \(dp_t/d\rho =0.223=v_t^2\) are consistent with the corresponding values of Table 2 for the pulsar under investigation.

Fig. 5
figure 5

a, c The behaviours of the EoS parameters, defined as \(w_r(r)=p_r/\rho \) and \(w_t(r)=p_t/\rho \), at different radial distances within the pulsar Her X-1 as predicted by RT and GR. We note that no EoS are imposed at any stage of the present work, while it is evidently that the result fit well with the linear behaviour whereas the best fit lines in b and d are given by \(p_r=0.414\,\rho -27.6\) and \(p_t=0.223\, \rho -11.8\) in RT case

The mass function given by Eq. (22) is plotted in Fig. 6a which shows that it is a monotonically increasing function of the radial coordinate whereas the mass at the center \(M(r=0) = 0\). The plot shows that theoretical M(r) curve of the pulsar Her X-1 according to RT is compatible with the observed values of the mass and the radius. In Fig. 6b we show the behavior of the compactness parameter of the pulsar. Interestingly the RT curve allows less size than the GR for same mass which may evidently reflects the role of the matter-geometry coupling to obtain slightly higher compactness. Also Fig. 6c shows the redshift of the pulsar is maximum at the center and decreases monotonically toward the surface. Notably the redshift at the surface is found to be \(Z_{R}\sim 0.204\) which is in an agreement with the upper bound constraints \(Z_{R}\le 2\) as given by Buchdahl [102], for anisotropic spheres see [103, 104] and for the upper bound on the surface redshift in presence of a cosmological constant see [105].

Fig. 6
figure 6

The mass function plot confirm that the model can predict the a of the pulsar Her X-1 in agreement with observational data. The plot shows that RT predicts compactness values higher than GR which reflects the role of the matter-geometry coupling to allow more compactness values. The redshift is finite everywhere within the pulsar and decreases toward the surface as stated by condition (x) in Sect. 4 and also predict a surface redshift consistent with the upper limit constraints as given by [105]

7 Stability of the model

In addition to the stability condition (ix) in Sect. 4 which has been shown to be verified we are going to discuss the stability of the obtained stellar model using two different techniques in the present section; that are the modified TOV equations and the adiabatic index.

7.1 Equilibrium analysis via Tolman–Oppenheimer–Volkoff equation

We assume hydrostatic equilibrium to be everywhere within the stable compact star. This configuration, then, can be described by the GR based TOV equation [106,107,108] which gives the following stability constraint

$$\begin{aligned} \frac{2(p_t-p_r)}{r}-\frac{M_g (\rho +p_r)\sqrt{F}}{r \sqrt{G}}-\frac{dp_r}{dr}=0, \end{aligned}$$
(37)

where \(M=M_g(r)\) is the gravitational mass within a radius r, which is defined by the Tolman–Whittaker mass formula

$$\begin{aligned} M_g(r)= & {} 4\pi {\int _0}^r\Big ({T_t}^t-{T_r}^r-{T_\theta }^\theta -{T_\phi }^\phi \Big )r^2\sqrt{FG}dr\nonumber \\= & {} \frac{r F' \sqrt{G}}{2 F \sqrt{F}}\,. \end{aligned}$$
(38)

Inserting Eq. (38) into (37), we get

$$\begin{aligned} \frac{2}{r}(p_t-p_r)-\frac{F'}{2 F}(\rho +p_r)-\frac{dp_r}{dr}=F_a+F_g+F_h=0\,,\nonumber \\ \end{aligned}$$
(39)

where \(F_g=-\frac{F'}{2 {F}}(\rho +p_r)\) and \(F_h=-\frac{dp_r}{dr}\) are the gravitational and the hydrostatic forces respectively, in addition to the anisotropic force \(F_a\). We note that the TOV equation should be modified in RT due to the non-minimal coupling constraint, \({\mathcal {T}}{^\alpha }{_{\beta ;\alpha }}=\epsilon \, \partial _{\beta } {\mathcal {R}}\), to include one more force \(F_R\) as following

$$\begin{aligned} F_a+F_g+F_h+F_R=0\,, \end{aligned}$$
(40)

where \(F_R=-\frac{\epsilon }{1-4\epsilon }\frac{d}{dr}(\rho -p_r-2p_t)\). These different forces, for GR (\(\epsilon =0\)) and RT (\(\epsilon \ne 0\)), are plotted in Fig. 7 using the pulsar \(\textit{Her X-1}\) data. For the RT case, the figure clearly shows that the pulsar is dominated by the negative gravitational force over the positive hydrostatics and anisotropic forces. Therefore, it holds the pulsar in a static equilibrium. In conclusion, we verify the stability of the model via TOV equation using the pulsar Her X-1 data.

Fig. 7
figure 7

Plots of the forces of TOV Eq. (39) in cases \(\epsilon =0\) and \(\epsilon =-0.1\) versus the radius r using the constants constrained from \(\textit{Her X-1}\). In the RT case the negative gravitational force is the dominant one over the hydrostatic and the anisotropic forces. This guarantees stable equilibrium configuration for the pulsar

7.2 Relativistic adiabatic indices

Another verification of the stable equilibrium configuration of a spherically symmetric object can be done via the adiabatic index, that is defined as the ratio of two specific heats and can be given as follows [109,110,111]

$$\begin{aligned} \varGamma =\frac{\rho +p_r}{p_r} v_r^2\,. \end{aligned}$$
(41)

For the general case of anisotropic spheroid fluid, it has been shown that the object is in a neutral equilibrium if its adiabatic index \(\varGamma =\gamma \) and in a stable equilibrium if \(\varGamma >\gamma \) [111], whereas

$$\begin{aligned} \gamma =\frac{4}{3}\left( 1+\frac{F_a}{2 |p'_r|}\right) _{max}\,. \end{aligned}$$
(42)

Clearly, for an isotropic fluid, the object is in a neutral equilibrium if the adiabatic index \(\varGamma =\frac{4}{3}\), while for \(\varGamma >\frac{4}{3}\) the object is in a stable equilibrium [112]. Using Eq. (42), we get

$$\begin{aligned} \gamma&=\frac{2}{3R^{8}}\biggl [\biggl (2R^{8} \biggl | \frac{r{a_2}^{4}}{{R}^{8} \left( a_0{R}^{2 }+2a_1{a_2}^{2}{R}^{2}-2a_1{a_2}^{4}{r}^{2 } \right) ^{2}} \nonumber \\&\quad \times \biggl \{ 216{r}^{8}{a_1}^{2}{a_2}^{12}\epsilon -12{r}^{8}{a_1}^{2}{a_2}^{12}\nonumber \\&\quad +56{r}^{6}{R}^{2}{a_1}^{2}{a_2}^{10}-880{r}^{6}{R}^{2}{a_1}^{2}{a_2}^{10}\epsilon \nonumber \\&\quad +1352 {r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\epsilon -100{r}^{4}{R}^{ 4}{a_1}^{2}{a_2}^{8}\nonumber \\&\quad -168{r}^{6}{R}^{2}a_1\,{a_2} ^{8}a_0\epsilon -4\,{r}^{6}{R}^{2}a_1\,{a_2}^{8}a_0\nonumber \\&\quad +80{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6}-928\,{r}^{2}{R}^{6} {a_1}^{2}{a_2}^{6}\epsilon \nonumber \\&\quad +520{r}^{4}{R}^{4}a_1{a_2}^{6}a_0\epsilon \nonumber \\&\quad +4\,{r}^{4}{R}^{4}a_1\,{a_2}^{ 6}a_0+240\,{R}^{8}{a_2}^{4}{a_1}^{2}\epsilon -24\,{R}^{8 }{a_2}^{4}{a_1}^{2}\nonumber \\&\quad -544\,{R}^{6}{a_2}^{4}{r}^{2}a_0\,a_1\,\epsilon +8\,{R}^{6}{a_2}^{4}{r}^{2}a_0\,a_1\nonumber \\&\quad +9\,{R}^{4}{a_2}^{4}{r}^{4}{a_0}^{2}+18\,{R}^{4}{a_2}^ {4}{r}^{4}{a_0}^{2}\epsilon \nonumber \\&\quad -8\,a_0\,{R}^{8}{a_2}^{2}a_1+192\,a_0\,{R}^{8}{a_2}^{2}a_1\,\epsilon \nonumber \\&\quad -16\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}+24{a_0}^{2 }{R}^{8}\epsilon \nonumber \\&\quad -40{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}\epsilon +6{a_0}^{2}{R}^{8}\biggr \} \biggr |+6{R}^{4}r{a_2}^{4}\nonumber \\&\quad -8{R}^{2}{r}^{3}{ a_2}^{6}+3{a_2}^{8}{r}^{5}\biggr ) \biggl | \nonumber \\&\quad \times \biggl \{{R}^{8} \biggl [ a_0{R}^{2}+2a_1\,{a_2}^{2}{R}^{ 2}\nonumber \\&\quad -2a_1\,{a_2}^{4}{r}^{2} \biggr ] ^{2}\biggr \}\biggl \{r{a_2}^{4} \biggl ( 216\,{r}^{8}{a_1}^{2}{a_2}^{12}\epsilon \nonumber \\&\quad -12\,{r}^{8}{a_1}^{2}{a_2}^{12}+56\,{r}^{6}{R}^{2}{a_1}^{2}{a_2}^{10}\nonumber \\&\quad -880\,{r}^{6}{R}^{2}{a_1}^{2}{a_2}^{10}\epsilon \nonumber \\&\quad +1352 {r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\epsilon -100{r}^{4}{R}^{ 4}{a_1}^{2}{a_2}^{8}\nonumber \\&\quad -168{r}^{6}{R}^{2}a_1{a_2} ^{8}a_0\epsilon -4\,{r}^{6}{R}^{2}a_1{a_2}^{8}a_0\nonumber \\&\quad +80\,{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6}-928{r}^{2}{R}^{6} {a_1}^{2}{a_2}^{6}\epsilon \nonumber \\&\quad +520{r}^{4}{R}^{4}a_1{a_2}^{6}a_0\epsilon \nonumber \\&\quad +4\,{r}^{4}{R}^{4}a_1\,{a_2}^{ 6}a_0+240{R}^{8}{a_2}^{4}{a_1}^{2}\epsilon -24{R}^{8 }{a_2}^{4}{a_1}^{2}\nonumber \\&\quad -544{R}^{6}{a_2}^{4}{r}^{2}a_0a_1\,\epsilon +8{R}^{6}{a_2}^{4}{r}^{2}a_0a_1\nonumber \\&\quad +9{R}^{4}{a_2}^{4}{r}^{4}{a_0}^{2}+18{R}^{4}{a_2}^ {4}{r}^{4}{a_0}^{2}\epsilon \nonumber \\&\quad -8a_0\,{R}^{8}{a_2}^{2}a_1+192\,a_0\,{R}^{8}{a_2}^{2}a_1\,\epsilon \nonumber \\&\quad -16\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}-40\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}\epsilon \nonumber \\&\quad +6\,{a_0}^{2}{R}^{8}+24\,{a_0}^{2 }{R}^{8}\epsilon \biggr ) \biggr \}^{-1} \biggr |\biggr ]\,. \end{aligned}$$
(43)
Fig. 8
figure 8

Plots of the Adiabatic indices \(\gamma \), \(\varGamma _r\) and \(\varGamma _t\), namely (43)–(45), versus the radius r using the constants constrained from \(\textit{Her X-1}\). For RT, the adiabatic index \(\gamma \) less than the GR case but still greater than the neutral equilibrium value \(\gamma =\frac{4}{3}\). The radial and tangential adiabatic indices have higher values whereas the stability constraints \(\varGamma _r>\gamma \) and \(\varGamma _t>\gamma \) are fulfilled everywhere within the pulsar

From Eq. (41), we obtain the adiabatic index of solution (21) in the form

$$\begin{aligned} \varGamma _r&=-4\biggl \{ \left( 4a_1{a_2}^{2}{R}^{2}+3a_0{R }^{2}-4a_1{a_2}^{4}{r}^{2} \right) \nonumber \\&\quad \times \left( R{}^2-a_2{}^2r^2 \right) ^{3} \biggl [216{r}^{8}{a_1}^{2}{a_2}^{12} \epsilon -12{r}^{8}{a_1}^{2}{a_2}^{12}\nonumber \\&\quad +56{r}^{6}{R}^{2}{a_1}^{2}{a_2}^{10}-880{r}^{6}{ R}^{2}{a_1}^{2}{a_2}^{10}\epsilon \nonumber \\&\quad +1352\,{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\epsilon -100\,{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\nonumber \\&\quad -168\,{r}^{6}{R}^{2}a_1\,{a_2}^{8}a_0\,\epsilon -4\,{r}^{6}{R}^{2}a_1\,{a_2}^{8}a_0\nonumber \\&\quad +80\,{r}^{2}{R}^{6}{ a_1}^{2}{a_2}^{6}-928\,{r}^{2}{R}^{6}{a_1}^{2}{a_2 }^{6}\epsilon \nonumber \\&\quad +520\,{r}^{4}{R}^{4}a_1\,{a_2}^{6}a_0\, \epsilon +4\,{r}^{4}{R}^{4}a_1\,{a_2}^{6}a_0\nonumber \\&\quad +240\,{R}^{8 }{a_2}^{4}{a_1}^{2}\epsilon -24\,{R}^{8}{a_2}^{4}{a_1}^{2}\nonumber \\&\quad -544\,{R}^{6}{a_2}^{4}{r}^{2}a_0\,a_1\,\epsilon +8\,{R}^{6}{a_2}^{4}{r}^{2}a_0\,a_1\nonumber \\&\quad +9\,{R}^{4}{a_2 }^{4}{r}^{4}{a_0}^{2}+18\,{R}^{4}{a_2}^{4}{r}^{4}{a_0}^ {2}\epsilon \nonumber \\&\quad -8\,a_0\,{R}^{8}{a_2}^{2}a_1+192\,a_0\, {R}^{8}{a_2}^{2}a_1\,\epsilon \nonumber \\&\quad -16\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}-40\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2} \epsilon +6\,{a_0}^{2}{R}^{8}\nonumber \\&\quad +24\,{a_0}^{2}{R}^{8}\epsilon \biggr ] \biggr \}\biggl \{ \biggl [36\,a_1\, {r}^{8}{a_2}^{10}\epsilon \nonumber \\&\quad -2\,a_1\,{r}^{8}{a_2}^{10}+10\,{r}^{6}{R}^{2}a_1\,{a_2}^ {8}\nonumber \\&\quad -148\,{r}^{6}{R}^{2}a_1\,{a_2}^{8}\epsilon \nonumber \\&\quad -20\,{r}^{4}{R} ^{4}a_1\,{a_2}^{6}+232\,{R}^{4}{r}^{4}{a_2}^{6}a_1\,\epsilon \nonumber \\&\quad -3\,{R}^{2}{r}^{6}{a_2}^{6}a_0-6\,{R}^{2}{r}^{6}{a_2}^{6}a_0\,\epsilon + 20\,{R}^{6}{r}^{2}{a_2}^{4}a_1\nonumber \\&\quad -168\,{R}^{6}{r}^{2}{a_2}^{4}a_1\,\epsilon +8\,{R}^{4}{r}^{4 }{a_2}^{4}a_0\nonumber \\&\quad +20\,{R}^{4}{r}^{4}{a_2}^{4}a_0\, \epsilon -8\,{R}^{8}{a_2}^{2}a_1\nonumber \\&\quad +48\,{R}^{8}{a_2}^{2}a_1\,\epsilon -6\,{R}^{6}{a_2}^{2}{r}^{2}a_0\nonumber \\&\quad -24\,{R}^{6}{ a_2}^{2}{r}^{2}a_0\,\epsilon +12\,\epsilon \,{R}^{8}a_0 \biggr ] \biggl [216\,{r}^{ 8}{a_1}^{2}{a_2}^{12}\epsilon \nonumber \\&\quad -108\,{r}^{8}{a_1}^{2}{a_2}^{12}+440\,{r}^{6}{R}^{2}{a_1}^ {2}{a_2}^{10}\nonumber \\&\quad -880{r}^{6}{R}^{2}{a_1}^{2}{a_2}^{10} \epsilon -676{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\nonumber \\&\quad +1352{r}^{4} {R}^{4}{a_1}^{2}{a_2}^{8}\epsilon -168{r}^{6}{R}^{2}a_1{a_2}^{8}a_0\epsilon \nonumber \\&\quad +108\,{r}^{6}{R}^{2}a_1{a_2}^{8}a_0+464\,{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6}\nonumber \\&\quad - 928\,{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6}\epsilon +520\,{r}^{4}{R }^{4}a_1\,{a_2}^{6}a_0\,\epsilon \nonumber \\&\quad -332\,{r}^{4}{R}^{4}a_1\,{a_2}^{6}a_0-120\,{R}^{8}{a_2}^{4}{a_1}^{ 2}\nonumber \\&\quad +240\,{R}^{8}{a_2}^{4}{a_1}^{2}\epsilon -544\,{R}^{6}{a_2}^{4}{r}^{2}a_0\,a_1\,\epsilon \nonumber \\&\quad +344\,{R}^{6}{a_2}^{4} {r}^{2}a_0\,a_1-27\,{R}^{4}{a_2}^{4}{r}^{4}{a_0}^{ 2}\nonumber \\&\quad +18\,{R}^{4}{a_2}^{4}{r}^{4}{a_0}^{2}\epsilon -120\,a_0\,{R}^{8}{a_2}^{2}a_1\nonumber \\&\quad +192\,a_0\,{R}^{8}{a_2}^{2}a_1\,\epsilon +56\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2} \nonumber \\&\quad -40\,{ a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}\epsilon -30\,{a_0}^{2}{R }^{8}+24\,{a_0}^{2}{R}^{8}\epsilon \biggr ] \biggr \}^{-1}\,,\nonumber \\ \end{aligned}$$
(44)

and

$$\begin{aligned} \varGamma _t&=-\biggl \{ \biggl [108\,{r}^{8 }{a_1}^{2}{a_2}^{12}\epsilon \nonumber \\&\quad -24\,{r}^{8}{a_1}^{2}{a_2}^{12}+96\,{r}^{6}{R}^{2}{a_1}^{2 }{a_2}^{10}\nonumber \\&\quad -440\,{r}^{6}{R}^{2}{a_1}^{2}{a_2}^{10} \epsilon +676\,{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\epsilon \nonumber \\&\quad -144\, {r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\nonumber \\&\quad -84\,{r}^{6}{R}^{2}a_1 \,{a_2}^{8}a_0\,\epsilon +16\,{r}^{6}{R}^{2}a_1\,{a_2}^{8}a_0\nonumber \\&\quad -464\,{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6} \epsilon +96\,{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6}\nonumber \\&\quad +260\,{r}^{4}{R }^{4}a_1\,{a_2}^{6}a_0\,\epsilon -48\,{r}^{4}{R}^{4}a_1\,{a_2}^{6}a_0\nonumber \\&\quad -24{R}^{8}{a_2}^{4}{a_1}^{2 }+120{R}^{8}{a_2}^{4}{a_1}^{2}\epsilon \nonumber \\&\quad -272{R}^{6}{a_2}^{4}{r}^{2}a_0a_1\,\epsilon +48{R}^{6}{a_2}^{4}{ r}^{2}a_0a_1\nonumber \\&\quad +9\,{R}^{4}{a_2}^{4}{r}^{4}{a_0}^{2} \epsilon \nonumber \\&\quad -16a_0\,{R}^{8}{a_2}^{2}a_1+12\,{a_0}^{2}{R}^{8}\epsilon \nonumber \\&\quad +96\,a_0\,{R} ^{8}{a_2}^{2}a_1\,\epsilon \nonumber \\&\quad -20\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2}\epsilon \biggr ] \biggl [ 10\,a_1\,{r}^{8}{a_2}^{10}\nonumber \\&\quad -42\,{r}^{6}{R}^{2}a_1\,{a_2}^{8}-9\,{R}^{2}{r}^{6}{a_2}^{6}a_0\nonumber \\&\quad +68\,{r}^{4}{ R}^{4}a_1\,{a_2}^{6}+28\,{R}^{4}{r}^{4}{a_2}^{4}a_0\nonumber \\&-52{R}^{6}{r}^{2}{a_2}^{4}a_1-30{R}^{6}{a_2}^{2}{r }^{2}a_0+16{R}^{8}{a_2}^{2}a_1\nonumber \\&\quad +12a_0\,{R}^{8} \biggr ] \biggr \}\biggl \{ \biggl [ 18a_1 {r}^{8}{a_2}^{10}\epsilon \nonumber \\&\quad -4a_1\,{r}^{8}{a_2}^{10}-74{r}^{6}{R}^{2}a_1{a_2}^ {8}\epsilon +16\,{r}^{6}{R}^{2}a_1\,{a_2}^{8}\nonumber \\&\quad +116\,{R}^{4}{r} ^{4}{a_2}^{6}a_1\,\epsilon -24\,{r}^{4}{R}^{4}a_1\,{a_2}^{6}\nonumber \\&\quad -3\,{R}^{2}{r}^{6}{a_2}^{6}a_0\,\epsilon -84\,{R} ^{6}{r}^{2}{a_2}^{4}a_1\,\epsilon \nonumber \\&\quad +16\,{R}^{6}{r}^{2}{a_2}^{4}a_1+10\,{R}^{4}{r}^{4}{a_2}^{4}a_0\,\epsilon -4\,{ R}^{8}{a_2}^{2}a_1\nonumber \\&\quad +24\,{R}^{8}{a_2}^{2}a_1\, \epsilon -12\,{R}^{6}{a_2}^{2}{r}^{2}a_0\,\epsilon \nonumber \\&\quad +6\, \epsilon \,{R}^{8}a_0 \biggr ] \biggl [ 216\,{r}^{8}{a_1}^{2}{a_2}^{12}\epsilon \nonumber \\&\quad -108\,{r}^{8}{a_1}^{2}{ a_2}^{12}+440\, {r}^{6}{R}^{2}{a_1}^{2}{a_2}^{10}\nonumber \\&\quad -880\,{r}^{6}{R}^{2}{a_1}^{2}{a_2}^{10}\epsilon \nonumber \\&\quad -676\,{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}+1352\,{r}^{4}{R}^{4}{a_1}^{2}{a_2}^{8}\epsilon \nonumber \\&\quad - 168\,{r}^{6}{R}^{2}a_1\,{a_2}^{8}a_0\,\epsilon +108\,{r} ^{6}{R}^{2}a_1\,{a_2}^{8}a_0\nonumber \\&\quad +464\,{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6}-928\,{r}^{2}{R}^{6}{a_1}^{2}{a_2}^{6} \epsilon \nonumber \\&\quad +520\,{r}^{4}{R}^{4}a_1\,{a_2}^{6}a_0\,\epsilon -332\,{r}^{4}{R}^{4}a_1\,{a_2}^{6}a_0\nonumber \\&\quad -120\,{R}^{8}{a_2}^{4}{a_1}^{2}+240\,{R}^{8}{a_2}^{4}{a_1}^{2} \epsilon \nonumber \\&\quad -544\,{R}^{6}{a_2}^{4}{r}^{2}a_0\,a_1\,\epsilon +344\,{R}^{6}{a_2}^{4}{r}^{2}a_0\,a_1\nonumber \\&\quad -27\,{R}^{4}{a_2}^{4}{r}^{4}{a_0}^{2}+18\,{R}^{4}{a_2}^{4}{r}^{4}{a_0}^{2}\epsilon \nonumber \\&\quad -120\,a_0\,{R}^{8}{a_2}^{2}a_1+192\,a_0\,{R}^{8}{a_2}^{2}a_1\,\epsilon \nonumber \\&\quad +56\,{a_0}^{2}{R}^{6} {a_2}^{2}{r}^{2}-40\,{a_0}^{2}{R}^{6}{a_2}^{2}{r}^{2} \epsilon \nonumber \\&\quad -30\,{a_0}^{2}{R}^{8}+24\,{a_0}^{2}{R}^{8}\epsilon \biggr ] \biggr \}\,. \end{aligned}$$
(45)

In Fig. 8a–c, we plot the profiles of the adiabatic indices \(\gamma \), \(\varGamma _r\) and \(\varGamma _t\) of the pulsar Her X-1, respectively. It is clear that the value of the adiabatic index \(\gamma \) as predicted by RT is less than the corresponding GR value everywhere within the pulsar. On the other hand, the other adiabatic indices \(\varGamma _r\) and \(\varGamma _t\) are higher in RT than GR, whereas the stability constraints, namely \(\varGamma _r>\gamma \) and \(\varGamma _t>\gamma \), as shown in the figures are clearly fulfilled.

8 More observational constraints

In this section we confront the present model with other pulsars’ data to examine its validity with wide range of astrophysical observations. Also, we plot the mass-radius profile corresponding to different choices of the surface density compatible with the nuclear saturation density as boundary conditions showing the capability of the model to predict masses in the lower mass gap \(2.5-5 M_\odot \). On the other hand, we confront the compactness parameter as predicted by the model with Buchdahl compactness bound.

8.1 Pulsars’ data

In addition to \(\textit{Her X-1}\), a similar analysis is developed for other twenty one pulsars cover a wide range of masses from \(0.8 M_\odot \) to heavy pulsars of mass \(2.01 M_\odot \). In Table 1, we give the observed masses and radii for each associated with the corresponding model parameters {\(a_0\), \(a_1\), \(a_2\)} assuming that the Rastall parameter \(\epsilon =-0.1\). We confirm that the model at hand can predict masses of those pulsars compatible with their observed values. In Table 2, we give the calculated values of physical quantities of most interest. As seen the values of the density are consistent with the nuclear density. It is to be mentioned that there are no EoSs are assumed, the obtained results however fit well with the linear behaviour, whereas the slopes \(dp_r/d\rho \) and \(dp_t/d\rho \) of the best fit lines are consistent with the values as obtained in Table 2. On the other hand these values confirm that the model is stable and causal for each case and satisfies all the physical constraints in Sect. 4. We additionally give the surface redshift values as predicted by the present model for the listed pulsars. All values are clearly in agreement with the upper bound constraint \(Z_{R}\le 2\) as given by Buchdahl [102], also for anisotropic spheres see [103, 104].

Table 1 Observed mass-radius of twenty pulsars and the corresponding model parameters (\(\epsilon =-0.1\)). \(^4\)We note that the estimated mass for massive pulsars slightly exceeds the observational value which would impose more strict constraints on Rastall parameter to be \(\epsilon =0.06\)
Table 2 Calculated physical quantities of the most interest

8.2 Mass-radius profile

As is shown in Table 2 the surface densities of the listed pulsars, \(2.14\times 10^{14}\lesssim \rho _R \lesssim 1.81\times 10^{15}\) \(\hbox {g/cm}^{3}\), are mostly compatible with a neutron core. For four different values of the surface density of the pulsars \(\rho _R=2.7\times 10^{14}\) \(\hbox {g/cm}^{3}\), \(4\times 10^{14}\) \(\hbox {g/cm}^{3}\), \(6\times 10^{14}\) \(\hbox {g/cm}^{3}\) and \(8\times 10^{14}\) \(\hbox {g/cm}^{3}\) we plot the corresponding compactness-radius curve as in Fig. 9a. In all cases the maximum compactness values do not exceed unity. However for a compact object to be stable it should satisfy Buchdahl compactness bound \(U=\frac{2G_N M}{c^2 R}\le 8/9\) (for isotropic sphere [102]). We visualize Buchdahl upper bound on the compactness parameter with the corresponding maximum radii as obtained for the four surface densities. It is convenient to give the model parameters {\(a_0\), \(a_1\), \(a_2\)} in terms of the total compactness parameter U. Recalling the matching conditions (35) and (36) we write

$$\begin{aligned} a_0= & {} \small {3\left\{ \left[ (U-\frac{8}{9})(1-U)^{\frac{1}{4}} +\frac{8}{9}(1-U)\right] \epsilon -\frac{1}{18}(1-U)^{\frac{1}{4}}U\right\} \sqrt{-(1-U)^2 (U-2+4(1-U)^{\frac{3}{4}}-6\sqrt{1-U}+4(1-U)^{\frac{1}{4}})} \over \left[ -\frac{1}{2}(1-U)^{\frac{1}{4}}+\sqrt{1-U}-\frac{1}{2}(1-U)^{\frac{3}{4}}\right] (\epsilon -\frac{1}{3})(U-1)},\nonumber \\ a_1= & {} -\frac{1}{2}{\left( \sqrt{1-U}-(1-U)^{\frac{3}{4}}\right) a_0 +4\sqrt{-(1-U)^2 (U-2+4(1-U)^{\frac{3}{4}}-6\sqrt{1-U}+4(1-U)^{\frac{1}{4}})} \over U-\sqrt{1-U}+2(1-U)^{\frac{3}{4}}-1},\nonumber \\ a_2= & {} \sqrt{1-(1-U)^{1/4}}. \end{aligned}$$
(46)
Fig. 9
figure 9

a Compactness-radius profiles for four surface densities, the horizontal dot and dash lines visualize Buchdahl (\(U=8/9\)) and the SEC bound (\(U(\epsilon =-0.1)=0.603\)) on the compactness parameter. Clearly both constraints give almost the same maximum radii. b Mass-radius profiles for four surface densities combined with observed mass-radius values of the pulsars in Table 1. The diagonal dot and dash lines set Buchdahl and SEC physical regions. Clearly all pulsars are below the SEC exclusion limit. The horizontal dot lines give the maximum possible mass as obtained by the SEC. c Pulsars on the red, green and blue mass-radius profiles are suggested to have neutron cores whereas the surface densities match superfluid, saturated, solidified nuclear densities. The pulsars on the gray mass-radius profile match perfectly a surface density boundary condition \(\rho _R=8\times 10^{14}\) \(\hbox {g/cm}^3\) which may suggest quark-gluon cores for those pulsars

Notably for the pulsar Her X-1 with \(\epsilon =-0.1\), the compactness parameter \(U=0.31\), which reproduces the set of constants \(a_0 \approx 0.369\), \(a_1\approx -0.622\) and \(a_2\approx 0.298\) as previously obtained in Sect. 6. Using Buchdahl limit \(U=8/9\), we obtain the maximum radii \(R=17.66\) km for \(\rho _R=2.7\times 10^{14}\) \(\hbox {g/cm}^{3}\), \(R=14.51\) km for \(\rho _R=4\times 10^{14}\) \(\hbox {g/cm}^{3}\), \(R=11.85\) km for \(\rho _R=6\times 10^{14}\) \(\hbox {g/cm}^{3}\) and \(R=10.26\) km for \(\rho _R=8\times 10^{14}\) \(\hbox {g/cm}^{3}\). However, more restricted values on the maximum compactness can be imposed by utilizing the SEC as obtained in the present model. Thus we write the density, radial and tangential pressures, namely (21), in terms of the compactness parameter U, after straight forward calculations we find that the SEC is satisfied when the compactness \(U\le 0.603\) (using \(\epsilon =-0.1\)). Higher U values can be obtained for higher values of \(\epsilon \), e.g. \(U(\epsilon =-0.05) \lesssim 0.639\). However, we restrict our discussion to \(\epsilon =-0.1\). We visualize the SEC constraint on the upper compactness value as in Fig. 9a. It can be seen that the lower U value as obtained by the SEC gives almost the same maximum radii as Buchdahl compactness bound or slightly lesser. However, it puts more restricted values on the maximum masses as will be discussed shortly. For a compact object to be physically stable we use \(U\le 0.603\) as obtained by the SEC. This determines the maximum radii as allowed by the present model as \(R=17.30\) km for \(\rho _R=2.7\times 10^{14}\) \(\hbox {g/cm}^{3}\), \(R=14.22\) km for \(\rho _R=4\times 10^{14}\) \(\hbox {g/cm}^{3}\), \(R=11.61\) km for \(\rho _R=6\times 10^{14}\) \(\hbox {g/cm}^{3}\) and \(R=10.05\) km for \(\rho _R=8\times 10^{14}\) \(\hbox {g/cm}^{3}\).

In Fig. 9b, we plot the mass-radius relation as obtained by the present model for the four surface densities along with the scatter plot of the observed mass-radius of the pulsars listed in Table 1. Consequently, we determine the maximum masses allowed by the present model according to Buchdahl limit for the surface densities \(\rho _R=2.7\times 10^{14}\) \(\hbox {g/cm}^{3}\), \(4\times 10^{14}\) g/cm\(^{3}\), \(6\times 10^{14}\) \(\hbox {g/cm}^{3}\) and \(8\times 10^{14}\) \(\hbox {g/cm}^{3}\), which have been found to be \(5.31 M_\odot \), \(4.37 M_\odot \), \(3.56 M_\odot \) and \(3.09 M_\odot \) respectively. In comparison with the GR case as obtained by Das et al. [96], RT allows more masses. Indeed these values provide unstable models, since they do not satisfy the SEC. We use the maximum compactness as obtained by the SEC, \(U=0.603\), which determines the physically stable pulsars with maximum masses \(3.53 M_\odot \), \(2.90 M_\odot \), \(2.37 M_\odot \) and \(2.05 M_\odot \). Obviously from Fig. 9b all pulsars are below the SEC exclusion limit.

In Fig. 9c, we split the pulsars into four groups according their matching with the mass-radius profiles of the surface densities. Notably, the nuclear saturation density \(\rho _\text {sat} = 2.7 \times 10^{14}\) \(\hbox {g/cm}^3\) and solidification density \(\rho _\text {solid}\) is expected to be from \(2.8 \times 10^{14}\) \(\hbox {g/cm}^3\) to \(5 \times 10^{14}\) \(\hbox {g/cm}^3\) whereas the maximum density of cold matter \(\rho _\text {max} \lesssim 4\times 10^{15}\) \(\hbox {g/cm}^3\) based on an EoS-independent analytic solutions of Einstein field equations. In the present work, we find that the pulsar X7 has a neutron core with density less than \(\rho _\text {sat}\) which matches anisotropic superfluid nuclear density \(\sim 1.5 \times 10^{14}\) \(\hbox {g/cm}^3\). The pulsars PSR J0030+0451, PSR J0037-4715 and the LIGO constraints have a neutron core with density matches \(\rho _\text {sat}\). The pulsars M13, KS 1731-260, EXO 1745-268, GW170817-2, GW170817-1, 4U 1820-30, 4U 1724-207 and SAX J1748.9-2021 have a neutron core with density \(\sim \rho _\text {solid}\). Notably, the most heaviest pulsars PSR J1614-2230 and PSR J0348+0432 fit well with the mass-radius curve corresponding to surface density \(4 \times 10^{14}\) \(\hbox {g/cm}^3\) which suggests that these pulsars are having solidified neutron cores. Similarly, the pulsars Her X-1, LMC X-4, EXO 1785-248, Cen X-3, 4U 1608-52 and Vela X-1 lie beyond neutron core density and match perfectly with mass-radius curve with a surface density of \(\rho _{R} = 8 \times 10^{14}\) \(\hbox {g/cm}^3\), this suggests that those pulsars may have quark-gluon cores. This claim should be verified by gravitational wave signals and by experimental tests. It is to be mentioned that the four categories presented here fit well with linear EoS as is shown earlier in Fig. 5 whereas their slopes are given in Table 2.

Interestingly, the obtained curves allow for a heavy neutron star to lie in the lower mass gap 2.5–5 \(M_\odot \) which keeps an open window for the binary secondary companion GW190814 [119] to be a neutron star with an anisotropic core whereas the EoS \(p_r(\rho )\) and \(p_t(\rho )\) are obtained by simple linear relations. Clearly RT (with \(\epsilon < 0\)), using Buchdahl limit, allows for higher maximum masses than the corresponding results as obtained by Das et al. within the GR framework [96]. This result is consistent with our earlier conclusion after Fig. 6a and also in agreement with the previous study of isotropic neutron stars in RT by Oliveira et al. [93]. However, in the present work we investigate anisotropic compact objects without assuming any EoS. In the following section we summarize and conclude the present work.

9 Summary and conclusions

One way to modify GR is to drop one of its main assumptions. Rastall questioned the local conservation in presence of curved spacetime, which led him to a set of field equations consistent with a different assumption, that is a non-minimal coupling between matter and geometry whereas the energy-momentum tensor \({\mathcal {T}}{^\alpha }{_{\beta ;\alpha }}\propto {\mathcal {R}}_{;\beta }\). Vissar, recently, claimed that RT is completely equivalent to GR [86]. On the contrary, Darabi et al. investigated Visser’s claim but they concluded that Visser misinterpreted the matter-geometry coupling term, and consequently led him to a wrong conclusion [87]. In addition, they showed that by applying Visser’s approach to f(R) theory one may conclude that it is equivalent to GR as well, which is not true. One of the good examples which may reveal the contribution of the matter-geometry coupling in RT in contrast to GR is the stellar models when the presence of matter plays a crucial role. In this study, we applied RT to anisotropic static star with spherical symmetry seeking for a non-trivial interior solution. We showed that, for static spherically symmetric stellar model, the Rastall parameter in general does not contribute to the anisotropy parameter while it contributes non-trivially to the density and the radial/tangential pressures. Applying appropriate ansatz we derived the corresponding density and pressure forms.

We matched the interior solution to the exterior Schwarzschild one (which is a solution in RT as well) in the case of the pulsar \(\textit{Her X-1 }\) (\(M= 0.85 \pm 0.15\, M_{\odot },\, R= 8.1 \pm 0.41\) km) and by recalling Zeldovich constraint, we determine the numerical values of the set of constants {\(a_0\), \(a_1\) and \(a_2\)} for a particular choice of Rastall parameter which has been found as \(\epsilon =-0.1\). We verified that the obtained model satisfies the physical constraints as listed in Sect. 4 and their predictions are slightly different from GR ones. We give detailed patterns of all physical quantities in Figs. 1, 2, 3, 4, 5, 6, 7 and 8. In addition, we confronted the model at hand with other pulsars’ observations and we confirm that all physical conditions are fulfilled in all cases. In Table 1, we give the numerical values of the set of constants for the same Rastall parameter value \(\epsilon =-0.1\) of twenty additional pulsars as is done in the case of the pulsar \(\textit{Her X-1 }\). Also, in Table 2, we give the corresponding physical quantities of the most interest for all pulsar at the present study. All results confirm that the model satisfies the physical conditions as listed in Sect. 4.

For four surface densities, we utilized the SEC to set an upper limit of the compactness \(U\sim 0.603\) (where \(\epsilon =-0.1\)) less than Buchdahl compactness \(U=8/9\), see Fig. 9. Consequently we determine the maximum possible masses with a stable configuration. For a boundary density compatible with neutron star core at saturation nuclear density the maximum mass \(\sim 3.53 M_\odot \). This results have been obtained without assuming a specific EoS, however, the pressure-density relation fits well with linear behaviour whereas the slopes keep a stable and causal structures. We split the twenty pulsars into four groups, three groups fit well with neutron cores with anisotropic superfluid, saturated and solidified cores. We found that the most massive pulsars PSR J1614-2230 and PSR J0348+0432 fit will with the mass-radius curve corresponding to surface density \(4 \times 10^{14}\) \(\hbox {g/cm}^3\) which suggests that those pulsars are having solidified neutron cores. Furthermore, we suggest that the following group of pulsars to have a quark-gluon cores, Her X-1, LMC X-4, EXO 1785-248, Cen X-3, 4U 1608-52 and Vela X-1. This group fit perfectly with a boundary density \(8\times 10^{14}\) g/cm\(^{3}\) lies beyond the neutron core and suggested to have quark-gluon core. Even for those of relatively small masses we find that corresponding radii are much smaller than what is expected for a typical size of neutron star 10 km, which characterizes low-mass quark star [128, 129]. In our case as we showed that the additional Rastall force in TOV equation contributes to resize the compact object to be smaller than GR prediction for the same mass. This in return results in higher core density \(\sim 10^{15}\) \(\hbox {g/cm}^3\). Noting that the nuclear saturation density \(\rho _\text {nuc} \approx 2.7-2.8 \times 10^{14}\) \(\hbox {g/cm}^3\), while the typical solidification density of neutron matter \(\rho _\text {solid} > rsim 4\times 10^{14}\) \(\hbox {g/cm}^3\).

To conclude: We investigated Rastall gravity, for an anisotropic star with a static spherical symmetry, whereas the matter-geometry coupling as assumed in RT is expected to play a crucial role differentiating RT predictions from GR ones. Indeed, all results confirm that RT is not equivalent to GR. However, Rastall parameter does not contribute to the anisotropy parameter, in general, i.e. RT predicts same amount of anisotropy as GR in the static spherically stellar models. Interestingly RT predicts more mass relative GR within same size which reflects the role of matter-geometry coupling to allow masses in the lower mass gap. This keeps the opportunity that the binary secondary companion GW190814 to be a neutron star with an anisotropic core whereas the EoS are obtained by simple linear relations.