1 Introduction

Owing to the difficulties encountered by the general theory of relativity (GTR) in explaining the anomalous behavior of gravitational events such as the accelerated expansion of the cosmos in a late-time [1, 2], alternative or extended gravity theories have suddenly gained considerable importance. Conjecturing the presence of exotic matter fields, including quintessence fields (QFs), ghost fields (GFs), dark energy (DE), and dark matter (DM), to name a few, is one approach to solving this problem. There is currently no empirical evidence for these conjectures, but a variety of experiments are being carried out. In this concern, de Rham [3] proposes that the graviton is not massless but actually bears a small mass to explain the dark sector. This has several implications for physics, which have already been addressed previously in the literature. Reexamining the geometrical side of the field equations offers an alternative approach, meanwhile higher curvature impacts may have a role to play. Specifically, the Einstein–Gauss–Bonnet (EGB) theory has shown to be promising in this aspect and is hence widely investigated. It should be noted that the EGB is part of a more generic category of theories named Lovelock’s polynomial Lagrangians which are the most comprehensive tensor theory yielding at most 2nd-order motion equations. The most common theory is owed to Horndeski [4] if one allows the Lagrangian to involve both tensor and scalar fields. The reality that the Gauss–Bonnet Lagrangian naturally manifests in the applicability of heterotic string theory at the low energy limit [5] provides another compelling argument in favor of the EGB theory. For inhomogeneous distributions of dust [6, 7] and null dust [8], the causal structure of the singularities deviates from general relativity. The challenge we are studying seems to be whether gravitational effects with higher curvature play an important role in stellar evolution. In fact, Einstein’s GTR forms the basis for the majority of our knowledge of discoveries in relativistic astrophysics. So it is therefore quite natural to wonder what consequence the higher curvature contributions have on stellar configurations if the GTR is to be replaced by a higher curvature theory that maintains 2nd order motion equations and shrinks to GTR in the solar system scale constraint.

Although five-dimensional celestial bodies are not physically obtainable, their occurrence has not been excluded. Kaluza [11] and Klein [12] made the first advances in higher dimensional gravity by analyzing a five-dimensional manifold and explaining the behavioral patterns of the electrodynamic field by four components of the metric tensor, ten by the typical four-dimensional space-time manifold, and one additional dimension by a scalar field. Following that, modern works on brane-world cosmologies requiring higher dimensions have received significant coverage, despite the fact that its emphasis has since waned. The additional dimensions are usually explained by the fact that they are topologically coiled and extremely tiny in size. Keep in mind that the LHC experiment probed for additional dimensions on a large scale but was unsuccessful in finding any. Nevertheless, this does not exclude the possibility of additional dimensions at the microscopic level. Indeed, quantum field theory actually requires space-time dimensions of the size of Ten and Eleven. As we demonstrate in this paper, despite their small size, they may have a significant impact on certain features of the gravitational field.

For a long time, the existence of spherically symmetric static black hole (BH) solutions in the EGB theory paradigm has been studied extensively [13,14,15]. Subsequently, several other factors have been explored for the GB solution in de Sitter (dS) and anti-de Sitter (AdS) space [16, 17], including thermophysical properties related to the cosmological horizon and the BH horizon. Additionally, some authors have recently examined specific solutions relating to BHs in great detail (see e.eg. Refs. [18,19,20,21]). Considerable efforts have been made to study the geodesic motion of a test particle [22], the radius of photon spheres [23], the Hawking evaporation of AdS BHs [24], the phase transition of RN-AdS BHs [25], solutions of regular BHs [26], solutions of wormholes fulfilling energy conditions [27, 28], and the gravitational collapse of an incoherent spherical dust cloud was proposed in [29,30,31,32].

The study of EGB gravity may also be important with respect to the prospect of overcoming some issues in strong field regimes. The study of cosmic structures may also offer important restrictions on the alternative theories of gravity that are being considered in this context. A significant number of mass-radius relations are accessible at the moment through electromagnetic measurements of extreme events like short gamma-ray bursts (SGRBs), and more recently through gravitational waves (GWs). It is worth noting that the theoretical building of the neutron star (NS) equation of state (EoS) is strongly constrained by the observational data for NSs with masses around \(2~M_{\odot }\) [33, 34]. Until now, the composition and structural properties of relativistic compact bodies are not well recognized in detail. Many solutions to Einstein’s gravitational field equations defining the internal construction of relativistic compact bodies have now been derived, all assuming static and spherical symmetry. Due to the complexity of the Einstein field equations, however, it is typically difficult to find exact solutions in GR that are physically realizable. In light of modified theories of gravity, the situation gets more challenging. So, in order to arrive at exact solutions, researchers employ a number of mathematical methodologies. Many such concepts have been discussed, in particular, an algorithm that produces all regular static, spherically symmetric perfect-fluid solutions of Einstein’s equations by selecting a single monotone function [35] and its enlargement to locally anisotropic fluids in [36]. With compact objects, however, there is flexibility in selecting the appropriate interior solutions. Schwarzschild found the first exact solution to Einstein’s field equations in 1916 [37], which improved our ability to predict many physical events. By using spherically symmetric perfect fluid solutions of Einstein’s equations, Tolman [9] initially derived the simplest model to represent stellar interiors. Following that, several works – both theoretical and observational – on various aspects of modified gravity theories have been reported in recent literature [38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55, 55,56,57,58,59,60,61,62,63,64].

The foregoing arguments encouraged us to make a thorough study of the stability and appropriateness of anisotropic solutions for relativistic compact stars. In this article, we are mainly interested in exploring the salient features of the static-charged anisotropic fluid sphere consisting of a charged perfect fluid in the framework of 5D EMGB gravity theory. We are using the well-behaved TK ansatz together with a linear EoS of the form \(p_r=\beta \rho -\gamma \), (where \(\beta \) and \(\gamma \) are constants) to generate exact solutions of the EMGB field equations and analyze the effect of the Gauss–Bonnet Lagrangian term \(\mathcal {L}_{GB}\) which is coupled with the Einstein–Hilbert action through the coupling constant \(\alpha \) on the principal physical characteristics of the stellar model. We would also like to point out that the characteristics of the matter configuration and higher dimensional effects are directly related.

