1 Introduction

Compact stellar objects such as white dwarfs and neutron stars are formed in gas and dust clouds during their evolution. The gravitational collapse of massive stars happens when there is insufficient pressure leading the spheres to exhaust all the nuclear fuel required to balance the nuclear force with the gravitational force of attraction [1]. This situation can change the physical behaviour of compact stellar objects. It has been found in [2,3,4] that the subsequent gravitational collapse is influenced by the presence of an electric charge, pressure anisotropy, shear stress, and dimensionality of spacetime. Investigations of Naidu and Govender [5] obtained different temperature profiles when two initially static spheres with the same masses and radii but different pressures undergo the collapsing process. Investigating the behaviour of compact stars provides information about the existence of gravitational interactions in extreme internal matter density and strong gravity. To do this, the Einstein–Maxwell field equations for charged matter distribution are investigated to find exact solutions related to gravitating objects.

The existence of unequal pressure in many astrophysical compact objects is an important phenomenon to consider when investigating the behaviour of these highly gravitating stellar objects. A comprehensive understanding of anisotropic matter is necessary when formulating physically realistic models of compact fluid spheres. In general relativity, the effect of anisotropic pressure on gravitational mass and surface red shift has been extensively investigated [6, 7]. The existence of anisotropic pressure within relativistic fluid spheres is due to the presence of strong gravity and extreme internal matter density [8, 9]. It has been found in [9] that pressure anisotropy on compact stars affects the stability of these objects. Ruderman [10] observed anisotropic behaviour in the nuclear matter when the density is of higher order (\(>10^{15}\mathrm{g/cm}^3\)). Weber [11] identified variations of magnetic field intensity within fluid spheres due to the existence of pressure anisotropy. Usov [12] observed that the presence of pressure anisotropy in relativistic bodies can cause strong electric fields. Dev and Gleiser [13] generated spherical models describing the effect of pressure anisotropy on the structure and properties of compact fluid spheres. Phase transitions and pion condensations in astrophysical bodies can be the source of pressure anisotropy as well [14, 15]. Recently, several spherically symmetric exact models describing the effect of pressure anisotropy on the matter variables have been generated [16,17,18,19,20,21,22,23].

In generating exact solutions to the nonlinear Einstein–Maxwell field equations, a number of approaches have been employed by various researchers. One can find an equation of state relating the matter density with the pressure of the fluid sphere [20, 24,25,26,27]. The technique of embedding lower dimensions into a higher dimensional manifold has been utilized by various researchers [28,29,30,31]. Investigations in [32,33,34] utilized the gravitational decoupling approach to find exact solutions to the field equations. One can choose a form of the gravitational potential on physical considerations to predict the behaviour of the matter variables [35,36,37]. The group theoretical approach on the spacetime manifold has also been adopted in several treatments [38,39,40,41].

In this investigation, we assume that the spacetime manifold admits conformal symmetry. The conformal symmetry provides a deeper insight into studying the geometry of spacetime manifold while taking into account the nonlinear effects of gravity in compact star objects. This gives the basics for adopting this approach for the current investigation. Recently, this approach has been adopted by several researchers for different kinds of symmetries [23, 42,43,44,45,46,47]. In particular, the conformal Killing vector (CKV) is imposed on the spacetime manifold to restrict the gravitational potentials for the purpose of solving the Einstein–Maxwell field equations. This approach is useful in generating astrophysical models with physical applications that can predict the internal structure and behaviour of compact star objects. The CKV restricts the gravitational metric potentials while conformally preserving the metric of spacetime. The CKV provides an equation relating the gravitational potentials which can be solved with the Einstein–Maxwell field equations to generate physically realistic models. Several recent exact models admitting CKV in static spherically spacetime have been generated by various researchers [21, 36, 48,49,50,51]. It is our hope that the approach followed in the current work will generate astrophysical models with physical significance.

2 The mathematical field equations

The gravitational line element for the matter distribution in spherically symmetric spacetime modelling the interior of the relativistic star is given in Schwarzschild coordinates as

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

where \(\nu (r)\) and \(\lambda (r)\) are functions of radial coordinate only defining the static gravitational metric potential functions. The exterior Reissner–Nordstrom spherical line element for the charged gravitating star model is given by

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

where M defines the total mass of the compact star object in radial distance r, and Q is the electric charge quantity. The highly nonlinear Einstein–Maxwell field equations are the appropriate equations when investigating highly dense gravitating stellar bodies. We consider these equations for charged anisotropic fluid spheres. These equations are defined with a comoving, unit and timelike fluid 4-velocity vector \(u^{a}\) given by \(u^{a}={e^{-v}}\delta ^{a}_{0}\). The associated energy momentum tensor describing the charged anisotropic matter distribution is given in the form

$$\begin{aligned} T_{\alpha \beta }= & {} \text{ diag } \left( -\rho - \frac{E^2}{2}, p_{r} - \frac{E^2}{2}, p_{t} + \frac{E^2}{2}, p_{t} + \frac{E^2}{2}\right) , \end{aligned}$$
(3)

where the quantities E, \(\rho\), \(p_{r}\), and \(p_{t}\) represent the electric field intensity, energy density, radial pressure, and the tangential pressure, respectively. For anisotropic spheres, the matter content experiences unequal pressures in radial and tangential directions \((p_r\ne p_t)\).

Using (1) and (2), with the energy momentum equation (3), the Einstein–Maxwell field equations for charged anisotropic stars are given by

