1 Introduction

Compact stars are the best sources to test a theory of gravity under the extreme cases with strong fields. Although they are generally considered as isotropic, there are important reasons to take into account anisotropic compact stars which have different radial and tangential pressures. First of all, the anisotropic spherically symmetric compact stars can be more stable than the isotropic ones [1]. The core region of the compact stars with very high nuclear matter density becomes more realistic in the presence of anisotropic pressures [2, 3]. Moreover the phase transitions [4], pion condensations [5] and the type 3A superfluids [6] in the cooling neutron matter core can lead to anisotropic pressure distribution. Furthermore, the mixture of two perfect fluid can generate anisotropic fluid [7]. Anisotropy can be also sourced by the rotation of the star [8,9,10]. Additionally, strong magnetic fields may lead to anisotropic pressure components in the compact stars [11]. Some analytic solutions of anisotropic matter distribution were studied in Einsteinian Gravity [8,9,10,11,12,13,14,15,16,17]. Recently it was shown that the “scalarization” can not arise without anisotropy and the anisotropy range can be determined by observations on binary pulsar in the Scalar-Tensor Gravity and General Relativity [10]. The anisotropic star solutions in \(R^2\) gravity can shift the mass-radius curves to the region given by observations [18]. It is interesting to note that anisotropic compact stars were investigated in Rastall theory and found exact solutions which permit the formation of super-massive star [19].

Additionally, the presence of a constant electric charge on the surface of compact stars may increase the stability [20] and protect them from collapsing [21, 22]. The charged fluids can be described by the minimally coupled Einstein–Maxwell field equations. An exact isotropic solution of the Einstein–Maxwell theory were found by Mak and Harko describing physical parameters of a quark star with the MIT bag equation of state under the existence of conformal motions [23]. Also, the upper and lower limits for the basic physical quantities such as mass-radius ratio, redshift were derived for charged compact stars [24] and for anisotropic stars [25]. A regular charged solution of the field equations which satisfy physical conditions was found in [26] and the constants of the solution were fixed in terms of mass, charge and radius [27]. Later the solutions were extended to the charged anisotropic fluids [28, 29]. Also, anisotropic charged fluid spheres were studied in D-dimensions [30].

In the investigation of compact stars, one of the most important problem is the mass discrepancy between the predictions of nuclear theories [31,32,33,34] and neutron star observations. The resent observations such as \(1.97M_\odot \) of the neutron star PSR J1614-2230 [35], \(2.4M_\odot \) of the neutron stars B1957+20 [36] and 4U 1700-377 [37] or \(2.7M_\odot \) of J1748-2021B [38] can not be explained by using any soft equation of state in Einstein’s gravity [31, 35, 39]. Since each different approach which solves this problem leads to different maximal mass, we need to more reliable models which satisfy observations and give the correct maximum mass limit of compact stars.

On the other hand, the observational problems such as dark energy and dark matter [40,41,42,43,44,45,46,47] at astrophysical scales have caused to search new modified theories of gravitation such as f(R) gravity [48,49,50,51,52,53,54]. As an alternative approach, the f(R) theories of gravitation can explain the inflation and cosmic acceleration without exotic fields and satisfy the cosmological observations [55, 56]. Therefore, in the strong gravity regimes such as inside the compact stars, f(R) gravity models can be considered to describe the more massive stars [57, 58] . Furthermore, the strong magnetic fields [59] and electric fields [60] can increase the mass of neutron stars in the framework of \(f(R)\) gravity.

On the other hand, in the presence of the strong electromagnetic fields, the Einstein–Maxwell theory can also be modified. The first modification is the minimal coupling between f(R) gravity and Maxwell field as the \(f(R)-\)Maxwell gravity which has only the spherically symmetric static solution [61, 62]. Therefore we consider the more general modifications such as \(Y(R)F_{ab}F^{ab}\) which allow a wide range of solutions [63,64,65,66,67,68,69,70,71,72,73].

A similar kind of such a modification which is \( R_{abcd}F^{ab} F^{cd} \) firstly was defined by Prasanna [74] and found a criterion for null electromagnetic fields in conformally flat space-times. Then the most general possible invariants which involves electromagnetic and gravitational fields (vector-tensor fields) including \(RF_{ab}F^{ab}\) term were studied in [75] and the spherically symmetric static solutions were obtained [76] for the unique composition of such couplings. Also such non-minimal modifications were derived by dimensional reduction of the five dimensional Gauss–Bonnet action [77, 78] and \(R^2\) gravity action [79, 80]. These invariant terms were also obtained by Feynman diagram method from vacuum polarization of the photon in the weak gravitational field limit [81]. The general form of the couplings such as \(R^nF^2\) were used to explain the seed magnetic fields in the inflation and the production of the primeval magnetic flux in the universe [67, 70,71,72,73, 82].

