1 Introduction

It is important to describe the physical properties and behaviour of charged localized distributions in relativistic astrophysics. This has a long history in physical theories since such structures model dense stars and astronomical bodies. These have been widely studied in a variety of physical scenarios over the decades. For some comprehensive studies of charged objects in general relativity see the treatments of Murad and Fatema [1, 2], Fatema and Murad [3], Murad [4], Kiess [5] and Ivanov [6, 7]. Fewer results are known in modified gravity theories such as Einstein–Gauss–Bonnet (EGB) gravity. The introduction of higher order curvature terms, together with the electromagnetic effects, leads to field equations which are difficult to integrate. However particular charged stars in EGB gravity have been generated by Hansraj [8], Bhar and Govender [9] and Banerjee et al. [10]. Such solutions of the combined EGB and Maxwell equations should match to the suitable exterior spacetimes of Boulware and Deser [11] and Wiltshire [12] to produce a charged stellar model. Exact solutions of the charged EGB equations may also be used to study a variety of physical phenomena. For example Sharif and Abbas [13] considered the dynamics of charged radiating collapse in EGB gravity demonstrating that the Gauss–Bonnet terms affect the role of collapse. It is important to note that the Gauss–Bonnet term corrects undesirable physical features that can arise in conventional Einstein stellar models [8].

For neutral matter with isotropic pressures in EGB gravity, the fundamental equation governing the behaviour of gravity is the condition of pressure isotropy. Stellar models satisfying this requirement have been found in [14,15,16,17,18,19,20,21]. In the presence of the electromagnetic field the condition of pressure isotropy is adapted to include the presence of the charge. The presence of charge changes the behaviour of the gravitational field and allows for a wide class of exact solutions to the field equations. Therefore in our treatment the charged condition of pressure isotropy is central to our investigation. This is a necessary condition to describe an isotropic charged self-gravitating body in EGB gravity. Two features of our approach are noteworthy. Firstly, the new charged condition of pressure isotropy is a simple generalization of the neutral case. Secondly, the connection to general relativity is easy to make as most of the known Einstein stellar models have isotropic pressures, both neutral and charged. Clearly much more general behaviour is allowed, with greater freedom in the analytical forms of the gravitational potentials, if anisotropic pressures are permitted.

It is our intention to develop an algorithm that may be utilized to find new charged exact solutions in EGB gravity. The idea is to extend this approach from general relativity to the charged EGB equations. In general relativity certain solution generating algorithms have been developed over time; these are contained in the papers [22,23,24,25,26,27,28]. The higher order curvature terms and charge have a profound impact on the charged condition of pressure isotropy in the EGB case. Naicker et al. [29] developed an EGB algorithm in N dimensions for neutral and static spherically symmetric metrics. We show in this treatment that a similar algorithm may be generated in the presence of the electromagnetic field. The charged condition of pressure isotropy is shown to be an Abelian differential equation of the second kind. It can be transformed to canonical form using a transformation suggested by Polyanin and Zaitsev [30]. We demonstrate that general solutions exist to the fundamental equation which is not the case for neutral matter. Particular charged exact models are found by specifying forms for the electric field and one of the potentials which contain neutral EGB models found earlier. It is the presence of the electromagnetic field that permits wider classes of solutions. Note that, in a different approach, Maharaj et al. [31] used an existing solution to generate a new exact EGB solution in their algorithm.

2 Charged EGB gravity

We first introduce the necessary quantities related to the electromagnetic field. The Faraday tensor \({{\varvec{F}}}\) is defined in terms of the electromagnetic potential \({{\varvec{A}}}\) by

$$\begin{aligned} F_{a b}=A_{b;a}-A_{a;b}. \end{aligned}$$
(1)

We note that the tensor \({{\varvec{F}}}\) is skew-symmetric. The electromagnetic matter tensor \({{\varvec{E}}}\) is composed of the Faraday tensor and the metric tensor, and is written as

$$\begin{aligned} E_{a b}=\frac{1}{{\mathscr {A}}_{N-2}}\left( F_{a c}F_{b}{}^{{}c}-\frac{1}{4}g_{a b}F_{c d}F^{c d}\right) , \end{aligned}$$
(2)

where \({\mathscr {A}}_{N-2}\) is the total surface area of the \((N-2)\)-sphere denoted by

$$\begin{aligned} {\mathscr {A}}_{N-2}=\frac{2 \pi ^{\frac{N-1}{2}}}{\varGamma \left( \frac{N-1}{2}\right) }. \end{aligned}$$
(3)

In the above \(\varGamma (\dots )\) is the gamma function. The electromagnetic field is governed by Maxwell’s equations. These fundamental equations are expressed covariantly as

$$\begin{aligned} F_{a b;c} + F_{bc;a} + F_{c a;b}= & {} 0, \end{aligned}$$
(4a)
$$\begin{aligned} F^{a b}{}_{{ };b}= & {} {\mathscr {A}}_{N-2}J^{a}. \end{aligned}$$
(4b)

In the above \(J^{a}\) is the current density defined by

$$\begin{aligned} J^{a}=\sigma u^{a}, \end{aligned}$$
(5)

for a non-conducting fluid, and \(\sigma \) is the proper charge density.

The energy momentum tensor for neutral matter is defined by

$$\begin{aligned} T_{a b}=(\rho + p)u_{a}u_{b} + p g_{a b}. \end{aligned}$$
(6)

In the above, \(\rho \) represents the energy density, p represents the isotropic pressure and \({{\varvec{u}}}\) is the comoving fluid velocity which is unit and timelike \((u^{a}u_{a}=-1, u^{a}=e^{-\nu }\delta ^a{{}}_{0}).\) The total energy momentum tensor \({{\mathscr {T}}}\) is then given by

$$\begin{aligned} {\mathscr {T}}_{ab}=T_{ab}+E_{ab}. \end{aligned}$$
(7)

The Gauss–Bonnet action, a modification of the Einstein–Hilbert action, is required to generate the EGB field equations in any spacetime dimension. Interestingly, this Gauss–Bonnet action contains quadratic curvature terms which yield field equations that are second order and quasilinear in the highest derivative. The Lovelock tensor \({{\varvec{H}}}\) is expressed by

$$\begin{aligned} H_{a b}= & {} g_{a b}L_{G B}-4RR_{a b} + 8R_{a c}R^c{}_{{} b} + 8R^{c d}R_{a c b d}\nonumber \\{} & {} -4R_{a}{}^{{}c d e} R_{b c d e}, \end{aligned}$$
(8)

and the Gauss–Bonnet term \(L_{G B}\) is given by

$$\begin{aligned} L_{G B} = R^{2} + R_{a b c d} R^{a b c d} - 4R_{c d}R^{c d}. \end{aligned}$$
(9)

The EGB field equations for charged matter are derived in the form

$$\begin{aligned} G_{a b} - \frac{\alpha }{2} H_{ab} = \kappa _{N} {{\mathscr {T}}}_{a b}. \end{aligned}$$
(10)

In the above, \(G_{a b}\) is the Einstein tensor, \(\alpha \) is the Gauss–Bonnet parameter, and \(\kappa _{N}\) is the gravitational coupling constant defined by

$$\begin{aligned} \kappa _{N}=\frac{2 \left( N-2\right) \pi ^{\frac{N-1}{2}} G}{c^{4}\left( N-3\right) \varGamma \left( \frac{N-1}{2}\right) }. \end{aligned}$$
(11)

If \(N=4,\) then we obtain \(\kappa \left( =\kappa _{4}\right) =\frac{8\pi G}{c^4}\) as the appropriate limit in general relativity. When the matter distribution contains electric charge, we must consider the contribution of the electromagnetic field to the total energy momentum tensor \({{\mathscr {T}}}.\) For a charged gravitating body we need to solve the EGB field equations (10) together with Maxwell’s equations (4).

3 Field equations

The interior spherically symmetric static stellar manifold in N dimensions has the metric

$$\begin{aligned} ds^2=-e^{2\nu (r)} dt^2 + e^{2\lambda (r)} dr^2 + r^2 d \varOmega ^{2}_{N-2}, \end{aligned}$$
(12)

where \(\nu (r)\) and \(\lambda (r)\) are the gravitational potentials that are arbitrary functions of r. The \((N-2)\)-sphere is given by

$$\begin{aligned} d\varOmega ^{2}_{N-2}=\sum _{i=1}^{N-2}\left[ \prod _{j=1}^{i-1} \sin ^2({\theta _{j}})\right] (d\theta _{i})^{2}. \end{aligned}$$
(13)

For charge we select the electromagnetic potential \({{\varvec{A}}}\) in the form

$$\begin{aligned} A_{a}= & {} \left( \varPhi (r), 0, 0,\ldots ,0\right) , \end{aligned}$$
(14)

which is usually the choice made when studying static spheres in general relativity. We then get the Faraday tensor component