$$\begin{aligned} {e^{-2\lambda }}\left( \frac{2\lambda ^\prime }{r}-\frac{1}{r^2}\right) +\frac{1}{r^{2}}= & {} 8\pi \rho +\frac{E^{2}}{2}, \end{aligned}$$
(4a)
$$\begin{aligned} {e^{-2\lambda }}\left( \frac{2\nu ^\prime }{r}+\frac{1}{r^2}\right) -\frac{1}{r^{2}}= & {} 8\pi p_{r}-\frac{E^{2}}{2}, \end{aligned}$$
(4b)
$$\begin{aligned} {e^{-2\lambda }}\left( \nu ^{\prime \prime }+\nu ^{\prime ^{2}}-\nu ^{\prime }\lambda ^{\prime }+\frac{\nu ^{\prime }-\lambda ^{\prime }}{r}\right)= & {} 8\pi p_{t}+\frac{E^{2}}{2}, \end{aligned}$$
(4c)
$$\begin{aligned} \frac{e^{-\lambda }\left( Er^{2}\right) ^\prime }{4\pi r^{2}}= & {} \sigma , \end{aligned}$$
(4d)

where \(\sigma\) is the quantity defining the charge density. The primes \((^\prime )\) mean that the respective functions are differentiated with respect to the radial coordinate r. We are considering geometrized units where the speed of light is taken as unity (\(8 \pi G=c=1\)).

The equation for the pressure anisotropy \(\Delta\) describing the difference in pressures, that is \(\Delta =p_{t}-p_{r}\), is obtained by subtracting equation (4b) from (4c) and given by

$$\begin{aligned} 8\pi \Delta= & {} {e^{-2\lambda }}\left( \nu ^{\prime \prime }+\nu ^{\prime ^{2}}-\nu ^{\prime }\lambda ^{\prime }-\frac{\nu ^{\prime }+\lambda ^{\prime }}{r}\right) +\frac{1-e^{-2\lambda }}{r^2}-E^2. \end{aligned}$$
(5)

When \(\Delta =0\), that is \(p_{t}=p_{r}\), the matter distribution becomes isotropic. In addition, \(E=0\) and \(\Delta =0\) describe perfect fluid neutral spheres.

The equation defining the mass function for a charged sphere with radius r, as given in [36, 52], is defined as

$$\begin{aligned} M(r) = 4\pi \int _{0}^{r}\left( \rho (\omega )+\frac{E^{2}}{8\pi }\right) \omega ^{2} \mathrm{d}\omega . \end{aligned}$$
(6)

3 Exact anisotropic model with conformal symmetry

3.1 Conformal symmetry

The Einstein–Maxwell field equations (4) are highly nonlinear and difficult to solve. To explore exact solutions to these equations, we assume that the spacetime manifold admits conformal symmetry. This helps to simplify these equations. This approach places additional restrictions on the gravitational potentials by adding an extra differential equation which has to be solved in addition to the existing Einstein–Maxwell field equations (4). The conformal Killing vector generates constants of the motion while conformally preserving the metric of spacetime. For the existence of the conformal Killing vector, we have the requirement

$$\begin{aligned} L_\mathbf{{X}}g_{ab}=2\xi g_{ab}, \end{aligned}$$
(7)

where \(g_{ab}\) is the metric tensor field, \(\xi\) is the conformal factor and \(L_\mathbf{{X}}\) is the Lie derivative operator along the vector field \(\mathbf {X}\). The conformal Killing vector \(\mathbf {X}\) and the conformal factor \(\xi\) can either be static or non-static. For our investigation, we follow the treatments in [23, 44, 46] where both the conformal Killing vector and conformal factor are non-static. From the symmetry assumption, we have, respectively, the conformal Killing vector and the conformal factor as

$$\begin{aligned} \mathbf{{X}}= & {} \alpha \left( t,r\right) \frac{\partial }{\partial {t}} + \beta \left( t,r\right) \frac{\partial }{\partial {r}}, \end{aligned}$$
(8a)
$$\begin{aligned} \xi= & {} \xi (t,r). \end{aligned}$$
(8b)

In consequence to the conformal Killing equation (7), the associated Weyl tensor integrability condition is given by

$$\begin{aligned} L_\mathbf{{X}}C^{a}_{bcd}=0, \end{aligned}$$
(9)

where \(C^{a}_{bcd}\) are the components of the Weyl tensor. For the integrability condition (9), the Killing equation (7) simplifies to

$$\begin{aligned} \nu ^{\prime \prime }+(\nu ^{\prime })^{2}-\nu ^{\prime }\lambda ^{\prime }-\frac{\nu ^{\prime }-\lambda ^{\prime }}{r}+\frac{1}{r^2}=\frac{e^{2\lambda }(1+k)}{r^{2}}, \end{aligned}$$
(10)

where k is a constant. Equation (10) is highly nonlinear but has been integrated in general [43, 53, 54], with solution given by