Thus it is natural to consider the more general modifications which couple a function of the Ricci scalar with Maxwell invariant as \(Y(R)F^2\) form inside the strong electromagnetic and gravitational fields such as compact astrophysical objects. The more general modifications have static spherically symmetric solutions [64,65,66, 70] to describe the flatness of velocity curves of galaxies, cosmological solutions to describe accelerating expansion of the universe [63, 67,68,69] and regular black hole solutions [83]. Furthermore, the charged, isotropic stars and radiation fluid stars can be described by the non-minimal couplings [84, 85]. Therefore in this study, we investigate the anisotropic compact stars in the non-minimal \(Y(R)F^2\) model and find a family of exact analytical solutions. Then we obtain the total mass, total charge and gravitational surface redshift by the parameters of the model and the boundary radius of the star.

2 The model for anisotropic stars

We will obtain the field equations of our model for the anisotropic stars by varying the action integral with respect to independent variables; the orthonormal co-frame 1-form \(e^a\), the Levi–Civita connection 1-form \(\omega _{ab}\), and the electromagnetic potential 1- form A,

$$\begin{aligned} I \!=\! \int _M{\left\{ \frac{1}{2\kappa } R*1 - \epsilon _0 Y(R) F\wedge *F + \frac{2}{c}A\wedge J + L_{mat} + \lambda _a\wedge T^a \right\} }, \end{aligned}$$
(1)

where \(\kappa \) is the coupling constant, \(\epsilon _0\) is the permittivity of free space, \(\wedge \) and \(*\) denote the exterior product and the Hodge map of the exterior algebra, respectively, R is the curvature scalar, Y(R) is a function of R representing the non-minimal coupling between gravity and electromagnetism, F is the electromagnetic 2-form, \(F=dA\), J is the electromagnetic current 3-form, \(L_{mat}\) is the matter Lagrangian 4-form, \(T^a := de^a + \omega ^a{}_b \wedge e^b\) is the torsion 2-form, \(\lambda _a\) Lagrange multiplier 2-form constraining torsion to zero and M is the differentiable four-dimensional manifold whose orientation is set by the choice \(*1=e^0 \wedge e^1 \wedge e^2 \wedge e^3\).

In this study, we use the SI units differently from the previous papers [84, 85]. We write \(F = -E_i e^{0i} + \frac{c}{2}\epsilon _{0ijk}B^k e^{ij}\), where c is the light velocity, \(E_i\) is electric field and \(B_i\) is magnetic field under the assumption of the Levi–Civita symbol \(\epsilon _{0123}=+1\). We adhere the following convention about the indices; \(a,b,c = 0,1,2,3\) and \(i,j, k = 1,2,3\). We also define \(J=-c \rho _e *e^0 + J_i *e^i\) where \(\rho _e\) is the charge density and \(J_i\) is the current density. We assume that the co-frame variation of the matter sector of the Lagrangian produces the following energy momentum 3-form

$$\begin{aligned} \tau _a^{mat}:= & {} \frac{\partial L_{mat}}{\partial e^a} \nonumber \\= & {} (\rho c^2 + p_t )u_a *u + p_t *e_a + (p_r - p_t ) v_a *v,\nonumber \\ \end{aligned}$$
(2)

where \(u = \delta _a^0 e^a \) is a time-like 1-form, \(v= \delta _a^1 e^a\) is a space-like 1-form, \(p_r\) is the radial component of pressure orthogonal to the transversal pressure \(p_t\), and \(\rho \) is the mass density for the anisotropic matter in the star. In this case it must be \(\kappa = 8\pi G / c^4\) for the correct Newton limit. The non-minimal coupling function Y(R) is dimensionless. Consequently every term in our Lagrangian has the dimension of (energy)(length). Finally we notice that the dimension of \(\lambda _a\) must be energy because torsion has the dimension of length.

After substituting the connection varied equation into the co-frame varied one, we obtain the modified Einstein equation for our model

$$\begin{aligned}&- \frac{1}{2 \kappa } R^{bc} \wedge *e_{abc} \nonumber \\&\quad = \epsilon _0 Y(\iota _a F \wedge *F - F \wedge \iota _a *F) + \epsilon _0 Y_R F_{bc} F^{bc}*R_a \nonumber \\&\qquad + \epsilon _0 D[\iota ^b \; d(Y_R F_{bc} F^{bc})] \wedge *e_{ab} + \tau _a^{mat}, \end{aligned}$$
(3)

where \(\iota \) denotes the interior product of the exterior algebra satisfying the duality relation, \(\iota _b e^a = \delta ^a_b\), through the Kronecker delta, \(R^a{}_b := d \omega ^a{}_b + \omega ^a{}_c \wedge \omega ^c{}_b \) is the Riemann curvature 2-form, \( R^a:= \iota _b R^{ba} \) is the Ricci curvature 1-form, \(R := \iota _a R^a \) is the curvature scalar, \(Y_R :=dY/dR\), \(e^{ab \cdots } := e^a \wedge e^b \wedge \cdots \) and \(F_{bc}:=\iota _c \iota _b F\). As the left hand side of the Eq. (3) constitutes the Einstein tensor, the right one is called the total energy momentum tensor for which the law of energy-momentum conservation is valid. For details one may consult Ref. [84].

