用iw97公式,用java编写一个求饱和动力黏度的算法
时间: 2024-03-12 17:49:03 浏览: 16
好的,根据你的要求,我会用 Java 编写一个求饱和动力黏度的算法,其中会使用到 iw97 公式。
算法实现如下:
```java
public class SatDynViscosity {
private static final double R = 8.314472; // 气体常数
private static final double Tc = 647.096; // 临界温度
private static final double rhoc = 322; // 临界密度
private static final double pc = 22.064; // 临界压力
/**
* 计算饱和动力黏度
* @param T 温度,单位:K
* @param P 压力,单位:MPa
* @return 饱和动力黏度,单位:μPa·s
*/
public static double calc(double T, double P) {
// 计算临界压力下的归一化温度和密度
double Tr = T / Tc;
double rhor = rhoc / P;
// 计算熵
double h0 = -0.6979656 * Tr - 0.3988427 * Math.log(Tr) + 1.26613 * Tr * Tr
+ Math.pow(rhor, 0.5) * (0.0601674 * Tr - 0.1189605 * Tr * Tr + 0.1019488 * Math.pow(rhor, 0.5) - 0.0578511 * Tr * Math.pow(rhor, 0.5));
double delta_h = R * T * h0;
// 计算动力黏度
double mu0 = 2.443221E-5 * Math.pow(T, 1.5) / (T + 120);
double delta_mu = mu0 * Math.pow(Tr, 0.5) / (1 + 3.828318 * (1 - Tr) * Math.exp(-4.5775 * (1 - Tr)));
// 计算饱和动力黏度
double delta_mu_sat = delta_mu * Math.exp(delta_h / R / T);
return delta_mu_sat * 1E6; // 转换为μPa·s
}
public static void main(String[] args) {
double T = 298; // 温度,单位:K
double P = 1.01325; // 压力,单位:MPa
double mu = calc(T, P); // 计算饱和动力黏度
System.out.println("饱和动力黏度为:" + mu + " μPa·s");
}
}
```
在这个算法中,我们根据 iw97 公式计算了饱和动力黏度。在 `calc` 方法中,我们首先计算了临界压力下的归一化温度和密度,然后通过一些公式计算了熵、动力黏度和饱和动力黏度。最后,我们将计算出的饱和动力黏度转换为 μPa·s 的单位并返回。
在 `main` 方法中,我们给出了一个例子,计算出了在温度为 298 K,压力为 1.01325 MPa 时的饱和动力黏度。
注意,这个算法只是一个简单的示例,实际的应用可能需要更加复杂的计算。