-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathproperties.rs
More file actions
55 lines (52 loc) · 1.58 KB
/
properties.rs
File metadata and controls
55 lines (52 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use approx::assert_relative_eq;
use feos::pcsaft::{PcSaft, PcSaftParameters};
use feos_core::parameter::{IdentifierOption, Parameter};
use feos_core::{EquationOfState, StateBuilder};
use ndarray::*;
use quantity::si::*;
use std::error::Error;
use std::sync::Arc;
#[test]
fn test_dln_phi_dp() -> Result<(), Box<dyn Error>> {
let params = PcSaftParameters::from_json(
vec!["propane", "butane"],
"tests/pcsaft/test_parameters.json",
None,
IdentifierOption::Name,
)?;
let saft = Arc::new(PcSaft::new(Arc::new(params)));
let t = 300.0 * KELVIN;
let p = BAR;
let h = 1e-1 * PASCAL;
let s = StateBuilder::new(&saft)
.temperature(t)
.pressure(p)
.molefracs(&arr1(&[0.5, 0.5]))
.vapor()
.build()?;
let sh = StateBuilder::new(&saft)
.temperature(t)
.pressure(p + h)
.molefracs(&arr1(&[0.5, 0.5]))
.vapor()
.build()?;
let ln_phi = s.ln_phi()[0];
let ln_phi_h = sh.ln_phi()[0];
let dln_phi_dp = s.dln_phi_dp().get(0);
let dln_phi_dp_h = (ln_phi_h - ln_phi) / h;
assert_relative_eq!(dln_phi_dp, dln_phi_dp_h, max_relative = 1e-6);
Ok(())
}
#[test]
fn test_virial_is_not_nan() -> Result<(), Box<dyn Error>> {
let params = PcSaftParameters::from_json(
vec!["water_np"],
"tests/pcsaft/test_parameters.json",
None,
IdentifierOption::Name,
)?;
let saft = Arc::new(PcSaft::new(Arc::new(params)));
let virial_b = saft.second_virial_coefficient(300.0 * KELVIN, None)?;
assert!(!virial_b.is_nan());
Ok(())
}