The variation of the action according to the electromagnetic potential A yields the modified Maxwell equation

$$\begin{aligned} \epsilon _0 d(*Y F)= & {} \frac{J}{c}. \end{aligned}$$
(4)

We have also noticed that the Maxwell 2-form is closed \(dF=0\) from the Poincaré lemma, since it is exact form \(F=dA\). Thus, the two field Eqs. (3) and (4) define our model and we will look for solutions to them under the condition

$$\begin{aligned} \epsilon _0 Y_R F_{bc} F^{bc} = - \frac{k}{ \kappa }, \end{aligned}$$
(5)

which removes the potential instabilities from the higher order derivatives for the non-minimal theory. Here the non-zero k is a dimensionless constant. The case of \(k=0\) leads to \(Y(R)= constant\) corresponding to the minimal Einstein–Maxwell theory which will be considered as the exterior vacuum solution with \(R=0\). We will see from solutions of the model that the total mass and total charge of the anisotropic star are critically dependent on the parameter k. The additional features of the constraint (5) may be found in [84]. We also notice that the trace of the modified Einstein equation (3), obtained by multiplying with \(e^a \wedge \), produces an explicit relation between the Ricci curvature scalar, energy density and pressures

$$\begin{aligned} (1- k) R = \kappa (\rho c^2 - p_r-2p_t). \end{aligned}$$
(6)

3 Static spherically symmetric anisotropic solutions

We propose the following metric for the static spherically symmetric spacetime and the Maxwell 2-form for the static electric field parallel to radial coordinate in (1+3) dimensions

$$\begin{aligned} ds^2= & {} -f^2(r) c^2 dt^2+g^2(r)dr^2+r^2d\theta ^2 +r^2\sin ^2\theta d\phi ^2,\nonumber \\ \end{aligned}$$
(7)
$$\begin{aligned} F= & {} E(r)e^1\wedge e^0, \end{aligned}$$
(8)

where f and g are the metric functions and E is the electric field in the radial direction which all three functions depend only on the radial coordinate r.

The integral of the electric current density 3-form J sourcing the electric field gives rise to the electric charge inside the volume V surrounded by the closed spherical surface \(\partial V\) with radius r

$$\begin{aligned} q(r):= & {} \frac{1}{c}\int _V{J} = \epsilon _0 \int _V{d(*YF)} \nonumber \\= & {} \epsilon _0 \int _{\partial V} {*YF} = 4\pi \epsilon _0 r^2 Y E \, . \end{aligned}$$
(9)

Here we used the Stoke’s theorem. The components of the modified Einstein equation (3) reads three coupled nonlinear differential equations

$$\begin{aligned}&\frac{1}{\kappa } \left( \frac{2g'}{g^3 r} + \frac{g^2 - 1}{g^2 r^2} \right) = \epsilon _0 YE^2 \nonumber \\&\quad - \frac{k }{\kappa }\left( \frac{f''}{fg^2} - \frac{f'g'}{fg^3} + \frac{2f'}{f g^2 r}\right) + \rho c^2, \end{aligned}$$
(10)
$$\begin{aligned}&\frac{1}{\kappa } \left( -\frac{2f'}{f g^2 r} + \frac{g^2 - 1}{g^2 r^2} \right) = \epsilon _0 YE^2 \nonumber \\&\quad + \frac{k }{\kappa }\left( -\frac{f''}{fg^2} + \frac{f'g'}{fg^3} + \frac{2g'}{g^3 r}\right) - p_r, \end{aligned}$$
(11)
$$\begin{aligned}&\frac{1}{\kappa } \left( \frac{f''}{f g^2} - \frac{f'g'}{f g^3} + \frac{f'}{fg^2 r} - \frac{g'}{g^3 r} \right) = \epsilon _0 YE^2 \nonumber \\&\quad - \frac{k }{\kappa }\left( -\frac{f'}{fg^2 r} +\frac{g'}{g^3 r} + \frac{g^2 - 1}{g^2 r^2} \right) + p_t, \end{aligned}$$
(12)

where prime stands for derivative with respect to r. We obtain one more useful equation by taking the covariant exterior derivative of (3)

$$\begin{aligned}&p_r' + \frac{f'(\rho c^2 + p_r)}{f} + \frac{2(p_r - p_t)}{r}\nonumber \\&\quad = 2\epsilon _0 (YE)' E + \frac{4 \epsilon _0 YE^2}{r}. \end{aligned}$$
(13)

In what follows we assume the linear equation of state in the star

