# Re: Comoving Density Conversion Question

From: Antonio Bibiano <antbbn_at_gmail.com>
Date: Fri, 7 Oct 2016 13:12:06 +1100

Hi Jared,
You are right, my answer didn't actually respond.

I went back and reread your mail and I think you have it right in the last
part,
rho_phys = rho_comoving / a^3
Don't know excatly what's the error in the first formula, I suspect the
last term should be elevated to the -3 .

But this does not change the dimension conversion,when changing form Mpc/h
to cm and
M_sun/h to grams no factor of "a" should appear. They only appear when you
convert from comoving to physical.

So to recap:
rho_cgs_comoving = rho * UnitMass_in_g / UnitLength_in_cm^3 * HubbleParam^2
Comoving cgs -> physical cgs:
rho_cgs_physical = rho_cgs_comoving / a^3

Does this make more sense?

Antonio

2016-10-07 12:42 GMT+11:00 Jared Coughlin <Jared.W.Coughlin.29_at_nd.edu>:

> Hi Antonio,
> Thanks for the response! I agree that what you wrote will convert the
> density to cgs, but won't it still be comoving?
> -Jared
>
> On Oct 6, 2016 9:19 PM, "Antonio Bibiano" <antbbn_at_gmail.com> wrote:
>
>> In the user guide it says:
>>
>>> Units are again in internal code units, i.e. for the above system of
>>> units,
>>
>> rho is given in 10^10 h^-1 M_sun / ( h^-1 kpc)^3.
>>>
>> It's kind of confusing, but I think it might the same thing as every
>> other quantity in the gadget snapshots.
>>
>> To convert to cgs you should just grab the number from the snapshot,
>> let's call it rho, and do
>> rho * UnitMass_in_g / UnitLength_in_cm^3 * HubbleParam^2
>>
>> With the last multiplication only if you want to get rid of little h.
>>
>> Let me know if the result makes sense.
>>
>> Antonio
>>
>> 2016-10-06 14:42 GMT+11:00 Jared Coughlin <Jared.W.Coughlin.29_at_nd.edu>:
>>
>>> 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
>>> about them, I've been calling a gadget unit of mass a GUM and a gadget unit
>>> 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
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------------
>>>
>>> If you wish to unsubscribe from this mailing, send mail to
>>> minimalist_at_MPA-Garching.MPG.de with a subject of: unsubscribe
>>> A web-archive of this mailing list is available here:
>>>
>>>
>>
>>
>> -----------------------------------------------------------
>>
>> If you wish to unsubscribe from this mailing, send mail to
>> minimalist_at_MPA-Garching.MPG.de with a subject of: unsubscribe
>> A web-archive of this mailing list is available here:
>>
>>
>
> -----------------------------------------------------------
>
> If you wish to unsubscribe from this mailing, send mail to
> minimalist_at_MPA-Garching.MPG.de with a subject of: unsubscribe gadget-list
> A web-archive of this mailing list is available here: