Density Calculator
To calculate the density of the fluid the ideal gas law is used. The 'start301' program is already equipped to handle the usual temperature units and also has the molecular weights of all the species in its database. The user specifies the pressure in Pascals. The program returns the density in the units kg/m^3. |
MATLAB Code
function
Density = rhocalc (T,P,index) % Uses the ideal gas law to calculate the density % Argument List: % T [=] temperature in the units of Tdeg % P [=] pressure in units of Pa % index [=] index of compounds whose densities are calculated % Returns: % rho [=] density in units of kg/m^3 % Example: % for a single component system of water (Tdeg=Kelvin) % >> rhocalc(500, 101325) % ans = % 0.4391 global mw T=at(T); R=8.3145; if nargin<2 fprintf('Too few arguments') elseif nargin==2 Density=P.*mw./R./T./1000; else Density=P.*mw(index)./R./T./1000; end |
Prashant Setty, 2005