$$\begin{aligned} p_r = \omega \rho c^2 \end{aligned}$$
(14)

where \(\omega \) is a constant in the interval \(0<\omega \le 1 \). Finally we calculate the crucial constraint (5)

$$\begin{aligned} \frac{dY}{dR}=\frac{k}{2\epsilon _0\kappa E^2 }, \end{aligned}$$
(15)

where the Ricci curvature scalar is

$$\begin{aligned} R = \frac{2}{g^2 }\left( -\frac{f''}{f} + \frac{f'g'}{fg} -\frac{2f'}{fr} + \frac{2g'}{gr} + \frac{g^2-1}{ r^2} \right) . \end{aligned}$$
(16)

3.1 Exact solutions with conformal symmetry

We will look for solutions to these differential Eqs. (10)–(15) assuming that the metric (7) admits a one-parameter group of conformal motions, since inside of stars can be described by using this symmetry [23, 86,87,88]. The symmetry is obtained by taking Lie derivative of the metric tensor \(\mathbf {g}_{ab}\) with respect to the vector field \(\xi \), \(L_\xi \mathbf {g}_{ab}= \frac{\phi _0}{g(r)} \mathbf {g}_{ab}\), for the arbitrary metric function g(r) and the following metric function f(r)

$$\begin{aligned} f^2(r) = a^2 r^2, \end{aligned}$$
(17)

with arbitrary constants a and \(\phi _0\). Here we consider the metric function g(r)

$$\begin{aligned} g^2(r) = \frac{3}{1+br^\alpha }, \end{aligned}$$
(18)

inspired by [23], where b and \(\alpha \) are arbitrary parameters. With these choices, the curvature scalar (16) is calculated as

$$\begin{aligned} R = -b(\alpha + 2) r^{\alpha -2}. \end{aligned}$$
(19)

We notice that it must be \(\alpha > 2\) and \(b \ne 0 \) in order for that the curvature scalar is nonzero and regular at the origin. If \(b = 0\), then the curvature scalar R becomes zero and this leads to constant Y(R) in which case the model reduces to the minimal Einstein–Maxwell theory.

Then the system of Eqs. (10)–(15) has the following solutions for the metric functions (17), (18) and the anisotropic pressure \(p_r = \omega \rho c^2\)

$$\begin{aligned} \rho (r)= & {} \frac{(k + 1)[2- br^\alpha (\alpha -2) ]}{3\kappa c^2 r^2 (\omega +1)}, \end{aligned}$$
(20)
$$\begin{aligned} p_t(r)= & {} \frac{br^\alpha [(k +1)(\alpha -2 ) -X ]}{3\kappa r^2 (\omega +1)} + \frac{(k+1)(1- \omega )}{3\kappa r^2(\omega +1)}, \end{aligned}$$
(21)
$$\begin{aligned} E^2(r)= & {} \frac{2\omega (k+1)}{3\kappa \epsilon _0 c_0 r^2 (\omega +1)} \left[ 1+\frac{X br^\alpha }{4\omega (k + 1)}\right] ^{1+ \frac{3k (\omega +1)(\alpha ^2-4)}{\alpha X}}, \nonumber \\ \end{aligned}$$
(22)
$$\begin{aligned} Y(r)= & {} c_0\left[ 1+\frac{X br^\alpha }{4\omega (k + 1)}\right] ^{-\frac{3k (\omega +1)(\alpha ^2-4)}{\alpha X}}, \end{aligned}$$
(23)

where the composite function Y(R(r)) have obtained in terms of r as Y(r) and we have defined

$$\begin{aligned} X = k \omega (\alpha + 4) + \alpha (3k - 2\omega )-2(\omega +3). \end{aligned}$$
(24)

After obtaining r(R) from (19)

$$\begin{aligned} r = \left[ \frac{-R}{b(\alpha + 2)}\right] ^{1/(\alpha - 2)} \end{aligned}$$
(25)

we rewrite explicitly the non-minimal coupling function in terms of \(R\)

$$\begin{aligned} Y(R) = c_0\left[ 1+ \frac{b X}{4\omega (k+1)}\left( \frac{-R}{\alpha b +2b}\right) ^{\alpha /(\alpha -2)} \right] ^{-\frac{3k(\omega +1)(\alpha ^2-4)}{\alpha X}}.\nonumber \\ \end{aligned}$$
(26)

Since the exterior vacuum region is described by Reissner–Nordström metric satisfying \(R=0\), the non-minimal coupling function becomes \(Y(R) = c_0 \). Therefore we can fix \(c_0=1\) without loss of generality. Then the corresponding model becomes

