# $w$CDM and quintessence

i was reading about alternative dark energy models and i stumbled across the concept of quintessence: a scalar field that should generate a dark energy component with a EoS parameter $$w$$ that varies with the redshift. In particular i wanted to read more about the wcdm model in which $$w$$ is still a constant but different from -1 but every source i found simply tells that

$$p= \frac{1}{2} \dot\phi^2 + V(\phi)$$ and

$$\rho= \frac{1}{2} \dot\phi^2 - V(\phi)$$

without explaining how they reach this conclusion. i know it comes from classical field theory but i was wondering if you could give me a source where it is explained in a more pedagogical way or explain to me what's the procedure to reach this conclusion.

Using the $$(- + + +)$$ sign convention, the stress-energy tensor for a classical scalar field is $$T_{\mu \nu} = \nabla_\mu \phi \nabla_\nu \phi - \frac{1}{2} g_{\mu\nu} (\nabla^\alpha \phi \nabla_\alpha \phi)-g_{\mu\nu} V(\phi) \tag{1}$$ This can, if you wish, be derived from the Lagrangian density $$\mathcal{L}_m = -\frac12 \nabla^\alpha \phi \nabla_\alpha \phi - V(\phi)$$ and the general definition of the (Hilbert) stress-energy tensor $$T_{\mu\nu}=\frac{-2}{\sqrt{-g}}\frac{\delta \mathcal{L}_m}{\delta g^{\mu\nu}}+g_{\mu\nu}\mathcal{L}_m.$$
In a FRW metric, the assumptions of isotropy means that all the spatial derivatives of $$\phi$$ vanish in (1), but we do have that $$\partial_t \phi = \dot{\phi} \neq 0$$; in other words, $$\partial_\mu \phi = (\dot{\phi}, 0, 0, 0)$$. Plugging these components in (along with the FRW metric) and using the fact that $$\rho = T_{t} {}^t$$ and $$P = T_x {}^x$$ yields the results you wrote out your question.