$$\begin{aligned} e^{\nu }= {\left\{ \begin{array}{ll} Ar\exp \left( \sqrt{1+k}\int {\frac{e^\lambda }{r}dr}\right) \\ + Br\exp \left( -\sqrt{1+k}\int {\frac{e^\lambda }{r}dr}\right) , \;\;\;\quad 1+k>0, \\ Ar\int {\frac{e^\lambda }{r}dr} +Br, \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\; \qquad 1+k=0, \\ Ar\exp \left( \sqrt{-\left( 1+k\right) }\int {\frac{e^\lambda }{r}dr}\right) \\ + Br\exp \left( -\sqrt{-\left( 1+k\right) }\int {\frac{e^\lambda }{r}dr}\right) , \;\; 1+k<0, \end{array}\right. } \end{aligned}$$
(11)

where A and B are constants. When \(k=0\), we have the conformally flat spacetime, otherwise \(k\ne 0\).

3.2 New anisotropic solution

We need to find the matter variables and gravitational potentials that describe realistic fluid spheres. We observe that equation (11) relates the gravitational potentials \(e^{\nu }\) and \(e^{\lambda }\). This indicates that when the potential \(e^{\lambda }\) is specified on physical grounds, then we can find the corresponding potential \(e^{\nu }\). Specification is made to the extent that equation (11) can be integrated. The choice of the potential \(e^{\lambda }\) should be finite and free from a central singularity. To get the solution to system (4), we consider the gravitational potential \(e^{\lambda }\) and electric field E with the forms

$$\begin{aligned}&e^{\lambda }=\frac{c\left( 1+\frac{2ar^2}{R^2}\right) }{c-bdr^2}, \end{aligned}$$
(12)
$$\begin{aligned}&E^2=\frac{a^2r^2}{\left( b+R^2r^2\right) ^2}, \end{aligned}$$
(13)

respectively, where a, b, c, d and R are constants, with \(c-bdr^2, b+R^2r^2 \ne 0\) and R being a curvature parameter for the geometry of spacetime. We observe from our choice in (12) that at the stellar centre (\(r=0\)), the potential \(e^{\lambda }=1\). This requirement is necessary for a finite, continuous and regular metric potential function. It can also be noted that the electric field (13) gives \(E=0\) at the stellar centre, which is a physical realistic requirement.

In the present investigation, we consider the cases \(1+k>0\), with \(k=0\) describing the conformally flat geometry, and \(1+k<0\), with \(k=-2\) for the non-conformally flat case. For both cases, with equation (11) and the choice of the potential (12), the corresponding gravitational metric potential \(e^{\nu }\) becomes

$$\begin{aligned} e^{\nu }=\frac{Ar^2h}{(c-bdr^2)^H}+\frac{B(c-bdr^2)^H}{h}, \end{aligned}$$
(14)

where h is a positive constant of integration and

$$\begin{aligned} H=\frac{2ac+bdR^2}{2bdR^2}. \end{aligned}$$

The quantities A and B are constants. We observe from (14) that for some parameters, \(e^{\nu }\ge 0\) at the stellar centre, which is a physical requirement. This indicates that the resulting gravitational potential \(e^{\nu }\) is also regular and finite at the stellar centre.

Using equations (12) - (14) together with the system (4), the matter variables become

$$\begin{aligned} \sigma= & {} \frac{aR^2\left( c-bdr^2\right) \left( 3b+r^2R^2\right) }{4\pi c\left( 2ar^2+R^2\right) \left( b+r^2R^2\right) ^2}, \end{aligned}$$
(15a)
$$\begin{aligned} \rho= & {} \frac{1}{8\pi }\left[ -\frac{a^2r^2}{2\left( b+r^2R^2\right) ^2} + \frac{\left( c-bdr^2\right) R^4F_1}{c^2r^2\left( 2ar^2+R^2\right) ^3}+\frac{1}{r^2}\right] , \end{aligned}$$
(15b)
$$\begin{aligned} p_r= & {} \frac{1}{8\pi }\left[ \frac{-1}{r^2}+\frac{a^2r^2}{2\left( b+r^2R^2\right) ^2}+\left( c-bdr^2\right) ^2\left( c+\frac{2acr^2}{R^2}\right) ^{-2}\right. \nonumber \\&\left. \times \left( \frac{2\left( 2acF_2+F_3\right) }{\left( c-bdr^2\right) R^2F_4}+\frac{1}{r^2}\right) \right] , \end{aligned}$$
(15c)
$$\begin{aligned} p_t= & {} \frac{1}{8\pi }\left[ \frac{-a^2r^2}{2\left( b+r^2R^2\right) ^2}+\frac{1}{c^2\left( 2ar^2+R^2\right) ^3F_4} \left( 8a^3c^2r^4F_4\right. \right. \nonumber \\&\left. \left. +4a^2cr^2R^2\left( F_5+F_6\right) +2aR^4\left( F_7-F_8\right) +\left( F_9+F_{10}\right) R^6\right) \right] , \end{aligned}$$
(15d)
$$\begin{aligned} \Delta= & {} p_t-p_r, \end{aligned}$$
(15e)

where for simplicity we have set

$$\begin{aligned} F_1= & {} \left( 2a\left( 3cr^2+bdr^4\right) -\left( c-5bdr^2\right) R^2\right) ,\\ F_2= & {} \left( Ah^2r^2-B\left( c-bdr^2\right) ^{1+\frac{2ac}{bdR^2}}\right) ,\\ F_3= & {} \left( -bBd(c-bdr^2)^{1+\frac{2ac}{bdR^2}}+Ah^2\left( 2c-bdr^2\right) \right) R^2 , \\ F_4= & {} \left( Ah^2r^2+B\left( c-bdr^2\right) ^{1+\frac{2ac}{bdR^2}}\right) ,\\ F_5= & {} Ah^2r^2(5c-2bdr^2),\\ F_6= & {} B\left( c-bdr^2\right) ^{\frac{2ac}{bdR^2}}\left( c^2+bcdr^2-2b^2d^2r^4\right) ,\\ F_7= & {} Ah^2r^2\left( 4c^2-2bcdr^2+b^2d^2r^4\right) , \\ F_8= & {} B\left( c-bdr^2\right) ^{\frac{2ac}{bdR^2}}\left( 4c^3-10bc^2dr^2 +5b^2cd^2r^4+b^3d^3r^6\right) ,\\ F_9= & {} -bBd\left( c-bdr^2\right) ^{\frac{2ac}{bdR^2}}\left( 4c^2-9bcdr^2+5b^2d^2r^4\right) ,\\ F_{10}= & {} Ah^2\left( 4c^2-8bcdr^2+5b^2d^2r^4\right) . \end{aligned}$$

Using (13) and (15b), the mass function (6) simplifies to

$$\begin{aligned} M(r)= & {} \frac{1}{8}\left[ -\frac{b^2d^2rR^4}{a^2c^2}-\frac{rR^4(2ac+bdR^2)^2}{a^2c^2(2ar^2+R^2)^2} +\frac{2bdrR^4(2ac+bdR^2)}{a^2c^2(2ar^2+R^2)}\right. \nonumber \\&\left. +\frac{a^2br}{R^4(b+r^2R^2)}+\frac{2a^2r}{R^4} - \frac{3a^2\sqrt{b}\arctan {\left( {rR /\sqrt{b}}\right) }}{R^5}+4r \right] . \end{aligned}$$
(16)

4 Known solutions

We have generated a new conformal symmetry class of exact solutions that reduces to several models found by various researchers in the past. The class of exact solutions generated represents compact star models with astrophysical significance. Some charged and uncharged astrophysical models regained for certain parameter settings are outlined in the following cases.

4.1 Case I: \(a=b=c=R=1\), \(d=-1\)

For these values, the gravitational potential \(e^{\lambda }\) becomes

$$\begin{aligned} e^{\lambda }=\frac{1+2r^2}{1+r^2}. \end{aligned}$$

This form of the gravitational potential is a particular form of the neutral anisotropic models generated in [55,56,57], and charged super dense star models generated in [58]. The corresponding metric function \(e^{\nu }\) for this case becomes

$$\begin{aligned} e^{\nu }=Ahr^2\sqrt{1+r^2}+\frac{B}{h\sqrt{1+r^2}}. \end{aligned}$$

4.2 Case II: \(a=0\), \(c=d=1\), \(R\ne 0\)

This case reduces the gravitational potential \(e^{\lambda }\) to

$$\begin{aligned} e^{\lambda }=\frac{1}{1-br^2}. \end{aligned}$$

This is a particular form of the charged anisotropic conformal model generated in [36]. The gravitational potential function \(e^{\nu }\) for these values simplifies to

$$\begin{aligned} e^{\nu }=\frac{Ahr^2}{\sqrt{1-br^2}}+\frac{B\sqrt{1-br^2}}{h}. \end{aligned}$$

4.3 Case III: \(a=0\), \(b=c=d=1\), \(R\ne 0\)

For this case, the gravitational potential \(e^{\lambda }\) takes the form

$$\begin{aligned} e^{\lambda }=\frac{1}{1-r^2}. \end{aligned}$$

This case regains the particular uncharged conformal model generated in [59]. The metric potential function \(e^{\nu }\) reduces to

$$\begin{aligned} e^{\nu }=\frac{Ahr^2}{\sqrt{1-r^2}}+\frac{B\sqrt{1-r^2}}{h}. \end{aligned}$$

4.4 Case IV: \(c=1\), \(d=0\), \(R=\sqrt{2}\)

These parameter values reduce the metric potential function to the form

$$\begin{aligned} e^{\lambda }={1+ar^2}. \end{aligned}$$

This gravitational potential function was adopted in the charged models generated in [60, 61] using a linear equation of state, while [62] generated a realistic uncharged stellar model using a polytropic equation of state. The metric function \(e^{\nu }\) for these values becomes

$$\begin{aligned} e^{\nu }=\frac{Ar^2h^2+B}{h}. \end{aligned}$$

4.5 Case V: \(a=\frac{1}{2}\), \(b=d=R=1\), \(c=2\)

For the set of the specified parameter values, the gravitational potential function \(e^{\lambda }\) takes the form

$$\begin{aligned} e^{\lambda }=\frac{2\left( 1+r^2\right) }{2-r^2}. \end{aligned}$$

This is a particular form of the choice adopted in the neutral astrophysical models generated in [63,64,65,66], charged isotropic fluid spheres generated in [67], and anisotropic compact star models generated in [68]. The second gravitational potential \(e^{\nu }\) for this case reduces to

$$\begin{aligned} e^{\nu }=Ar^2h\left( 2-r^2\right) ^{-3/2}+\frac{B\left( 2-r^2\right) ^{3/2}}{h}. \end{aligned}$$

4.6 Case VI: \(a=\frac{1}{2}\), \(c=1\), \(d=0\)

For the given parameter values, the gravitational metric potential function \(e^{\lambda }\) reduces to

$$\begin{aligned} e^{\lambda }=1+\frac{r^2}{R^2}. \end{aligned}$$

This potential regains the particular choice adopted in [26, 69] for the neutral anisotropic stellar models using a linear equation of state describing quark stars. We observe that the gravitational potential \(e^{\nu }\) for the specified values takes the form

$$\begin{aligned} e^{\nu }=\frac{Ar^2h^2+B}{h}. \end{aligned}$$

4.7 Case VII: \(c=1\), \(d=0\)

This case reduces the metric function \(e^{\lambda }\) to the form

$$\begin{aligned} e^{\lambda }=1+\frac{2ar^2}{R^2}. \end{aligned}$$

This particular form of the gravitational potential was also used in the neutral stellar model generated in [70]. The gravitational potential \(e^{\nu }\) for this case simplifies to

$$\begin{aligned} e^{\nu }=\frac{Ar^2h^2+B}{h}. \end{aligned}$$

4.8 Case VIII: \(a=R=2\), \(c=1\), \(d=0\)

For these parameter values, the gravitational potential function \(e^{\lambda }\) takes the form

$$\begin{aligned} e^{\lambda }=1+r^2. \end{aligned}$$

This particular form regains the choice of the potential adopted in the charged anisotropic conformal model generated in [44], the uncharged models found in [71,72,73], where the equations of state were extracted from the field equations. The gravitational potential \(e^{\nu }\) for the specified values reduces to

$$\begin{aligned} e^{\nu }=\frac{Ar^2h^2+B}{h}. \end{aligned}$$

4.9 Case IX: \(c=1\), \(d=-1\), \(R=\sqrt{2}\)

We observe that these values simplify the gravitational potential \(e^{\lambda }\) to the form

$$\begin{aligned} e^{\lambda }=\frac{1+ar^2}{1+br^2}. \end{aligned}$$

This gravitational potential regains the charged models generated in [74, 75] using a quadratic equation of state, and linear and quadratic equations of state for the core and envelope, respectively, in [76] using a quadratic equation of state, and [77] for the uncharged anisotropic embedding solution. The second gravitational potential function \(e^{\nu }\) for this case reduces to

$$\begin{aligned} e^{\nu }=\frac{Ahr^2}{\left( 1+br^2\right) ^{\frac{-a+b}{2}}}+\frac{B{\left( 1+br^2\right) ^{\frac{-a+b}{2}}}}{h}. \end{aligned}$$

We observe from the cases I-IX that the gravitational metric potentials satisfy \(e^{\lambda }=1\) and \(e^{\nu }\ge 0\) at the stellar centre. This behaviour indicates that the metric functions are finite and regular at the centre of the fluid sphere. These cases show that our generalized model is physical and realistic as it regains several models with astrophysical significance.

5 Analysis of the physical conditions

We investigate several requirements for the physical acceptability of a realistic model. We give a physical analysis of the conditions that the gravitational potentials and matter variables need to satisfy. These physical conditions include regularity, bounds on the surface red shift and mass-radius ratio, stability, equilibrium, and energy conditions for the behaviour of the energy momentum tensor. The graphs on the profiles of the gravitational potentials and matter variables were obtained using the Python Programming Language. The various mathematical equations were checked using the Mathematica software package.

5.1 Junction conditions

Formulation of anisotropic conformal models requires a smooth matching of the interior solution to the exterior at the boundary of the stellar object. This is achieved when the corresponding coefficients of the metrics (1) and (2) are compared at the boundary junction \(r=R_b\), that is,

$$\begin{aligned} e^{2\nu (R_b)}= & {} \left( 1-\frac{2M}{R_b}+\frac{Q^{2}}{{R_{b}}^{2}}\right) , \end{aligned}$$
(17a)
$$\begin{aligned} e^{2\lambda (R_b)}= & {} \left( 1-\frac{2M}{R_b}+\frac{Q^{2}}{{R_{b}}^{2}}\right) ^{-1}. \end{aligned}$$
(17b)

The quantity \(\frac{Q^{2}}{{R_{b}}^{2}}=E^2{R_{b}}^2\). It is also required the radial pressure vanishes at the boundary. We observe from Fig. 1 that the radial pressure vanishes even before reaching the boundary point. Similar profiles were generated in [60, 78, 79]. Using the gravitational potentials (12) and (14), the mass function (16), together with the electric field intensity (13), the matching conditions in system (17) simplify to

$$\begin{aligned} 0= & {} \left( \frac{A^2h^2}{\left( {c-bd{R_b}^2}\right) ^{2H}}-\frac{a^2}{\left( b+R^2{R_b}^2\right) ^2}\right) {R_b}^4 +\left( \frac{bd\left( 2ac+bdR^2\right) }{(2a{R_b}^2+R^2)}\right. \nonumber \\&\left. -\frac{\left( 2ac+bdR^2\right) ^2}{2\left( 2a{R_b}^2+R^2\right) ^2}-\frac{b^2d^2}{2}\right) \frac{R^4}{2a^2c^2}\nonumber \\&+\left( \frac{b}{2\left( b+{R_b}^2R^2\right) }+1\right) \frac{a^2}{2R^4}\nonumber \\&-\frac{3a^2\sqrt{b}\arctan {\left( {R_bR/\sqrt{b}}\right) }}{4R_bR^5}+ \frac{B^2\left( c-bd{R_b}^2\right) ^{2H}}{h^2}+2AB{R_b}^2, \end{aligned}$$
(18a)
$$\begin{aligned} 0= & {} \frac{\left( c-bd{R_b}^2\right) ^2}{c^2\left( 1+\frac{2a{R_b}^2}{R^2}\right) ^2}-\frac{a^2{R_b}^4}{\left( b+R^2{R_b}^2\right) ^2}\nonumber \\&+\left( \frac{bd\left( 2ac+bdR^2\right) }{(2a{R_b}^2+R^2)}-\frac{\left( 2ac+bdR^2\right) ^2}{2\left( 2a{R_b}^2+R^2\right) ^2}\right. \nonumber \\&\left. -\frac{b^2d^2}{2}\right) \frac{R^4}{2a^2c^2}+\left( \frac{b}{2\left( b+{R_b}^2R^2\right) }+1\right) \frac{a^2}{2R^4}\nonumber \\&-\frac{3a^2\sqrt{b}\arctan {\left( {R_bR/\sqrt{b}}\right) }}{4R_bR^5}, \end{aligned}$$
(18b)

where H is given by equation (14). The matching at the boundary junction for the generated model (15) is provided by the system of equations (18). We have explicitly expressed the junction conditions (18) in terms of the constants a, b, c, d, R, \(R_b\), h, A, and B. It is observed that there are sufficient free parameters to satisfy conditions (18).

5.2 Mass-radius ratio and surface red shift

From the mass equation (16), the mass-radius ratio defining the compactification parameter \(\mu\) is given by

$$\begin{aligned} \mu (r)= & {} \frac{M(r)}{r}\nonumber \\= & {} \frac{1}{8}\left[ \frac{2a^2}{R^4}-\frac{b^2d^2R^4}{a^2c^2}-\frac{R^4(2ac+bdR^2)^2}{a^2c^2(2ar^2+R^2)^2}\right. \nonumber \\&\left. +\frac{2bdR^4(2ac+bdR^2)}{a^2c^2(2ar^2+R^2)}\right. \nonumber \\&\left. +\frac{a^2b}{R^4(b+r^2R^2)}- \frac{3a^2\sqrt{b}\arctan {\left( {rR/\sqrt{b}}\right) }}{rR^5}+4\right] . \end{aligned}$$
(19)

The expression for the surface red shift \(z_s\) is given by

$$\begin{aligned} z_s= & {} \frac{1}{\sqrt{1-\frac{2M(r)}{r}}}-1\nonumber \\= & {} -1+2\sqrt{a^2R^5}\left( -2a^4R +\frac{b^2d^2R^9}{c^2}-\frac{a^4bR}{b+r^2R^2}\right. \nonumber \\&\left. -\frac{2bdR^9\left( 2ac+bdR^2\right) }{c^2\left( 2ar^2+R^2\right) }\right. \nonumber \\&\left. +\frac{R^9\left( 2ac+bdR^2\right) ^2}{c^2\left( 2ar^2+R^2\right) ^2}+\frac{3a^4\sqrt{b}\arctan {\left( {rR/\sqrt{b}}\right) }}{r} \right) ^{-\frac{1}{2}}. \end{aligned}$$
(20)

It is observed from Fig. 2 that the mass of the sphere increases toward the boundary of the stellar object. We also observe from Fig. 3 that the mass-radius ratio (compactness factor \(\mu\)) increases with an increase in radial coordinate. It attains its maximum value at \(\mu =0.4812\). This value is within the bound required for anisotropic matter distribution, that is, \(\frac{M}{r}=\mu \le 0.587\) [6, 63, 80]. The behaviour of the surface red shift inside the star is shown in Fig. 4. We observe that its value increases with the increase in radial coordinate r with maximum value attained at \(z_s=5.0127\). For realistic charged anisotropic compact spheres, the value of the surface red shift should not exceed 5.211 [48, 63, 81]. This requirement is satisfied as illustrated in Fig. 4.

Fig. 1
figure 1

Profile of the radial pressure \(p_r\) against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.014\), \(R=3.500\), \(A=0.075\), \(B=1.050\), and \(h=3.550\)