$$\begin{aligned} L= & {} \frac{1}{2\kappa ^2} R*1 \nonumber \\&- \epsilon _0 \left[ 1+ \frac{b X}{4\omega (k+1)}\left( \frac{-R}{(\alpha +2) b }\right) ^{\frac{\alpha }{\alpha -2}} \right] ^{-\frac{3k(\omega +1)(\alpha ^2-4)}{\alpha X}} \quad F\wedge *F \nonumber \\&+ 2A\wedge J + L_{mat} + \lambda _a\wedge T^a. \ \ \ \ \ \ \end{aligned}$$
(27)

admitting the interior metric

$$\begin{aligned} ds^2 _{in}= - a^2r^2 c^2 dt^2 + \frac{3}{1+br^\alpha } dr^2 + r^2 d\Omega ^2; \end{aligned}$$
(28)

and the the Maxwell 2-form

$$\begin{aligned} F = \frac{q(r)}{4 \pi \epsilon _0 Y r^2} e^1 \wedge e^0, \end{aligned}$$
(29)

in the interior of star, where q(r) is obtained from (9) as

$$\begin{aligned} q^2(r)=\frac{32\pi ^2\epsilon _0\omega (k + 1)r^2}{3\kappa (\omega +1)}\left[ 1+\frac{X br^\alpha }{4\omega (k + 1)}\right] ^{1-\frac{3k(\omega +1)(\alpha ^2-4)}{\alpha X}}.\nonumber \\ \end{aligned}$$
(30)
Fig. 1
figure 1

The radial (a) and tangential (b) pressures as a function of the radial distance r for \(k=1\), \(\alpha =4\), \(r_b=10\) km and some different \(\omega \) values. (The energy density \( c^2\rho \) is proportional to the radial pressure as \(p_r =\omega c^2\rho \))

On the other hand at the exterior, the model admit the Reissner–Nordström metric

$$\begin{aligned} ds^2_{out}= & {} -\left( 1- \frac{2GM}{c^2r} + \frac{\kappa Q^2}{(4 \pi )^2 \epsilon _0 r^2} \right) c^2 dt^2 \nonumber \\&+ \left( 1-\frac{2GM}{c^2r} + \frac{\kappa Q^2}{(4 \pi )^2 \epsilon _0 r^2} \right) ^{-1} dr^2 + r^2d\Omega ^2,\nonumber \\ \end{aligned}$$
(31)

and the Maxwell 2-formFootnote 1

$$\begin{aligned} F = \frac{Q}{4 \pi \epsilon _0 r^2} e^1 \wedge e^0 \end{aligned}$$
(32)

which represents the electric field in the radial direction, \( \mathbf {E} = {\hat{r} Q}/{4 \pi \epsilon _0 r^2} \), where Q is the total electric charge of the star which is obtained by writing \(r=r_b\) in (30). We will be able to determine some of the parameters from the matching and the continuity conditions, and the others from the observational data.

3.2 Matching conditions

We will match the interior metric (28) and the exterior metric (31) at the boundary of the star \(r=r_b\) for continuity of the gravitational potential,

$$\begin{aligned} a^2 r_b ^2= & {} 1 - \frac{2GM}{c^2 r_b} + \frac{\kappa Q^2}{(4\pi )^2 \epsilon _0 r_b^2}, \end{aligned}$$
(33)
$$\begin{aligned} \frac{3}{1 + br^\alpha _b}= & {} \left( 1 - \frac{2GM}{c^2 r_b} + \frac{\kappa Q^2}{(4\pi )^2 \epsilon _0 r_b^2}\right) ^{-1}. \end{aligned}$$
(34)

These equations are solved for a and b appeared in the interior metric functions

$$\begin{aligned} b= & {} \frac{2r_b^2 - 6GMr_b/c^2 + 3 \kappa Q^2/(4\pi )^2\epsilon _0}{r_b^{2+\alpha }}, \end{aligned}$$
(35)
$$\begin{aligned} a^2= & {} \frac{1}{r_b^2} - \frac{2GM}{c^2 r_b^3} + \frac{\kappa Q^2}{(4\pi )^2 \epsilon _0 r_b^4}. \end{aligned}$$
(36)

Vanishing of the radial pressure at the boundary, \(p_r(r_b)= \omega c^2 \rho (r_b) = 0\) in (20), determines the parameter b

$$\begin{aligned} b=\frac{2}{(\alpha -2)r_b^\alpha }. \end{aligned}$$
(37)
Fig. 2
figure 2

The dimensionless quantity which is related with the total charge Q as a function of the parameter \(\alpha \) for \(\omega =0.1\)(a) and \(\omega =0.3\) (b)

The behavior of the pressures and energy density is given in Fig. 1 in terms of the radial distance r for \(k=1\). Moreover the decreasing behavior of the quantities does not change for \(k\ne 1\). We can obtain an upper bound of the parameter k using the non-negative tangential pressure \(p_t(r)\) in (21). In order to obtain the bound we need to determine the interval of \(\omega \). Since the radial component of the sound velocity \( \frac{d p_r}{d\rho } \) is non-negative and should not be bigger than the square of light velocity \(c^2\) for the normal matter, the parameter \(\omega \) takes values in the range \(0\le \omega \le 1\). We see from the Fig. 1b that the tangential pressure curves decrease for the increasing \(\omega \) values and the minimum curve can be obtained from the case with \(\omega = 1\). Then we obtain the following inequality from the first part of \(p_t(r)\)

