# Comoving Density Conversion Question

From: Jared Coughlin <Jared.W.Coughlin.29_at_nd.edu>
Date: Wed, 5 Oct 2016 23:42:43 -0400

Hello! I know this is a pretty stupid question, but I'm drawing a blank on
it so I figured I'd ask. I want to know how to convert density from
comoving gadget units to proper cgs units. I've run a cosmological
simulation (so comoving integration is on), which means that Gadget is
writing the densities in comoving internal code units. For ease of talking
of length a GUL.

(NOTE: I'm using the tex for gmail plugin on chrome, if that helps make

That is,

1GUL = 3.085678e21 cm/h = X cm/h
1GUM = 1.989e43 g/h = Y g/h (the use of X and Y is just for ease of writing)

in the default system, which is what I'm using. For one of my analysis
codes I need to convert the densities from comoving gadget units to proper
cgs units. Let a subscript c is for comoving, and a subscript p is for
proper, and the cg subscript is for comoving gadget units.

[image: \rho_{cg} =
\left(\frac{|\rho_{cg}|\text{GUM}}{\text{GUL}_c^3}\right)\left(\frac{Y\text{g}}{h\text{GUM}}\right)\left(\frac{h\text{GUL}_c}{X\text{cm}_c}\right)^3\left(\frac{1\text{cm}_c}{\frac{1\text{cm}_p}{a}}\right)^3]

Where the || just means the magnitude of the density (no units attached).
This is the number contained in the snapshot. The above simplifies to:
[image: \rho_{cg} =
|\rho_{cg}|\left(\frac{Y}{X^3}\right)a^3h^2\text{gcm}^{-3}_p]

Therefore, it seems to me, from the above, that the magnitude of the
density in proper cgs units is the value given in the snapshot ([image:
|\rho_{cg}|]) multiplied by the scale factor cubed and then the other
constants. That is:

[image: |\rho_{p\text{cgs}}|=|\rho_{cg}|\left(\frac{Y}{X^3}\right)a^3h^2]

However, this seems wrong to me, as I know that:

[image: \rho_c=a^3\rho_p]

So it seems like I could do:

[image: \rho_{pg}=\frac{\rho_{cg}}{a^3}]

That is, the density in proper gadget units is just the value given in the
snapshot divided by the scale factor cubed. This quantity could then
undergo the conversion to cgs units as above, with the only difference
being that this method has me dividing by the scale factor cubed, which is,
of course, different than what happened the first time.

I've thought myself into a corner on this, if that makes any sense, and so
my question is this: Can anyone tell me the right way to convert the
densities from comoving gadget units to proper cgs units? I would greatly
appreciate it, and I apologize for such a stupid question. Thank you very
much!

Sincerely,
-Jared