Scalar curvature

In a given space-time region there's a fluid with stress-energy tensor given by $$T_{\mu \nu} = {\rm diag}( - \rho , p, p, p)$$. A local observer verifies that scalar curvature $$R$$ is almost constant and that $$R \approx 1/a^2$$, in which $$a$$ is the surface radius. Can $$R$$ be negative? In my opinion, it can't, due to the fact that $$a$$ is a squared quantity, but I was thinking can $$a$$ be negative?

What if space-time is filled with an electromagnetic field $$A_{\mu}$$ characterized by the following Lagrangian density $$\mathcal{L}_{EM} = - \frac{1}{4}\sqrt{-g}F_{\mu \nu} F^{\mu \nu},$$ in this situation how can I find the scalar curvature value?

In a regular case, I would take the trace w.r.t. the metric of the Ricci tensor, but how should I do it if I have a space-time filled with some field?

Write down Einstein's equation and trace it. This will give a relation for the scalar curvature. In your example where the energy momentum tensor is the one obtained form the Maxwell Lagrangian the scalar curvature will be related to the trace of the energy momentum tensor. You can verify that for a four dimensional spacetime the scalar curvature will be zero because the Maxwell stress tensor is traceless (this happens only in four dimensions).

Starting with Einstein´s equation:

$$R_{\mu\nu}- \frac{1}{2}g_{\mu\nu}R=8 \pi G T_{\mu\nu}$$

The trace inverted version of Einsteins equation makes it easier here so, first multiplying by $$g^{\mu\nu}$$:

$$R_{\mu\nu}g^{\mu\nu}- \frac{1}{2}g_{\mu\nu}g^{\mu\nu}R=8 \pi G T_{\mu\nu}g^{\mu\nu}$$

$$R- \frac{1}{2}4R=8 \pi G T$$

$$-R=8 \pi G T$$

Multiplying everything by $$-\frac{1}{2}g_{\mu\nu}$$ we obtain:

$$\frac{1}{2}g_{\mu\nu}R=-4 \pi G T g_{\mu\nu}$$

$$- \frac{1}{2}g_{\mu\nu}R=4 \pi G T g_{\mu\nu}$$

Subtracting Einsteins equation to this one we get:

$$- \frac{1}{2}g_{\mu\nu}R - \left( R_{\mu\nu}- \frac{1}{2}g_{\mu\nu}R \right) = 4 \pi G T g_{\mu\nu} - \left( 8 \pi G T_{\mu\nu} \right)$$

$$-R_{\mu\nu}= -8 \pi G \left( -\frac{T}{2} g_{\mu\nu}+ T_{\mu\nu}\right)$$

$$R_{\mu\nu}=8 \pi G \left(T_{\mu\nu}- \frac{1}{2} g_{\mu\nu}T \right)$$

Now, considering the Maxwell energy momentum tensor, that you can obtain from varying the action w.r.t. the metric we find:

$$S=\int d^4x \sqrt-g \left( - \frac{1}{4}F_{\mu\nu}F^{\mu\nu} \right)$$

$$\delta S=\int d^4x \delta \left[ \sqrt-g \left( - \frac{1}{4}F_{\mu\nu}F^{\mu\nu} \right ) \right]$$

$$\delta S=\int d^4x \sqrt-g \left(-\frac{1}{2}\right) \left( - \frac{1}{4}F_{\alpha\beta}F^{\alpha\beta}g_{\mu\nu} +F_{\mu\beta}F^{\beta}_{\nu}\right ) \delta g^{\mu\nu}$$

The energy-momentum tensor is then:

$$T_{\mu\nu}= \frac{-2}{\sqrt-g} \frac{\delta S_{matter}}{\delta g^{\mu\nu}}$$

$$T_{\mu\nu}= \frac{-2}{\sqrt-g} \left( -\frac{1}{2} \sqrt-g \left( - \frac{1}{4}F_{\alpha\beta}F^{\alpha\beta}g_{\mu\nu} +F_{\mu\beta}F^{\beta}_{\nu}\right ) \right)$$

$$T_{\mu\nu}= - \frac{1}{4}F_{\alpha\beta}F^{\alpha\beta}g_{\mu\nu} +F_{\mu\beta}F^{\beta}_{\nu}$$

From here notice the 4D trace of the energy momentum tensor:

$$T =T_{\mu\nu} g^{\mu\nu}= - \frac{1}{4}F_{\alpha\beta}F^{\alpha\beta}g_{\mu\nu} g^{\mu\nu} +F_{\mu\beta}F^{\beta}_{\nu}g^{\mu\nu}$$

$$T = - \frac{1}{4}F_{\alpha\beta}F^{\alpha\beta}4 +F_{\mu\beta}F^{\mu\beta}=0$$

Therefore, substituting back in Einsteins equation:

$$R_{\mu\nu}=8 \pi G T_{\mu\nu}$$

Multiplying by the inverse metric tensor once more:

$$R_{\mu\nu}g^{\mu\nu}=8 \pi G T_{\mu\nu}g^{\mu\nu}$$

$$R=8 \pi G T$$

$$R=0$$

Scalar curvature can become negative. Please See the question about this issue: How to interpret the sign change of scalar Ricci curvature in Schwarzschild interior solution? .