$$\begin{aligned} (k+1)(\alpha -2) -X \ge 0, \end{aligned}$$
(38)

which turns out to be

$$\begin{aligned} 3(1-k)(\alpha +2) \ge 0, \end{aligned}$$
(39)

for the case \(\omega =1\), that leads to the minimum \(p_t(r) \) function. Thus the parameter k must be \(k \le 1\) for the non-negative tangential pressure. On the other hand, the total electric charge (42) must be a real valued exponential function, then we obtain the inequality

$$\begin{aligned} 1+\frac{2X}{4\omega (k+1)(\alpha -2)} \ge 0 \end{aligned}$$
(40)

which leads to \(k\ge \frac{2}{\alpha }\). Thus k must take values in this range

$$\begin{aligned} \frac{2}{\alpha }<k \le 1. \end{aligned}$$
(41)

and we find the maximum lower bound for the parameter k as \(k>\frac{2}{3}\) for \(\alpha >3 \) (which leads to positive gravitational redshift).

While the interior side of the star has the electrically charged matter distribution, the outer side is vacuity. Then the excitation 2-form \(\mathcal {G} = YF\) in the interior becomes the Maxwell 2-form \(\mathcal {G} = F\) at the exterior. Therefore the interior electric charge q(r) which found from \(\epsilon _0 c d*YF = J \) must be equal to the total electric charge Q obtained from \( d* F = 0 \) at the exterior. Thus the continuity of the excitation 2-form at the boundary leads to \(q(r_b)= Q\) as the last matching condition

$$\begin{aligned} Q^2= & {} \frac{32\pi ^2\epsilon _0 \omega (k +1)r_b^2 }{3\kappa (\omega +1)}\left[ 1\nonumber \right. \\&\left. +\frac{2X}{4\omega (k+1)(\alpha -2)}\right] ^{1 -\frac{3k(\omega +1)(\alpha ^2-4)}{\alpha X}} \end{aligned}$$
(42)

where we eliminated the parameter b via (37). The total electric charge is shown as a function of \(\alpha \) in Fig. 2 for \(\omega =0.1 \) (a) and \(\omega =0.3 \) (b) taking some different k values. We see that the increasing k values increase the total charge values. The substitution of (37)–(35) allows us writing the total mass of the star in terms of its total charge

$$\begin{aligned} M = \left( \frac{\alpha -3}{\alpha -2}\right) \frac{c^2 r_b}{3G} + \frac{\kappa c^2 Q^2 }{2(4\pi )^2 \epsilon _0 G r_b}. \end{aligned}$$
(43)

Then from (42) the total mass becomes

$$\begin{aligned} M= & {} \left( \frac{\alpha -3}{\alpha -2}\right) \frac{c^2 r_b}{3G} \nonumber \\&+\frac{c^2r_b\omega (k+1)}{3G (\omega +1)}\left[ 1+\frac{2X}{4\omega (k+1)(\alpha -2)} \right] ^{1-\frac{3k(\omega +1)(\alpha ^2-4)}{\alpha X}}. \end{aligned}$$
(44)

We depict the graph of the total mass as a function of \(\alpha \) in Fig. 3 for \(\omega =0.15 \) (a) and \(\omega =0.5 \) (b) taking some different k values.

Fig. 3
figure 3

The dimensionless quantity related with the total mass as a function of \(\alpha \) for \(\omega = 0.15\) (a) and \(\omega =0.5\) (b)

Additionally, the gravitational surface redshift defined by \(z := \frac{1}{f(r_b)} - 1\) is calculated as

$$\begin{aligned} z =\sqrt{\frac{3(\alpha -2)}{\alpha }} -1. \end{aligned}$$
(45)
Fig. 4
figure 4

The gravitational surface redshift versus the parameter \(\alpha \)

We see that the gravitational redshift is independent of the parameters \(\omega \) and k then the limit \(\alpha \rightarrow \infty \) gives the upper bound for the redshift, \(z < 0.732\). On the other hand, \(\alpha =3\) gives \(z=0\). Then \(\alpha \) must be \(\alpha >3 \) for the observational requirements. Variation of the surface redshift is shown in Fig. 4.

