Skip to content

Commit 806a8e7

Browse files
authored
Implement pair_potential function for pets and pcsaft (#24)
* Implement pair_potential function for pets and pcsaft * fixes
1 parent bb82878 commit 806a8e7

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/pcsaft/dft/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ impl FluidParameters for PcSaftFunctional {
166166

167167
impl PairPotential for PcSaftFunctional {
168168
fn pair_potential(&self, i: usize, r: &Array1<f64>, _: f64) -> Array2<f64> {
169-
unimplemented!()
169+
let sigma_ij = &self.parameters.sigma_ij;
170+
let eps_ij_4 = 4.0 * &self.parameters.epsilon_k_ij;
171+
Array::from_shape_fn((self.parameters.m.len(), r.len()), |(j, k)| {
172+
let att = (sigma_ij[[i, j]] / r[k]).powi(6);
173+
eps_ij_4[[i, j]] * att * (att - 1.0)
174+
})
170175
}
171176
}

src/pets/dft/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,16 @@ impl FluidParameters for PetsFunctional {
143143

144144
impl PairPotential for PetsFunctional {
145145
fn pair_potential(&self, i: usize, r: &Array1<f64>, _: f64) -> Array2<f64> {
146-
todo!()
146+
let eps_ij_4 = 4.0 * self.parameters.epsilon_k_ij.clone();
147+
let shift_ij = &eps_ij_4 * (2.5.powi(-12) - 2.5.powi(-6));
148+
let rc_ij = 2.5 * &self.parameters.sigma_ij;
149+
Array::from_shape_fn((self.parameters.sigma.len(), r.len()), |(j, k)| {
150+
if r[k] > rc_ij[[i, j]] {
151+
0.0
152+
} else {
153+
let att = (self.parameters.sigma_ij[[i, j]] / r[k]).powi(6);
154+
eps_ij_4[[i, j]] * att * (att - 1.0) - shift_ij[[i, j]]
155+
}
156+
})
147157
}
148158
}

0 commit comments

Comments
 (0)