Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
implemented dumb test and required imports mod cubic.rs
  • Loading branch information
JelleLagerweij committed May 16, 2025
commit 694b319465ca299902c8f12562dd256beb91ce79
3 changes: 3 additions & 0 deletions crates/feos/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"todo-tree.tree.showBadges": true
}
2 changes: 2 additions & 0 deletions crates/feos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ uvtheory = []
pets = []
saftvrqmie = []
saftvrmie = []
cubic = []
rayon = ["dep:rayon", "ndarray/rayon", "feos-core/rayon", "feos-dft?/rayon"]
all_models = [
"dft",
Expand All @@ -54,6 +55,7 @@ all_models = [
"pets",
"saftvrqmie",
"saftvrmie",
"cubic"
]

[[bench]]
Expand Down
25 changes: 25 additions & 0 deletions crates/feos/TASKS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# src/cubic/mod.rs

[x] use feos_core::parameter::Parameter;
[x] use feos_core::si::{MolarWeight, GRAM, MOL};
[X] use feos_core::{Components, Residual, StateHD};
[ ] use mixing_rules::{MixingRule, MixingRuleFunction, MixtureParameters, Quadratic};
[x] use ndarray::{Array1, ScalarOperand, Zip};
[x] use num_dual::DualNum;
[x] use std::f64::consts::SQRT_2;
[x] use std::fmt;
[x] use std::sync::Arc;


Finding Problems:
[ ] use feos_core::{EoSresult}

Still to implement:
[ ] mod alpha;
[ ] use alpha::{Alpha, AlphaFunction, PengRobinson1976, RedlichKwong1972};
[ ] mod mixing_rules;
[ ] mod parameters;
[ ] use parameters::CubicParameters;


# src/cubic/mod.rs
45 changes: 45 additions & 0 deletions crates/feos/src/cubic/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use feos_core::parameter::Parameter;
use feos_core::{Components, Residual, StateHD}; // Whereis EosResult?
use ndarray::{Array1, ScalarOperand, Zip};
use num_dual::DualNum;
use quantity::{GRAM, MOL, MolarWeight};
use std::f64::consts::SQRT_2;
use std::fmt;
use std::sync::Arc;

/// To learn some testing setup.
pub fn dumb_sum(a: f64, b: f64) -> f64 {
// This is a dumb function that just adds two numbers together.
println!("we are in the dumb function");
println!("Adding {} and {}", a, b);
let c = a + b;
println!("Result: {}", c);
c
}

#[cfg(test)]
#[cfg(feature = "cubic")]
mod tests {
use crate::cubic; // Import from parent module
use approx::assert_relative_eq;

#[test]
fn test_dumb_equation() {
let a = 1.0;
let b = 2.0;

let result = cubic::dumb_sum(a, b);
assert_relative_eq!(result, a + b, epsilon = 1e-10);
}

#[test]
fn fail_dumb_equation() {
let a = 1.0;
let b = 2.0;

let deviation = 1.0;

let result = cubic::dumb_sum(a, b);
assert_ne!(result, a + b + deviation);
}
}
1 change: 1 addition & 0 deletions crates/feos/src/cubic/parameters.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions crates/feos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub mod association;
pub mod hard_sphere;

// models
#[cfg(feature = "cubic")]
pub mod cubic;
#[cfg(feature = "epcsaft")]
pub mod epcsaft;
#[cfg(feature = "gc_pcsaft")]
Expand Down
4 changes: 2 additions & 2 deletions crates/feos/src/pcsaft/eos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::association::Association;
use crate::hard_sphere::{HardSphere, HardSphereProperties};
use feos_core::parameter::Parameter;
use feos_core::{
Components, EntropyScaling, FeosError, FeosResult, Molarweight, ReferenceSystem, Residual, State,
StateHD,
Components, EntropyScaling, FeosError, FeosResult, Molarweight, ReferenceSystem, Residual,
State, StateHD,
};
use ndarray::Array1;
use num_dual::DualNum;
Expand Down
2 changes: 1 addition & 1 deletion crates/feos/src/pets/eos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::hard_sphere::HardSphere;
use feos_core::parameter::Parameter;
use feos_core::{Components, Molarweight, Residual};
use ndarray::Array1;
use quantity::{MolarWeight, GRAM, MOL};
use quantity::{GRAM, MOL, MolarWeight};
use std::f64::consts::FRAC_PI_6;
use std::sync::Arc;

Expand Down