In this model, we see that \(\alpha \) can be fixed by the gravitational surface redshift observations due to (45). However, the gravitational redshift measurements do not have enough precise results [89, 90]. Moreover, the observational value of the mass-radius ratio determines one of the two parameters \(\omega \) and k from (44). If we can also predict the total charge of star, we can fix \( \omega \) and k separately from (42). For example, when we take the gravitational redshift of the neutron star EXO 0748-676 as \(z=0.35\) with \(M=2M_{\odot }\) and \(R=13.1\) km [90], we find that \(\alpha \approx 5.08 \) from (45) and there is one free parameter k or \(\omega \) that must be fixed in (44). Then we can fix \(k=1\) which leads to \(\omega \approx 0.01\).

Fig. 5
figure 5

The dimensionless quantities related with the total electric charge Q (a) and the total mass M (b) as a function of \(\alpha \) for some different \( \omega \) values and \(k=1\)

3.3 The Simple Model with \(\alpha =4 \)

The model simplifies for \(\alpha =4 \) as follows

$$\begin{aligned} L= & {} \frac{1}{2\kappa } R*1 - \epsilon _0\left[ 1 + \frac{XR^2}{144 b\omega (k+1)} \right] ^{-\frac{ 9 k(\omega +1) }{X}} F\wedge *F \nonumber \\&+ 2A\wedge J + L_{mat} + \lambda _a\wedge T^a\;. \ \ \ \ \ \ \end{aligned}$$
(46)

where \(X= 8k\omega +12k -10\omega -6\) for \(\alpha =4\). Here we emphasize that the non-minimal function in this model can be expanded Maclaurin series as

$$\begin{aligned} Y(R) = 1- \frac{9k(\omega +1)}{144b \omega (k+1)} R^2 + \mathcal {O}(R^4) \end{aligned}$$
(47)

for \( | \frac{XR^2}{144b\omega (k +1) } | < 1\). Then the model admits the interior metric with the energy density, tangential pressure and electric field from (20), (21), (22) and (28)

$$\begin{aligned} ds^2 _{in}= & {} - a^2r^2 c^2 dt^2 + \frac{3}{1+br^4} dr^2 + r^2 d\Omega ^2 \; \end{aligned}$$
(48)
$$\begin{aligned} \rho (r)= & {} \frac{(k + 1)[2- 2br^4 ]}{3\kappa c^2 r^2 (\omega +1)}, \end{aligned}$$
(49)
$$\begin{aligned} p_t(r)= & {} \frac{br^2 [2(k +1) -X ]}{3\kappa (\omega +1)} + \frac{(k+1)(1- \omega )}{3\kappa (\omega +1) r^2}, \end{aligned}$$
(50)
$$\begin{aligned} E^2(r)= & {} \frac{2\omega (k +1)}{3\kappa \epsilon _0 r^2 (\omega +1)} \left[ 1+\frac{X br^4}{4\omega (k + 1)}\right] ^{1+ \frac{9k (\omega +1)}{ X}}. \end{aligned}$$
(51)

In this case, the model gives only one redshift which is \(z= 0.225\) from (45). Thus, if we observe the gravitational surface redshift for a compact star we can set the other parameters k and \(\omega \) for each observational mass value M and boundary radius \(r_b\) to describe the star.

3.4 The special case with \(k =1\)

Now we focus on the case with \(k=1\) in which the equation of state must satisfy the special constraint, \(\rho c^2 = p_r+2p_t\) because of (6). Now we compute the associated quantities by using the Eqs. (20), (21), (22)

$$\begin{aligned} \rho (r)= & {} \frac{2[ 2- br^\alpha (\alpha - 2) ]}{3\kappa c^2 r^2 (\omega +1 )}, \end{aligned}$$
(52)
$$\begin{aligned} p_t(r)= & {} \frac{( 1-\omega )[2- br^\alpha (\alpha - 2) ]}{3\kappa r^2 (\omega + 1)}, \end{aligned}$$
(53)
$$\begin{aligned} E^2(r)= & {} \frac{ 4\omega }{3\kappa \epsilon _0 r^2 (\omega + 1)} \left[ 1 + \frac{br^\alpha (3-\omega )(\alpha - 2)}{8\omega } \right] ^{1-\frac{3(\omega + 1)(\alpha + 2)}{\alpha (\omega - 3)}}, \nonumber \\ \end{aligned}$$
(54)

with the interior metric (28).

The non-minimal coupling function (26) becomes explicitly

$$\begin{aligned} Y(R) = \left[ 1 + \frac{b (3- \omega )(\alpha - 2)}{8\omega } \left( \frac{-R}{\alpha b + 2b}\right) ^{\alpha /(\alpha - 2)}\right] ^{\frac{3(\omega + 1)(\alpha + 2)}{\alpha (\omega - 3)}}.\nonumber \\ \end{aligned}$$
(55)

We also calculate the total charge inside of the sphere with radius r eliminating b from (30)

$$\begin{aligned} q^2(r) = \frac{64\pi ^2\omega \epsilon _0 r^2}{3\kappa (\omega + 1)} \left[ 1 + \frac{br^\alpha (3- \omega )(\alpha - 2)}{8\omega }\right] ^{\frac{4\omega \alpha + 6\omega + 6}{\alpha (\omega - 3)}}.\nonumber \\ \end{aligned}$$
(56)

