1 Introduction

Einstein’s general theory of relativity has successfully accounted for various observations or cosmological scales as well as in astrophysical contexts [1, 2]. The golden age of cosmology has seen the theory fine-tuned to a high degree of accuracy in explaining the Hubble rate, matter content, baryogenesis, nucleosynthesis, as well as the possible origin and subsequent evolution of the Universe. General relativity, as an extension of Newtonian gravity, is especially useful in describing compact objects in which the gravitational fields are very strong. Some of these objects include neutron stars, pulsars and black holes where densities are of the order of \(10^{14}\) g cm\(^{-3}\) or greater. The first exact solution of the Einstein field equations representing a bounded matter distribution was provided by Schwarzschild [3]. This solution described a constant density sphere with the exterior being empty. The constant density Schwarzschild solution was a toy model which cast light on the continuity of the gravitational potentials and the behaviour of the pressure at the surface of the star. However, the interior Schwarzschild solution was noncausal in the sense that it allowed for faster than light propagation velocities within the stellar interior. This prompted the search for physically viable solutions of the Einstein field equations describing realistic stars. Now we are a century later and we have thousands of exact solutions of the field equations describing a multitude of stellar objects ranging from perfect fluids, charged bodies, anisotropic matter distributions, higher-dimensional stars and exotic matter configurations. Spherical symmetry is the most natural assumption to describe stellar objects. However, there is a wide range of stellar solutions exhibiting departure from sphericity. These solutions include the Kerr metric which describes the exterior gravitational field of a rotating stellar object [4]. In the limit of vanishing angular momentum, the Kerr solution reduces to the exterior Schwarzschild solution. There have also been numerous attempts at extending the Kerr metric to allow for dissipation and rotation [5,6,7].

In order to generate exact solutions of the Einstein field equations, researchers have employed a wide range of techniques to close this system of highly nonlinear, coupled partial differential equations. In the quest to obtain exact solutions describing static compact objects one imposes (i) symmetry requirements such as spherical symmetry, (ii) an equation of state relating the pressure and energy density of the stellar fluid, (iii) the behaviour of the pressure anisotropy or isotropy, (iv) vanishing of the Weyl stresses, (v) space-time dimensionality, to name just a few [8,9,10,11,12,13,14]. These assumptions render the problem of finding exact solutions of the field equations mathematically more tractable. There is no guarantee that the resulting stellar model actually describes a physically realizable stellar structure. In the case of nonstatic, radiating stars, various exact solutions are known in the literature ranging from acceleration-free collapse, Weyl-free collapse, vanishing of shear, collapse from/to an initial/final static configuration as well as anisotropic collapse models.

The Randall–Sundrum braneworld scenario has generated an intense interest in higher-dimensional gravity and modified theories of gravity [15]. Braneworld stars were shown to have nonunique exteriors due to radiative-type stresses arising from five-dimensional graviton effects emitting from the bulk [16]. Govender and Dadhich showed that the gravitational collapse of a star on the brane is accompanied by Weyl radiation [17]. They concluded that a collapsing sphere on the brane is enveloped by the brane generalised Vaidya solution which is in turn matched to the Reissner–Nordstrom metric. The mediation of the Vaidya envelope is a unique feature of the braneworld collapse which is not present in standard 4-d Einstein gravity. A recent model by Banerjee et al. showed that Weyl stresses lead naturally to anisotropic pressures within the core of a braneworld gravastar [18]. In their model the Mazur and Mottola gravastar picture [19] is considered within the Randall–Sundrum II type braneworld scenario. Recently, Dadhich et al. demonstrated the universality of the constant density Schwarzschild solution in general Einstein–Lovelock gravity and the universality of the isothermal sphere for pure Lovelock gravity when \(d \ge 2N + 2\). In a recent paper Chakrabory and Dadhich ask a pertinent question: “Do we really live in four dimensions or higher?” This question arises from the fact that while gravity is free to propagate in higher dimensions while all other matter fields are confined to four dimensions, gravity cannot distinguish between 4-d Einstein or in particular, 7-d pure Gauss–Bonnet dynamics [20].

The idea of embedding a purely gravitational field represented by a four-dimensional Riemannian metric into a flat space of higher dimensions has resurrected interest in so-called class one space-times. Karmarkar derived the necessary condition for a general spherically symmetric metric to be of class one [21]. In general, if the lowest number of dimensions of flat space in which a Riemannian space of dimension n can be embedded in \(n + p\), then the Riemannian space is referred to as class p. Class one space-times have been successfully utilised to model compact objects such as strange star candidates, neutron stars and pulsars [22,23,24,25,26,27,28]. These theoretical models accurately predict and agree with observations regarding the masses, radii, compactness and densities of these objects within experimental error. On the other hand Momeni et al. [29,30,31] have obtained the realistic compact objects for Tolman–Oppenheimer–Volkoff equations in f(R) gravity in different context.

In this work we use the condition arising from embedding a 4-d spherically symmetric static metric in Schwarzschild coordinates into a 5-d flat space-time to model a charged compact object. By choosing one of the metric potentials on physical grounds, the embedding condition gives us the second metric potential which then completely describes the gravitational behaviour of the model. This paper is structured as follows: In Sect. 2 we introduce the 4-d Einstein space-time and provide the necessary and sufficient condition for embedding this space-time into a 5-d flat space-time. The Einstein–Maxwell field equations describing the gravitational behaviour of our stellar model are presented in Sect. 3. In Sect. 4 we derive an exact solution of the Einstein–Maxwell equations describing a charged static sphere by making use of the embedding condition derived in the previous section. The boundary conditions required for the smooth matching of the interior of the star to the vacuum Schwarzschild exterior solution is given in Sect. 5. The physical viability of our model is considered in Sect. 6. We conclude with a discussion in Sect. 7.

2 Class one condition for spherical symmetric metric

The spherically symmetric line element in Schwarzschild coordinates \((x^{i})=(t,r,\theta ,\phi )\) is given by

$$\begin{aligned} \mathrm{d}s^{2}=e^{\nu (r)}\mathrm{d}t^{2}-e^{\lambda (r)}\mathrm{d}r^{2}-r^{2}\left( \mathrm{d}\theta ^{2}+\sin ^{2}\theta \mathrm{d}\phi ^{2} \right) \end{aligned}$$
(1)

where \(\lambda \) and \(\nu \) are functions of the radial coordinate r.

To determine the class one condition of the metric above (1), we suppose that the five-dimensional metric is flat,

$$\begin{aligned} \mathrm{d}s^{2}=-\left( \mathrm{d}z^1\right) ^2-\left( \mathrm{d}z^2\right) ^2-\left( \mathrm{d}z^3\right) ^2-\left( \mathrm{d}z^4\right) ^2+\left( \mathrm{d}z^5\right) ^2, \end{aligned}$$
(2)

where \(z^1=r\sin \theta \cos \phi \), \(z^2=r\sin \theta \,\sin \phi \), \(z^3=r\cos \theta \), \(z^4=\sqrt{K} e^{\frac{\nu }{2}}\,\cosh {\frac{t}{\sqrt{K}}}\), \(z^5=\sqrt{K}\,e^{\frac{\nu }{2}}\,\sinh {\frac{t}{\sqrt{K}}}\), and K is a positive constant. On inserting the components \( z^1,z^2, z^3, z^4 \) and \(z^5\) into the metric (2), we obtain

