We apply the Lewis-Riesenfeld invariant method for the harmonic oscillator with time dependent mass and frequency to the modes of a charged scalar field that propagates in a curved, homogeneous and isotropic spacetime. We recover the Bunch-Davies vacuum in the case of a flat DeSitter spacetime, the equivalent one in the case of a closed DeSitter spacetime and the invariant vacuum in a curved spacetime that evolves adiabatically. In the three cases, it is computed the thermodynamical magnitudes of entanglement between the modes of the particles and antiparticles of the invariant vacuum, and the modification of the Friedmann equation caused by the existence of the energy density of entanglement. The amplitude of the vacuum fluctuations are also computed.