$$\begin{aligned} F^{0 1}= e^{-2(\nu +\lambda )}\varPhi '(r)=e^{-\left( \nu +\lambda \right) }E(r). \end{aligned}$$
(15)

Hence we obtain the following form for the electrostatic field intensity

$$\begin{aligned} E(r)=e^{-(\nu +\lambda )}\varPhi '(r). \end{aligned}$$
(16)

Then the static spherically symmetric metric (12), the electromagnetic potential (14) and the matter distribution (7) lead to the charged EGB field equations. If we equate the curvature and the matter components using the definition (10), we obtain the EGB field equations in N dimensions. These are expressed by

$$\begin{aligned}{} & {} \!\!\kappa _{N}\left( \rho {+}\frac{E^{2}}{2 {\mathscr {A}}_{N{-}2}}\right) =\frac{\left( N{-}2\right) }{r^{4}e^{4\lambda }}\left[ r^{3}e^{2\lambda } \lambda '{+} \frac{\left( N-3\right) r^{2}e^{4\lambda }}{2}\right. \nonumber \\{} & {} \qquad {-}\frac{\left( N-3\right) r^{2}e^{2\lambda }}{2}{+} \alpha \left( N-3\right) \left( N-4\right) \left( e^{2\lambda }{-}1\right) \nonumber \\{} & {} \qquad \left. \times \left( 2r\lambda ' + \frac{\left( N-5\right) \left( e^{2\lambda }-1\right) }{2}\right) \right] , \end{aligned}$$
(17a)
$$\begin{aligned}{} & {} \!\!\kappa _{N}\left( p-\frac{E^{2}}{2 {\mathscr {A}}_{N-2}}\right) =\frac{\left( N-2\right) }{r^{4}e^{4\lambda }}\left[ r^{3}e^{2\lambda }\nu '+\frac{\left( N-3\right) r^{2}e^{2\lambda }}{2}\right. \nonumber \\{} & {} \qquad -\frac{\left( N-3\right) r^{2}e^{4\lambda }}{2}+ \alpha \left( N-3\right) \left( N-4\right) \left( e^{2\lambda }-1\right) \nonumber \\{} & {} \qquad \left. \times \left( 2r\nu ' - \frac{\left( N-5\right) \left( e^{2\lambda }-1\right) }{2}\right) \right] , \end{aligned}$$
(17b)
$$\begin{aligned}{} & {} \!\!\kappa _{N}\left( p+\frac{E^{2}}{2{\mathscr {A}}_{N-2}}\right) \nonumber \\{} & {} \quad =\frac{1}{r^{2}e^{2 \lambda }}\left[ \frac{\left( N-3\right) \left( N-4\right) }{2}+ r^{2}\nu '' \right. \nonumber \\{} & {} \qquad + r^{2}\nu '^{2} -r^{2}\nu '\lambda ' + \left( N-3\right) r\left( \nu '-\lambda '\right) \nonumber \\{} & {} \qquad \left. + 2\alpha \left( N-3\right) \left( N-4\right) \bigg (\nu ''+\nu '^{2}-\nu '\lambda '\bigg )\right] \nonumber \\{} & {} \qquad + \frac{\left( N-3\right) \left( N-4\right) }{r^{2}e^{4\lambda }}\nonumber \\{} & {} \qquad \times \bigg [6\alpha \nu '\lambda '-\frac{e^{4\lambda }}{2}-2\alpha \left( \nu ''+\nu '^{2}\right) \bigg ]\nonumber \\{} & {} \qquad + 2 \alpha \left( N-3\right) \left( N-4\right) \nonumber \\{} & {} \qquad \bigg [\frac{\left( N-5\right) }{r^{3}e^{4\lambda }}\left( e^{2\lambda }-1\right) \left( \nu '- \lambda '\right) \bigg ]\nonumber \\{} & {} \qquad -\frac{\alpha \left( N-3\right) \left( N-4\right) \left( N-5\right) \left( N-6\right) }{2r^{4}e^{4\lambda }}\left( e^{2\lambda }-1\right) ^{2},\nonumber \\ \end{aligned}$$
(17c)
$$\begin{aligned}{} & {} \sigma =\frac{e^{-\lambda } \left( r^{\left( N-2\right) }E\right) ' }{r^{\left( N-2\right) }{\mathscr {A}}_{N-2}}. \end{aligned}$$
(17d)

Note that primes represent differentiation with respect to the variable r. Then the combined field equations describe the gravitational behaviour of a charged gravitating fluid in EGB gravity in N dimensions.

If we set \(E=0\) then we obtain the neutral EGB field equations of Naicker et al. [29]. Note that the system (17) contains several cases that arise in general relativity and EGB gravity: spacetime dimensions \(N=4,\) \(N\ge 5,\) neutral and charged matter. This is reflected in Table 1. Our investigation allows for a comprehensive treatment of all the cases.

We now apply the transformation

$$\begin{aligned} e^{2\nu (r)} =y^{2}(x) ,\quad e^{-2\lambda (r)} = Z(x) ,\quad x = r^2, \end{aligned}$$
(18)
Table 1 Fluids with isotropic pressures in general relativity and EGB gravity

first introduced by Durgapal and Bannerji [32] in general relativity, to simplify the system (17). The charged EGB field equations can then be recast as

$$\begin{aligned}{} & {} \!\!\!\kappa _{N}\!\left( \rho {+}\frac{E^{2}}{2 {\mathscr {A}}_{N{-}2}}\right) =\left( N{-}2\right) \left[ \frac{\left( N{-}3\right) \left( 1{-}Z\right) {-}2x\dot{Z}}{2x}\right. \nonumber \\{} & {} \qquad \left. {+} \frac{\alpha \left( N{-}3\right) \left( N{-}4\right) \left( 1{-}Z\right) }{2 x^{2}}\left( {-}4x\dot{Z}{+} \left( N{-}5\right) \left( 1{-}Z\right) \right) \!\right] \!,\nonumber \\ \end{aligned}$$
(19a)
$$\begin{aligned}{} & {} \!\!\!\kappa _{N}\!\left( p-\frac{E^{2}}{2 {\mathscr {A}}_{N-2}}\right) =\left( N-2\right) \left[ \frac{2Z\dot{y}}{y}+ \frac{\left( N-3\right) \left( Z-1\right) }{2x}\right. \nonumber \\{} & {} \qquad \left. {+} \alpha \left( N{-}3\right) \!\left( N{-}4\right) \left( 1{-}Z\right) \left( \frac{4Z\dot{y}}{x y}{-}\frac{\left( N{-}5\right) \left( 1{-}Z\right) }{2 x^2}\right) \!\right] \!,\nonumber \\ \end{aligned}$$
(19b)
$$\begin{aligned}{} & {} \!\!\kappa _{N}\left( p+\frac{E^{2}}{2 {\mathscr {A}}_{N-2}}\right) =\frac{2}{y}\left[ 2 x Z \ddot{y}+ x \dot{Z} \dot{y}+ \left( N-2\right) \dot{y} Z\right] \nonumber \\{} & {} \qquad {+} \left( N{-}3\right) \left[ \dot{Z}{+} \frac{\left( N{-}4\right) \left( Z{-}1\right) }{2x}\right] \nonumber \\{} & {} \qquad {+}\alpha \left( N{-}3\right) \left( N{-}4\right) \left[ \frac{4\dot{Z}\dot{y} \left( 1{-}3Z\right) }{y}{+} \frac{8Z\left( 1{-}Z\right) \ddot{y}}{y}\right. \nonumber \\{} & {} \qquad {+}\frac{4\left( N-4\right) Z\left( 1-Z\right) \dot{y}}{ x y} + \frac{2\left( N-5\right) \dot{Z}\left( 1-Z\right) }{x}\nonumber \\{} & {} \qquad \left. -\frac{\left( N-5\right) \left( N-6\right) \left( 1-Z\right) ^{2}}{2 x^{2}}\right] , \end{aligned}$$
(19c)
$$\begin{aligned}{} & {} \sigma ^{2}=\frac{ Z \left[ 2 x^{\frac{(N-1)}{2}}\dot{E} + \left( N-2\right) x^{\frac{(N-3)}{2}}E\right] ^{2}}{({\mathscr {A}}_{N-2})^2 \, x^{\left( N-2\right) }}. \end{aligned}$$
(19d)

Note that dots represent differentiation with respect to the variable x.

If we equate (19b) and (19c) then we find the charged isotropic pressure condition

$$\begin{aligned}{} & {} \!\!4x^{2}Z\left[ x+2\alpha \left( N-3\right) \left( N-4\right) \left( 1-Z\right) \right] \ddot{y}\nonumber \\{} & {} \!\quad + 2x\left[ x^{2}\dot{Z}-2\alpha \left( N-3\right) \left( N-4\right) \left( 2Z\left( 1-Z\right) \right. \right. \nonumber \\{} & {} \!\quad \left. \left. -x\left( 1-3Z\right) \dot{Z}\right) \right] \dot{y}+\left. \bigg [\left( N-3\right) \left( x\dot{Z}-Z+1\right) \right. \nonumber \\{} & {} \!\quad \left. \times \left( x + 2\alpha \left( N-4\right) \left( N-5\right) \left( 1-Z\right) \right) \right. \nonumber \\{} & {} \!\quad \left. - \frac{\left( N-2\right) }{\left( N-3\right) }xE^{2}\right] y=0. \end{aligned}$$
(20)

The charged condition of pressure isotropy has to be integrated to find an exact model of a charged gravitating sphere. To solve Eq. (20) we need to restrict two of the quantities yZ and E. Note that the case \(N=5\) is special as the term \(2\alpha \left( N-4\right) \left( N-5\right) \left( 1-Z\right) \) vanishes. There is simplification in (20) and most exact solutions found correspond to \(N=5.\) The dimensions \(N\ge 6\) have a dramatic effect and lead to new features absent in the model when \(N=5.\) A choice of the potentials y and Z may lead to a model with unphysical behaviour. Consequently in many investigations, a choice for the electric field is made on physical grounds. For recent examples of this approach see the treatments of Mathias et al. [33], Lighuda et al. [34] and Mafa Takisa et al. [35].

We can summarize our results in the following statements:

Theorem 1

If the electric field E is specified then the condition of pressure isotropy,  a nonlinear second order differential equation,  has to be integrated.

Corollary 1

We can obtain a general form for E without integration if the potentials \(Z=Z_{0}\) and \(y=y_{0}\) are specified.

4 Abelian differential equation

Progress in the integration of (20) can be made if we write it in a particular analytic form. Expression (20) can also be regarded as a first order nonlinear ordinary differential equation in Z. This is given by

$$\begin{aligned}{} & {} \!\!\left. \bigg [2x^{3}\dot{y}+ 4 \alpha \left( N-3\right) \left( N-4\right) x^{2}\dot{y} + \left( N-3\right) x^{2}y \right. \nonumber \\{} & {} \quad \left. + 2\alpha \left( N-3\right) \left( N-4\right) \left( N-5\right) \left( 1-Z\right) xy\right. \nonumber \\{} & {} \!\quad \left. -12\alpha \left( N-3\right) \left( N-4\right) x^{2}\dot{y}Z \bigg ]\right. \dot{Z}\nonumber \\{} & {} \!\quad +2\alpha \left( N-3\right) \left( N-4\right) \left[ 4x\dot{y}-4x^{2}\ddot{y}+ \left( N-5\right) y\right] Z^{2}\nonumber \\{} & {} \!\quad +\bigg [4x^{3}\ddot{y}+8\alpha \left( N-3\right) \left( N-4\right) x^{2}\ddot{y} \nonumber \\{} & {} \!\quad -8\alpha \left( N-3\right) \left( N-4\right) x \dot{y}-\left( N-3\right) xy\nonumber \\{} & {} \!\quad -4\alpha \left( N-3\right) \left( N-4\right) \left( N-5\right) y\bigg ]Z\nonumber \\{} & {} \!\quad +\left. \bigg [\left( N-3\right) x+2\alpha \left( N-3\right) \left( N-4\right) \left( N-5\right) \right. \nonumber \\{} & {} \!\quad \left. -\frac{\left( N-2\right) }{\left( N-3\right) }xE^{2}\right] y=0. \end{aligned}$$
(21)

The above is further identified as an Abel differential equation of the second kind in Z if y and E are specified. It is important to find exact solutions to this equation in order to determine the dynamics of our model. In general (21) is difficult to solve, however it can be simplified by making use of a transformation similar to that in Polyanin and Zaitsev [30]. We now present the new variable

$$\begin{aligned} w= & {} \left( Z-\frac{ \left( N-3\right) \left[ 2\alpha \left( N-4\right) \left( N-5\right) +x\right] y}{2\alpha \left( N-3\right) \left( N-4\right) \left[ 6x\dot{y}+\left( N-5\right) y\right] } \right. \nonumber \\{} & {} \left. -\frac{2x\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}}{2\alpha \left( N-3\right) \left( N-4\right) \left[ 6x\dot{y}+\left( N-5\right) y\right] }\right) W, \end{aligned}$$
(22)

where \(w= w(x)\) and

$$\begin{aligned} W= & {} \exp \left( -\int \frac{\left( 4x\dot{y}-4x^{2}\ddot{y}+ \left( N-5\right) y\right) }{x\left[ 6x\dot{y}+\left( N-5\right) y\right] } \ dx\right) . \end{aligned}$$
(23)

Equation (21) then reduces to the canonical differential equation of the form

$$\begin{aligned} w \dot{w}=F_{1}w + F_{0}, \end{aligned}$$
(24)

where the new functions \(F_{1}\) and \(F_{0}\) depend on the metric potential y,  its derivatives and E. These are expressed by

$$\begin{aligned} F_{1}= & {} \frac{x\left[ y-2\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}\right] }{\alpha \left( N-3\right) \left( N-4\right) \big [6x\dot{y}+\left( N-5\right) y\big ]^{2}}\nonumber \\{} & {} \times \left[ \left( N-3\right) \dot{y}-2x\ddot{y}\right] W, \end{aligned}$$
(25)

and

$$\begin{aligned} F_{0}= & {} x^2 \left( -2y+4\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}\right) \nonumber \\{} & {} \times \left[ \left( N-3\right) y \left( \dot{y}+2\left( x+ 2\alpha \left( N-4\right) \left( N-5\right) \right) \ddot{y}\right) \right. \nonumber \\{} & {} \left. +2\dot{y}\left[ \left( x-4\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}\right. \right. \nonumber \\{} & {} \left. \left. +2x\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \ddot{y}\right] \right] \nonumber \\{} & {} \times \frac{W^2}{2\alpha ^2\left( N-3\right) ^2\left( N-4\right) ^2\left[ 6x\dot{y}+\left( N-5\right) y\right] ^{3}}\nonumber \\{} & {} -\frac{\left( N-2\right) yE^{2} W^2}{2\alpha \left( N-3\right) ^{2}\left( N-4\right) \left[ 6x\dot{y}+\left( N-5\right) y\right] }. \end{aligned}$$
(26)

