Calculate pressure of a real gas using Van der Waal’s Equation
Last Updated :
02 Nov, 2023
Given integers V, T, and n representing the volume, temperature and the number of moles of a real gas, the task is to calculate the pressure P of the gas using Van der Waal’s Equation for real gas.
Van der Waal’s Equation for Real Gas:
( P + a * n2 / V2 ) * (V – n * b) = n R T)
where, average attraction between particles (a) = 1.360,
volume excluded by a mole of particles (b) = 0.03186,
Universal Gas constant (R) = 8.314
Examples:
Input: V = 5, T = 275, n = 6
Output: 2847.64
Input: V = 7, T = 300, n = 10
Output: 3725.43
Approach: To solve the problem, simply calculate the pressure P of real gas by using the equation P = ((n * R * T) / (V — n * b)) — (a* n * n) / (V * V) and print the result.
Below is the implementation of the above approach:
C++
#include <bits/stdc++.h>
using namespace std;
void pressure_using_vanderwall( double V,
double T, double n)
{
double a = 1.382;
double b = 0.031;
double R = 8.314;
double P = ((n * R * T) / (V - n * b))
- (a * n * n) / (V * V);
cout << P << endl;
}
int main()
{
double V = 7, T = 300, n = 10;
pressure_using_vanderwall(V, T, n);
return 0;
}
|
Java
class GFG{
public static void pressure_using_vanderwall( double V,
double T,
double n)
{
double a = 1.382 ;
double b = 0.031 ;
double R = 8.314 ;
double P = ((n * R * T) / (V - n * b)) -
(a * n * n) / (V * V);
System.out.println(String.format( "%.2f" , P));
}
public static void main(String[] args)
{
double V = 7 , T = 300 , n = 10 ;
pressure_using_vanderwall(V, T, n);
}
}
|
Python3
def pressure_using_vanderwall(V, T, n):
a = 1.382
b = 0.031
R = 8.314
P = ((n * R * T) / (V - n * b)) - (a * n * n) / (V * V)
print ( round (P, 2 ))
V, T, n = 7 , 300 , 10
pressure_using_vanderwall(V, T, n)
|
C#
using System;
class GFG{
public static void pressure_using_vanderwall( double V,
double T,
double n)
{
double a = 1.382;
double b = 0.031;
double R = 8.314;
double P = ((n * R * T) / (V - n * b)) -
(a * n * n) / (V * V);
Console.WriteLine(Math.Round(P, 2));
}
public static void Main(String[] args)
{
double V = 7, T = 300, n = 10;
pressure_using_vanderwall(V, T, n);
}
}
|
Javascript
<script>
function pressure_using_vanderwall(V, T, n)
{
let a = 1.382;
let b = 0.031;
let R = 8.314;
let P = ((n * R * T) / (V - n * b)) - (a * n * n) / (V * V);
document.write(P.toFixed(2));
}
let V = 7, T = 300, n = 10;
pressure_using_vanderwall(V, T, n);
</script>
|
Time Complexity: O(1)
Auxiliary Space: O(1)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...