To discover how temperature affects the density of a fluid substance, use one of two methods depending on the fluid you wish to measure. For gases, use an adaptation of the Ideal Gas Law, which, when rewritten, gives you the equation for density based on the temperature and pressure. For other fluids such as water or alcohol, you must use more information to find their densities at various temperatures. When you have all of the information required for the calculation, solving it just takes a little math.
Find the Density of Liquids
Subtract the final temperature in degrees Celsius from the initial temperature in degrees Celsius. For instance, a final temperature of 20 degrees C and an initial temperature of 30 degrees Celsius would yield a difference of: 30 degrees C – 20 degrees C = 10 degrees C.
Multiply this temperature difference by the volumetric temperature expansion coefficient for the substance being measured, and add one to this number. If using water, for the example, use its volumetric temperature expansion coefficient (0.0002 m3/m3 degrees C) and multiply it by the temperature difference of the example: 10 degrees C = 0.0002 x 10 = 0.002. Add one to this number to get: 1 + 0.002 = 1.002.
Divide the initial density of the fluid by this number to find the final density at the new temperature. If the initial density of the water was 1000 kg/m3 then divide this by 1.002 to find the final density: 1000/1.002 = 998 kg/m3.
Find the Density of Gases
Add 273.15 to the degrees in Celsius to find the degrees in Kelvin. For instance, a temperature of 10 degrees C = 10 + 273.15 = 283.15 Kelvin
Multiply the temperature in Kelvin by the gas constant. In dry air with a gas constant of 287.05 J/(kg*degreesK) 283.15 x 287.05 = 81278.21
Divide this number by the current pressure measured in Pascals to find the density in kg/m3. For instance, a pressure of 10,000 Pascals would result in 10,000 Pascals/81278.21 = 0.123 kg/m3
TL;DR (Too Long; Didn't Read)
Some commonly used volumetric expansion coefficients include: water : 0.0002 (m3/m3 oC) ethyl alcohol : 0.0011 (m3/m3 oC)
For the gas constant of dry air, use: 287.05 J/(kg*degK)
You will need to know the pressure of a gas measured with the unit Pascals. If you only have the pressure in mb, multiply the pressure in mb by100 to convert the pressure of the gas to Pascals. (see reference 1)