Fig. 2
figure 2

Behaviour of the mass \(M(M_{\odot })\) against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.014\), and \(R=3.500\)

Fig. 3
figure 3

Behaviour of the mass-radius ratio \(\frac{M}{r}=\mu\) against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.014\), and \(R=3.500\)

5.3 Behaviour of the pressure anisotropy, charge density, and electric field intensity

We observe from Fig. 5 that the pressure anisotropy \(\Delta\) increases from the centre to some point toward the surface and then starts to decrease. It is zero at the stellar centre and nonzero elsewhere, meaning that \(p_r\) and \(p_t\) are not equal except at the stellar centre. Similar profiles of pressure anisotropy have been generated in [55, 75]. The electric field E is zero at the stellar centre, sharply increases to some points toward the boundary and then starts to decrease (Fig. 6). The charge density is positive with a maximum value at the centre while decreasing toward the stellar boundary (Fig. 7). Similar profiles to these quantities are observed in [50, 76, 82, 83]. These behaviours are required for any physically relativistic fluid sphere.

Fig. 4
figure 4

Behaviour of the surface red shift \(z_s\) against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.014\), and \(R=3.500\)

Fig. 5
figure 5

Profile of the pressure anisotropy \(\Delta\) against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.014\), \(R=3.500\), \(A=0.075\), \(B=1.050\), and \(h=3.550\)

