Skip to content
This repository was archived by the owner on Jul 28, 2022. It is now read-only.
Merged
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
Prev Previous commit
Next Next commit
fix m for hetero functionals
  • Loading branch information
prehner committed Apr 8, 2022
commit fff69b433966a011d92253410e65c06a81dcbabf
9 changes: 5 additions & 4 deletions src/adsorption/pore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use ndarray::Axis as Axis_nd;
use ndarray::Zip;
use ndarray_stats::QuantileExt;
use quantity::{QuantityArray, QuantityArray2, QuantityArray4, QuantityScalar};
use std::borrow::Cow;
use std::rc::Rc;

const POTENTIAL_OFFSET: f64 = 2.0;
Expand Down Expand Up @@ -457,10 +458,6 @@ impl Helium {
}

impl HelmholtzEnergyFunctional for Helium {
fn components(&self) -> usize {
1
}

fn contributions(&self) -> &[Box<dyn FunctionalContribution>] {
&[]
}
Expand All @@ -472,6 +469,10 @@ impl HelmholtzEnergyFunctional for Helium {
fn compute_max_density(&self, _: &Array1<f64>) -> f64 {
1.0
}

fn m(&self) -> Cow<Array<f64, Ix1>> {
Cow::Owned(Array1::ones(1))
}
}

impl FluidParameters for Helium {
Expand Down
7 changes: 2 additions & 5 deletions src/functional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ impl<T: HelmholtzEnergyFunctional> EquationOfState for DFT<T> {

/// A general Helmholtz energy functional.
pub trait HelmholtzEnergyFunctional: Sized {
/// Return the number of components of the Helmholtz energy functional.
fn components(&self) -> usize;

/// Return a slice of [FunctionalContribution]s.
fn contributions(&self) -> &[Box<dyn FunctionalContribution>];

Expand Down Expand Up @@ -165,9 +162,9 @@ pub trait HelmholtzEnergyFunctional: Sized {
/// Return the chain length parameter $m$.
///
/// Overwrite this, if the functional describes non-spherical
/// moelcules using a homosegmented approach.
/// molecules using a homosegmented approach.
fn m(&self) -> Cow<Array1<f64>> {
Cow::Owned(Array1::ones(self.components()))
Cow::Owned(Array1::ones(self.component_index().len()))
}

/// Return the component index for every segment.
Expand Down
9 changes: 5 additions & 4 deletions src/fundamental_measure_theory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::weight_functions::{WeightFunction, WeightFunctionInfo, WeightFunction
use feos_core::EosResult;
use ndarray::*;
use num_dual::DualNum;
use std::borrow::Cow;
use std::f64::consts::PI;
use std::fmt;
use std::rc::Rc;
Expand Down Expand Up @@ -303,10 +304,6 @@ impl FMTFunctional {
}

impl HelmholtzEnergyFunctional for FMTFunctional {
fn components(&self) -> usize {
self.properties.sigma.len()
}

fn contributions(&self) -> &[Box<dyn FunctionalContribution>] {
&self.contributions
}
Expand All @@ -322,6 +319,10 @@ impl HelmholtzEnergyFunctional for FMTFunctional {
fn compute_max_density(&self, moles: &Array1<f64>) -> f64 {
moles.sum() / (moles * &self.properties.sigma).sum() * 1.2
}

fn m(&self) -> Cow<Array1<f64>> {
Cow::Owned(Array1::ones(self.properties.sigma.len()))
}
}

impl PairPotential for FMTFunctional {
Expand Down