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
11 changes: 5 additions & 6 deletions src/dft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::eos::PcSaftOptions;
use crate::parameters::PcSaftParameters;
use association::AssociationFunctional;
use dispersion::AttractiveFunctional;
use feos_core::parameter::Parameter;
use feos_core::MolarWeight;
use feos_dft::adsorption::FluidParameters;
use feos_dft::fundamental_measure_theory::{FMTContribution, FMTProperties, FMTVersion};
Expand Down Expand Up @@ -30,21 +31,19 @@ pub struct PcSaftFunctional {
}

impl PcSaftFunctional {
pub fn new(parameters: PcSaftParameters) -> DFT<Self> {
pub fn new(parameters: Rc<PcSaftParameters>) -> DFT<Self> {
Self::new_with_options(parameters, FMTVersion::WhiteBear, PcSaftOptions::default())
}

pub fn new_full(parameters: PcSaftParameters, fmt_version: FMTVersion) -> DFT<Self> {
pub fn new_full(parameters: Rc<PcSaftParameters>, fmt_version: FMTVersion) -> DFT<Self> {
Self::new_with_options(parameters, fmt_version, PcSaftOptions::default())
}

fn new_with_options(
parameters: PcSaftParameters,
parameters: Rc<PcSaftParameters>,
fmt_version: FMTVersion,
saft_options: PcSaftOptions,
) -> DFT<Self> {
let parameters = Rc::new(parameters);

let mut contributions: Vec<Box<dyn FunctionalContribution>> = Vec::with_capacity(4);

if matches!(
Expand Down Expand Up @@ -100,7 +99,7 @@ impl PcSaftFunctional {
impl HelmholtzEnergyFunctional for PcSaftFunctional {
fn subset(&self, component_list: &[usize]) -> DFT<Self> {
Self::new_with_options(
self.parameters.subset(component_list),
Rc::new(self.parameters.subset(component_list)),
self.fmt_version,
self.options,
)
Expand Down
2 changes: 0 additions & 2 deletions src/eos/association.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ use std::f64::consts::{FRAC_PI_3, PI};
use std::fmt;
use std::rc::Rc;

#[derive(Debug, Clone)]
pub struct Association {
pub parameters: Rc<PcSaftParameters>,
}

#[derive(Debug, Clone)]
pub struct CrossAssociation {
pub parameters: Rc<PcSaftParameters>,
pub max_iter: usize,
Expand Down
9 changes: 4 additions & 5 deletions src/eos/dispersion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ pub const B2: [f64; 7] = [
-29.66690558514725,
];

#[derive(Debug, Clone)]
pub struct Dispersion {
pub parameters: Rc<PcSaftParameters>,
}
Expand Down Expand Up @@ -132,7 +131,7 @@ mod tests {
#[test]
fn helmholtz_energy() {
let disp = Dispersion {
parameters: Rc::new(propane_parameters()),
parameters: propane_parameters(),
};
let t = 250.0;
let v = 1000.0;
Expand All @@ -145,13 +144,13 @@ mod tests {
#[test]
fn mix() {
let c1 = Dispersion {
parameters: Rc::new(propane_parameters()),
parameters: propane_parameters(),
};
let c2 = Dispersion {
parameters: Rc::new(butane_parameters()),
parameters: butane_parameters(),
};
let c12 = Dispersion {
parameters: Rc::new(propane_butane_parameters()),
parameters: propane_butane_parameters(),
};
let t = 250.0;
let v = 2.5e28;
Expand Down
9 changes: 4 additions & 5 deletions src/eos/hard_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use num_dual::*;
use std::fmt;
use std::rc::Rc;

#[derive(Debug, Clone)]
pub struct HardChain {
pub parameters: Rc<PcSaftParameters>,
}
Expand Down Expand Up @@ -45,7 +44,7 @@ mod tests {
#[test]
fn helmholtz_energy() {
let hc = HardChain {
parameters: Rc::new(propane_parameters()),
parameters: propane_parameters(),
};
let t = 250.0;
let v = 1000.0;
Expand All @@ -58,13 +57,13 @@ mod tests {
#[test]
fn mix() {
let c1 = HardChain {
parameters: Rc::new(propane_parameters()),
parameters: propane_parameters(),
};
let c2 = HardChain {
parameters: Rc::new(butane_parameters()),
parameters: butane_parameters(),
};
let c12 = HardChain {
parameters: Rc::new(propane_butane_parameters()),
parameters: propane_butane_parameters(),
};
let t = 250.0;
let v = 2.5e28;
Expand Down
9 changes: 4 additions & 5 deletions src/eos/hard_sphere.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ impl PcSaftParameters {
}
}

#[derive(Debug, Clone)]
pub struct HardSphere {
pub parameters: Rc<PcSaftParameters>,
}
Expand Down Expand Up @@ -76,7 +75,7 @@ mod tests {
#[test]
fn helmholtz_energy() {
let hs = HardSphere {
parameters: Rc::new(propane_parameters()),
parameters: propane_parameters(),
};
let t = 250.0;
let v = 1000.0;
Expand All @@ -89,13 +88,13 @@ mod tests {
#[test]
fn mix() {
let c1 = HardSphere {
parameters: Rc::new(propane_parameters()),
parameters: propane_parameters(),
};
let c2 = HardSphere {
parameters: Rc::new(butane_parameters()),
parameters: butane_parameters(),
};
let c12 = HardSphere {
parameters: Rc::new(propane_butane_parameters()),
parameters: propane_butane_parameters(),
};
let t = 250.0;
let v = 2.5e28;
Expand Down
21 changes: 7 additions & 14 deletions src/eos/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::parameters::PcSaftParameters;
use feos_core::joback::Joback;
use feos_core::parameter::Parameter;
use feos_core::{
Contributions, EntropyScaling, EosError, EosResult, EosUnit, EquationOfState, HelmholtzEnergy,
IdealGasContribution, MolarWeight, State,
Expand Down Expand Up @@ -53,12 +54,11 @@ pub struct PcSaft {
}

impl PcSaft {
pub fn new(parameters: PcSaftParameters) -> Self {
pub fn new(parameters: Rc<PcSaftParameters>) -> Self {
Self::with_options(parameters, PcSaftOptions::default())
}

pub fn with_options(parameters: PcSaftParameters, options: PcSaftOptions) -> Self {
let parameters = Rc::new(parameters);
pub fn with_options(parameters: Rc<PcSaftParameters>, options: PcSaftOptions) -> Self {
let mut contributions: Vec<Box<dyn HelmholtzEnergy>> = Vec::with_capacity(7);
contributions.push(Box::new(HardSphere {
parameters: parameters.clone(),
Expand Down Expand Up @@ -117,17 +117,10 @@ impl EquationOfState for PcSaft {
}

fn subset(&self, component_list: &[usize]) -> Self {
Self::with_options(self.parameters.subset(component_list), self.options)
// match &self.ideal_gas {
// IdealGasContributions::QSPR(_) => {
// Self::with_options(self.parameters.subset(component_list), self.options, None)
// }
// IdealGasContributions::Joback(joback) => Self::with_options(
// self.parameters.subset(component_list),
// self.options,
// Some(joback.parameters.subset(component_list)),
// ),
// }
Self::with_options(
Rc::new(self.parameters.subset(component_list)),
self.options,
)
}

fn compute_max_density(&self, moles: &Array1<f64>) -> f64 {
Expand Down
5 changes: 1 addition & 4 deletions src/eos/polar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ fn triplet_integral_ijk_dq<D: DualNum<f64>>(mijk: f64, eta: D, c: &[[f64; 2]]) -
.sum()
}

#[derive(Debug, Clone)]
pub struct Dipole {
pub parameters: Rc<PcSaftParameters>,
}
Expand Down Expand Up @@ -278,7 +277,6 @@ impl fmt::Display for Dipole {
}
}

#[derive(Debug, Clone)]
pub struct Quadrupole {
pub parameters: Rc<PcSaftParameters>,
}
Expand Down Expand Up @@ -376,13 +374,12 @@ impl fmt::Display for Quadrupole {
}
}

#[derive(Debug, Clone)]
#[derive(Clone, Copy)]
pub enum DQVariants {
DQ35,
DQ44,
}

#[derive(Debug, Clone)]
pub struct DipoleQuadrupole {
pub parameters: Rc<PcSaftParameters>,
pub variant: DQVariants,
Expand Down
1 change: 0 additions & 1 deletion src/eos/qspr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const AP_400: [f64; 6] = [
-12669.4196622924,
];

#[derive(Debug)]
#[allow(clippy::upper_case_acronyms)]
pub struct QSPR {
pub parameters: Rc<PcSaftParameters>,
Expand Down
Loading