Fig. 6
figure 6

Profile of the electric field \(E^2\) against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), and \(R=3.500\)

Fig. 7
figure 7

Profile of the charge density \(\sigma\) against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.014\), and \(R=3.500\)

5.4 Regularity conditions

Any physical realistic conformal model needs to satisfy the following conditions for regularity [23, 36, 81, 84]:

  1. (i)

    It is required that the gravitational metric potential functions \(e^{\lambda }\) and \(e^{\nu }\) to be increasing functions and free from a central singularity. These values are supposed to be \(e^{\lambda }=1\) and \(e^{\nu }\ge 0\) at the stellar centre. This requirement is satisfied as illustrated in Figs. 8 and 9.

  2. (ii)

    The matter density \(\rho\) needs to be positive with maximum value at the stellar centre. It is also required to decrease toward the boundary of the sphere. This behaviour is satisfied as indicated in Fig. 10.

  3. (iii)

    The regularity conditions also require that if there are unequal pressures in radial and tangential directions, then their values must be equal and maximum at the centre of compact stars. This property is shown in Figs. 1 and 11.

Fig. 8
figure 8

Profile of the gravitational potential \(e^{\lambda }\) against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.014\), and \(R=3.500\)

Fig. 9
figure 9

Profile of the gravitational potential \(e^{\nu }\) against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.014\), \(R=3.500\), \(A=0.075\), \(B=1.050\), and \(h=3.550\)