$$\begin{aligned} \mathrm{d}s^{2}= & {} -\left( \,1+\frac{K\,e^{\nu }}{4}\,{\nu '}^2\,\right) \,\mathrm{d}r^{2}-r^{2}\left( \mathrm{d}\theta ^{2}+\sin ^{2}\theta \mathrm{d}\phi ^{2} \right) \nonumber \\&+\,e^{\nu (r)}\mathrm{d}t^{2}. \end{aligned}$$
(3)

Comparing the line element (3) with the line element (1) we get

$$\begin{aligned} e^{\lambda }=\left( \,1+\frac{K\,e^{\nu }}{4}\,{\nu '}^2\,\right) . \end{aligned}$$
(4)

The condition (4) implies that the class of metric is one because we have embedded four-dimensional space-time into five-dimensional flat space-time. We should point out that (4) is equivalent to the condition derived by Karmarkar in terms of the Riemann tensor components,

$$\begin{aligned} \mathcal{R}_{1414}\mathcal{{R}}_{2323} = \mathcal{{R}}_{1212}\mathcal{{R}}_{3434} + \mathcal{{R}}_{1224}\mathcal{{R}}_{1334} \end{aligned}$$
(5)

where \(\mathcal{{R}}_{2323}\ne 0\). Pandey and Sharma [32].

3 Einstein–Maxwell field equations

The Einstein–Maxwell field equations can be written as

$$\begin{aligned} 8\pi \,\left( \,T_{\nu }^{\mu }+E_{\nu }^{\mu }\,\right) = R_{\nu }^{\mu }-\frac{1}{2}\,R\,g_{\nu }^{\mu }. \end{aligned}$$
(6)

Here we assume that the matter is a perfect fluid within the star, then \(T_{\nu }^{\mu }\) and \(E_{\nu }^{\mu }\) are the corresponding energy-momentum tensor and electromagnetic field tensor, respectively, defined by

$$\begin{aligned} T^\nu _\mu= & {} (\rho + p)v^\nu v_\mu - p\delta ^\nu _\mu ,\end{aligned}$$
(7)
$$\begin{aligned} E^\nu _\mu= & {} \frac{1}{4\pi }\left( -F^{\nu \gamma }F_{\mu \gamma } + \frac{1}{4}\delta ^\nu _\mu F^{\gamma {j}}F_{\gamma {j}}\right) , \end{aligned}$$
(8)

where \(\rho \) is the energy density, p is the isotropic pressure and \(v^\nu \) is the fluid four-velocity given as \(e^{-\nu (r)/2}v^\nu =\delta ^\nu _\mu \). We are using geometrized units and thus take \(\kappa =8\pi \) and \(G=c=1\).

The Maxwell equations for the electromagnetic field are given by

$$\begin{aligned} F_{\mu \nu }= & {} A_{\nu ,\mu } - A_{\mu ,\nu },\end{aligned}$$
(9)
$$\begin{aligned} F^{\mu \nu }_{;\nu }= & {} 4\pi J^{\mu } \end{aligned}$$
(10)

where A is the four-potential and \(J^\mu \) is the four-current. Since the charge is at rest there will be no magnetic field generated in the rest frame (at each interior point of the star) and the four-potential and four-current are given, respectively, as

$$\begin{aligned} A_\nu= & {} \left( 0,0,0, \phi (r)\right) ,\end{aligned}$$
(11)
$$\begin{aligned} J^\nu= & {} \sigma u^\nu ,\end{aligned}$$
(12)

where \(\sigma \) is the charge density. This choice of the gauge yields

$$\begin{aligned} F_{41} = - F_{14} = -\frac{\partial {\phi }}{\partial {r}}. \end{aligned}$$
(13)

Substituting (12) and (13) into the Maxwell equations (9) and (10) and integrating yields

$$\begin{aligned}&\frac{\partial {\phi }}{\partial {r}} = \frac{e^{\nu - \lambda }}{2} \frac{q(r)}{r^2},\end{aligned}$$
(14)
$$\begin{aligned}&q(r) = 4\pi \int _0^r{\sigma r^2e^{\lambda /2}\mathrm{d}r}. \end{aligned}$$
(15)

We introduce the electric field intensity defined by \(E^2 = -F_{41}F^{41}\), which leads to

$$\begin{aligned} E = \frac{q(r)}{r^2}. \end{aligned}$$
(16)

The components of \(T^\nu _\mu \) and \(E^\nu _\mu \) are as follows: \({T^1}_1=-p,\, {T^2}_2={T^3}_3=-p,\, {T^4}_4=\rho \) and \({E^1}_1=-{E^2}_2=-{E^3}_3={E^4}_4=\frac{1}{8\,\pi }\,\frac{q^2}{r^4}\).

For the spherically symmetric metric of Eq. (1), the Einstein–Maxwell field equations (6) are [33]

$$\begin{aligned} \frac{e^{-\lambda }-1}{r^{2}}+\frac{e^{-\lambda }\nu '}{r}=8\pi \, p-\frac{q^2}{r^4}, \end{aligned}$$
(17)
$$\begin{aligned} e^{-\lambda }\left( \frac{\nu ''}{2}+\frac{\nu '^{2}}{4}-\frac{\nu '\lambda '}{4}+\frac{\nu '-\lambda '}{2r} \right) =8\pi \, p + \frac{q^2}{r^4}, \end{aligned}$$
(18)
$$\begin{aligned} \frac{1-e^{-\lambda }}{r^{2}}+\frac{e^{-\lambda }\lambda '}{r}=8\pi \,\rho + \frac{q^2}{r^4}. \end{aligned}$$
(19)

If we now demand that the radial and transverse stresses are equal at each interior point of the stellar configuration we obtain from equating Eqs. (17) and (18)

$$\begin{aligned} \frac{2\,q^2}{r^4}= e^{-\lambda }\,\left[ \frac{2\,\nu ''-\nu '\,\lambda '+\nu '^{2}}{4}-\frac{\lambda '+\nu '}{2r} \right] -\frac{e^{-\lambda }-1}{r^2}, \end{aligned}$$
(20)

known as the condition of pressure isotropy. It is clear that (20), when plugged back into (15), becomes the definition of the charge density \(\sigma \). We note that the Einstein–Maxwell equations (17)–(19) can be viewed as describing a perfect fluid with anisotropic pressure. Equation (20) can be used as a definition for the electric field intensity. Alternatively, if we specify the nature of the electric field intensity then Eq. (20) gives a relation between \(\nu \) and \(\lambda \). This is a common approach in solving the Einstein–Maxwell system. In our approach we will utilise the embedding condition given in Eq. (4) to obtain an exact solution of the Einstein–Maxwell field equations.

However, if m(r) is the mass function for an electrically charged compact star model then it can be defined in terms of the metric function \(e^{\lambda }\) and electric charge q as

$$\begin{aligned} m(r)=\frac{r}{2}\,\left[ \,1-e^{-\lambda (r)}+\frac{q^2}{r^2} \,\right] . \end{aligned}$$
(21)

4 New class of general solutions for a charged compact star

We note that Eq. (4) relates the metric functions \(\nu \) and \(\lambda \) thus reducing the task of finding exact solutions to a single-generating function. Now to determine the mass function m(r) and electric charge q, we assume the following form for the metric function \(e^{\nu }\) (Fig. 1):

$$\begin{aligned} e^{\nu }=B\,(1-Ar^2)^n, \end{aligned}$$
(22)

where A and B are positive constants and \(n \le -1\). This form of the metric function is well motivated and has been utilised by Maurya et al. [34] to model charged compact stars arising from the Karmarkar condition. In these models they took \(n > 2\). The parameter n acts as a ’switch’ and characterises various well-known models available in the literature. It is clear from Eq. (22) that \(n = 0\) renders the space-time flat, which is meaningless in the present context of this paper. It was first pointed out by Tikekar and more recently by Maurya et al. [35] that the Karmarkar condition together with isotropic pressure (in the case of neutral fluids) admits two solutions: the Schwarzschild interior solution and the Kohler–Chao–Tikekar solution [40,41,42]. The Schwarzschild solution is conformally flat, ie., the Weyl tensor vanishes at each interior point of the sphere. The Kohler–Chao–Tikekar solution is not conformally flat and furthermore represents a cosmological solution. This is to say that there is no finite radius for which the pressure vanishes in the Kohler–Chao–Tikekar solution. We regain the Kohlar–Chao–Tikekar solution when we set \(n = 1\) in Eq. (22). Furthermore, we observe from Table 3 that the product nA is approximately constant for large n. As pointed out here that as \(n \rightarrow -\infty \) the metric function \(\nu = Cr^2 + \ln {B}\) where we have defined here \(C = - nA\). This form of the metric function \(\nu \) has been already used to construct electromagnetic mass (EMMM) models by Maurya et al. [35]. These models have the peculiar feature of vanishing electromagnetic field, mass, pressure and density when the parameter \(n = 0\). In addition, the fluid obeys an equation of state of the form \(p + \rho = 0\) implying that the pressure within the bounded configuration is negative. In this study we will consider solutions for \(n < 0\). We should point out that the solution describes a physical viable compact when \(n \le -2.7\). For \(n > -2.7\), causality is violated within the stellar fluid as the sound speed exceeds unity. We have started our physical analysis with \(n =-6.5\), since there are no physically realizable stars between \(n = -2.7\) to \(-6.5\) as observed by Gangopadhyay et al. [36] In the limiting case \( n= -2.7 \) one expects low mass stars.

Fig. 1
figure 1

Variation of the metric function \(e^{\nu }\) with the radial coordinate (r / R) for \(4U 1538-52\) with mass \((M)= 0.87 M_\odot \) and radius \((R)=7.866\) km (Table 2). For plotting this figure, the values of the constants for different n are as follows: (i) \(A=5.3980 \times 10^{-4} \), \(B=0.548101\), \(D=10.38552\), \(K=8.30822\times 10^{2}\) for \(n=-6.5\), (ii) \(A=3.5121\times 10^{-4} \), \(B=0.549818\), \(D=16.26344\), \(K=8.422215\times 10^{2}\) for \(n=-10\), (iii) \(A=7.0350\times 10^{-5}\), \(B=0.552284\), \(D=83.46073\), \(K=8.592418 \times 10^{2}\) for \(n=-50\), (iv) \(A=7.03753\times 10^{-6}\), \(B=0.552841\), \(D=8.39474\times 10^{2}\), \(K=8.630715 \times 10^{2}\) for \(n=-500\), (v) \(A=7.03753\times 10^{-7}\), \(B=0.552899\), \(D=8.39963\times 10^{3}\), \(K=8.634831 \times 10^{2}\) for \(n=-5000\), (vi) \(A=7.03753\times 10^{-8}\), \(B=0.552905\), \(D=8.40010\times 10^{4}\), \(K=8.635231 \times 10^{2}\) for \(n=-50000\) (Table 5)

Now by plugging our choice of \(e^{\nu }\) from Eq. (22) into Eq. (4), we obtain \(e^{\lambda }\) (Fig. 2)

$$\begin{aligned} e^{\lambda }=[1+D\,Ar^2\,(1-Ar^2)^{n-2}], \end{aligned}$$
(23)

where \(D=n^2\,A\,B\, K \).

Fig. 2
figure 2

Variation of metric function \(e^{\lambda }\) with the radial coordinate (r / R) for \(4U 1538-52\) with mass \((M)= 0.87 M_\odot \) and radius \((R)=7.866\) km (Table 2). For plotting of this figure, we have employed same values of the constant as used in Fig. 1. The corresponding numerical values can be seen from Table 5

Then on inserting \(e^{\nu }\) and \(e^{\lambda }\) from Eqs. (22) and (23), respectively, into Eqs. (20) and (21), we get electric charge and mass function (Fig. 3) as

$$\begin{aligned} \frac{2q^2}{r^4}=Ar^2 \left[ \frac{n^2\,{\psi ^2}-2\,n\,\psi \,({\psi }-D\,{\psi ^n})+D\,{\psi ^n}\,(-2{\psi }+D\,{\psi ^n})}{({\psi ^2} + D\,Ar^2\,{\psi ^n})^2} \right] ,\nonumber \\ \end{aligned}$$
(24)
$$\begin{aligned} m(r)=\frac{A^2r^5\,[3D^2\psi ^{2n}+n(n-2)\,\psi ^2]+2\,D\,Ar^3\,\psi ^{n+1}[1+(n-2)\,Ar^2]}{4 \left[ {\psi ^2} + D\,Ar^2\,{\psi ^n}\right] ^2},\quad \end{aligned}$$
(25)

where \(\psi =(1-Ar^2)\).

Fig. 3
figure 3

Variation of electric charge, q, (left panel) and mass function, m(r), (right panel) with the radial coordinate (r / R) for \(4U 1538-52\) with mass \((M)= 0.87 M_\odot \) and radius \((R)=7.866\) km (Table 2). For plotting of this figure, we have employed same values of the constant as used in Figs. 1 and 2. The corresponding numerical values can be seen from Table 5

The expressions for the pressure and energy density are determined from Eqs. (17) and (19), respectively, and can be written (Fig. 4 and Fig 5) as

$$\begin{aligned} \frac{8\pi \,p}{A}=\frac{n^2\,Ar^2\,\psi ^{2}{-}D\,\psi ^{n}\,[2\psi {+}D\,Ar^2\,\psi ^{n}]-2\,n\,\psi \,[(2-Ar^2)\,\psi +D\,Ar^2\,\psi ^n]}{2\left[ {\psi ^2} + D\,Ar^2\,{\psi ^n}\right] ^2},\nonumber \\ \end{aligned}$$
(26)
$$\begin{aligned} \frac{8\pi \,\rho }{A}=\frac{D^2\,Ar^2\psi ^{2n}-n(n{-}2)\,Ar^2\,\psi ^{2}{-}2D\,\psi ^{n+1}\,[-3{+}(3n-2)\,Ar^2]}{2\left[ {\psi ^2} + D\,Ar^2\,{\psi ^n}\right] ^2}. \end{aligned}$$
(27)
Fig. 4
figure 4

Variation of pressure p with the radial coordinate (r / R) for \(4U 1538-52\) with mass \((M)= 0.87 M_\odot \) and radius \((R)=7.866\) km (Table 2). For plotting of this figure, the values of constants for different n are as follows: (i) \(A=5.3980 \times 10^{-4} \), \(B=0.548101\), \(D=10.38552\), \(K=8.30822\times 10^{2}\) for \(n=-6.5\), (ii) \(A=3.5121\times 10^{-4} \), \(B=0.549818\), \(D=16.26344\), \(K=8.422215\times 10^{2}\) for \(n=-10\), (iii) \(A=7.0350\times 10^{-5}\), \(B=0.552284\), \(D=83.46073\), \(K=8.592418 \times 10^{2}\) for \(n=-50\), (iv) \(A=7.03753\times 10^{-6}\), \(B=0.552841\), \(D=8.39474\times 10^{2}\), \(K=8.630715 \times 10^{2}\) for \(n=-500\), (v) \(A=7.03753\times 10^{-7}\), \(B=0.552899\), \(D=8.39963\times 10^{3}\), \(K=8.634831 \times 10^{2}\) for \(n=-5000\), (vi) \(A=7.03753\times 10^{-8}\), \(B=0.552905\), \(D=8.40010\times 10^{4}\), \(K=8.635231 \times 10^{2}\) for \(n=-50000\) (Table 5)

5 Boundary conditions

In order to fix the constants appearing in our solution the following conditions must be satisfied: (i) The interior metric must join smoothly with the exterior Reissner–Nördstrom metric at the boundary of charged compact star (\(r=R\)). The Reissner–Nördstrom metric takes the form (Fig. 5)

$$\begin{aligned} \mathrm{d}s^{2}= & {} \left( 1-\frac{2M}{r}+\frac{q^2}{r^2}\right) \, \mathrm{d}t^{2} -\left( 1-\frac{2M}{r}+\frac{q^2}{r^2} \right) ^{-1}\nonumber \\&\times \mathrm{d}r^{2}-r^{2} (\mathrm{d}\theta ^{2} +\sin ^{2} \theta \, \mathrm{d}\phi ^{2} ), \end{aligned}$$
(28)

where M is a constant representing the total mass of the charged compact star.

Fig. 5
figure 5

Variation of density \(\rho \) with the radial coordinate (r / R) for \(4U 1538-52\) with mass \((M)= 0.87 M_\odot \) and radius \((R)=7.866Km \) (Table 2). For plotting of this figure, we have employed same values of the constant as used in Fig. 3. The corresponding numerical values can be seen from Table 5

(ii) The radial pressure \(p_{\mathrm{r}}\) must vanish at the boundary (\(r = R\)) of the star (i.e. the continuity of \(\frac{\partial g_{tt}}{\partial r}\) across the boundary of the star) [50], which is known as the second fundamental form.

Vanishing of the radial pressure at the boundary, \(p_r(R) =0\), yields

$$\begin{aligned} D=\frac{-2\,\Psi ^{n+1}\,(1+n\,AR^2)+\sqrt{4\,(1+n\,AR^2)^2\,\Psi ^{2n+2}+4\,AR^2\,\Psi ^{2n}\,\Phi (R)}}{2\,AR^2\,(1-AR^2)^{2n}} \end{aligned}$$
(29)

where we have defined

$$\begin{aligned}&\Psi =(1-AR^2),\end{aligned}$$
(30)
$$\begin{aligned}&\Phi (R)=[-4n+10n\,AR^2+n^2\,AR^2\nonumber \\&~~~~~~~~~~~~~~~-2n\,A^2R^4\,(4+n)+n\,A^3R^6\,(2+n)]. \end{aligned}$$
(31)

The constant B can be determined by using the condition \(e^{\nu (R)}=e^{-\lambda (R)}\), which yields

$$\begin{aligned} B=\frac{1}{(1-AR^2)^n\,[1+D\,AR^2\,(1-AR^2)^{n-2}]}. \end{aligned}$$
(32)

The condition \(e^{-\lambda (R)}=1-\frac{2M}{R}+\frac{Q^2}{R^2}\) gives the total mass of the charged compact star:

$$\begin{aligned} \frac{M}{R}=\frac{A^2R^4\,[3D^2\Psi ^{2n}+n(n-2)\,\Psi ^2]+2\,D\,AR^2\,\Psi ^{n+1}[1+(n-2)\,AR^2]}{4 \left[ {\Psi ^2} + D\,AR^2\,{\Psi ^n}\right] ^2}. \end{aligned}$$
(33)

By using the density of the star at surface, the value of constant A can be determined from the expression

$$\begin{aligned} A=\frac{16\pi \,\rho _\mathrm{s}[\Psi ^2+D\,AR^2\,\Psi ^n]^2}{D^2\,AR^2\Psi ^{2n}-n(n-2)\,AR^2\,\Psi ^{2}-2D\,\Psi ^{n+1}\,[-3+(3n-2)\,AR^2]}. \end{aligned}$$
(34)

The expressions for the pressure gradient and density gradient, respectively, are

$$\begin{aligned} \frac{8\pi \,\mathrm{d}p}{\mathrm{d}r}=\frac{2\,A^2\,r\,[2n^3\,D\,\psi ^{n+1}\,A^2r^4-n^2\,\phi _1(r) +\phi _2(r)+\phi _3(r)]}{2\,\left[ {\psi ^2} + D\,Ar^2\,{\psi ^n}\right] ^2}, \end{aligned}$$
(35)
$$\begin{aligned} \frac{8\pi \,\mathrm{d}\rho }{\mathrm{d}r}=\frac{2\,A^2\,r\,[-2D\,n^3\,\psi ^{n+1}\,A^2r^4+n^2\phi _4(r)+\phi _5(r)+2n\,\phi _6(r)]}{2\,\left[ {\psi ^2} + D\,Ar^2\,{\psi ^n}\right] ^3}, \end{aligned}$$
(36)

where

$$\begin{aligned}&\phi _1(r)=[-1+Ar^2(2+7D\psi ^{n})-2D\psi ^{n}\,A^2r^4\,(4-D\,\psi ^{n})\\&~~~~~~~~~~~~~-(2-D\,\psi ^{n})A^3r^6+A^4r^8],\\&\phi _2(r)=2\,n\,\psi \,[(Ar^2-3)\,\psi ^{2}+D^2\,Ar^2\,\psi ^{2n}\\&~~~~~~~~~~~~~+D\,\psi ^{n}\,(4-3Ar^2+A^2r^4)],\\&\phi _3(r)=D\,\psi ^{n}\,[-6\,\psi ^{2}+D^2\,\psi ^{2n}\,Ar^2\\&~~~~~~~~~~~~~+D\,\psi ^{n}\,(3-4Ar^2+3A^2r^4)],\\&\phi _4(r)=[-1+(2+7D\,\psi ^{n})Ar^2\\&~~~~~~~~~~~~~-2\,D\,\psi ^{n}\,A^2r^4\,(4+3D\,\psi ^{n})\\&~~~~~~~~~~~~~-(2-D\,\psi ^{n})A^3r^6+A^4r^8],\\&\phi _5(r)=-D\,\psi ^{n}\,[D^2\,\psi ^{2n}\,Ar^2-2\,\psi ^{2}\,(11+4\,Ar^2)\\&~~~~~~~~~~~~~+D\psi ^{n}\,(11-4Ar^2+3\,A^2r^4)],\\&\phi _6(r)=[\psi ^{3}(1+Ar^2)+D^2\,\psi ^{2n}\,Ar^2\,(5+3Ar^2)\\&~~~~~~~~~~~~~-D\,\psi ^{n}\,(6-3Ar^2-10A^2r^2+7A^3r^6)]. \end{aligned}$$

6 Physical properties of the solution

6.1 Regularity

  1. (i)

    Metric functions at the centre, \(r=0\): we observe from Eqs. (22) and (23) that the metric functions at the centre \(r=0\) assume the values \(e^{\nu (0)}=B\) and \(e^{\lambda (0)}=1\). This shows that metric functions are free of a singularity and positive at the centre (since B is positive). Also, the two metric functions \(e^{\nu }\) and \(e^{\lambda }\) are monotonically increasing function of r (Figs. 1 and 2).

  2. (ii)

    Pressure at the centre \(r=0\): From Eq. (26), we obtain the pressure p at the centre \(r=0\) as \(p_0=-A\,(D+2n)/8\,\pi \). Since A and D are positive, it follows that the central pressure is positive provided that \(D < - 2n\).

  3. (iii)

    Matter density at the centre \(r=0\): We require that the matter density be positive at central point of the star. Inspection of Eq. (26) gives us \(\rho _{0}=(3\,A\,D/8\,\pi )\). Since A and \(D(=A\,B\,n^{2}\,K)\) are positive due to positivity of AB, \(n^{2}\) and  K, the central density \(\rho _c\) is positive.

6.2 Causality

Causality requires that the speed of sound be less than the speed of light within the stellar interior. The speed of sound for the charged fluid sphere should be monotonically decreasing from centre to the boundary of the star (\(v=\sqrt{\mathrm{d}p/\mathrm{d}\rho } < 1\)). It is clear from Fig. 6 that the speed of sound is monotonically decreasing away from the centre and less than 1. This implies that our fluid model fulfills causality requirements.

Fig. 6
figure 6

Variation of sound velocity V with the radial coordinate (r / R) for \(4U 1538-52\) with mass \((M)= 0.87 M_\odot \) and radius \((R)=7.866\) km (Table 2). For plotting of this figure, the values of constants for different n are as follows: (i) \(A=5.3980 \times 10^{-4} \), \(B=0.548101\), \(D=10.38552\), \(K=8.30822\times 10^{2}\) for \(n=-6.5\), (ii) \(A=3.5121\times 10^{-4} \), \(B=0.549818\), \(D=16.26344\), \(K=8.422215\times 10^{2}\) for \(n=-10\), (iii) \(A=7.0350\times 10^{-5}\), \(B=0.552284\), \(D=83.46073\), \(K=8.592418 \times 10^{2}\) for \(n=-50\), (iv) \(A=7.03753\times 10^{-6}\), \(B=0.552841\), \(D=8.39474\times 10^{2}\), \(K=8.630715 \times 10^{2}\) for \(n=-500\), (v) \(A=7.03753\times 10^{-7}\), \(B=0.552899\), \(D=8.39963\times 10^{3}\), \(K=8.634831 \times 10^{2}\) for \(n=-5000\), (vi) \(A=7.03753\times 10^{-8}\), \(B=0.552905\), \(D=8.40010\times 10^{4}\), \(K=8.635231 \times 10^{2}\) for \(n=-50000\) (Table 5)

6.3 Energy conditions

The charged fluid sphere should satisfy the following three energy conditions, viz.: (i) null energy condition (NEC), (ii) weak energy condition (WEC) and (iii) strong energy condition (SEC). For satisfying the above energy conditions, the following inequalities must hold simultaneously inside the charged fluid sphere:

$$\begin{aligned} \mathrm{NEC:}\,\, \rho +\frac{E^2}{8\pi }\ge 0, \end{aligned}$$
(37)
$$\begin{aligned} \mathrm{WEC:}\,\, \rho +p \ge 0, \end{aligned}$$
(38)
$$\begin{aligned} \mathrm{SEC:}\,\, \rho +3p-\frac{E^2}{4\pi } \ge 0. \end{aligned}$$
(39)

It is clear from Fig. 7 that all three energy conditions are satisfied at each interior point of the configuration.

Fig. 7
figure 7

Variation of energy conditions NEC (top left), WEC (top right) and SEC (bottom) with the radial coordinate (r / R) for \(4U 1538-52\) with mass \((M)= 0.87 M_\odot \) and radius \((R)=7.866\) km (Table 2). For plotting this figure, we have employed the same values of the constant as used in Fig. 6. The corresponding numerical values can be seen from Table 5

6.3.1 Equilibrium condition

The Tolman–Oppenheimer–Volkoff (TOV) equation [37, 38] in the presence of charge is given by

$$\begin{aligned} -\frac{M_\mathrm{G}(\rho +p_r)}{r^2}e^{\frac{\lambda -\nu }{2}}-\frac{\mathrm{d}p}{\mathrm{d}r}+ \sigma \frac{q}{r^2}e^{\frac{\lambda }{2}} =0, \end{aligned}$$
(40)

where \(M_\mathrm{G}\) is the effective gravitational mass given by

$$\begin{aligned} M_\mathrm{G}(r)=\frac{1}{2}r^2 \nu ^{\prime }e^{(\nu - \lambda )/2}. \end{aligned}$$
(41)

Plugging the value of \(M_\mathrm{G}(r)\) in Eq. (40), we get

$$\begin{aligned} -\frac{\nu '}{2}(\rho +p_r)-\frac{\mathrm{d}p}{\mathrm{d}r}+\sigma \frac{q}{r^2}e^{\frac{\lambda }{2}} =0. \end{aligned}$$
(42)

The above equation can be expressed into three different components gravitational \((F_\mathrm{g})\), hydrostatic \((F_\mathrm{h})\) and electric \((F_\mathrm{e})\), which are defined by

$$\begin{aligned} F_g= & {} -\frac{\nu '}{2}(\rho +p_\mathrm{r})\nonumber \\= & {} -\frac{n\,A^2\,r}{4\,\pi }\frac{\left[ {-}D\,\psi ^n\,(1{+}Ar^2){+} n\,\psi ^2 + 2n\,D\,Ar^2\,\psi ^n\right] }{[\psi ^2+D\,Ar^2\,\psi ^n]^2},\nonumber \\ \end{aligned}$$
(43)
$$\begin{aligned} F_\mathrm{h}=-\frac{\mathrm{d}p_\mathrm{r}}{\mathrm{d}r}, \end{aligned}$$
(44)
$$\begin{aligned} F_\mathrm{e}=\frac{A^2\,r}{4\,\pi }\,\frac{\left[ \,2 D n^3\, \psi ^{n+1} A^2r^4 {+} n^2\,F_{e1} {+} D\,\psi ^n \,F_{e2} {-} 2 n\,F_{e3}\,\right] }{2\,[\psi ^2 + D\,Ar^2\,\psi ^n]^3}, \end{aligned}$$
(45)

where

$$\begin{aligned}&F_{\mathrm{e1}}=[3-(10+ D\,\psi ^n)Ar^2 +2(6-2 D \,\psi ^n \\&~~~~~~~~~~+ D^2\,\psi ^{2 n})A^2r^4 - (6-5\,D\,\psi ^{n}) A^3r^6 + A^4r^8],\\&F_{\mathrm{e2}}=[-6 \psi ^2 + D^2 \psi ^{2 n}\, Ar^2 + D \psi ^n \,(3 - 4 Ar^2 + 3 A^2r^4)],\\&F_{\mathrm{e3}}=[-(Ar^2-3) \psi ^3 + 2 D^2 \psi ^{2 n}\, A^2r^4 \\&~~~~~~~~~~+ D\,\psi ^n (-3 + 6 Ar^2 - 5 A^2r^4 + 2 A^3r^6)]. \end{aligned}$$

The balancing of these three forces within the stellar interior leads to hydrostatic equilibrium of the fluid sphere (Fig. 8).

6.3.2 Stability through adiabatic index

The stability of the charged fluid models depends on the adiabatic index \(\Gamma \). Heintzmann and Hillebrandt [42] proposed that a neutron star model with equation of state is stable if \(\Gamma > 1\). This condition for a stable model is necessary but not sufficient [41]. In Newton’s theory of gravitation, it is also well known that one has no upper mass limit if the equation of state has an adiabatic index \(\Gamma > 4/3\);

$$\begin{aligned} \Gamma =\frac{p+\rho }{p}\,\frac{\mathrm{d}p}{\mathrm{d}\rho }. \end{aligned}$$
(46)

Equation (46) arises from an assumption within the Harrison–Wheeler formalism [43]. Chan et al. [44] in their study of dissipative gravitational collapse of an initially static matter distribution which is perturbed showed that Eq. (46) follows from the equation of state of the unperturbed, static matter distribution. In the case of anisotropic fluids the ratio of the specific heats assumes the following form:

$$\begin{aligned} \Gamma > \frac{4}{3} - \left[ \frac{4}{3}\frac{p_\mathrm{r} - p_\mathrm{t}}{rp_\mathrm{r}'}\right] _{\mathrm{max}}. \end{aligned}$$
(47)

As pointed out earlier a charged mass distribution can be viewed as an anisotropic system in which the radial and tangential stresses are unequal (Fig. 9). In the case of isotropic pressure (\(p_\mathrm{r} = p_\mathrm{t}\)) we regain the classical Newtonian result from Eq. (47). It is clear from Eq. (47) that the instability is increased when \(p_\mathrm{r} < p_\mathrm{t}\) and decreases when \(p_\mathrm{r} > p_\mathrm{t}\).

Fig. 8
figure 8

Variation of different forces, \(F_\mathrm{h}\) (solid lines), \(F_\mathrm{e}\) (long dash lines), \(F_\mathrm{g}\) (dotted lines) with the radial coordinate (r / R) for \(4U 1538-52\) with mass \((M)= 0.87 M_\odot \) and radius \((R)=7.866\) km (Table 2). For plotting this figure, we have employed same values of the constant as used in Figs. 6 and 7. The corresponding numerical values can be seen from Table 5

Fig. 9
figure 9

Variation of adiabatic index \(\Gamma \) with the radial coordinate (r / R) for \(4U 1538-52\) with mass \((M)= 0.87 M_\odot \) and radius \((R)=7.866\) km (Table 2). For plotting this figure, the values of constants for different n are as follows: (i) \(A=5.3980 \times 10^{-4} \), \(B=0.548101\), \(D=10.38552\), \(K=8.30822\times 10^{2}\) for \(n=-6.5\), (ii) \(A=3.5121\times 10^{-4} \), \(B=0.549818\), \(D=16.26344\), \(K=8.422215\times 10^{2}\) for \(n=-10\), (iii) \(A=7.0350\times 10^{-5}\), \(B=0.552284\), \(D=83.46073\), \(K=8.592418 \times 10^{2}\) for \(n=-50\), (iv) \(A=7.03753\times 10^{-6}\), \(B=0.552841\), \(D=8.39474\times 10^{2}\), \(K=8.630715 \times 10^{2}\) for \(n=-500\), (v) \(A=7.03753\times 10^{-7}\), \(B=0.552899\), \(D=8.39963\times 10^{3}\), \(K=8.634831 \times 10^{2}\) for \(n=-5000\), (vi) \(A=7.03753\times 10^{-8}\), \(B=0.552905\), \(D=8.40010\times 10^{4}\), \(K=8.635231 \times 10^{2}\) for \(n=-50000\) (Table 5)

6.3.3 Harrison–Zeldovich–Novikov static stability criterion

In order for the configuration to be stable, the Harrison–Zeldovich–Novikov static stability criterion requires that the mass of the star increases with central density i.e. \(\mathrm{d}M/\mathrm{d}\rho _0 > 0\) and it is unstable if \(\mathrm{d}M/\mathrm{d}\rho _0 \le 0\). We have

$$\begin{aligned} M=\frac{R\,{\rho _1}^2\, [3\, D^2 \,\Phi ^{2\,n}\, \rho _1 {+} n\,(n{-}2 )\,\Phi ^2\,\rho _1] {+} 2\,D\,R\,\rho _1\,\Phi ^{n+1}\,[\,1+(n-2)\,\rho _1\,]}{4\,[\Phi ^{2} + D\,\rho _1\, \Phi ^n]^2}, \end{aligned}$$
(48)
$$\begin{aligned} \frac{\mathrm{d}M}{\mathrm{d}\rho _0}=\frac{R^3\,[\,M_1+M_2+M_3+M_4\,]}{2\,[\Phi ^{2} + D\,\rho _1\, \Phi ^n]^3}, \end{aligned}$$
(49)

where \(\rho _1=\frac{8\,\pi \,\rho _0}{3\,D}\,R^2\), \(\Phi =1-\rho _1\), \(\rho _0=\) central density,

$$\begin{aligned}&M_1=D\, \Phi ^n - (n-2)\,{\rho _1}^4\, [n-D\,\Phi ^n + D\, n^2\,\Phi ^n],\\&M_2=\rho _1\,[n^2 + n\,(-2 + D \Phi ^n) + 2\, D\,\Phi ^n\, (-2 + D \Phi ^n)],\\&M_3={\rho _1}^3\,[D\,n^3\, \Phi ^n -D\, \Phi ^n\, (-2 + D\, \Phi ^n)\\&~~~~~~~~~~-3\, n\, (2 + D\, \Phi ^n) + n^2\, (3 - D\,\Phi ^n + D^2\,\Phi ^{2\,n})],\\&M_4=-{\rho _1}^2\,[-3\, D\, \Phi ^n + n^2\, (3 + D\,\Phi ^n)\\&~~~~~~~~~~ - n\, (6 + D\, \Phi ^n - 2\, D^2\, \Phi ^{2\,n})]. \end{aligned}$$

Figure 10 shows that \(\mathrm{d}M/\mathrm{d}\rho _0 > 0\) thus indicating that our model is stable. We further note that \(\mathrm{d}M/\mathrm{d}\rho _0\) is independent of n for low density stars. It is clear that \(\mathrm{d}M/\mathrm{d}\rho _0\) decreases as |n| increases for high density stars.

Fig. 10
figure 10

Variation of mass (M) versus central density \(8\,\pi \,\rho _0 \,(0\)\(9.666\times 10^{14} \mathrm{gm/cm}^3) \) for the anisotropic star \(4U1608-52\). For this graph we have employed the same numerical values for the constants as used in Fig. 9 (Table 1)

6.4 Electric charge

Table 1 displays the magnitude of the charge at the centre and boundary for different stars. Also, from Fig. 3, it is clear that the charge profile is zero at the centre (corresponding to vanishing electric field) and monotonically increasing away from the centre, acquiring a maximum value at the boundary of the star. We further note that the charge increases with an increase in |n| with the difference becoming indistinguishable at the stellar surface for very large |n|. We may then interpret n as a ’stabilizing’ factor. The variation of charge with n suggests that lower values of n imply lower charge which in turn means smaller electromagnetic repulsion. Figure 3 shows that larger |n| leads to greater surface charge thus indicating greater electromagnetic repulsion here. This would mean that the surface layers of the charged body is more stable than the inner core. The onset of collapse of such a body could proceed in an anisotropic manner or the collapse could lead to the cracking of the object thus avoiding the formation of a black hole. As pointed out by Ray et al. [45] the charge can be as high as \(10^{20}\) coulombs and hydrostatic equilibrium may still be achieved, however, these equilibrium states are unstable. Bekenstein [46] argued that high charge densities will generate very intense electric fields. This will in turn induce pair production within the star, thus destabilizing the core. As an illustration we calculate the amount of charge at the boundary in units of coulombs for the compact star \(4U1608-52\) as follows: (i) \(8.90468 \times 10^{19}\) coulomb for \(n = - 6.5\), (ii) \(9.52895\times 10^{19}\) coulomb for \( n = -10 \), (iii) \(1.0370\times 10^{20}\) coulomb for \(n = - 50\), (iv) \(1.05471\times 10^{20}\) coulomb for \(n= - 500\), (v) \(1.05645\times 10^{20}\) coulomb for \(n= - 5000\), (vi) \(1.05662\times 10^{20}\) coulomb for \(n = - 50000\). However, the amount of charge in coulombs throughout the star can be determined by multiplying every recorded value in Table 1 by a factor of \(1.1659\times 10^{20}\).

Table 1 The electric charge for compact star \(4U 1538-52\) for different values of n in the relativistic unit (km)

6.5 Effective mass and compactness parameter for the charged compact star

The maximal absolute limit of mass–radius (M / R) ratio as proposed by Buchdahl [49] for static spherically symmetric isotropic fluid models is given by \(2M/R\le 8/9 \). On the other hand, [51] proved that for a compact charged fluid sphere there is a lower bound for the mass–radius ratio,

$$\begin{aligned} \frac{Q^{2}\, (18 R^2+ Q^2) }{2R^{2}\, (12R^2+Q^2)} \le \frac{M}{R}, \end{aligned}$$
(50)

for the constraint \(Q < M\).

However, this upper bound of the mass–radius ratio for charged compact star was generalized by [47], who proved that

$$\begin{aligned} \frac{M}{R} \le \left[ \frac{4R^2+3Q^2}{9R^2} +\frac{2}{9R}\,\sqrt{R^2+3Q^2}\right] . \end{aligned}$$
(51)

Equations (50) and (51) imply that

$$\begin{aligned} \frac{Q^{2}\, (18 R^2+ Q^2) }{2R^{2}\, (12R^2+Q^2)}\le & {} \frac{M}{R}\nonumber \\\le & {} \left[ \frac{4R^2+3Q^2}{9R^2} +\frac{2}{9R}\,\sqrt{R^2+3Q^2}\right] .\nonumber \\ \end{aligned}$$
(52)

The effective mass of the charged fluid sphere can be determined:

$$\begin{aligned} m_{\mathrm{eff}}=4\pi {\int ^R_0{\left( \rho +\frac{E^2}{8\,\pi }\right) \,r^2\,\mathrm{d}r}}=\frac{R}{2}[1-e^{-\lambda (R)}] \end{aligned}$$
(53)

where \(e^{-\lambda }\) is given by Eq. (23) and compactness u(r) is defined by

$$\begin{aligned} u(R)=\frac{m_{\mathrm{eff}}(R)}{R}=\frac{1}{2}[1-e^{-\lambda (R)}]. \end{aligned}$$
(54)

6.6 Redshift

The maximum possible surface redshift for a bounded configuration with isotropic pressure is \(Z_\mathrm{s} = 4.77\). Bowers and Liang showed that this upper bound can be exceeded in the presence of pressure anisotropy [8]. When the anisotropy parameter is positive (\(p_\mathrm{t} > p_\mathrm{r}\)) the surface redshift is greater than its isotropic counterpart. Haensel et al. [48] showed that for strange quark stars the surface redshift is higher in low mass stars with the difference being as high as 30% for a 0.5 solar mass star and 15% for a 1.4 solar mass star. The gravitational surface redshift (\(Z_\mathrm{s}\)) is given by

$$\begin{aligned} Z_\mathrm{s}= (1-2\,u)^{\frac{-1}{2}} -1=\sqrt{1+D\,AR^2\,(1-AR^2)^{n-2}}-1. \end{aligned}$$
(55)

From Eq. (55), we note that the surface redshift depends upon the compactness u, which implies that the surface redshift for any star cannot be arbitrarily large because the compactness u satisfies the Buchdahl maximally allowable mass–radius ratio (Fig. 11). However, the surface redshift will increase with increase of compactness u. Also, from Table 5. we observe that the surface redshift decreases with an increase in |n|.

Fig. 11
figure 11

Variation of redshift (Z) with the radial coordinate (r / R) for \(4U 1538-52\) with mass \((M)= 0.87 M_\odot \) and radius \((R)=7.866\) km (Table 2). For plotting this figure, the values of constants for different n are as follows: (i) \(A=5.3980 \times 10^{-4} \), \(B=0.548101\), \(D=10.38552\), \(K=8.30822\times 10^{2}\) for \(n=-6.5\), (ii) \(A=3.5121\times 10^{-4} \), \(B=0.549818\), \(D=16.26344\), \(K=8.422215\times 10^{2}\) for \(n=-10\), (iii) \(A=7.0350\times 10^{-5}\), \(B=0.552284\), \(D=83.46073\), \(K=8.592418 \times 10^{2}\) for \(n=-50\), (iv) \(A=7.03753\times 10^{-6}\), \(B=0.552841\), \(D=8.39474\times 10^{2}\), \(K=8.630715 \times 10^{2}\) for \(n=-500\), (v) \(A=7.03753\times 10^{-7}\), \(B=0.552899\), \(D=8.39963\times 10^{3}\), \(K=8.634831 \times 10^{2}\) for \(n=-5000\), (vi) \(A=7.03753\times 10^{-8}\), \(B=0.552905\), \(D=8.40010\times 10^{4}\), \(K=8.635231 \times 10^{2}\) for \(n=-50000\) (Table 5)

6.7 Equation of state

An equation of state (EoS), \(p = p(\rho )\), relates the pressure and the density of the stellar fluid and is an important indicator of the nature of the matter making up the configuration. The MIT bag model arising from observations in fundamental particle physics relates the pressure to the density of the star via a linear relation of the form \(p = \alpha \rho - B\) where B is the bag constant. This equation of state has been successfully used to model compact objects in general relativity ranging from neutron stars through to strange star candidates. A recent model of a radiating star in which the collapse proceeds from an initial static configuration obeying a linear equation of state of the form \(p_\mathrm{r} = \alpha (\rho - \rho _\mathrm{s})\) where \(p_\mathrm{r}\) is the radial pressure, \(\rho _\mathrm{s}\) is the surface energy density and \(\alpha \) is the EoS parameter showed that the variation of \(\alpha \) affects the temperature profile of the collapsing body. Figure 12 shows the variation of the ratio \(p/\rho \) with r / R. We note that the pressure is less than the density at each interior point of the configuration. This ratio is also positive everywhere inside the star. As |n| increases, the ratio \(p/\rho \) decreases with the differences tending to zero towards the surface layers of the star (Fig. 12).

Fig. 12
figure 12

Variation of the ratio \(\frac{p}{\rho }\) with respect to the radial coordinate (r / R) for \(4U 1538-52\) with mass \((M)= 0.87 M_\odot \) and radius \((R)=7.866\) km (Table 2). For plotting this figure, the values of constants for different n are as follows: (i) \(A=5.3980 \times 10^{-4} \), \(B=0.548101\), \(D=10.38552\), \(K=8.30822\times 10^{2}\) for \(n=-6.5\), (ii) \(A=3.5121\times 10^{-4} \), \(B=0.549818\), \(D=16.26344\), \(K=8.422215\times 10^{2}\) for \(n=-10\), (iii) \(A=7.0350\times 10^{-5}\), \(B=0.552284\), \(D=83.46073\), \(K=8.592418 \times 10^{2}\) for \(n=-50\), (iv) \(A=7.03753\times 10^{-6}\), \(B=0.552841\), \(D=8.39474\times 10^{2}\), \(K=8.630715 \times 10^{2}\) for \(n=-500\), (v) \(A=7.03753\times 10^{-7}\), \(B=0.552899\), \(D=8.39963\times 10^{3}\), \(K=8.634831 \times 10^{2}\) for \(n=-5000\), (vi) \(A=7.03753\times 10^{-8}\), \(B=0.552905\), \(D=8.40010\times 10^{4}\), \(K=8.635231 \times 10^{2}\) for \(n=-50000\) (Table 5)

Table 2 Comparison between estimated and observed values of mass and radius for different compact stars [36]
Table 3 Numerical data of \(AR^2\) corresponding to observed mass and radius with reference to Table 1 for different values of n
Table 4 Numerical data of \(AR^2\) corresponding to observed mass and radius with reference to Table 1 for different values of n
Table 5 Numerical data of physical parameters \(AR^2\), A, B, D, K and nA for different values of n for \(4U 1538-52\)
Table 6 Numerical data of physical parameters \(AR^2\), A, B, D, K and nA for different values of n for \(SAX J1808.4-3658\)
Table 7 The central density, surface density and central pressure for compact star candidate \(4U 1538-52\)
Table 8 The central density, surface density and central pressure for compact star candidate \(PSR J1903+327\)

7 Discussion

In this paper we attempted to obtain electromagnetic mass models (EMMM) which were first addressed by Lorentz. The Lorentz electromagnetic mass models had the distinguishing feature that vanishing charge density is accompanied by the simultaneous vanishing of all other thermodynamical quantities. In addition, the equation of state of these models is of the form \(\rho + p = 0\), giving rise to negative pressure. The solution obtained in this work relaxes this particular equation of state, allowing for positive pressure. The gravitational and thermodynamical behaviour of our model is controlled by a parameter n. Switching off n results in the vanishing of the charge density and all other thermodynamical quantities such as density and pressure. We use a novel approach: embedding a spherically symmetric, static metric in Schwarzschild coordinates into a five-dimensional flat metric. This embedding is equivalent to the Karmarkar condition: the requirement for a spherically symmetric metric to be of embedding class 1. The condition obtained from this embedding relates the gravitational potentials thus reducing the problem of finding an exact solution of the Einstein–Maxwell field equations to a single-generating function. By specifying one of the gravitational potentials on physical grounds, we obtain the second potential which completely describes the gravitational behaviour of the compact object. The junction conditions required for the smooth matching of the interior space-time to the exterior Reissner–Nördstrom space-time fixes the constants in our solution and determines the mass contained within the charged sphere. Our model displays many salient features which bode well for describing a compact, self-gravitating object. Graphical analysis of the solution shows that the density and pressure are monotonically decreasing functions of the radial coordinate. The pressure vanishes at some finite radius. This indicates that our solution can be utilised to describe a bounded object unlike the Kohler–Chao solution, which arises from the imposition of the Karmarkar condition together with pressure isotropy. Causality is obeyed at each interior point of the configuration. Stability analysis via the adiabatic index and the Harrison–Zeldovich–Novikov static stability criterion indicate that our model is stable. Analysis of the variation of charge with the radial coordinate reveals an interesting characteristic of our model. The charge increases with the parameter |n|. This increase is largest towards the surface layers of the charged object becoming simultaneously indistinguishable for very large values at the surface. This implies that the surface layers are more stable (larger repulsive forces here) than the inner core layers. This ’differentiated’ stability may lead to anisotropic collapse or the subsequent cracking of the sphere should this object starts to collapse. This phenomenon has not been discussed elsewhere in the literature. The influence of the parameter n is clearly drawn out in Tables 2, 3, 4. Table 2 shows that our theoretical model describes compact objects to a very good degree of accuracy with regards to observed masses and radii of stars. Tables 5 and 6 clearly show that variations in the model parameters stabilise for very large n. Tables 7 and 8 illustrate the influence of the parameter n on the central density, surface density, central pressure and surface redshift for the stars 4U 1538–52 and SAX J1808.4–3658. It is clear that for very large n variations in these physical quantities tend to zero. This feature indicates that the parameter n can be viewed as a ’building’ constant, that is to say, an increase in n is accompanied by an increase in mass, radius and charge which builds up the star from \(r = 0\) through to the surface. In this work we have utilised \(n < 0\) and the case \(n \ge 0\) was studied by [34]. Future work has been initiated to consider the case of general n.