In order to find a solution for \(w = w(x),\) we must integrate (24) and make appropriate choices for y and E. Since \(F_{1}\) and \(F_{0}\) both depend on an arbitrary function of y in a complicated manner and \(F_{0}\) contains contributions from the electromagnetic field, it will not be possible to find a general solution to (24). However particular solutions do exist.

We summarize our result in the following:

Theorem 2

When \(\alpha \ne 0\) and \(6x\dot{y}+\left( N-5\right) y\ne 0,\) the condition of pressure isotropy is classified as an Abelian differential equation of the second kind in Z,  in N dimensions,  which can be transformed to the canonical form \(w\dot{w}=F_{1}w+F_{0}.\)

Corollary 2

If particular choices for the potential \(y=y_{0}\) and the electromagnetic field \(E=E_{0}\) are made,  then \(w\dot{w}=F_{1}w+F_{0}\) can be solved to find the metric potential \(Z=Z_{0}.\)

Observe that the above result is a generalisation of the model presented in Naicker et al. [29] to include the electromagnetic field; we regain the result by [29] when \(E=0.\) It is indeed interesting that the canonical form (24) is not affected by the electromagnetic field. However it is important to observe that the presence of E leads to a new differential equation. We note that our result provides a solution generating algorithm for the charged EGB field equations which extends the neutral algorithm of [29] to include the electromagnetic field.

4.1 A specific metric

Equation (24) does admit exact solutions. As an example we illustrate a solution to (24) by setting

$$\begin{aligned} y=\sqrt{x}. \end{aligned}$$
(27)

This metric potential was also used by Hansraj and Mkhize [19] when \(N=6\) and by Naicker et al. [29] for arbitrary spacetime dimensions \(N\ge 5,\) for uncharged matter. The integral (23) evaluates to

$$\begin{aligned} W=\frac{1}{x}. \end{aligned}$$
(28)

Then expression (24) now has the form

$$\begin{aligned} w\dot{w}= & {} -\frac{1}{\left( N-2\right) x^{2}}w- \frac{ 2}{ \left( N-2\right) ^{2} x^{3}}\nonumber \\{} & {} -\frac{E^2}{2 \alpha \left( N-3\right) ^2\left( N-4\right) x^2}. \end{aligned}$$
(29)

In order to solve Eq. (29) we must specify a form for the electromagnetic field. We choose a form for E as

$$\begin{aligned} E^{2}=\frac{2A\left( N-3\right) ^2 \left( N-4\right) }{\left( N-2\right) ^2 x}, \end{aligned}$$
(30)

