Skip to content
This repository was archived by the owner on Jul 28, 2022. It is now read-only.

Commit 90f5466

Browse files
committed
Tangential pressure
1 parent 2baece9 commit 90f5466

9 files changed

Lines changed: 50 additions & 31 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ pyo3 = { version = "0.15", optional = true }
3434

3535
[features]
3636
default = []
37-
python = ["pyo3", "numpy", "feos-core/python"]
37+
python = ["pyo3", "numpy", "feos-core/python"]

src/adsorption/mod.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::solver::DFTSolver;
44
use feos_core::{
55
Contributions, EosError, EosResult, EosUnit, EquationOfState, StateBuilder, VLEOptions,
66
};
7-
use ndarray::{arr1, Array1, Dimension, Ix1, Ix3};
7+
use ndarray::{arr1, Array1, Dimension, Ix1, Ix3, RemoveAxis};
88
use quantity::{QuantityArray1, QuantityArray2, QuantityScalar};
99
use std::rc::Rc;
1010

@@ -55,12 +55,17 @@ where
5555
})
5656
}
5757

58-
fn equilibrium<D: Dimension, F: HelmholtzEnergyFunctional + FluidParameters>(
58+
fn equilibrium<
59+
D: Dimension + RemoveAxis + 'static,
60+
F: HelmholtzEnergyFunctional + FluidParameters,
61+
>(
5962
&self,
6063
equilibrium: &Adsorption<U, D, F>,
6164
) -> EosResult<(QuantityArray1<U>, QuantityArray1<U>)>
6265
where
6366
D::Larger: Dimension<Smaller = D>,
67+
D::Smaller: Dimension<Larger = D>,
68+
<D::Larger as Dimension>::Larger: Dimension<Smaller = D::Larger>,
6469
{
6570
let p_eq = equilibrium.pressure().get(0);
6671
match self {
@@ -111,10 +116,16 @@ pub type Adsorption1D<U, F> = Adsorption<U, Ix1, F>;
111116
/// Container structure for adsorption isotherms in 3D pores.
112117
pub type Adsorption3D<U, F> = Adsorption<U, Ix3, F>;
113118

114-
impl<U: EosUnit, D: Dimension, F: HelmholtzEnergyFunctional + FluidParameters> Adsorption<U, D, F>
119+
impl<
120+
U: EosUnit,
121+
D: Dimension + RemoveAxis + 'static,
122+
F: HelmholtzEnergyFunctional + FluidParameters,
123+
> Adsorption<U, D, F>
115124
where
116125
QuantityScalar<U>: std::fmt::Display,
117126
D::Larger: Dimension<Smaller = D>,
127+
D::Smaller: Dimension<Larger = D>,
128+
<D::Larger as Dimension>::Larger: Dimension<Smaller = D::Larger>,
118129
{
119130
fn new<S: PoreSpecification<U, D>>(
120131
functional: &Rc<DFT<F>>,

src/adsorption/pore.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::solver::DFTSolver;
88
use feos_core::{Contributions, EosResult, EosUnit, State, StateBuilder};
99
use ndarray::prelude::*;
1010
use ndarray::Axis as Axis_nd;
11-
use ndarray::Zip;
11+
use ndarray::{RemoveAxis, Zip};
1212
use ndarray_stats::QuantileExt;
1313
use quantity::{QuantityArray2, QuantityScalar};
1414
use std::rc::Rc;
@@ -132,22 +132,19 @@ impl<U: Copy, D: Dimension, F> Clone for PoreProfile<U, D, F> {
132132
}
133133
}
134134

135-
impl<U: EosUnit, D: Dimension, F: HelmholtzEnergyFunctional> PoreProfile<U, D, F>
135+
impl<U: EosUnit, D: Dimension + RemoveAxis + 'static, F: HelmholtzEnergyFunctional>
136+
PoreProfile<U, D, F>
136137
where
137138
D::Larger: Dimension<Smaller = D>,
139+
D::Smaller: Dimension<Larger = D>,
140+
<D::Larger as Dimension>::Larger: Dimension<Smaller = D::Larger>,
138141
{
139142
pub fn solve_inplace(&mut self, solver: Option<&DFTSolver>, debug: bool) -> EosResult<()> {
140143
// Solve the profile
141144
self.profile.solve(solver, debug)?;
142145

143146
// calculate grand potential density
144-
let omega = self
145-
.profile
146-
.integrate(&self.profile.dft.grand_potential_density(
147-
self.profile.temperature,
148-
&self.profile.density,
149-
&self.profile.convolver,
150-
)?);
147+
let omega = self.profile.grand_potential()?;
151148
self.grand_potential = Some(omega);
152149

153150
// calculate interfacial tension

src/functional.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl<T: HelmholtzEnergyFunctional> DFT<T> {
190190
let rho = density.to_reduced(U::reference_density()).unwrap();
191191
let (mut f, dfdrho) = self.functional_derivative(t, &rho, convolver)?;
192192

193-
// calculate the grand potential density
193+
// Calculate the grand potential density
194194
for ((rho, dfdrho), &m) in rho.outer_iter().zip(dfdrho.outer_iter()).zip(self.m.iter()) {
195195
f -= &((&dfdrho + m) * &rho);
196196
}

src/interface/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,8 @@ impl<U: EosUnit, F: HelmholtzEnergyFunctional> PlanarInterface<U, F> {
4040

4141
// postprocess
4242
self.surface_tension = Some(self.profile.integrate(
43-
&(self.profile.dft.grand_potential_density(
44-
self.profile.temperature,
45-
&self.profile.density,
46-
&self.profile.convolver,
47-
)? + self.vle.vapor().pressure(Contributions::Total)),
43+
&(self.profile.grand_potential_density()?
44+
+ self.vle.vapor().pressure(Contributions::Total)),
4845
));
4946
let delta_rho = self.vle.liquid().density - self.vle.vapor().density;
5047
self.equimolar_radius = Some(

src/profile.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,15 @@ where
555555
Ok(self.integrate(&self.entropy_density(contributions)?))
556556
}
557557

558+
pub fn grand_potential_density(&self) -> EosResult<QuantityArray<U, D>> {
559+
self.dft
560+
.grand_potential_density(self.temperature, &self.density, &self.convolver)
561+
}
562+
563+
pub fn grand_potential(&self) -> EosResult<QuantityScalar<U>> {
564+
Ok(self.integrate(&self.grand_potential_density()?))
565+
}
566+
558567
pub fn internal_energy(&self, contributions: Contributions) -> EosResult<QuantityScalar<U>> {
559568
// initialize convolver
560569
let t = self.temperature.to_reduced(U::reference_temperature())?;

src/python/profile.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,20 @@ macro_rules! impl_profile {
171171
self.0.profile.internal_energy(contributions.0)?,
172172
))
173173
}
174+
175+
#[getter]
176+
fn grand_potential_density(&self) -> PyResult<$si_arr> {
177+
Ok($si_arr::from(
178+
self.0.profile.grand_potential_density()?,
179+
))
180+
}
181+
182+
#[getter]
183+
fn grand_potential(&self) -> PyResult<PySINumber> {
184+
Ok(PySINumber::from(
185+
self.0.profile.grand_potential()?,
186+
))
187+
}
174188
}
175189
};
176190
}

src/solvation/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,7 @@ impl<U: EosUnit, F: HelmholtzEnergyFunctional> SolvationProfile<U, F> {
3636
self.profile.solve(solver, debug)?;
3737

3838
// calculate grand potential density
39-
let omega = self
40-
.profile
41-
.integrate(&self.profile.dft.grand_potential_density(
42-
self.profile.temperature,
43-
&self.profile.density,
44-
&self.profile.convolver,
45-
)?);
39+
let omega = self.profile.grand_potential()?;
4640
self.grand_potential = Some(omega);
4741

4842
// calculate solvation free energy

src/solvation/pair_correlation.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,8 @@ impl<U: EosUnit, F: HelmholtzEnergyFunctional + PairPotential> PairCorrelation<U
7676

7777
// calculate self solvation free energy
7878
self.self_solvation_free_energy = Some(self.profile.integrate(
79-
&(self.profile.dft.grand_potential_density(
80-
self.profile.temperature,
81-
&self.profile.density,
82-
&self.profile.convolver,
83-
)? + self.profile.bulk.pressure(Contributions::Total)),
79+
&(self.profile.grand_potential_density()?
80+
+ self.profile.bulk.pressure(Contributions::Total)),
8481
));
8582

8683
// calculate structure factor

0 commit comments

Comments
 (0)