Skip to content
This repository was archived by the owner on Sep 14, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/dft/association.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct AssociationFunctional {
impl AssociationFunctional {
pub fn new(parameters: Rc<PcSaftParameters>, max_iter: usize, tol: f64) -> Self {
Self {
parameters: parameters.clone(),
parameters,
max_iter,
tol,
}
Expand Down Expand Up @@ -54,7 +54,7 @@ where
.add(
WeightFunction {
prefactor: p.m.mapv(N::from),
kernel_radius: r.clone(),
kernel_radius: r,
shape: WeightFunctionShape::Theta,
},
true,
Expand Down
4 changes: 1 addition & 3 deletions src/dft/dispersion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ pub struct AttractiveFunctional {

impl AttractiveFunctional {
pub fn new(parameters: Rc<PcSaftParameters>) -> Self {
Self {
parameters: parameters.clone(),
}
Self { parameters }
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/dft/hard_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(super) fn hard_chain_weight_functions<N: DualNum<f64> + ScalarOperand, P: FM
lambda: bool,
) -> WeightFunctionInfo<N> {
let d = p.hs_diameter(temperature);
let mut weight_functions = WeightFunctionInfo::new(p.component_index().clone(), true)
let mut weight_functions = WeightFunctionInfo::new(p.component_index(), true)
.add(
WeightFunction {
prefactor: p.chain_length().mapv(|m| m.into()) / (&d * 8.0),
Expand Down Expand Up @@ -48,9 +48,7 @@ pub struct ChainFunctional {

impl ChainFunctional {
pub fn new(parameters: Rc<PcSaftParameters>) -> Self {
Self {
parameters: parameters.clone(),
}
Self { parameters }
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/dft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,27 @@ impl PcSaftFunctional {
) && parameters.m.len() == 1
{
let fmt_assoc = PureFMTAssocFunctional::new(parameters.clone(), fmt_version);
contributions.push(Box::new(fmt_assoc.clone()));
contributions.push(Box::new(fmt_assoc));
if parameters.m.iter().any(|&mi| mi > 1.0) {
let chain = PureChainFunctional::new(parameters.clone());
contributions.push(Box::new(chain.clone()));
contributions.push(Box::new(chain));
}
let att = PureAttFunctional::new(parameters.clone());
contributions.push(Box::new(att.clone()));
contributions.push(Box::new(att));
} else {
// Hard sphere contribution
let hs = FMTContribution::new(&parameters, fmt_version);
contributions.push(Box::new(hs.clone()));
contributions.push(Box::new(hs));

// Hard chains
if parameters.m.iter().any(|&mi| !mi.is_one()) {
let chain = ChainFunctional::new(parameters.clone());
contributions.push(Box::new(chain.clone()));
contributions.push(Box::new(chain));
}

// Dispersion
let att = AttractiveFunctional::new(parameters.clone());
contributions.push(Box::new(att.clone()));
contributions.push(Box::new(att));

// Association
if parameters.nassoc > 0 {
Expand All @@ -83,7 +83,7 @@ impl PcSaftFunctional {
saft_options.max_iter_cross_assoc,
saft_options.tol_cross_assoc,
);
contributions.push(Box::new(assoc.clone()));
contributions.push(Box::new(assoc));
}
}

Expand All @@ -93,7 +93,7 @@ impl PcSaftFunctional {
};

(Self {
parameters: parameters.clone(),
parameters,
fmt_version,
options: saft_options,
contributions,
Expand Down
2 changes: 1 addition & 1 deletion src/dft/pure_saft_functional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl<N: DualNum<f64> + ScalarOperand> FunctionalContributionDual<N> for PureChai
.add(
WeightFunction {
prefactor: (&self.parameters.m / 8.0).mapv(|x| x.into()),
kernel_radius: d.clone(),
kernel_radius: d,
shape: WeightFunctionShape::Theta,
},
false,
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#![warn(clippy::all)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_operation_groupings)]

mod dft;
mod eos;
mod parameters;
Expand Down
9 changes: 5 additions & 4 deletions tests/dft.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::excessive_precision)]
use approx::assert_relative_eq;
use feos_core::parameter::{IdentifierOption, Parameter};
use feos_core::{Contributions, PhaseEquilibrium, State};
Expand Down Expand Up @@ -41,19 +42,19 @@ fn test_bulk_implementations() -> Result<(), Box<dyn Error>> {
println!("{}: {}", p[0].0, p[0].1);
println!("{}: {}", p_pure[0].0, p_pure[0].1);
println!("{}: {}", p_full[0].0, p_full[0].1);
println!("");
println!();
println!("{:20}: {}", p[1].0, p[1].1);
println!("{:20}: {}", p_pure[1].0, p_pure[1].1);
println!("{:20}: {}", p_full[1].0, p_full[1].1);
println!("");
println!();
println!("{:21}: {}", p[2].0, p[2].1);
println!("{:21}: {}", p_pure[2].0, p_pure[2].1);
println!("{:21}: {}", p_full[2].0, p_full[2].1);
println!("");
println!();
println!("{:21}: {}", p[3].0, p[3].1);
println!("{:21}: {}", p_pure[3].0, p_pure[3].1 + p_pure[4].1);
println!("{:21}: {}", p_full[3].0, p_full[3].1 + p_full[5].1);
println!("");
println!();
println!("{:21}: {}", p[4].0, p[4].1);
println!("{:21}: {}", p_full[4].0, p_full[4].1);

Expand Down
6 changes: 3 additions & 3 deletions tests/stability_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn test_stability_analysis() -> Result<(), Box<dyn Error>> {
DensityInitialization::Liquid,
)?;
let check = unstable.stability_analysis(Default::default())?;
assert!(check.len() > 0);
assert!(!check.is_empty());

let params = PcSaftParameters::from_json(
vec!["propane", "butane"],
Expand All @@ -42,7 +42,7 @@ fn test_stability_analysis() -> Result<(), Box<dyn Error>> {
)?;
let vapor_check = vle.vapor().stability_analysis(Default::default())?;
let liquid_check = vle.liquid().stability_analysis(Default::default())?;
assert!(vapor_check.len() == 0);
assert!(liquid_check.len() == 0);
assert!(vapor_check.is_empty());
assert!(liquid_check.is_empty());
Ok(())
}