Fig. 10
figure 10

Profile of the matter density \(\rho\) against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.014\), and \(R=3.500\)

Fig. 11
figure 11

Profile of the tangential pressure \(p_t\) against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.014\), \(R=3.500\), \(A=0.075\), \(B=1.050\), and \(h=3.550\)

Fig. 12
figure 12

Behaviour of the weak energy condition against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.014\), \(R=3.500\), \(A=0.075\), \(B=1.050\), and \(h=3.550\)

5.5 Conditions for the energy momentum

For any physically charged anisotropic solution, the energy momentum tensor should satisfy the following conditions [82, 85, 86]:

  1. (i)

    The null energy condition (N.E.C) requiring the matter density \(\rho \ge {0}\).

  2. (ii)

    The weak energy condition (W.E.C) for the energy flow within the sphere demanding \(\rho -p_r, \rho -p_t \ge {0}\).

  3. (iii)

    The weak dominant energy condition (W.D.E.C) requiring \(\rho -3p_r, \rho -3p_t \ge {0}\), and

  4. (iv)

    The strong energy condition (S.E.C) demanding \(\rho -p_r-2p_t\ge {0}\). The conformal symmetry class of exact solutions generated in this work satisfies all these conditions throughout the stellar interior as illustrated in Figs. 10, 12, 13 and 14.