We check that the charge is regular at the origin for \(\alpha > 2\). Then we can find the the total charge and mass in terms of the boundary radius \(r_b\), the parameters \(\omega \) and \(\alpha \) from (42) and (44).

$$\begin{aligned} Q^2 = \frac{64\pi ^2\epsilon _0\omega r_b^2}{3\kappa (\omega + 1)}\left[ 1 + \frac{3-\omega }{4\omega } \right] ^{\frac{4\omega \alpha + 6\omega + 6}{\alpha (\omega - 3)}},\nonumber \\ \end{aligned}$$
(57)
$$\begin{aligned} M = \frac{(\alpha - 3) }{(\alpha - 2)} \frac{c^2 r_b}{3G}+ \frac{2c^2\omega r_b}{3G (\omega + 1)}\left[ 1 + \frac{3- \omega }{4\omega } \right] ^{\frac{4\omega \alpha + 6\omega + 6}{\alpha (\omega - 3)}}. \nonumber \\ \end{aligned}$$
(58)

Variation of the total mass and electric charge as a function of the parameter \(\alpha \) is shown in Fig. 5 for some different \(\omega \) values. As we can see from the Figures that the increasing \(\omega \) values increase the total mass and electric charge. Then we can find upper bound for the total mass and charge by taking \(\omega =1\) and \(\alpha \rightarrow \infty \).

$$\begin{aligned} \frac{GM}{c^2 r_b} = 0.48, \quad \frac{\kappa Q^2}{16\pi ^2\epsilon _0 r_b^2} = 0.296 \end{aligned}$$
(59)

In this case, if we observe the gravitational surface redshift of a compact star, we can find \(\alpha \) from (45) and \(\omega \) from (58) for each observational mass M and boundary radius \(r_b\) ratio \(\frac{M}{r_b}\) to describe compact stars with the model. In future, the observations with different redshifts in Table 1 lead to different \(\omega \) and k values with the corresponding \(\alpha \).

Table 1 The dimensionless parameter \(\alpha \), the dimensionless charge-radius ratio \(\frac{\kappa ^2Q^2}{16\pi ^2 \epsilon _0 r_b^2} \) and the surface redshift z obtained by using the observational mass M and the radius \(r_b\) for some neutron stars with \(\omega =0.2 \) and \(k=1 \)

4 Conclusion

We have studied spherically symmetric anisotropic solutions of the non-minimally coupled \(Y(R)F^2\) theory. We have established the non-minimal model which admits the regular interior metric solutions satisfying conformal symmetry inside the star and Reissner–Nordstrom solution at the exterior assuming the linear equation of state between the radial pressure and energy density as \(p_r = \omega \rho c^2 \). We found that the pressures and energy density decrease with the radial distance r inside the star.

We matched the interior and exterior metric, and used the continuity conditions at the boundary of the star. Then we obtained such quantities as total mass, total charge and gravitational surface redshift in terms of the parameters of the model and the boundary radius of the star. We see that the parameter k can not be more than 1 for non-negative tangential pressure and can not be less than \(\frac{2}{\alpha } \) with \(\alpha >3 \) for the real valued total mass and electric charge. The total mass and electric charge increases with the increasing \(\omega \) values, while the gravitational redshift does not change. The total mass-boundary radius ratio has the upper bound \(\frac{GM}{c^2r_b} = 0.48\) which is grater than the Buchdahl bound [94] and the bounds given by [24, 84]. The gravitational redshift at the surface only depends on the parameter \(\alpha \) and increases with increasing \(\alpha \) values up to the limit \(z= 0.732\), which is the same result obtained from the isotropic case with \(k=1\) [84]. We also investigated some sub cases such as \(\alpha =4, k\ne 1\) and \(\alpha >3, k=1\), which can be model of anisotropic stars.

We note that an interesting investigation of anisotropic compact stars was recently given by Salako et al. [19] in the non-conservative theory of gravity. Then, the constants of the interior metric were determined for some known masses and radii. Then the physical parameters such as anisotropy, gravitational redshift, matter density and pressures were calculated and found that this model can describe even super-massive compact stars. On the other hand, in our conservative model (see [84] for energy-momentum conservation), \(\alpha \) can be determined by the gravitational surface redshift observations due to (45). Furthermore, if we can also determine the mass-boundary radius ratio \(\frac{M}{r_b}\) from observations, we can fix one of the two parameters \(\omega \) and k via (44). Additionally, the observation of the total charge can fix both of the parameters \(\omega \) and k from (42). Thus we can construct a non-minimal \(Y(R)F^2\) model for each charged compact star. But, the gravitational redshift measurements [89, 90] and total charge predictions do not have enough precise results. However we can predict possible ranges of these quantities.