This repository was archived by the owner on Sep 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathstability_analysis.rs
More file actions
48 lines (46 loc) · 1.44 KB
/
stability_analysis.rs
File metadata and controls
48 lines (46 loc) · 1.44 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
use feos_core::parameter::{IdentifierOption, Parameter};
use feos_core::{DensityInitialization, PhaseEquilibrium, State};
use feos_pcsaft::{PcSaft, PcSaftParameters};
use ndarray::arr1;
use quantity::si::*;
use std::error::Error;
use std::rc::Rc;
#[test]
fn test_stability_analysis() -> Result<(), Box<dyn Error>> {
let params = PcSaftParameters::from_json(
vec!["water_np", "hexane"],
"tests/test_parameters.json",
None,
IdentifierOption::Name,
)?;
let mix = Rc::new(PcSaft::new(Rc::new(params)));
let unstable = State::new_npt(
&mix,
300.0 * KELVIN,
1.0 * BAR,
&(arr1(&[0.5, 0.5]) * MOL),
DensityInitialization::Liquid,
)?;
let check = unstable.stability_analysis(Default::default())?;
assert!(!check.is_empty());
let params = PcSaftParameters::from_json(
vec!["propane", "butane"],
"tests/test_parameters.json",
None,
IdentifierOption::Name,
)?;
let mix = Rc::new(PcSaft::new(Rc::new(params)));
let vle = PhaseEquilibrium::bubble_point(
&mix,
300.0 * KELVIN,
&arr1(&[0.5, 0.5]),
Some(6.0 * BAR),
None,
Default::default(),
)?;
let vapor_check = vle.vapor().stability_analysis(Default::default())?;
let liquid_check = vle.liquid().stability_analysis(Default::default())?;
assert!(vapor_check.is_empty());
assert!(liquid_check.is_empty());
Ok(())
}