Fig. 13
figure 13

Behaviour of the weak dominant energy condition against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.014\), \(R=3.500\), \(A=0.075\), \(B=1.050\), and \(h=3.550\)

Fig. 14
figure 14

Behaviour of the strong energy condition against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.014\), \(R=3.500\), \(A=0.075\), \(B=1.050\), and \(h=3.550\)

5.6 Stability through adiabatic index

For a relativistic anisotropic star, the stability is associated with the adiabatic index \(\Gamma\) defining the ratio between two specific heats. Stability requires the adiabatic index to be greater than \(\frac{4}{3}\) [28, 87, 88]. For charged anisotropic fluid spheres, the function defining the adiabatic index is given by

$$\begin{aligned} \Gamma >\frac{4}{3}+\left( \frac{4\left( p_t-p_r\right) }{3rp'_r}\right) _{max.} \end{aligned}$$
(21)

[30, 48]. It has been observed in [89, 90] that some instabilities within anisotropic compact stars can be present due to the relativistic corrections of the adiabatic index. To overcome this, [91] provided a strict condition on the critical value of the adiabatic index to have a stable structure. The relativistic anisotropic critical value of the adiabatic index \(\Gamma _{crit}\) depends on the compactification parameter and amplitude of the Lagrangian displacement from equilibrium. This critical value is given by

$$\begin{aligned} \Gamma _{crit}= \frac{4}{3}+\frac{19}{21}{\mu }, \end{aligned}$$
(22)

where \(\mu\) is the compactness factor. For the anisotropic case, it is required that \(\Gamma \ge \Gamma _{crit}\) [92, 93]. We observe from Fig. 15 that the stability requirement is satisfied as the adiabatic index values are greater than \(\frac{4}{3}\) throughout the interior of the compact star.

Fig. 15
figure 15

Profile of the adiabatic indexes \(\Gamma\), \(\Gamma _{crit}\) against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.0014\), \(R=3.500\), \(A=0.075\), \(B=1.050\), and \(h=3.550\)

5.7 Physical forces for equilibrium condition

The total forces within the stellar interior need to balance at equilibrium. This is to say that the physical forces have to sum up to zero for equilibrium. For charged anisotropic spheres, this condition is given by the Tolman–Oppenheimer–Volkoff (TOV) equation

$$\begin{aligned} \frac{-M_g \left( \rho +p_r\right) }{r^2}e^{\lambda -\nu }-\frac{dp_r}{dr}+ \frac{\sigma e^{\lambda }q}{r^2} +\frac{2\Delta }{r}=0, \end{aligned}$$
(23)
Fig. 16
figure 16

Behaviour of the physical forces against radial coordinate r. For plotting the graph, the following numerical values of the free constants have been specified: \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.014\), \(R=3.500\), \(A=0.075\), \(B=1.050\), and \(h=3.550\)