where A is some arbitrary constant. Other forms of E are possible but the chosen form simplifies the integration process. The form for E selected leads to a singularity at the centre so that the model applies to an envelope region away from the centre. Equation (29) then becomes

$$\begin{aligned} w\dot{w}=-\frac{1}{\left( N-2\right) x^{2}}w- \frac{ 2}{ \left( N-2\right) ^{2} x^{3}}-\frac{A}{ \alpha \left( N-2\right) ^2 x^3}. \nonumber \\ \end{aligned}$$
(31)

This equation can be identified as a nonlinear first order differential equation in the variable w(x) which can be simplified further using the substitution

$$\begin{aligned} {\mathscr {W}}(x)= & {} \left( 2+\frac{A}{\alpha }\right) ^{-1}\left( N-2\right) x w(x). \end{aligned}$$
(32)

As a result, we obtain

$$\begin{aligned} \frac{\left( 2+\frac{A}{\alpha }\right) {\mathscr {W}}\, \dot{{\mathscr {W}}}}{\left( 2+\frac{A}{\alpha }\right) {\mathscr {W}}^2 - {\mathscr {W}}-1}= \frac{1}{x}, \end{aligned}$$
(33)

in terms of the new variable \({\mathscr {W}}(x).\) The structure of expression (33) is a separable differential equation which can be solved to obtain

$$\begin{aligned}{} & {} \left[ 2\left( 2+\frac{A}{\alpha }\right) {\mathscr {W}}-1-\sqrt{9+\frac{4A}{\alpha }}\right] ^{1+\left( 9+\frac{4A}{\alpha }\right) ^{-1/2}}\nonumber \\{} & {} \quad \times \left[ 2\left( 2+\frac{A}{\alpha }\right) {\mathscr {W}}-1+\sqrt{9+\frac{4A}{\alpha }}\right] ^{1-\left( 9+\frac{4A}{\alpha }\right) ^{-1/2}}\nonumber \\{} & {} \quad \times \frac{1}{4\left( 2+\frac{A}{\alpha }\right) }=C_{1}x^2, \end{aligned}$$
(34)

where \(C_{1}>0\) represents an integration constant. We can then write Eq. (34) in terms of the variable w(x) in the form

$$\begin{aligned}{} & {} \left[ 2\left( N-2\right) wx-1-\sqrt{9+\frac{4A}{\alpha }}\right] ^{1+\left( 9+\frac{4A}{\alpha }\right) ^{-1/2}}\nonumber \\{} & {} \quad \times \left[ 2\left( N-2\right) wx-1+\sqrt{9+\frac{4A}{\alpha }}\right] ^{1-\left( 9+\frac{4A}{\alpha }\right) ^{-1/2}}\nonumber \\{} & {} \quad \times \frac{1}{4\left( 2+\frac{A}{\alpha }\right) }=C_{1}x^2 , \end{aligned}$$
(35)

using (32).

Therefore we have solved Eq. (31). The solution (35) is provided implicitly. In terms of the potential Z we can obtain the form

$$\begin{aligned}{} & {} \!\!\left[ 2\left( N-2\right) \left( Z-\frac{ \left( N-2\right) x+ 2\alpha \left( N-3\right) \left( N-4\right) ^2 }{2\alpha \left( N-2\right) \left( N-3\right) \left( N-4\right) }\right) \right. \nonumber \\{} & {} \quad \left. -\sqrt{9+\frac{4A}{\alpha }}-1\right] ^{1+\left( 9+\frac{4A}{\alpha }\right) ^{-1/2}}\nonumber \\{} & {} \quad {\times }\left[ 2\left( N{-}2\right) \left( Z-\frac{ \left( N{-}2\right) x{+} 2\alpha \left( N-3\right) \left( N-4\right) ^2 }{2\alpha \left( N-2\right) \left( N-3\right) \left( N-4\right) }\right) \right. \nonumber \\{} & {} \quad \left. +\sqrt{9+\frac{4A}{\alpha }}-1\right] ^{1-\left( 9+\frac{4A}{\alpha }\right) ^{-1/2}}\nonumber \\{} & {} \quad =4\left( 2+\frac{A}{\alpha }\right) C_{1}x^2 . \end{aligned}$$
(36)

Hence the gravitational potential Z is given exactly, containing elementary functions of x for all spacetime dimensions \(N\ge 5.\) The charged condition of pressure isotropy (21) admits the particular exact solutions given by (27), (30) and (36).

Earlier solutions are contained in our general result. When \(A=0\) in expression (36) we obtain, for all \(N\ge 5,\) the solution

$$\begin{aligned} Z= & {} \frac{1}{N-2}\left. \bigg [\left( -1\pm \sqrt{2 C_{1}} x^{3}\right. \right. \nonumber \\{} & {} \left. \left. +\sqrt{\mp 2\sqrt{2C_{1}}x^3 + 2 C_{1} x^6}\right) ^{-\frac{1}{3}} + \left( -1\pm \sqrt{2 C_{1}} x^{3}\right. \right. \nonumber \\{} & {} \left. \left. +\sqrt{\mp 2\sqrt{2C_{1}}x^3 + 2 C_{1} x^6}\right) ^{\frac{1}{3}}+1\right] \nonumber \\{} & {} + \frac{ \left( N-2\right) x+ 2\alpha \left( N-3\right) \left( N-4\right) ^2 }{2\alpha \left( N-2\right) \left( N-3\right) \left( N-4\right) }, \end{aligned}$$
(37)

which is explicit. This regains the neutral solution found by Naicker et al. [29]. The uncharged model of Hansraj and Mkhize [19] with \(N=6\) is a special case of (37). The uncharged solutions generate an explicit form for Z. The electromagnetic field also leads to exact models but its overall effect on Z is that it has to satisfy an implicit equation.

5 Dimension \(N=5\)

Note that the spacetime dimension \(N=5\) leads to simplification in the Abelian differential equation (21) with several terms vanishing. In addition the transformation (22) takes on the simpler form

$$\begin{aligned} w=\left( Z-\frac{\left[ y + \left( x+4\alpha \right) \dot{y} \right] }{12\alpha \dot{y}}\right) W , \end{aligned}$$
(38)

where the function W now has the explicit form

$$\begin{aligned} W= & {} \left( \frac{\dot{y}}{x}\right) ^{\frac{2}{3}}. \end{aligned}$$
(39)

The functions \(F_{1}\) and \(F_{0}\) in (24) can then be written as

$$\begin{aligned} F_{1}= & {} \left( \frac{\dot{y}}{x}\right) ^{\frac{2}{3}}\left[ -\frac{1}{18 \alpha } + \frac{y}{36 \alpha x \dot{y} } +\frac{x\ddot{y} }{18 \alpha \dot{y}} + \frac{2 \ddot{y}}{ 9 \dot{y}}\right. \nonumber \\{} & {} \left. - \frac{y \ddot{y}}{36 \alpha \dot{y}^{2}} -\frac{2}{9 x}\right] , \end{aligned}$$
(40)
$$\begin{aligned} F_{0}= & {} \left( \frac{\dot{y}}{x}\right) ^{\frac{4}{3}}\left[ \frac{y}{432\alpha ^{2} \dot{y}} -\frac{y^{2}\ddot{y} }{216\alpha ^{2} \dot{y}^{3}} -\frac{1}{54 \alpha } +\frac{y}{27\alpha x \dot{y}} \right. \nonumber \\{} & {} \left. +\frac{\ddot{y}}{\dot{y}}\left( \frac{4}{27}+\frac{2x}{27\alpha } + \frac{x^{2}}{108\alpha ^{2}}\right) + \frac{x}{ 216\alpha ^{2}}+ \frac{x y \ddot{y}}{216 \alpha ^{2} \dot{y}^{2}}\right. \nonumber \\{} & {} \left. -\frac{y^{2}}{432 \alpha ^{2} x \dot{y}^{2}}- \frac{4}{27x}+ \frac{y\ddot{y}}{54 \alpha \dot{y}^{2}} - \frac{y E^{2}}{16\alpha \dot{y}}\right] . \end{aligned}$$
(41)

We can observe that the spacetime dimension \(N=5\) is special as integration of the canonical form (24) is now possible and the functions \(F_{1}\) and \(F_{0}\) are expressed in a simpler form.

We now demonstrate an explicit solution to (24) when \(N=5.\) The choice \(y=\frac{1}{2}D_{1}x^{2}+D_{2}\) for the potential and \(E^{2}=bx\) for the electrostatic field intensity in (24) then yields

$$\begin{aligned} w\dot{w}= & {} \left( D_{1}\right) ^{\frac{4}{3}}\left[ \frac{x}{64\alpha ^{2}}+\frac{1}{12\alpha }+\frac{D_{2}}{18\alpha D_{1}x^2}-\frac{D_{2}^2}{144\alpha ^{2}D_{1}^2 x^{3}}\right. \nonumber \\{} & {} \left. -\frac{bx^{2}}{32\alpha }-\frac{D_{2}b}{16\alpha D_{1}}\right] , \end{aligned}$$
(42)

