The Comprehensive Flowmeters Resource

Density Calculator

Density Calculator

Online Density Converter .Convert instantly from one Density unit to another and vice versa without having to
Use a density conversion chart.

{source}

<?php
/* Program name: DensityCalculator.php
* Description: Converts density units
* Last Updated: 15 Oct 05
*/

// define default values
$Unit_index = 5;
$Convert_value = “”;
$ConvertUnit_value = $Unit_index;
$To_value = “”;
$ToUnit_value = $Unit_index;

//define constants
$FlowRateConst = 0.002827;

// define units
$Units = array(“grains/gallon (UK)”, “grains/gallon (US)”, “grams/cubic centimeters”, “grams/liter”, “grams/milliliters”,
“kilograms/cubic meters”, “kilograms/liter”, “megagrams/cubic meter”,
“milligrams/milliliter”, “milligrams/liter”,
“ounces/cubic inch”, “ounces/gallon (UK)”, “ounces/gallon (US)”,
“pounds/cubic inch”, “pounds/cubic foot”, “pounds/gallon (UK)”, “pounds/gallon (US)”,
“slugs/cubic foot”, “tonnes/cubic meter”, “tons (UK)/cubic yard”, “tons (US)/cubic yard”);
$UnitsNo = 20;

// define conversion rates
$DensityConv[0] = 70.156;
$DensityConv[1] = 58.418;
$DensityConv[2] = 0.001;
$DensityConv[3] = 1;
$DensityConv[4] = 0.001;
$DensityConv[5] = 1;
$DensityConv[6] = 0.001;
$DensityConv[7] = 0.001;
$DensityConv[8] = 1;
$DensityConv[9] = 1000;
$DensityConv[10] = 0.00057804;
$DensityConv[11] = 0.160359;
$DensityConv[12] = 0.133526;
$DensityConv[13] = 0.0000361273;
$DensityConv[14] = 0.062428;
$DensityConv[15] = 0.010022;
$DensityConv[16] = 0.008345;
$DensityConv[17] = 0.001941;
$DensityConv[18] = 0.001;
$DensityConv[19] = 0.0007525;
$DensityConv[20] = 0.0008428;

// get selected units
if (@$_POST[‘ConvertUnit’] != “”)
{
$ConvertUnit_value = $_POST[‘ConvertUnit’];
}
else
{
$_POST[‘ConvertUnit’] = $Unit_index;
}
if (@$_POST[‘ToUnit’] != “”)
{
$ToUnit_value = $_POST[‘ToUnit’];
}
else
{
$_POST[‘ToUnit’] = $Unit_index;
}

if (@$_POST[‘Calculate’] == “Calculate”) // calculate
{
if (@$_POST[‘Convert’] != “”)
{
if ($ConvertUnit_value != $ToUnit_value)
{
if ($ConvertUnit_value != $Unit_index)
{
$To_value = 1 / $DensityConv[$ConvertUnit_value];
if ($ToUnit_value != $Unit_index)
{
$To_value = $DensityConv[$ToUnit_value] * $To_value * $_POST[‘Convert’];
}
Else
{
$To_value = $To_value * $_POST[‘Convert’];
}
}
Else
{
$To_value = $DensityConv[$ToUnit_value] * $_POST[‘Convert’];
}
}
Else
{
$To_value = $_POST[‘Convert’];
}
$_POST[‘To’] = sprintf(‘%0.8f’, $To_value);
}

}
else // reset
{
$_POST[‘Convert’] = “”;
$_POST[‘To’] = “”;
}
?>

<?php
echo “<html>
<head><title>Density Calculator</title><style type=text/css>
<!–
.style8 {color: #FFFFFF}
–>
</style>
</head>
<meta http-equiv=’Content-Type’ content=’text/html; charset=iso-8859-1′>
<META NAME=’description’ CONTENT=’Flowmeter Directory Flow meters manufacturers of magnetic turbine vortex venturi multiphase open channel variable area liquid and gas flowmeters’>
<META NAME=’keywords’ CONTENT=’Coriolis Mass,Electromagnetic Magnetic,Multiphase,Orifice plate,Positive Displacement,Target,Turbine,Thermal Mass,Ultrasonic , Venturi, Vortex shedding,flowmeter,flowmeters,flow meter,open channel,meters,measurement,directory,list ‘>
<style type=’text/css’>
<!–
body { margin: 0px 0px; padding: 0px 0px}

.size10pt { font-family: Arial, Helvetica, sans-serif; font-size: 10px}
.size12pt { font-family: Arial, Helvetica, sans-serif; font-size: 12px}
.size14pt { font-family: Arial, Helvetica, sans-serif; font-size: 14px}
.size16pt { font-family: Arial, Helvetica, sans-serif; font-size: 16px}
–>
</style>
<script language=’JavaScript’>
<!–
window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
//–>
</script>
<style type=text/css>
<!–
.style8 {color: #FFFFFF}
–>
</style>
</head>”

?>

<style type=”text/css”>
<!–
.size12pt {font-family: Arial, Helvetica, sans-serif; font-size: 12px}
–>
</style>
<body>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”5″>
<tr>
<td valign=”top”><div align=”left”>
<div align=”left”>
<div align=”left”>
<form name=”Calculator” method=”POST”>
<input type=”hidden” name=”Calculate” value=”Calculate”>
<table border=”0″ cellspacing=”0″ cellpadding=”2″>
<tr>
<td><b>Convert:</b></td>
<td><input type=”text” name=”Convert” value=”<?php echo @$_POST[‘Convert’]?>”></td>
<td><select name=”ConvertUnit”>
<?php
for ($i=0;$i<=$UnitsNo;$i++)
{
echo “<option value=’$i'”;
if (@$_POST[‘ConvertUnit’] == $i)
{
echo ” selected”;
}
echo “>$Units[$i]</option>\n”;
}
?>
</select></td>
</tr>
<tr>
<td><b>To:</b></td>
<td><input type=”text” name=”To” value=”<?php echo @$_POST[‘To’]?>”></td>
<td><select name=”ToUnit”>
<?php
for ($i=0;$i<=$UnitsNo;$i++)
{
echo “<option value=’$i'”;
if (@$_POST[‘ToUnit’] == $i)
{
echo ” selected”;
}
echo “>$Units[$i]</option>\n”;
}
?>
</select></td>
</tr>
</table>
<p>
<input name=”submit” type=”submit” value=”Calculate”>
&nbsp;&nbsp;
<input name=”button” type=”button” onClick=”self.document.Calculator.Calculate.value=’Reset’;self.document.Calculator.submit()” value=”Reset”>
</p>
<hr>
</form>
</div>
</div>

</div></td>
</tr>
</table>
</body>
</html>

{/source}

Units

Grains/gallon (UK)
Grains/ gallon (US)
Grams/ cubic centimeters
Grams/liter
Grams/milliliters
Kilograms/liter
Megagrams/ cubic meter
Milligrams/milliliter
Milligrams/liter
Ounces /cubic inch
Ounces/gallon (UK)
Ounces/gallon (US)
Pounds/cubic inch
Pounds/cubic foot
Pounds/gallon (UK)
Pounds/gallon (US)
Slugs/cubic foot
Tonnes/cubic meter
Tons (UK)/cubic yard
Tons (US) cubic yard

Featured Product of the Month!

Flowmeter Supplier Texas, Louisiana, Arkansas and more

We are teamed up with suppliers of various flow meter designs and techniques to solve flow measurements in liquids. If in doubt, give us a call. We have access to reliable flow meter solutions and manufacturers.

Scroll to Top