📜  使用Van der Waal方程计算真实气体的压力

📅  最后修改于: 2021-05-20 07:35:36             🧑  作者: Mango

给定整数VTn,它们代表真实气体的体积,温度和摩尔数,任务是使用真实气体的Van der Waal方程计算气体的压力P。

例子:

方法:为了解决这个问题,简单地通过使用等式P计算真实气体的压力P =((N * R * T)/(V – N * B)) – (A * N * N)/(V * V)并打印结果。

下面是上述方法的实现:

C++
// C++ Program to implement
// the above approach
 
#include 
using namespace std;
 
// Function to calculate the pressure of a
// real gas using Van der Wall's equation
void pressure_using_vanderwall(double V,
                               double T, double n)
{
 
    double a = 1.382;
    double b = 0.031;
    double R = 8.314;
 
    // Calculating pressure
    double P = ((n * R * T) / (V - n * b))
               - (a * n * n) / (V * V);
 
    // Print the obtained result
    cout << P << endl;
}
 
// Driver code
int main()
{
 
    double V = 7, T = 300, n = 10;
    pressure_using_vanderwall(V, T, n);
    return 0;
}


Java
// Java program to implement
// the above approach
class GFG{
     
// Function to calculate the pressure of a
// real gas using Van der Wall's equation
public static void pressure_using_vanderwall(double V,
                                             double T,
                                             double n)
{
    double a = 1.382;
    double b = 0.031;
    double R = 8.314;
  
    // Calculating pressure
    double P = ((n * R * T) / (V - n * b)) -
                (a * n * n) / (V * V);
  
    // Print the obtained result
    System.out.println(String.format("%.2f", P));
}
 
// Driver Code
public static void main(String[] args)
{
    double V = 7, T = 300, n = 10;
     
    pressure_using_vanderwall(V, T, n);
}
}
 
// This code is contributed by divyesh072019


Python3
# Python3 Program to implement
# the above approach
 
# Function to calculate the pressure of a
# real gas using Van der Wall's equation
def pressure_using_vanderwall(V, T, n):
 
    a = 1.382
    b = 0.031
    R = 8.314
 
    # Calculating pressure
    P = ((n * R * T) / (V - n * b)) - (a * n * n) / (V * V)
 
    # Print the obtained result
    print(round(P, 2))
 
# Driver code
V, T, n = 7, 300, 10
pressure_using_vanderwall(V, T, n)
 
# This code is contributed by divyeshrabadiya07


C#
// C# program to implement
// the above approach
using System;
 
class GFG{
      
    // Function to calculate the pressure of a
    // real gas using Van der Wall's equation
    public static void pressure_using_vanderwall(double V,
                                                 double T,
                                                 double n)
    {
        double a = 1.382;
        double b = 0.031;
        double R = 8.314;
       
        // Calculating pressure
        double P = ((n * R * T) / (V - n * b)) -
                    (a * n * n) / (V * V);
       
        // Print the obtained result
        Console.WriteLine(Math.Round(P, 2));
    }
      
    // Driver Code
    public static void Main(String[] args)
    {
        double V = 7, T = 300, n = 10;
          
        pressure_using_vanderwall(V, T, n);
    }
}
  
// This code is contributed by AnkitRai01


Javascript


输出:
3725.43

时间复杂度: O(1)
辅助空间: O(1)