which is a separable differential equation that can be integrated to obtain w and consequently Z. The gravitational potential Z is then provided by

$$\begin{aligned} Z= & {} \left[ \left( \frac{\left( D_{1}\right) ^{ \frac{4}{3}}}{\alpha }\right) \left[ \frac{x^{2}}{64 \alpha }+ \frac{(D_{2})^{2}}{144 \alpha (D_{1})^{2} x^{2}}+ \frac{x}{6}-\frac{D_{2}}{9C_{1} x}\right. \right. \nonumber \\{} & {} \left. \left. -\frac{bx^{3}}{48}-\frac{D_{2}b}{8 D_{1}}\right] + C\right] ^{\frac{1}{2}}\left( \frac{1}{D_{1}}\right) ^{\frac{2}{3}}\nonumber \\{} & {} + \frac{1}{3}+ \frac{x}{8 \alpha }+ \frac{ D_{2}}{12 \alpha D_{1} x}. \end{aligned}$$
(43)

Note that \(D_{1},\) \(D_{2}\) and b are constants. The solution for the potential Z is thus provided explicitly in closed form and is expressed in terms of elementary functions of x. This appears to be a new class of solutions to the charged EGB field equations. When \(b=0,\) we obtain the uncharged case similar to the solution illustrated in Hansraj et al. [17].

6 Exceptional metrics

The transformation given by (22) holds when \(\alpha \ne 0\) and \(6x\dot{y}+ \left( N-5\right) y\ne 0.\) Therefore we need to consider these cases separately.

Firstly we consider the case when \(\alpha =0,\) then the condition of pressure isotropy (21) takes on the form

$$\begin{aligned}{} & {} \left[ 2x^{3}\dot{y}+ \left( N-3\right) x^{2}y \right] \dot{Z} +\left[ 4x^{3}\ddot{y}-\left( N-3\right) xy\right] Z\nonumber \\{} & {} \quad +\left( N-3\right) xy- \frac{\left( N-2\right) }{\left( N-3\right) }xE^{2}y=0. \end{aligned}$$
(44)

This is a first order linear ordinary differential equation in Z which can be solved by making a choice for the potential \(y=y_{0}\) and the electromagnetic field \(E=E_{0}.\) For a recent general treatment of (44) see Komathiraj and Sharma [36]. In particular, if we let \(y=\sqrt{x}\) and use (30) for E,  then (44) has the solution

$$\begin{aligned} Z={\mathscr {B}}x- \left( N-3\right) \frac{\left[ A\left( N-4\right) - \left( N-2\right) x\right] }{\left( N-2\right) ^2 x}, \end{aligned}$$
(45)

where \({\mathscr {B}}\) is a constant of integration. Note that when \(A=0\) (45) reduces to the neutral case in Naicker et al. [29].

Secondly we consider the case

$$\begin{aligned} 6x\dot{y}+\left( N-5\right) y=0. \end{aligned}$$
(46)

We can integrate the above to get

$$\begin{aligned} y=\tilde{C}x^{\frac{5-N}{6}}, \end{aligned}$$
(47)

where \(\tilde{C}\) is an integration constant. This potential y leads to

$$\begin{aligned}{} & {} \!\!-6x\left[ \alpha \left( N-3\right) \left( N-4\right) \left( N-5\right) + \frac{ \left( N-2\right) x}{2}\right] \dot{Z} \nonumber \\{} & {} \!\quad +\alpha \left( N-2\right) \left( N-3\right) \left( N-4\right) \left( N-5\right) Z^{2} \nonumber \\{} & {} \!\quad {-} \left( N{-}11\right) \left[ \frac{\left( N{-}2\right) x}{2}{+}\alpha \left( N{-}3\right) \left( N{-}4\right) \left( N{-}5\right) \right] Z \nonumber \\{} & {} \!\quad -9 \left( N-3\right) \left[ \frac{x}{2}+\alpha \left( N-4\right) \left( N-5\right) \right] \nonumber \\{} & {} \!\quad + \frac{9\left( N-2\right) x E^2 }{2\left( N-3\right) } =0, \end{aligned}$$
(48)

for the isotropy pressure condition (21). We can solve the above equation by specifying a form for the electromagnetic field E. We choose

$$\begin{aligned} E^{2}=\frac{2A\left( N-3\right) ^2 \left( N-4\right) }{\left( N-2\right) ^2 x}. \end{aligned}$$
(49)

Then expression (48) has the form

$$\begin{aligned}{} & {} \!-6x\left[ \alpha \left( N-3\right) \left( N-4\right) \left( N-5\right) + \frac{ \left( N-2\right) x}{2}\right] \dot{Z} \nonumber \\{} & {} \!\quad +\alpha \left( N-2\right) \left( N-3\right) \left( N-4\right) \left( N-5\right) Z^{2} \nonumber \\{} & {} \!\quad {-} \left( N-11\right) \left[ \frac{\left( N-2\right) x}{2}{+}\alpha \left( N{-}3\right) \left( N{-}4\right) \left( N{-}5\right) \right] Z \nonumber \\{} & {} \!\quad -9 \left( N-3\right) \left[ \frac{x}{2}+\alpha \left( N-4\right) \left( N-5\right) \right] \nonumber \\{} & {} \!\quad + \frac{9A \left( N-3\right) \left( N-4\right) }{\left( N-2\right) } =0. \end{aligned}$$
(50)

We show that (50) can be solved.

For the particular spacetime dimension \(N=5,\) expression (50) is a linear differential equation in Z. The solution is given by

$$\begin{aligned} Z=\tilde{C}_{1}x +1 -\frac{A}{3x}. \end{aligned}$$
(51)

Note that \(\tilde{C}_{1}\) is an integration constant, and setting \(A=0\) regains the generalised Einstein static model in EGB theory as expected for the neutral case.

When \(N\ne 5\) then (50) is not linear in Z,  it is a Riccati equation. When \(A=0\) (corresponding to uncharged matter) it reduces to the equation considered by Naicker et al. [29]. When \(A\ne 0,\) other solutions are then possible which we present in Appendix A. It is clear that the spacetime dimension N and the charge parameter A have a profound effect on the dynamics.

7 General cases

The charged condition of pressure isotropy has been transformed to the canonical form (24). We have shown that exact solutions exist by choosing specific functions for y and E,  and then integrating to find Z. We now show that it is possible to find general solutions to (24) without having to make a choice for yZ or E. These new classes of solutions arise by placing restrictions on the functions \(F_{0}\) and \(F_{1}.\) The presence of the electromagnetic field allows for greater freedom and permits these three new classes of solutions to exist. In the absence of charge there is less freedom.

7.1 Case I: \(F_{0}=0\)

We set

$$\begin{aligned} F_{0}=0, \end{aligned}$$
(52)

so that

$$\begin{aligned} F_{0}= & {} 2x^2 \left( -2y+4\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}\right) \nonumber \\{} & {} \times \left[ \left( N-3\right) y \left( \dot{y}+2\left( x+ 2\alpha \left( N-4\right) \left( N-5\right) \right) \ddot{y}\right) \right. \nonumber \\{} & {} \left. +2\dot{y}\left[ \left( x-4\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}\right. \right. \nonumber \\{} & {} \left. \left. +2x\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \ddot{y}\right] \right] \nonumber \\{} & {} -\alpha \left( N-2\right) \left( N-4\right) yE^{2} \left[ 6x\dot{y}+\left( N-5\right) y\right] ^2=0. \nonumber \\ \end{aligned}$$
(53)

From Eq. (53) we can obtain a general form for the electric field intensity E as

$$\begin{aligned} E= & {} \bigg (2x^2 \left( -2y+4\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}\right) \nonumber \\{} & {} \times \left[ \left( N-3\right) y \left( \dot{y}+2\left( x+ 2\alpha \left( N-4\right) \left( N-5\right) \right) \ddot{y}\right) \right. \nonumber \\{} & {} \left. +2\dot{y}\left[ \left( x-4\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}\right. \right. \nonumber \\{} & {} \left. \left. +2x\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \ddot{y}\right] \right] \nonumber \\{} & {} \times \frac{1}{\alpha \left( N-2\right) \left( N-4\right) y\left[ 6x\dot{y}+\left( N-5\right) y\right] ^2}\bigg )^{\frac{1}{2}}. \end{aligned}$$
(54)

Equation (24) is now written as

$$\begin{aligned} \dot{w} =F_{1}, \end{aligned}$$
(55)

which is identified as a separable differential equation. We integrate Eq. (55) to obtain w,  and consequently Z in the form