The manuscript is organized in the following way: in Sects. 2, 3 and 4, we are providing the relevant EGB gravity formalism as well as the EMGB field equations and their solutions, respectively. The discussion of matching conditions for constant evaluations can be found in Sect. 5. In Sect. 6, we have been discussing significant results for the actual charged model and its stability in Sect. 6.6. Finally, we are presenting our concluding remarks in Sect. 7. Throughout the paper, we have employed the essentially positive signature (\(-,~+,~+,~+,~+\)).

2 Einstein–Gauss–Bonnet gravity

To construct the field equations in EGB gravity, we need a modified action that differs from the Einstein scenario. In this study, we will be working on five dimensions. In five-dimensional spacetime with a matter field, the modified action for EGB gravity can be written as,

$$\begin{aligned} \mathcal {I}_{G}=\frac{1}{16 \pi }\int d^{5}x\sqrt{-g}\left[ R-2\Lambda +\alpha \mathcal {L}_{\text {GB}} \right] + \mathcal {S}_{\text {matter}}. \end{aligned}$$
(1)

where g signifies the determinant of the metric \(g_{ij}\), R displays the five-dimensional Ricci scalar, and \(\Lambda \) stands for the cosmological constant, whereas \(\mathcal {S}_{\text {matter}}\) denotes the action related to the matter field. The GB coupling constant \(\alpha \) is correlated to the string tension in string theory and has length squared dimensions, representing ultraviolet corrections to Einstein’s theory. It should be noted that according to Maedaa [30], the coupling constant \(\alpha \) must be nonnegative for Minkowski spacetime to be stable. Consequently, we will constrain our study to the case where the GB coupling constant \(\alpha \) is non-negative. The Ricci scalar, Ricci tensor, and Riemann curvatures are specifically combined in the GB term \(\mathcal {L}_{\text {GB}}\), which is stated by

$$\begin{aligned} \mathcal {L}_{\text {GB}}=R^{ijkl} R_{ijkl}- 4 R^{ij}R_{ij}+ R^2. \end{aligned}$$
(2)

We also incorporate the matter action \(\mathcal {S}_{\text {matter}}\), which triggers the stress-energy tensor for the matter field, \({T}_{ij}\). We now get the following equations of motion by varying the action (1) in relation to the metric \(g_{ij}\),

$$\begin{aligned}{} & {} G_{ij}+\alpha H_{ij} = \frac{8 \pi G}{c^4} T_{ij}, \nonumber \\{} & {} \text {where} \quad {T}_{ij}=-\frac{2}{\sqrt{-g}}\frac{\delta \left( \sqrt{-g}\mathcal {S}_m\right) }{\delta g^{ij}}. \end{aligned}$$
(3)

Here, the Einstein tensor and the tensor containing the contributions from the GB component are denoted by the symbols \(G_{ij}\) and \(H_{ij}\), respectively. These both tensors are explicitly expressed as

$$\begin{aligned} G_{ij}= & {} R_{ij}-\frac{1}{2}R~ g_{ij},\nonumber \\ H_{ij}= & {} 2\Big ( R R_{ij}-2R_{ik} {R}^k_j -2 R_{ijkl}{R}^{kl} - R_{ikl\delta }{R}^{kl\delta }_j\Big ) \nonumber \\{} & {} -\frac{1}{2}\,g_{ij}\,\mathcal {L}_{\text {GB}}. \end{aligned}$$
(4)

The GB term does not exist for \(n \le 4\) but actively contributes to the curvature of the spacetime for \(n \ge 5\) since it is a topological invariant in the four-dimensional spacetime. In writing the Einstein–Maxwell–Gauss–Bonnet (EMGB) field equations, here we are using geometrized units, and thus we have taken \(G = c = 1\) throughout the discussion.

3 Field equations

The five-dimensional line element for a static spherically symmetric spacetime has the standard form

$$\begin{aligned} ds^{2}= & {} -e^{2\nu (r)} dt^{2} + e^{2\lambda (r)} dr^{2} + r^{2}(d\theta ^{2}\nonumber \\{} & {} + \sin ^{2}{\theta } d\phi ^2 +\sin ^{2}{\theta } \sin ^{2}{\phi ^2} d\psi ), \end{aligned}$$
(5)

in coordinates (\(x^i = t,r,\theta ,\phi ,\psi \)). By considering the comoving fluid velocity as \(u^a=e^{-\nu }\delta _0^a\), the Einstein–Maxwell–Gauss–Bonnet (EMGB) field equation (3) yields the following set of independent equations in view of the metric (5),

