|
1 | 1 | use approx::assert_relative_eq; |
2 | 2 | use feos::pcsaft::{PcSaft, PcSaftParameters}; |
3 | | -use feos_core::State; |
4 | 3 | use feos_core::parameter::IdentifierOption; |
| 4 | +use feos_core::{SolverOptions, State}; |
5 | 5 | use nalgebra::dvector; |
6 | 6 | use quantity::*; |
7 | 7 | use std::error::Error; |
| 8 | +use std::sync::Arc; |
8 | 9 | use typenum::P3; |
9 | 10 |
|
10 | 11 | #[test] |
@@ -47,3 +48,31 @@ fn test_critical_point_mix() -> Result<(), Box<dyn Error>> { |
47 | 48 | ); |
48 | 49 | Ok(()) |
49 | 50 | } |
| 51 | + |
| 52 | +#[test] |
| 53 | +fn test_critical_point_limits() -> Result<(), Box<dyn Error>> { |
| 54 | + let params = PcSaftParameters::from_json( |
| 55 | + vec!["propane", "butane"], |
| 56 | + "tests/pcsaft/test_parameters.json", |
| 57 | + None, |
| 58 | + IdentifierOption::Name, |
| 59 | + )?; |
| 60 | + let options = SolverOptions { |
| 61 | + verbosity: feos_core::Verbosity::Iter, |
| 62 | + ..Default::default() |
| 63 | + }; |
| 64 | + let saft = Arc::new(PcSaft::new(params)); |
| 65 | + let cp_pure = State::critical_point_pure(&saft, None, None, options)?; |
| 66 | + println!("{} {}", cp_pure[0], cp_pure[1]); |
| 67 | + let molefracs = dvector![0.0, 1.0]; |
| 68 | + let cp_2 = State::critical_point(&saft, Some(&molefracs), None, None, options)?; |
| 69 | + println!("{}", cp_2); |
| 70 | + let molefracs = dvector![1.0, 0.0]; |
| 71 | + let cp_1 = State::critical_point(&saft, Some(&molefracs), None, None, options)?; |
| 72 | + println!("{}", cp_1); |
| 73 | + assert_eq!(cp_pure[0].temperature, cp_1.temperature); |
| 74 | + assert_eq!(cp_pure[0].density, cp_1.density); |
| 75 | + assert_eq!(cp_pure[1].temperature, cp_2.temperature); |
| 76 | + assert_eq!(cp_pure[1].density, cp_2.density); |
| 77 | + Ok(()) |
| 78 | +} |
0 commit comments