$$\begin{aligned} Z= & {} \left[ \int \frac{x\left[ y-2\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}\right] }{\alpha \left( N-3\right) \left( N-4\right) \big [6x\dot{y}+\left( N-5\right) y\big ]^{2}}\right. \nonumber \\{} & {} \left. \times \left[ \left( N-3\right) \dot{y}-2x\ddot{y}\right] W \,\,dx + \,C\bigg ]\right. \frac{1}{W}\nonumber \\{} & {} +\frac{\left( N-3\right) \left[ 2\alpha \left( N-4\right) \left( N-5\right) +x\right] y}{2\alpha \left( N-3\right) \left( N-4\right) \left[ 6x\dot{y}+\left( N-5\right) y\right] }\nonumber \\{} & {} +\frac{2x\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}}{2\alpha \left( N-3\right) \left( N-4\right) \left[ 6x\dot{y}+\left( N-5\right) y\right] }, \end{aligned}$$
(56)

where C is a constant of integration.

Hence we have solved the charged condition of pressure isotropy when \(F_{0}=0.\) There is freedom of choice for the metric function y. Any choice \(y=y_{0}\) generates forms for E and Z via (54) and (56) respectively. We can state our result as

Proposition 1

If \(F_{0}=0\) then a general expression for the electric field E is provided by Eq. (54). Any choice of the potential \(y=y_{0}\) leads to an exact solution for the charged EGB field equations.

7.2 Case II: \(F_{1} = 0\)

We now let

$$\begin{aligned} F_{1} = 0, \end{aligned}$$
(57)

which yields the following constraint

$$\begin{aligned} \left[ y{-}2\left( x{+}2\alpha \left( N{-}3\right) \left( N{-}4\right) \right) \dot{y}\right] \left[ \left( N{-}3\right) \dot{y}{-}2x\ddot{y}\right] = 0.\nonumber \\ \end{aligned}$$
(58)

Equation (58) is a product of a first order linear ordinary differential equation and a second order linear differential equation. The permissible solutions are given by

$$\begin{aligned} y={\left\{ \begin{array}{ll} \tilde{Q}\sqrt{x + 2 \alpha \left( N-3\right) \left( N-4\right) },\\ \frac{ 2B_{1}x^{\frac{N-1}{2}}}{N-1}+ B_{2}, \end{array}\right. } \end{aligned}$$
(59)

where \(\tilde{Q},\) \(B_{1}\) and \(B_{2}\) represent integration constants.

It now remains to find the potential Z if the constraint (57) holds. Equation (24) then has the form

$$\begin{aligned} w \dot{w} =F_{0}, \end{aligned}$$
(60)

which is a separable equation. Integrating we obtain w and then the function Z in the form

$$\begin{aligned} Z= & {} \left( 2\int \bigg (x^2 \left( -2y+4\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}\right) \right. \nonumber \\{} & {} \times \left. \left[ \left( N-3\right) y \left( \dot{y}+2\left( x+ 2\alpha \left( N-4\right) \left( N-5\right) \right) \ddot{y}\right) \right. \right. \nonumber \\{} & {} \left. \left. +2\dot{y}\left[ \left( x-4\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y} \right. \right. \right. \nonumber \\{} & {} \left. \left. \left. +2x\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \ddot{y}\right] \right] \right. \nonumber \\{} & {} \left. \times \frac{W^2}{2\alpha ^2\left( N-3\right) ^2\left( N-4\right) ^2\left[ 6x\dot{y}+\left( N-5\right) y\right] ^{3}}\right. \nonumber \\{} & {} \left. {-}\frac{\left( N{-}2\right) yE^{2} W^2}{2\alpha \left( N{-}4\right) \left( N{-}3\right) ^{2}\left[ 6x\dot{y}{+}\left( N{-}5\right) y\right] }\bigg ) dx {+} C\right) ^{\frac{1}{2}}\frac{1}{W} \nonumber \\{} & {} +\frac{\left( N-3\right) \left[ 2\alpha \left( N-4\right) \left( N-5\right) +x\right] y}{2\alpha \left( N-3\right) \left( N-4\right) \left[ 6x\dot{y}+\left( N-5\right) y\right] }\nonumber \\{} & {} +\frac{2x\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}}{2\alpha \left( N-3\right) \left( N-4\right) \left[ 6x\dot{y}+\left( N-5\right) y\right] }. \end{aligned}$$
(61)

With \(F_{1}=0\) we have integrated the charged condition of pressure isotropy. The form of y in (59) and any choice \(E=E_{0}\) leads to a functional form for Z via (61). This result leads to the statement:

Proposition 2

If \(F_{1}=0\) then two forms for the potential y are possible. The potential Z is given by (61): Any choice of the electric field \(E=E_{0}\) leads to an exact solution of the charged EGB field equations.

7.3 Case III: \(F_{1}=KF_{0}\)

An interesting class of models are possible if \(F_{0}\) and \(F_{1}\) are related. We let the function \(F_{1}\) be proportional to \(F_{0}\) where K is some constant. This gives the condition

$$\begin{aligned} F_{1}= K F_{0}. \end{aligned}$$
(62)

From Eqs. (25), (26) and (62) we obtain

$$\begin{aligned} E= & {} \left. \bigg [x^2 \left( -2y+4\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}\right) \right. \nonumber \\{} & {} \times \left. \left[ \left( N-3\right) y \left( \dot{y}+2\left( x+ 2\alpha \left( N-4\right) \left( N-5\right) \right) \ddot{y}\right) \right. \right. \nonumber \\{} & {} \left. \left. +2\dot{y}\left[ \left( x-4\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}\right. \right. \right. \nonumber \\{} & {} \left. \left. \left. +2x\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \ddot{y}\right] \right] \right. \nonumber \\{} & {} \left. \times \frac{1}{\alpha \left( N-2\right) \left( N-4\right) y\left[ 6x\dot{y}+\left( N-5\right) y\right] ^{2}}\right. \nonumber \\{} & {} \left. -\frac{2\left( N-3\right) x\left[ y-2\left( x+2\alpha \left( N-3\right) \left( N-4\right) \right) \dot{y}\right] }{KW\left( N-2\right) \left( N-4\right) y\left[ 6x\dot{y}+\left( N-5\right) y\right] }\right. \nonumber \\{} & {} \left. \times \left[ \left( N-3\right) \dot{y}-2x\ddot{y}\right] \bigg ]\right. ^{\frac{1}{2}}. \end{aligned}$$
(63)

Therefore the electric field E is specified. On substituting (62) in Eq. (24) we obtain

$$\begin{aligned} w \dot{w} =F_{0}\left( K w + 1\right) , \end{aligned}$$
(64)

which is a separable equation. Integrating we obtain

$$\begin{aligned} \frac{w}{K} - \frac{\ln \left( 1 + K \,w\right) }{K^{2}} = \int F_{0}\,dx + C. \end{aligned}$$
(65)

Note that \(K\ne 0\) and we obtain a class of models different from Case II in Sect. 7.2. In terms of the variable Z we obtain

$$\begin{aligned}{} & {} \frac{1}{K}\left( Z-\frac{ \left[ 2\alpha \tilde{N}\left( N-5\right) +\left( N-3\right) x\right] y }{2\alpha \tilde{N}\left[ 6x\dot{y}+\left( N-5\right) y\right] }\right. \nonumber \\{} & {} \qquad \left. - \frac{ 2x\left( x+2\alpha \tilde{N} \right) \dot{y} }{2\alpha \tilde{N}\left[ 6x\dot{y}+\left( N-5\right) y\right] }\right) W\nonumber \\{} & {} \qquad {-}\frac{1}{K^{2}} \ln \left( 1 {+} K \left( Z{-}\frac{ \left[ 2\alpha \tilde{N}\left( N{-}5\right) {+}\left( N{-}3\right) x\right] y }{2\alpha \tilde{N}\left[ 6x\dot{y}{+}\left( N{-}5\right) y\right] }\right. \right. \nonumber \\{} & {} \qquad \left. \left. - \frac{ 2x\left( x+2\alpha \tilde{N} \right) \dot{y} }{2\alpha \tilde{N}\left[ 6x\dot{y}+\left( N-5\right) y\right] }\right) W\right) \nonumber \\{} & {} \quad =\int \frac{x\left[ y-2\left( x+2\alpha \tilde{N}\right) \dot{y}\right] \left[ \left( N-3\right) \dot{y}-2x\ddot{y}\right] W}{\alpha K\tilde{N}\left[ 6x\dot{y}+\left( N-5\right) y\right] ^{2}} \,\,dx \nonumber \\{} & {} \qquad + \,C, \end{aligned}$$
(66)

where \(\left( N-3\right) \left( N-4\right) =\tilde{N}\) and C is a constant of integration.

We have solved the charged condition of pressure isotropy when \(F_{1}=KF_{0}.\) The integration in (66) can be completed once a functional form for \(y=y_{0}\) is selected. We can state our result as:

Proposition 3

If \(F_{1}=KF_{0}\) then a general expression for the electric field E is given by (63). Any choice for the metric function \(y=y_{0}\) results in an exact solution of the charged EGB field equations.