$$\begin{aligned}{} & {} \!\!\!\kappa \rho + E^2\nonumber \\{} & {} \quad = -\frac{3}{e^{4\lambda }r^3} \Bigg [4\alpha \lambda ' +re^{2\lambda }-re^{4\lambda }- r^2 e^{2\lambda }\lambda ' -4\alpha e^{2\lambda }\lambda '\Bigg ],\nonumber \\ \end{aligned}$$
(6)
$$\begin{aligned}{} & {} \!\!\!\kappa p_r - E^2 \nonumber \\{} & {} \quad = \frac{3}{e^{4\lambda }r^3} \Big [-re^{4\lambda }+ \Big (r^2 \nu ' +r +4\alpha \nu '\Big )e^{2\lambda } -4\alpha \nu '\Big ], \nonumber \\ \end{aligned}$$
(7)
$$\begin{aligned}{} & {} \!\!\!\kappa p_t + E^2\nonumber \\{} & {} \quad = \frac{1}{e^{4\lambda }r^2} \Big [- e^{4\lambda }- 4\alpha \nu ''+ 12 \alpha \nu ' \lambda ' -4 \alpha (\nu ')^2\Big ]\nonumber \\{} & {} \qquad +\frac{1}{e^{2\lambda }r^2} \Big [1- r^2 \nu ' \lambda ' +2r \nu ' -2r \lambda ' +r^2(\nu ')^2 \Big ] \nonumber \\{} & {} \qquad +\frac{1}{e^{2\lambda }r^2} \Big [r^2 \nu '' -4\alpha \nu '\lambda ' + 4\alpha (\nu ')^2 +4\alpha \nu ''\Big ],\nonumber \\ \end{aligned}$$
(8)
$$\begin{aligned}{} & {} \kappa \sigma = \frac{2}{r^2} e^{-\lambda /2} (r^2 E)', \end{aligned}$$
(9)

where \(\rho \), \(p_r\) and \(p_t\) respectively denote the matter density, radial and transverse pressure of the fluid. Here E is the electric field intensity, \(\sigma \) is the proper charge density and \(\kappa = 8\pi \). Note that a \(\prime \) denotes the differentiation with respect to the radial coordinate r. If q(r) represents the total charge contained within the \(5-\) D sphere of radius r, then it can be defined by the relativistic Gauss law as

$$\begin{aligned} q(r) = 2 \pi ^2 \int _0^r \sigma r^3 e^{\lambda } dr. \end{aligned}$$
(10)

4 Solution of the field equations

To solve the above field equations (6)–(8) we utilize the following ansatz

$$\begin{aligned} e^{\lambda (r)}= 1 + ar^2 + br^4, e^{\nu (r)}= & {} C^2 e^{B r^2}, \end{aligned}$$
(11)

where abBC are constants. These metric potentials conform to the well-known Tolman–Kuchowicz [9, 10] spacetime.

Using this Tolman–Kuchowicz ansatz given in Eq. (11), the field equations (6)–(8) can be rewritten as,

$$\begin{aligned} \kappa \rho + E^2= & {} \frac{3}{r^3 \Psi ^4}\Big [-\frac{8 \alpha r (a + 2 b r^2)}{\Psi } \nonumber \\{} & {} \quad + 8 \alpha r (a + 2 b r^2) \Psi \nonumber \\{} & {} \quad {+} 2 r^3 (a {+} 2 b r^2) \Psi {-} r \Psi ^2 {+} r \Psi ^4)\Big ] \end{aligned}$$
(12)
$$\begin{aligned} \kappa p_r - E^2= & {} \frac{3}{r^3 \Psi ^4}\Big [-8 \alpha B r + (r \nonumber \\{} & {} \quad + 8 \alpha B r + 2 B r^3) \Psi ^2 - r \Psi ^4\Big ] \end{aligned}$$
(13)
$$\begin{aligned} \kappa p_t + E^2&{=}&\frac{1}{\Psi ^5}\Big [48 \alpha B (a {+} 2 b r^2) \nonumber \\{} & {} \quad {+} 8 \alpha B (a {-} 2 B {+} b r^2) \Psi \nonumber \\{} & {} \quad {-} 4 \Big (a {-} 2 B {+} 2 a \alpha B {+} A_1 r^2\Big ) \Psi ^2 {-} (a {+} b r^2) \Psi ^4 \nonumber \\{} & {} \quad {-} \Psi ^3 \Big (a {+} 2 B {+} b r^2 {-} 4 B^2 (4 \alpha + r^2)\Big )\Big ] \end{aligned}$$
(14)

The anisotropic factor \(\Delta = p_t - p_r\) assumes the following form

$$\begin{aligned} \Delta= & {} \frac{1}{4\pi \Psi ^5} \Big [24 \alpha B (a + 2 b r^2) - 8 \alpha B (a + B + b r^2) \Psi \nonumber \\{} & {} - 2 (a - 2 B + 8 a \alpha B + A_2 r^2) \Psi ^2 + (a + b r^2) \Psi ^4 \nonumber \\{} & {} + \Psi ^3 \Big (a + b r^2 + 2 B (-2 + 4 \alpha B + B r^2)\Big )\Big ]-\frac{E^2}{4\pi } \nonumber \\ \end{aligned}$$
(15)

where,

$$\begin{aligned} \Psi= & {} (1 + a r^2 + b r^4),\\ A_1= & {} -a B + b (2 + 6 \alpha B),\\ A_2= & {} -a B + 2 b (1 + 6 \alpha B) \end{aligned}$$

Along with TK-metric we also assume that the radial pressure \(p_r\) is related to the matter density \(\rho \) by a linear equation of state,

$$\begin{aligned} p_r= & {} \beta \rho - \gamma \end{aligned}$$
(16)

where \(\beta \) and \(\gamma \) are positive constants.

Adding Eqs. (9) and (13) we get,

$$\begin{aligned} \rho + p_r= & {} \frac{1}{4\pi \Psi ^5} \Big [3 \Big (a + B + (2 b + a B) r^2 + b B r^4\Big ) \nonumber \\{} & {} \times \Big (1 + (4 \alpha + r^2) (a + b r^2) (1 + \Psi )\Big )\Big ] \end{aligned}$$
(17)

Solving Eq. (17) with the help of Eq. (16), the matter density(\(\rho \)) and radial pressure(\(p_r\)) are obtained as,

$$\begin{aligned} \rho= & {} \frac{1}{(1 + \beta )} \bigg [\gamma + \frac{1}{4 \pi \Psi ^5}\bigg (3 \Big (a + B \nonumber \\{} & {} + (2 b + a B) r^2 + b B r^4\Big )\nonumber \\{} & {} \times \Big (1 + (4 \alpha + r^2) (a + b r^2) (1 + \Psi )\Big )\bigg )\bigg ] \end{aligned}$$
(18)
$$\begin{aligned} p_r= & {} \frac{1}{4(1 + \beta )} \bigg [-4\gamma + \frac{1}{\pi \Psi ^5}\nonumber \\{} & {} \times \bigg (3\beta \Big (a + B + (2 b + a B) r^2 + b B r^4\Big )\nonumber \\{} & {} \times \Big (1 + (4 \alpha + r^2) (a + b r^2) (1 + \Psi )\Big )\bigg )\bigg ] \end{aligned}$$
(19)

By using the expression of \(\rho \) in Eq. (6) the expression for the electric field intensity is obtained as,

$$\begin{aligned} E^2= & {} \frac{3}{r^3 \Psi ^4}\Big [-\frac{8 \alpha r (a + 2 b r^2)}{\Psi } + 8 \alpha r (a + 2 b r^2) \Psi \nonumber \\{} & {} + 2 r^3 (a + 2 b r^2) \Psi - r \Psi ^2 + r \Psi ^4)\Big ] \nonumber \\{} & {} -\frac{8\pi }{(1 + \beta )} \bigg [\gamma + \times \frac{1}{4 \pi \Psi ^5}\bigg (3 \Big (a + B \nonumber \\{} & {} + (2 b + a B) r^2 + b B r^4\Big ) \nonumber \\{} & {} \times \Big (1 + (4 \alpha + r^2) (a + b r^2) (1 + \Psi )\Big )\bigg )\bigg ] \end{aligned}$$
(20)

Consequently the expression for the transverse pressure \(p_t\) is obtained as,

$$\begin{aligned} p_t= & {} \frac{1}{8\pi \Psi ^5}\bigg [48 \alpha B (a + 2 b r^2) + 8 \alpha B (a - 2 B + b r^2) \Psi \nonumber \\{} & {} - 4 \Big (a - 2 B + 2 a \alpha B + A_1 r^2\Big ) \Psi ^2 - (a + b r^2) \Psi ^4 \nonumber \\{} & {} - \Psi ^3 \Big (a + 2 B + b r^2 - 4 B^2 (4 \alpha + r^2)\Big )\bigg ] - \frac{E^2}{8\pi } \nonumber \\ \end{aligned}$$
(21)

5 Exterior spacetime and boundary condition

In order to determine the constant parameters i.e., abB,  and C for our proposed model it is necessary to match the interior space-time solution in a smooth way with an appropriate static and spherically symmetric exterior vacuum Schwarzschild solution. Since here we are investigating the interior anisotropic solution in 5-D Einstein–Gauss–Bonnet gravity, the most suitable and appropriate static exterior vacuum Schwarzschild solution is proposed by Boulware–Deser [65]. This Einstein–Gauss–Bonnet–Schwarzschild solution is expressed by the following line element:

$$\begin{aligned} ds^2= & {} -\mathcal{F}(r)dt^2 + \frac{dr^2}{\mathcal{F}(r)} \nonumber \\{} & {} + r^{2}\big (d\theta ^{2} + \sin ^{2}{\theta } d\phi ^2 +\sin ^{2}{\theta } \sin ^{2}{\phi ^2} d\psi ^2\big ) \end{aligned}$$
(22)

where \(\mathcal{{F}}(r) = K + \frac{r^2}{4\alpha }\left( 1 - \sqrt{1 + \frac{8\alpha M}{r^4} - \frac{8\alpha Q^2}{3r^6}}\right) \). The quantities M is the gravitational mass, Q represents the charge of the fluid as determined by an isolated observer at spatial infinity and K is an arbitrary constant.

Using continuity of the metric functions and their derivatives, namely \(g_{rr}\), \(g_{tt}\) and \(\frac{\partial g_{tt}}{\partial r}\) across the boundary \(r=R\) we get,

$$\begin{aligned}{} & {} \frac{1}{1 + aR^2 + bR^4} = \mathcal{{F}}(R), \end{aligned}$$
(23)
$$\begin{aligned}{} & {} C^2 e^{BR^{2}} = \mathcal{{F}}(R), \end{aligned}$$
(24)
$$\begin{aligned}{} & {} 2BRC^2 e^{BR^{2}} = \frac{-4 \sqrt{3} \alpha Q^2 + 3R^6 \Big (Q_1- \sqrt{3} \Big )}{6 \alpha R^5 Q_1}. \end{aligned}$$
(25)

where, \(Q_1=\sqrt{3 - \frac{8 \alpha (Q^2 - 3 M R^2)}{R^6}}\)

Now by solving Eq. (23), we obtain the expression for b as a function of \(\alpha \) and a as,

$$\begin{aligned} b= & {} \frac{12 \alpha (1 - K - a K R^2) + R^2 (1 + a R^2)(Q_2 -3)}{12 \alpha K R^4 + 3 R^6 - Q_2 R^6}\nonumber \\ \end{aligned}$$
(26)

where, \(Q_2=\sqrt{9 - \frac{24 \alpha (Q^2 - 3 M R^2)}{R^6}}\)

Now from the condition \(p_r(r = R) = 0\) we get,

$$\begin{aligned} 0= & {} \frac{1}{4(1 + \beta )} \bigg [-4\gamma + \frac{1}{\pi \Psi _R^5}\nonumber \\{} & {} \times \bigg (3\beta \Big (a + B + (2 b + a B) R^2 + b B R^4\Big )\nonumber \\{} & {} \times \Big (1 + (4 \alpha + R^2) (a + b R^2) (1 + \Psi _R)\Big )\bigg )\bigg ] \end{aligned}$$
(27)

where, \(\Psi _R=(1 + a R^2 + b R^4)\) At the center of the star the electric field is obtained as,

$$\begin{aligned} E^2(0)= & {} \frac{ 6 a (1 - 8 \alpha B + 2 \beta + 8 a \alpha \beta ) -6 B - 8 \gamma \pi }{1 + \beta } \end{aligned}$$
(28)

We know from regularity of electric charge that the electric field vanishes at the center of the fluid configuration, \(E^2(r=0)=0\). Thus by simultaneously solving the equations \(p_r(r = R) = 0\) and \(E^2(r=0)=0\), we obtain the expressions for B and \(\gamma \) as functions of \(\alpha , \beta \), a and b as,

$$\begin{aligned} B= & {} \Bigg [\Psi _R^4 \bigg (a + 2 a \beta + 8 a^2 \alpha \beta \nonumber \\{} & {} - \frac{1}{\Psi _R^5} \Big [\beta \Big (a + 2 b R^2\Big ) \Big (1 + (4 \alpha + R^2) \nonumber \\{} & {} \times (a + b R^2) (1 + \Psi _R)\Big )\Big ]\bigg )\Bigg ] \Biggm / \Bigg [8 a^5 \alpha R^8 + \nonumber \\{} & {} {\times } (1 {+} b R^4)^4 {+}4 a^3 R^4 \Big (1 {+} b R^4\Big ) \Big (R^2 {+} 12 \alpha (1 {+} b R^4)\Big ) \nonumber \\{} & {} + a^4 R^6 \Big (R^2 + 32 \alpha (1 + b R^4)\Big )+\beta \Big (1 + b R^2 (4 \alpha \nonumber \\{} & {} {+} R^2)(2 {+} b R^4)\Big ){+}2 a \Big (1 {+} b R^4\Big ) \Big (R^2 \big (\beta + 2 (1 + b R^4)^2\big ) \nonumber \\{} & {} +4 \alpha \big (\beta + (1 + b R^4)^3\big )\Big ) +a^2 R^2 \Big (R^2 \big (\beta +\nonumber \\{} & {} \times 6 (1 + b R^4)^2\big )+4 \alpha \big (\beta + 8 (1 + b R^4)^3\big )\Big )\Bigg ], \end{aligned}$$
(29)
$$\begin{aligned} \gamma= & {} \Bigg [3 \beta \bigg (2 a (1 + 4 a \alpha ) (1 + \beta ) \nonumber \\{} & {} + \Big [2 b + a \Big (a + 16 \alpha b + 2 a (1 + 4 a \alpha ) \beta \Big )\Big ]\nonumber \\{} & {} \times R^2 + a b \Big (1 + (2 + 8 a \alpha ) \beta \Big ) R^4\bigg )\nonumber \\{} & {} \times \bigg (1 + (4 \alpha + R^2) (a + b R^2) (1+\Psi _R)\bigg )\Bigg ] \Biggm / \Bigg [4 \pi \Psi _R \nonumber \\{} & {} \times \bigg (8 a^5 \alpha R^8 + (1 + b R^4)^4 + 4 a^3 R^4 (1+ b R^4) \nonumber \\{} & {} \big (R^2 + 12 \alpha (1 + b R^4)\big )+a^4 R^6 \big (R^2 + 32 \alpha (1 + b R^4)\big ) \nonumber \\{} & {} +\beta \big (1 + b R^2 (4 \alpha + R^2) (2 + b R^4)\big )+2 a (1 + b R^4)\nonumber \\{} & {} \times \Big [R^2 \big (\beta +2 (1 + b R^4)^2\big )+4 \alpha \big (\beta + (1 + b R^4)^3\big )\Big ] \nonumber \\{} & {} {+}a^2 R^2 \Big [R^2 \big (\beta {+} 6 (1 {+} b R^4)^2\big ) {+}4 \alpha \big (\beta {+} 8 (1 {+} b R^4)^3\big )\Big ]\bigg )\Bigg ] \nonumber \\ \end{aligned}$$
(30)

Now by solving Eq. (24), we obtain the expression for C in terms of B as,

$$\begin{aligned} C= & {} e^{-\frac{BR^{2}}{2}} \mathcal{{F}}(R), \end{aligned}$$
(31)

Here we have used the approximated mass and radius of the compact star candidate EXO 1785-248 to determine the values of bCB and \(\gamma \). To design a realistic stellar model, we fix the values of \(\beta \) and a as \(\beta =0.25\) and \(a=0.031\) with \(K=0.29\) so as to obtain physical validity. Using these determined constants, we will now discuss the physical characteristics of our obtained solution.

Fig. 1
figure 1

Variation of metric functions \(e^{\lambda }\) and \(e^{\nu }\) with respect to r for EXO 1785-248

6 Physical analysis of the present charged model

The model must satisfy the following regularity and reality requirements within the stellar configuration in order to be a viable, regular, and stable charged anisotropic compact stellar model with a certain radius. The behavior of anisotropic solutions of our compact stellar model is investigated through graphical analysis of metric potentials, matter variables, energy conditions, causality conditions, Herrera’s cracking approach, adiabatic index, compactness factor, and redshift parameters.

6.1 Regularity of metric co-efficient

In the survey of relativistic compact stars, the presence of singularities is recognized as a crucial problem. With this in mind, we are investigating the nature of the metric constituents in the core of these compact relativistic stars. For the solutions to be physically realizable [35], the metric constituents inside the compact stars must be regular and positive. From Eq. (11), we can see that

$$\begin{aligned} \frac{d}{dr}\left[ e^{\nu }\right] {=}2BC^2 r e^{B r^2},~~\frac{d^2}{dr^2}\left[ e^{\nu }\right] {=}\left( 1{+}2 r^2\right) e^{B r^2}. \end{aligned}$$
(32)

This gives \(\frac{d}{dr}\left[ e^{\nu }\right] _{r=0}=0\) and \(\frac{d^2}{dr^2}\left[ e^{\nu }\right] _{r=0}>0\) at the center. We can also notice in Eq. (11) that the other metric element ensures the form \(\left[ e^{\lambda }\right] _{r\ne 0}=1+O(r^2)\) near the center. Therefore, the metric components considered are non-singular at \(r = 0\) and monotonically increasing. They thus satisfy all the conditions required to be physically acceptable which can be verified from Fig. 1.

6.2 Regularity of pressure and density

To reinforce the physical validity of our solution, the central values of the other physical quantities, namely matter density, and pressure must also be finite and non-singular to show their finiteness at the center. In this context, we found the central values of the physical quantities at the center \(r = 0\). Firstly, the central density is obtained as,

$$\begin{aligned} \rho _c=\rho (r=0)= & {} \frac{3 (1 + 8 a \alpha ) (a + B) + 4 \gamma \pi }{4 (1 + \beta ) \pi }, \end{aligned}$$
(33)

and secondly, the expression for central pressure is obtained as,

$$\begin{aligned} p_c= & {} p_r(r=0)= \frac{3 (1 + 8 a \alpha ) (a + B)\beta - 4 \gamma \pi }{4 (1 + \beta ) \pi }. \end{aligned}$$
(34)

The radial and tangential pressures are equal and always positive at the center, where \(r = 0\). A graphical representation of the requirements of the star enables for testing if they are always satisfied.

Fig. 2
figure 2

(Left) matter density (\(\rho \)), (middle) radial pressure (\(p_r\)) and (right) tangential pressure (\(p_t\)) are plotted against the radial distance r

Fig. 3
figure 3

Density and pressure gradients: (left) \(\frac{d\rho }{dr}\), (middle) \(\frac{dp_r}{dr}\) and (right) \(\frac{dp_t}{dr}\) are shown against the radial distance r

Fig. 4
figure 4

(Left) anisotropic factor (\(\Delta \)) and (right) trace profile (\(\frac{p_r+2p_t}{\rho }\)) are plotted against the radial distance r

6.3 Evolution of fluid parameters

Here we explore the viable properties of charged anisotropic compact stellar configuration and describe its evolution graphically. Furthermore, the comparison of our theoretical findings with empirical data could provide strong evidence in favor of the considered 5-D EMGB model. We start by analyzing some realistic characteristics of the stellar configurations such as the matter density, radial and lateral pressures along with their derivatives, the anisotropy factor, and the trace profile through graphs. We acknowledge that due to the extremely dense stellar profile, the matter contents should be higher in the stellar interior. In this respect, we have shown in Fig. 2 that the behavior of the physical parameters, namely \(\rho \), \(p_r\) and \(p_t\) is positive and decreases monotonically towards the stellar surface, which shows a very compact profile of the considered stellar configuration. Then, we analyzed the density and pressure gradients viz., \({d\rho }/{dr}\), \({dp_r}/{dr}\), \({dp_t}/{dr}\) and demonstrated that their behaviors are negative and regular, which ensures the presence of an intensive stellar object in the 5-D EMGB model, as illustrated in Fig. 3. It’s worth noting that the matter variables have high values compared to the GTR.

An interesting key factor when analyzing the matter configuration is the pressure anisotropy, whose direction relies on the pressure components. When \(\Delta = p_t - p_r < 0\), the anisotropy is negative, indicating that the pressure is oriented internally, while when \(\Delta = p_t - p_r > 0\), the anisotropy is positive, indicating that the pressure is oriented externally. The graphical visualization of the anisotropy factor \(\Delta \) is yielded in Fig. 4 (left panel), which shows that the current stellar model has a positive anisotropy factor \(\Delta \), where \(p_{t}>p_{r}\) then \(\Delta >0\). Therefore, the stellar structure is disclosed to a repulsive force that offsets the gravitational gradient, this phenomenon enables the production of a more compact stellar configuration. The radial and transverse pressures coincide at the center, i.e., \(\Delta \) vanishes at \(r=0\). Additionally, the radial and transverse pressure values diverge with increasing radius, which causes the anisotropy to keep moving in the direction of the surface of the spherical stellar configuration. Besides, Fig. 4 (right panel) demonstrates that the trace profile i.e., (\(\frac{p_r+2p_t}{\rho }\)) is positive with increasing behavior throughout the interior of the object. This result advocates the hefty profile of stellar matter variables, thereby representing compact environments of the considered stellar configuration.

6.4 Electric field

It is generally recognized that the regularity of the electric charge must be effectively zero at the center and positive for \(r > 0\), which aids in avoiding gravitational collapse. To confirm this regularity, we have presented in Fig. 5 (left panel), the trend in the electric field. In this context, we notice that the electric field vanishes at the stellar core and is positive throughout the stellar configuration, but it takes a maximum value within the stellar configuration at \(r\approx 5.5\) km instead of the stellar surface. It is well-known that the stellar core can become unstable under the effect of strong electric fields. On the other hand, quasi-static equilibrium states can be generated by the presence of charges up to \(10^{20}\) coulombs. Due to pair production within the stellar configuration caused by very high charge densities and extremely strong electric fields, the core of the stellar configuration becomes unstable. Next, Fig. 5 (right panel) illustrates how the charge density behaved for the hypothetical stellar configuration. The charge density is consequently seen to be non-singular at the stellar configuration’s center, decreases monotonically to the stellar configuration’s surface layer, and attains a non-zero value at the stellar frontier.

Fig. 5
figure 5

(Left) total charge (\(E^2\)) and (right) charge density (\(\sigma \)) are shown against the radial distance r

Fig. 6
figure 6

Variation of energy conditions with respect to the radial distance r

6.5 Energy conditions

An ordinary matter can be distinguished from an exotic fluid on the basis of the energy conditions (ECs) on matter variables. These restrictions give detailed information about the physical viability of the solutions. Strong, weak, null, and dominant energy conditions (SEC, WEC, NEC, and DEC) for charged stellar configuration are given by the following inequalities,

$$\begin{aligned}{} & {} SEC:\rho +p_r+2p_t+\frac{E^{2}}{4\pi }\ge 0, \end{aligned}$$
(35)
$$\begin{aligned}{} & {} WEC: \rho +p_r\ge 0,~~ \rho +p_t+\frac{E^{2}}{4\pi }\ge 0 \end{aligned}$$
(36)
$$\begin{aligned}{} & {} NEC:\rho +\frac{E^{2}}{8\pi }\ge 0, \end{aligned}$$
(37)
$$\begin{aligned}{} & {} DEC:\rho -p_r+\frac{E^{2}}{4\pi }\ge 0, ~~ \rho -p_t\ge 0. \end{aligned}$$
(38)

Figure 6 illustrates the graphical behavior of these energy conditions which shows that our system is consistent with all these ECs. This guarantees that the charged matter that composes our stellar model is realistic and physically viable.

6.6 Stability of the stellar model

In this section, we will investigate the stability of our stellar model by using the two methods given by (i) causality condition via Herrera’s cracking concept and (ii) determining the relativistic adiabatic index.

6.6.1 Causality condition via Herrera’s cracking concept

A very important condition to be a physically acceptable stellar model is the causality condition, which states that the square of the radial sound velocity (\(v_r^2 = \frac{dp_r}{d\rho }\)) and that for tangential sound velocity (\(v_t^2 = \frac{dp_t}{d\rho }\)) for anisotropic compact object should be less than unity everywhere [69], i.e.,

$$\begin{aligned} 0< v_r^2= & {} \frac{dp_r}{d\rho }< 1 \nonumber \\ 0< v_t^2= & {} \frac{dp_t}{d\rho } < 1 \end{aligned}$$
(39)
Fig. 7
figure 7

Components of sound velocity: (left) \(v_r^2\) is plotted against r, (middle) \(v_t^2\) is shown against the radial distance r and (right) the stability factor \(|v_t^2 - v_r^2| \) is plotted against r

In other words, these conditions state that the velocity components of sound must be less than the speed of light. Since we have assumed a linear equation of state for radial pressure \(p_r\), then from Eq. (16), we obtain \(v_r ^2 = \beta \). Therefore, the radial velocity component is constant throughout the stellar model and totally depends on parameter \(\beta \), while tangential velocity component varies with parameter \(\alpha \). The expression of \(v_t ^2\) in EMGB gravity is highly non-linear and complicated that has to be analyzed numerically. From Fig. 7, it is very clear that the values of all velocity components lie within [0, 1].

On the other hand, Herrera et al. [66,67,68] proposed the cracking concept for self-gravitating compact stellar model by considering perfect fluid and anisotropic matter distributions. Following this concept, we have checked the cracking condition \(|v_t^2 - v_r^2| \le 1\) and thus from Fig. 7 we find that the present compact stellar model is potentially stable by satisfying both the causality conditions and the Herrera’s cracking concept.

6.6.2 Relativistic adiabatic index

The adiabatic index, which measures the stiffness of the matter, is crucial for understanding the dynamical stability of a relativistic compact object. Chandrasekhar first proposed the dynamical stability of stellar systems against infinitesimal radial adiabatic perturbation [72]. In his pioneering work, he predicted that for stability of a stellar system the value of adiabatic index \(\Gamma \) should be greater that 4/3. Several researchers have tested the predictions of Chandrasekhar for both isotropic and anisotropic stellar objects [73,74,75,76].

The adiabatic index is defined as,

$$\begin{aligned} \Gamma =\frac{\rho +p_r}{p_r}v_r^2. \end{aligned}$$
(40)

We have successfully plotted the behaviour of the adiabatic index \(\Gamma \) in Fig. 8 which shows that \(\Gamma \) is greater than 4/3 for our proposed model. This confirms the stability of this stellar system.

6.7 Hydrostatic equilibrium via modified TOV equation

The four different forces, namely gravitational force, hydrostatics force, electric force and anisotropic force are acting in our present model. In this section, we will investigate the hydrostatic equilibrium of our proposed model via the modified Tolman–Oppenheimer–Volkoff (TOV) equation under different forces. To analyze, we write the general form of the modified TOV equation as follows:

$$\begin{aligned} -\frac{M_G(r)(\rho +p_r)}{r}e^{\nu -\lambda }-\frac{dp_r}{dr}+\frac{3}{r}(p_t-p_r)+\sigma Ee^{\lambda }=0, \end{aligned}$$
(41)

proposed by Tolman–Oppenheimer–Volkoff and named as TOV equation.

Fig. 8
figure 8

Behavior of the adiabatic index \(\Gamma \) as a function of the radial distance r

Where \(M_G(r)\) is the gravitational mass within the radius r derived from the Tolman–Whittaker formula and the Einstein’s field equations and is defined by

$$\begin{aligned} M_G(r)=\frac{1}{2}re^{\lambda -\nu }\nu '. \end{aligned}$$
(42)

Using the expression for \(M_G(r)\) in Eq. (41), we get (Fig. 9)

$$\begin{aligned} -\frac{\nu '}{2}(\rho +p_r)-\frac{dp_r}{dr}+\frac{3}{r}(p_t-p_r)+\sigma Ee^{\lambda }=0. \end{aligned}$$
(43)
Fig. 9
figure 9

Variations of different forces, such as the gravitational force \(F_g\), hydrostatic-gradient force \(F_h\), anisotropic force \(F_a\) and electric force \(F_e\) respectively versus radial coordinate r for different values of \(\alpha \)

The above expression may also be written as

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

where \(F_g, F_h\), \(F_a\), and \(F_e\) represent the gravitational, hydrostatic-gradient, anisotropic and electric force respectively given by the following expression.

$$\begin{aligned} F_g= & {} -\frac{\nu '}{2}(\rho +p_r) \end{aligned}$$
(45)
$$\begin{aligned} F_h= & {} -\frac{dp_r}{dr}\end{aligned}$$
(46)
$$\begin{aligned} F_a= & {} \frac{3}{r}(p_t-p_r)\end{aligned}$$
(47)
$$\begin{aligned} F_e= & {} \sigma Ee^{\lambda }. \end{aligned}$$
(48)

6.8 Some physical implications of the solutions for a toy stellar model

we can readily measure the mass function inside the radius R by computing the integral connected directly to the density level using the following definition,

$$\begin{aligned} m(R)=4\pi \int ^R_0{\bigg (\rho +\frac{q^2}{8\pi \,r^4}\bigg )r^2\,dr}+\frac{Q^2}{2R},~~~ \end{aligned}$$
(49)

conversely employing the metric function suggested by

$$\begin{aligned} m(R)=\frac{R}{2}\Big (1-e^{-2\lambda (R)}+\frac{Q^2}{R^2}\Big ). \end{aligned}$$
(50)

On the other hand, using the formula suggested by Böhmer and Harko [70], it is easy to determine the lower and upper limits of the mass–radius ratio,

$$\begin{aligned} \frac{Q^{2}\left( 18\,R^{2}{+}Q^{2}\right) }{2\,R^{2}\left( 12\,R^{2}+Q^{2}\right) } \le \frac{{M}}{R}\le \frac{2}{9}{+} \frac{3Q^{2}+2R\sqrt{R^{2}+3Q^{2}}}{9R^{2}},\nonumber \\ \end{aligned}$$
(51)

In addition, one may get the effective mass for the distribution of charged matter by,

$$\begin{aligned} M_{\text {eff}} =4\pi \int _{0}^{R}\left( {\rho }{+}\frac{q^{2}}{8\pi \,r^4}\right) r^{2}dr {=}\frac{R}{2}\left[ 1-e^{-2\lambda (R)}\right] . \end{aligned}$$
(52)

We also signify compactification for the effective mass-to-radius ratio, u, which is given as follows,

$$\begin{aligned} u=\frac{M_{\text {eff}}}{R}. \end{aligned}$$
(53)

This serves as the basis for evaluating the surface redshift function \(z_s\), which is stated as,

$$\begin{aligned} z_s=\left( 1-2u\right) ^{-\frac{1}{2}}-1. \end{aligned}$$
(54)
Fig. 10
figure 10

Variation of (I) mass function, (II) compactness factor, (III) gravitational redshift, and (IV) surface redshift versus radial coordinate r for the compact object for different values of \(\alpha \)

Table 1 Comparative study of lower bound, mass-radius ratio, compactness, upper bound, and surface red-shift of the stellar toy model for different values of \(\alpha \)

These four quantities’ behaviors, namely, mass function, compactness factor, gravitational redshift, and surface redshift, are displayed in Fig. 10. The graph demonstrates that each physically significant variable meets the criteria of a realizable stellar configuration. It should be noted that the mass function at the center is guaranteed to be regular. We can also see that the three quantities, namely mass function, compactness factor, and surface redshift are monotonically increasing functions, but the quantity: gravitational redshift is a monotonically decreasing function as a function of the radius r and also all these quantities are positive inside the stellar body. In particular, the plot demonstrates that the mass-radius ratio and its lower and upper limits for the compact stellar candidate under consideration in this research comply completely with the criteria listed in Table 1, which may be confirmed in [70]. However, the authors [70, 71] contend that the surface redshift of an anisotropic fluid sphere is hypothesized to be less than \(z_s\le 5\) or \(z_s\le 5.211\). Hence, under these restrictions, the surface redshift is fulfilled everywhere within the stellar configuration, which demonstrates the viability of our stellar model.

Moreover, we analyzed whether the charged matter is realistic or exotic based on various constraints applicable to EoS components such as \(0\le w_r<1,\;\;and\;\;0<w_t<1\). These matter-related constraints should be maintained for a realistically charged and uncharged matter composition. The EoS has the following mathematical forms,

$$ \begin{aligned} w_r = \frac{p_r}{\rho }\quad \& \quad w_t = \frac{p_t}{\rho }. \end{aligned}$$
(55)

It is straightforward to establish that our model of the heavenly objects faithfully reflects the realistic nature of the composition of matter under the radial and transverse components of the EoS. These \( w_r,\;\; \& \;\;w_t\) profiles’ graphs are displayed in Fig. 11. The evolution of radial and transverse pressures versus density is also shown in Fig. 11 for different values of \(\alpha \).

Fig. 11
figure 11

(Left) EoS parameter \(\omega _r\) is shown against the radial distance r, (middle) EoS parameter \(\omega _t\) is shown against the radial distance r, (right) relation between \(p_r\) and \(\rho \), (bottom) relation between \(p_t\) and \(\rho \)

7 Concluding remarks

In this paper, we have extensively explored the viability and stability of a static charged anisotropic fluid sphere consisting of a charged perfect fluid in the framework of 5D EMGB gravity theory. What’s more, we have employed the well-behaved TK ansatz together with a linear EoS of the form \(p_r=\beta \rho -\gamma \), (where \(\beta \) and \(\gamma \) are constants) to generate exact solutions of the EMGB field equations and analyze the effect of the Gauss–Bonnet Lagrangian term \(\mathcal {L}_{GB}\) which is coupled with the Einstein–Hilbert action through the coupling constant \(\alpha \) on the main physical properties of the stellar model.

The eventual model has been thoroughly analyzed to identify whether it conforms to strict regularity and stability conditions. In addition, the causality condition via Herrera’s cracking concept and the relativistic adiabatic index was deemed to be satisfactory. The adherence of the principal features such as energy density, pressure components, anisotropy factor, sound velocity, hydrostatic equilibrium of the stellar system via a modified TOV equation, mass-radius relation, compactness factor, surface redshift with the recognized physical behavior for different values of coupling constant \(\alpha \) has been confirmed by graphical plots using the stated parametric values. Furthermore, our analysis demonstrates that matter configuration attributes and higher dimensional effects are intimately associated. The interior spacetime and the exterior space-time described by the EGB Schwarzschild metric were also matched to settle all integration constants that arose along the way.

This study has shown the meaning and significance of the Gauss–Bonnet Lagrangian term \(\mathcal {L}_{GB}\) which is coupled with the Einstein–Hilbert action through the coupling constant \(\alpha \) together with the TK ansatz and a linear EoS in the development of astrophysical models that harmonize with observed data.