FUNCTION
gaslaw
Returns the pressure, volume, weight or temperature inside a gas given the other three parameters.
You're viewing an older version of this page (#382). View the current version.
Interface
#include <codecogs/engineering/fluids/imperial/gaslaw.h>
using namespace Engineering::Fluids::Imperial;
Given four of the five parameters in the ideal gas law:
this function is able to deduce the fifth one, where is the pressure of gas,
is the volume,
is the weight,
is the individual gas constant and
is the absolute temperature in degrees Rankine.
In order to return the desired parameter, the function takes a target argument which can be PRESSURE, VOLUME, WEIGHT, GAS or TEMPERATURE correspondingly. The value of the desired parameter as argument in the function call is ingored, but a convenient way is to denote it by a null value.
You may notice that in the example code below we are considering carbon dioxide with gas constant = 1130.
Example 1
#include <stdio.h>
#include <codecogs/engineering/fluids/imperial/gaslaw.h>
int main()
{
double
p = Engineering::Fluids::Imperial::gaslaw
(PRESSURE, 0, 1000, 850.3, 1130, 10),
V = Engineering::Fluids::Imperial::gaslaw
(VOLUME, 9608.39, 0, 850.3, 1130, 10),
w = Engineering::Fluids::Imperial::gaslaw
(WEIGHT, 9608.39, 1000, 0, 1130, 10),
R = Engineering::Fluids::Imperial::gaslaw
(GAS, 9608.39, 1000, 850.3, 0, 10),
T = Engineering::Fluids::Imperial::gaslaw
(TEMPERATURE, 9608.39, 1000, 850.3, 1130, 0);
printf(" Pressure = %.2lf lb/ft^3\n", p);
printf(" Volume = %.2lf ft^3\n", V);
printf(" Weight = %.2lf lb\n", w);
printf("Gas constant = %.2lf ft lb/slug deg.R\n", R);
printf(" Temperature = %.2lf deg.R\n", T);
return 0;
}Output
Pressure = 9608.39 lb/ft^3
Volume = 1000.00 ft^3
Weight = 850.30 lb
Gas constant = 1130.00 ft lb/slug deg.R
Temperature = 10.00 deg.RParameters
Returns
To add table with gas constants on http://www.engineeringtoolbox.com/individual-universal-gas-constant-d_588.html
References
The Engineering Division, Crane Co., "Flow of fluids through valves, fittings, and pipe", Chicago, 1957
Interactive Calculator
Computing…
Set a range above first to export a graph.