We have established that three propositions, resulting from restrictions on \(F_{1}\) and \(F_{0},\) that allow for integration, lead to expressions for the first potential Z in terms of the second potential y. A specific choice of y will lead to a functional form for Z. Clearly the choice made for y should simplify the integration and lead to an acceptable model.

8 Matching

The solutions found in this paper may be interpreted as static cosmological models or more realistically as interior descriptions of static charged stars. For a stellar structure there has to be matching at the surface at an exterior gravitational field. In general models, including spherical geometry, the matching conditions are well known and can be written as

$$\begin{aligned} \left( ds^{2}_{-}\right) _{\varSigma }= & {} \left( ds^{2}_{+}\right) _{\varSigma }, \end{aligned}$$
(67a)
$$\begin{aligned} \left( K^{-}_{ab}\right) _{\varSigma }= & {} \left( K^{+}_{ab}\right) _{\varSigma }, \end{aligned}$$
(67b)

across a comoving boundary surface \(\varSigma \) for the line element \(ds^{2}\) and the extrinsic curvature \(K_{a b}.\) The matching conditions (67) hold in general relativity. Several models of static relativistic stars have been found in the past which satisfy the conditions in (67). In EGB gravity the boundary conditions on \(\varSigma \) have the form

$$\begin{aligned}{} & {} \left( ds^{2}_{-}\right) _{\varSigma }=\left( ds^{2}_{+}\right) _{\varSigma }, \end{aligned}$$
(68a)
$$\begin{aligned}{} & {} \left[ K_{ab}-Kh_{ab}\right] ^{\pm }+2\alpha \left[ 3J_{ab}-Jh_{ab}+2\hat{P}_{a b cd}K^{bc}\right] ^{\pm }{=}0,\nonumber \\ \end{aligned}$$
(68b)

as given by Davis [37]. In the above we have

$$\begin{aligned} \hat{P}_{abcd}{=}\hat{R}_{a b c d}{+}2\hat{R}_{b[c}h_{d]a}{-}2\hat{R}_{a[c}h_{d]b}{+}\hat{R}h_{a[c}h_{d]b}, \end{aligned}$$
(69)

where the caret “\(\hat{}\)” indicates quantities associated with the induced metric and \(P_{abcd}\) is the divergence free part of the Riemann tensor. The tensor \(J_{ab}\) is defined by

$$\begin{aligned} J_{ab}= & {} \frac{1}{3}\left( 2KK_{ac}K^c{}_{ {}b}+K_{cd}K^{cd}K_{ab}\right. \nonumber \\{} & {} \left. -2K_{ac}K^{cd}K_{db}-K^{2}K_{ab}\right) , \end{aligned}$$
(70)

and J is its trace.

For a proper distribution of a static star in EGB gravity we need to match an interior solution to an exterior vacuum solution, say the Boulware–Deser metric. In many EGB treatments the matching conditions are taken to be the general relativity equations (67); for an example of this approach see [16]. Such investigations do produce useful physical features of the stellar model but it has to be acknowledged that the resulting structure is incomplete as Eqs. (68) may not be satisfied. However it is difficult to solve (68) in general. In an attempt to circumvent this problem Maurya et al. [38] have suggested that the conservation of energy momentum could be used in the analysis of the boundary conditions. This approach is helpful but the boundary conditions (68) are still not satisfied in general. In an ongoing investigation we are presently studying the general matching of the Boulware–Deser spacetime to the interior static spherically symmetric matter distribution. This will then produce a complete stellar model in EGB gravity.

We now consider the existence of stellar models in EGB gravity using the approach of Maurya et al. [38] for the solutions found in this paper. We expect that the dimension N should affect the matter content and the geometry. The interior spacetime is described by the metric (12), and the exterior spacetime is described by

$$\begin{aligned} ds^{2}=-F(r)dt^{2}+\frac{1}{F(r)}dr^{2}+r^{2}d\varOmega ^{2}_{N-2}, \end{aligned}$$
(71)

where

$$\begin{aligned} F(r)= & {} 1+\frac{r^{2}}{2\alpha \left( N-3\right) \left( N-4\right) }\left. \bigg (1 -\left. \bigg (1+4\alpha \left( N-4\right) \right. \right. \nonumber \\{} & {} \left. \left. \times \left( \frac{2M}{r^{N-1}}-\frac{\kappa _{N}Q^{2}}{\left( N-2\right) {\mathscr {A}}_{N-2}r^{2N-4}}\right) \right) ^{\frac{1}{2}}\right) , \end{aligned}$$
(72)

which is the Boulware–Deser–Wiltshire metric in N spacetime dimensions. In the above M is the gravitational mass of the hypersphere and Q is its charge. Note that in the limit as \(\alpha \rightarrow 0\) we regain the Reissner–Nordstrom solution in N dimensions.

The first fundamental form is the direct matching of the line elements (12) and (72) at the boundary \(r={\mathscr {R}}.\) This yields

$$\begin{aligned} \varepsilon _{1}^{2}= & {} 1+\frac{{\mathscr {R}}^{2}}{2\alpha \left( N-3\right) \left( N-4\right) }\left. \bigg (1 -\left. \bigg (1+4\alpha \left( N-4\right) \right. \right. \nonumber \\{} & {} \left. \left. \times \left( \frac{2M}{{\mathscr {R}}^{N-1}}-\frac{\kappa _{N}Q^{2}}{\left( N-2\right) {\mathscr {A}}_{N-2}{\mathscr {R}}^{2N-4}}\right) \right) ^{\frac{1}{2}}\right) , \end{aligned}$$
(73)
$$\begin{aligned} \varepsilon _{2}= & {} \frac{1}{4{\mathscr {R}}^{2}}\left( 1{+}\frac{{\mathscr {R}}^{2}}{2\alpha \left( N{-}3\right) \left( N{-}4\right) }\left. \bigg (1 {-}\left. \bigg (1{+}4\alpha \left( N{-}4\right) \right. \right. \right. \nonumber \\{} & {} \left. \left. \left. \times \left( \frac{2M}{{\mathscr {R}}^{N-1}}{-}\frac{\kappa _{N}Q^{2}}{\left( N-2\right) {\mathscr {A}}_{N-2}{\mathscr {R}}^{2N-4}}\right) \right) ^{\frac{1}{2}}\right) \right) , \end{aligned}$$
(74)

where \(\varepsilon _{1}=y({\mathscr {R}}^2)\) and \(\varepsilon _{2}=Z({\mathscr {R}}^2).\) The gravitational mass M is given by

$$\begin{aligned} M= & {} \left[ \frac{\left( N-3\right) }{2}\left. \bigg ({\mathscr {R}}^{N-3}\left( 1-\varepsilon _{2}\right) \right. \right. \nonumber \\{} & {} \left. \left. +\frac{\kappa _{N}Q^{2}}{\left( N-2\right) \left( N-3\right) {\mathscr {A}}_{N-2}{\mathscr {R}}^{N-3}}\right. \right. \nonumber \\{} & {} \left. \left. +\alpha \left( N-3\right) \left( N-4\right) {\mathscr {R}}^{N-5}\left( 1-\varepsilon _{2}\right) ^{2}\bigg )\right. \bigg ]\right. , \nonumber \\= & {} M_{E}+M_{GB}, \end{aligned}$$
(75)

where

$$\begin{aligned} M_{E}= & {} \frac{\left( N-3\right) }{2}\left. \bigg ({\mathscr {R}}^{N-3}\left( 1-\varepsilon _{2}\right) \right. \nonumber \\{} & {} \left. +\frac{\kappa _{N}Q^{2}}{\left( N-2\right) \left( N-3\right) {\mathscr {A}}_{N-2}{\mathscr {R}}^{N-3}}\right) , \end{aligned}$$
(76)

and

$$\begin{aligned} M_{GB}=\frac{1}{2}\left( \alpha \left( N-3\right) ^{2}\left( N-4\right) {\mathscr {R}}^{N-5} \left( 1-\varepsilon _{2}\right) ^{2}\right) . \end{aligned}$$
(77)

In the above \(M_{E}\) and \(M_{GB}\) are the masses corresponding to the contributions from general relativity and Einstein–Gauss–Bonnet gravity respectively. It is clear that the dimension N affects the value of the gravitational mass M.

The second fundamental form implies that the radial pressure vanishes at the boundary \(r={\mathscr {R}}.\) From (19b) we obtain