[25, 82, 94], where \(\frac{q}{r^2}=E\) is the electric field intensity while \(M_g=\frac{r^2v'e^{\nu -\lambda }}{2}\) is the effective gravitational mass. With these definitions, equation (23) reduces to

$$\begin{aligned} \frac{-\nu ' \left( \rho +p_r\right) }{2}-\frac{dp_r}{\mathrm{d}r}+\sigma E e^{\lambda } +\frac{2\Delta }{r}=0. \end{aligned}$$
(24)

The first, second, third and fourth terms of the left hand side of equation (24) stand for the gravitational force \((F_g)\), hydrostatic force \((F_h)\), electric force \((F_e)\) and anisotropic force \((F_a)\), respectively. For the generated model, the explicit forms for these different forces are given by

$$\begin{aligned} F_a= & {} \frac{2\Delta }{r}=\frac{2\left( p_t-p_r\right) }{r}, \end{aligned}$$
(25a)
$$\begin{aligned} F_e= & {} \sigma Ee^{\lambda }=\frac{a^2r\left( 3b+r^2R^2\right) }{4\pi \left( b+r^2R^2\right) ^3}, \end{aligned}$$
(25b)
$$\begin{aligned} F_h= & {} -\frac{dp_r}{\mathrm{d}r}, \end{aligned}$$
(25c)
$$\begin{aligned} F_g= & {} -\left[ \left( r\left( 2ac\left( Ah^2r^2-B\left( c-bdr^2\right) ^{1+\frac{2ac}{bdR^2}}\right) \right. \right. \right. \nonumber \\&\left. \left. \left. +\left( -bBd\left( c-bdr^2\right) ^{1+\frac{2ac}{bdR^2}} \right. \right. \right. \right. \nonumber \\&\left. \left. \left. \left. +Ah^2\left( 2c-bdr^2\right) \right) R^2\right) \left( 4a^2cr^2\left( Ah^2r^2\right. \right. \right. \right. \nonumber \\&\left. \left. \left. \left. -B\left( c-bdr^2\right) ^{1+\frac{2ac}{bdR^2}}\right) \right. \right. \right. \nonumber \\&\left. \left. \left. +2aR^2\left( B\left( c-bdr^2\right) ^{2+\frac{2ac}{bdR^2}}+Ah^2r^2\left( 5c -bdr^2\right) \right. \right. \right. \right. \nonumber \\&\left. \left. \left. \left. +\left( bBd\left( c-bdr^2\right) ^{1+\frac{2ac}{bdR^2}}\right. \right. \right. \right. \right. \nonumber \\&\left. \left. \left. \left. \left. +Ah^2\left( 2c+bdr^2\right) \right) R^4\right) \right) \div \left( 8c^2\pi \left( Ah^2r^2\right. \right. \right. \right. \nonumber \\&\left. \left. \left. \left. +B\left( c-bdr^2\right) ^{1+\frac{2ac}{bdR^2}}\right) ^2\right. \right. \right. \nonumber \\&\left. \left. \left. \times \left( 2ar^2+R^2\right) ^3\right) \right) \right] . \end{aligned}$$
(25d)

The TOV equation (24) implies that the sum of these forces becomes zero so that

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

The behaviour of these physical forces are illustrated in Fig. 16.

Table 1 Numerical values for the central pressure, central and surface density, \(\Gamma _{0}\), \(\Gamma _{crit}\), surface red shift, and mass-radius ratio for \(a=0.050\), \(b=2.750\), \(c=5.500\), \(d=0.0014\), \(R=3.500\), \(A=0.075\), \(B=1.050\), and \(h=3.550\)

6 Conclusions

In this article, we have considered a charged anisotropic model of a compact fluid sphere that admits conformal symmetry. The conformal Killing vector is used to provide an equation relating the gravitational potentials. This equation, with the choice of one of these potentials on physical grounds, is simultaneously solved with the Einstein–Maxwell field equations to generate a realistic exact model with astrophysical significance. The conformal class of exact solution was examined for conformally flat (\(k=0\)) and non-conformally flat (\(k\ne 0\)) cases. We have provided a detailed physical analysis of the matter variables and gravitational potentials to examine the physical acceptability for the generated class of exact solutions. The gravitational potentials are regular and well behaved throughout the stellar interior. We have generated a realistic stellar model in which the surface red shift and mass-radius ratio are within acceptable limits. The energy conditions and stability through the adiabatic index are satisfied as well. The physical forces describing the behaviour of the body at an equilibrium point are balanced. Moreover, real data have been used to obtain the values of some physical parameters that characterized the solution as indicated in Table 1. It is observed that the surface red shift values go up to 5.01270 which is physically realistic as for anisotropic models this value can go up to 5.211 as outlined in [80]. The compactness factor was found to be 0.48120. The values in Table 1 are physically reasonable. We have also regained several charged and uncharged models found by various researchers as outlined in Sect. 4. These include well-known models generated in [56, 57, 63, 64]. The analysis given shows that conformal symmetry contributes to understanding the structure and properties of relativistic compact spheres. It is interesting to observe that a variety of known solutions found under different assumptions, possess a conformal symmetry and are contained in our generalized family of exact solutions with a conformal Killing vector. Other exact solutions may be obtained by considering different forms for the gravitational potential \(e^\lambda\) and electric field intensity E with conformal symmetry.