3. The pressure of a gas changes as the volume and temperature of the gas vary.
ID: 3592494 • Letter: 3
Question
3. The pressure of a gas changes as the volume and temperature of the gas vary. Write a program that uses the Van der Waals equation of state for a gas, (P + (a*n^2) / V^2) * (V - b*n) = n*R*T to display in tabular form the relationship between the pressure and the volume of n moles of carbon dioxide at a constant absolute temperature (T). P is the pressure in atmospheres, and V is the volume in liters. The Van der Waals constants for carbon dioxide are: a = 3.592 (L^2*(atm/mol^2) and b = 0.0427 L/mol. Use 0.08206 (L*atm)/(mol*K) for the gas constant R. Inputs to the program include n, the Kelvin temperature, the initial and final volumes in milliliters, and the volume increment between lines of the table. Your program will output a table that varies the volume of the gas from the initial to the final volume in steps prescribed by the volume increment. Here is a sample run: Please enter at the prompts the number of moles of carbon dioxide, the absolute temperature, the initial volume in milliliters, the final volume, and the increment volume between lines of the table. Quantity of carbon dioxide (moles)> 0.02 Temperature (Kelvin)> 300 Initial volume (milliliters)> 400 Final volume (milliliters)> 600 Volume increment (milliliters)> 50 Output File
0.0200 moles of carbon dioxide at 300 Kelvin Volume (ml) Pressure (atm) 400 1.2246 450 1.0891 500 0.9807 550 0.8918 600 0.8178
Explanation / Answer
Program is done as per the desired output, the implemetation of Van der Walls Equation of state for gases.
Although the sample input output you are giving in the question for run does not working, as there is error in your calculation I cross checked the values in the below program are true, it is problem in your calculations So kindly check that.
// Start of program
#include <iostream>
#include <iomanip> // for displaying in formatted output
using namespace std;
int main ()
{
//Variable declarations
const double a_const= 3.592, b_const= 0.0427, R=0.08206; // Declaring constant values
double v, n, t, initial, final, inc, pressure; //Defined all used variable
char sentinel; //sentinel=n continue
//sentinel=y done
cout <<endl <<endl;
cout << "Van der Waals equation of state for a gas Enter the Values: ";
cout << "Enter quantity of carbon dioxide (moles): ";
cin >> n;
cout << " Enter the temperature (kelvin): ";
cin >> t;
cout << " Enter initial volume (milliliters): ";
cin >> initial;
cout << " Enter the final volume (mililiters): ";
cin >> final;
cout << " Enter the volume increase (mililiters): ";
cin >> inc;
cout << endl << n <<" moles of carbon dioxide at " << t <<" kelvin. ";
cout << " Volume (ml) pressure (atm) ";
for (v = initial; v <= final; v +=inc) // to diaplay against for desired increments
{
(pressure= ((n*R*t)/(v-(b_const*n)))-((a_const*n*n)/(v*v)));
// (P + (a*n^2) / V^2) * (V - b*n) = n*R*T
//Implementing van der formula
cout << setw(5) << v << setw(12) << pressure <<endl;
}
return 0;
}
// End of code
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.