$$\begin{aligned}{} & {} \left( N-2\right) \left[ \frac{2\varepsilon _{2}\varepsilon _{3}}{\varepsilon _{1}}+ \frac{\left( N-3\right) \left( \varepsilon _{2}-1\right) }{2{\mathscr {R}}^{2}}\right. \nonumber \\{} & {} \quad \left. + \alpha \left( N-3\right) \left( N-4\right) \left( 1-\varepsilon _{2}\right) \left( \frac{4\varepsilon _{2}\varepsilon _{3}}{{\mathscr {R}}^{2} \varepsilon _{1}}\right. \right. \nonumber \\{} & {} \quad \left. \left. -\frac{\left( N-5\right) \left( 1-\varepsilon _{2}\right) }{2 {\mathscr {R}}^{4}}\right) \right] +\frac{\kappa _{N}\varepsilon _{4}^{2}}{2 {\mathscr {A}}_{N-2}}=0, \end{aligned}$$
(78)

where \(\varepsilon _{3}=y'({\mathscr {R}}^2)\) and \(\varepsilon _{4}=E({\mathscr {R}}^2).\) The charge density at \(r={\mathscr {R}}\) is expressed by

$$\begin{aligned} \sigma= & {} \frac{ \sqrt{\varepsilon _{2}} \left[ {\mathscr {R}}^{N-2}E'({\mathscr {R}}^2) + \left( N-2\right) {\mathscr {R}}^{N-3}E({\mathscr {R}}^2)\right] }{({\mathscr {A}}_{N-2}) \, {\mathscr {R}}^{\left( N-2\right) }}. \end{aligned}$$
(79)

The total charge within a radius r of the hypersphere of radius \({\mathscr {R}}\) is given by

$$\begin{aligned} Q{=}\int _{0}^{{\mathscr {R}}} \frac{ \left[ r^{N-2}E'(r^2) + \left( N-2\right) r^{N-3}E(r^2)\right] }{ r^{\left( N-2\right) }} r^{2} dr, \end{aligned}$$
(80)

where Q is the charge as measured by an external observer at infinity. Observe that Eq. (80) generates a restriction on the parameters when the electric field is specified. If E is given by (30) then (80) becomes

$$\begin{aligned} Q=\left[ \frac{2\varepsilon _{5}\left( N-3\right) ^4 \left( N-4\right) }{\left( N-2\right) ^2}\right] ^{\frac{1}{2}} {\mathscr {R}}, \end{aligned}$$
(81)

where we have set \(\varepsilon _{5}=A\) which is a charge parameter. Hence the matching at \(r={\mathscr {R}}\) gives the four restrictions, (73), (74), (78) and (81). Observe that the free parameters are \(\varepsilon _{1},\) \(\varepsilon _{2},\) \(\varepsilon _{3},\) \(\varepsilon _{4},\) \(\varepsilon _{5}\) and \({\mathscr {R}}\) so that we have an algebraic system of four equations with six unknowns. Hence this system always admits a real solution when two unknowns are specified. (Note that Q is defined in terms of \({\mathscr {R}},\) \(\varepsilon _{5}\) and M is given in terms of \({\mathscr {R}},\) \(\varepsilon _{2}\) and Q). It is important to note that Z is given implicitly in general by Eq. (36). When the charge parameter \(A=0\) then an explicit form for Z results which is also the case for the parameters \(\varepsilon _{1}\)\(\varepsilon _{5}.\) When \(A\ne 0\) then the junction conditions have to be solved numerically.

The dimension of spacetime is critical in our analysis. We note that for the spacetime dimension \(N=5\) the junction conditions take on the simpler form

$$\begin{aligned}{} & {} 3\left[ \frac{2\varepsilon _{2}\varepsilon _{3}}{\varepsilon _{1}}+ \frac{\left( \varepsilon _{2}-1\right) }{{\mathscr {R}}^{2}} + 8\alpha \left( 1-\varepsilon _{2}\right) \frac{\varepsilon _{2}\varepsilon _{3}}{{\mathscr {R}}^{2}\varepsilon _{1} }\right] +\frac{2\varepsilon _{5}}{3{\mathscr {R}}^{2}}=0,\nonumber \\ \end{aligned}$$
(82)
$$\begin{aligned}{} & {} Q=\left[ \frac{32\varepsilon _{5} }{9}\right] ^{\frac{1}{2}}{\mathscr {R}}, \end{aligned}$$
(83)

due to the fact that the term \(\frac{\left( N-5\right) \left( 1-\varepsilon _{2}\right) }{2 {\mathscr {R}}^{4}}\) in (78) vanishes. This indicates that the dimension \(N=5\) is a special case. We note that the EGB part of the mass function \(M_{GB}\) in (77) also takes on the simpler form \(M_{GB}=2\alpha (1-\varepsilon _{2})^{2}\) which is independent of \({\mathscr {R}}.\) For \(N\ge 6\) note that \(M_{GB}\) depends on \({\mathscr {R}}.\) The evolution of the static star is therefore different in five dimensions than in higher dimensions. When the dimension of spacetime is \(N=6,\) the junction conditions become

$$\begin{aligned}{} & {} 4\left[ \frac{2\varepsilon _{2}\varepsilon _{3}}{\varepsilon _{1}}+ \frac{3\left( \varepsilon _{2}-1\right) }{2{\mathscr {R}}^{2}}\right. \nonumber \\{} & {} \qquad \left. + 6\alpha \left( 1-\varepsilon _{2}\right) \left( \frac{4\varepsilon _{2}\varepsilon _{3}}{\varepsilon _{1}{\mathscr {R}}^{2} }-\frac{\left( 1-\varepsilon _{2}\right) }{2{\mathscr {R}}^{4}}\right) \right] +\frac{3\varepsilon _{5}}{ 2{\mathscr {R}}^{2}}=0,\nonumber \\ \end{aligned}$$
(84)
$$\begin{aligned}{} & {} Q=\left[ \frac{81\varepsilon _{5} }{4}\right] ^{\frac{1}{2}}{\mathscr {R}}, \end{aligned}$$
(85)

where the term \(\frac{\left( N-5\right) \left( 1-\varepsilon _{2}\right) }{2 {\mathscr {R}}^{4}}\) now comes into effect. We also note that the mass function (77) is greater in six dimensions because of the effect of the \({\mathscr {R}}^{N-5}\) term; for \({\mathscr {R}}>1.\) The charge Q also increases in magnitude, as the spacetime dimension increases, from Eqs. (83) and (85), for \(N=5\) and \(N=6\) respectively.

9 Discussion

We have studied static spherically symmetric models in a higher dimensional charged EGB gravity setting. The matter distribution considered is a perfect fluid, in an electric field, with isotropic pressure. The charged EGB field equations for such a fluid distribution were found for all spacetime dimensions \(N\ge 5.\) We demonstrate that the charged condition of pressure isotropy is an Abelian differential equation of the second kind in Z which is reduced to the canonical form \(w\dot{w}=F_{1}w+F_{0}\) after using a transformation. This generalises the Naicker et al. [29] result to include the electromagnetic field. It is interesting to observe that a solution generating algorithm to this equation exists for all dimensions \(N\ge 5.\) The canonical equation is solved by choosing a specific form for the potential y and the electromagnetic field E. As a result the gravitational potential Z is defined exactly in an implicit manner. An important point to note is that the presence of the electromagnetic field permits an implicit equation in the potential Z. However, if the electromagnetic field vanishes, we regain an explicit exact solution in Z as demonstrated in [29]. Furthermore, three new classes of exact solutions to the charged EGB field equations were generated by placing constraints on the functions \(F_{1}\) and \(F_{0}.\) In the first approach, we set \(F_{0}=0\): this permitted a general expression for E without integration, and any choice for the potential y will yield a functional form for the potential Z. The second approach, \(F_{1}=0,\) yielded two analytic forms for the metric y and any choice for the electromagnetic field E will result in an exact solution for Z. In the third and final constraint, \(F_{1}=KF_{0},\) a general form for the electromagnetic field E is illustrated. As a result the gravitational potential Z can be determined exactly by specifying any form for the metric function y. These families of exact solutions arise due to the presence of charge. Charge allows for a greater degree of freedom which is not the case for neutral models. Other possible exact solutions to the charged EGB condition of pressure isotropy are found when exceptional metrics are considered. The matching conditions in EGB gravity were also considered for our model. A complete stellar model in EGB gravity (and general Lovelock gravity) is not yet known, yet it is still possible to ascertain the existence of a static star in EGB gravity. The higher dimensional interior spherically symmetric spacetime was matched to the exterior vacuum solution of Boulware–Deser and it was shown that the radial pressure vanishes at the boundary of the star as expected. The mass function was also obtained in N dimensions. The dimension N critically affects the geometry of the star as well as its matter distribution.

An important point to note is that our classes of interior models have no general relativity counterpart. These models exist only in EGB gravity. The charged condition of pressure isotropy, an Abel differential equation of the second kind, is reduced to a canonical form which is different from general relativity. This is a nonlinear differential equation (an Abelian differential equation of the second kind) in Z. In general relativity the charged condition of pressure isotropy is a linear differential equation in Z if y is specified. An explicit solution to this Abelian equation for Z,  in tandem with a resolution of the boundary condition from the matching will yield a complete stellar model.