You are on page 1of 8

Introduction.

The Van Der Waals equation is an equation of state for a fluid composed of
particles that have a non-zero volume and a pairwise attractive inter-particle force.
The equation uses the following state variables:
a). The pressure of the fluid, p
b). total volume of the container containing the fluid V
c). number of moles, n
d). absolute temperature of the system, K

The function of the program is to use Van der Waals equation of state for a
gas 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). It also shows
the volume of gas from the initial to final volume by the volume increment.

Algorithm.

Test Data.

Program Source Code.


#include <iostream>
using namespace std;

// Define constants.
#define a 3.952
#define b 0.0427
#define R 0.08206
#define mL_L .001

int main ()
{

double Nofmoles;
double temp;
double initialV;

//Number of moles of CO2 (n).


//Temperature (K).
//Initial volume (mL).

double finalV;

//Final volume (mL).

double incrementV;

//Increment volume (mL) b/w lines of the

table.
double pressure;

//Pressure (atm).

double volumeV;

//Variable assignment for calculations.

int ans;

//Repetition

do
{
cout<<"\n ****** Van Der Waals Equations ******\n";
cout<<" Welcome to Van Der Waals equation.\n ";

//Request user input.


cout<<"\n Please enter the quantity of Carbon Dioxide (moles)
==> ";
cin>> Nofmoles;

cout<<"\n Please enter the Temperature (K) ==> ";


cin>>temp;

cout<<"\n Please enter the Initial Volume (mL) ==> ";


cin >>initialV;

cout<<"\n Please enter the Final Volume (mL) ==> ";


cin>>finalV;

cout<<"\n Please enter the Volume Increment (mL) ==> ";


cin>>incrementV;

//Set for table.

cout << "\n\n Volume (mL)

Pressure (atm)" << endl;

//formula and calculations.

for(initialV; initialV <= finalV; initialV += incrementV)


{
cout<<" "<<initialV;

volumeV = initialV * mL_L;


pressure = ((Nofmoles * R * temp)/(volumeV - b *
Nofmoles))-((a * Nofmoles * Nofmoles)/(volumeV * volumeV));

cout<<" \t\t "<< pressure<<endl;

while (initialV <= finalV);

//Repetition

cout<< "\n Do you wish to continue ?\n";


cout<< " Press 1 to continue.\n";
cout<< " Press 2 to EXIT.\n";
cin >>ans;

while(ans<2);

//user exits the system


if(ans=2);
cout<<"\n Thank you for using our service.";

return 0;
}

You might also like