Skip to content

Commit e2fcc17

Browse files
committed
Restructure Python DFT interface
1 parent 3317792 commit e2fcc17

22 files changed

Lines changed: 748 additions & 1484 deletions

File tree

‎Cargo.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ petgraph = "0.8"
3838
rustdct = "0.7"
3939
rustfft = "6.0"
4040
libm = "0.2"
41-
gauss-quad = "0.3"
4241
approx = "0.5"
4342
criterion = "0.8"
4443
paste = "1.0"

‎crates/feos-dft/Cargo.toml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ rustdct = { workspace = true }
2323
rustfft = { workspace = true }
2424
num-traits = { workspace = true }
2525
libm = { workspace = true }
26-
gauss-quad = { workspace = true, optional = true }
2726
petgraph = { workspace = true }
2827

2928
feos-core = { workspace = true }
3029

3130
[features]
3231
default = []
33-
rayon = ["gauss-quad", "ndarray/rayon"]
32+
rayon = ["ndarray/rayon"]

‎crates/feos-dft/src/adsorption/external_potential.rs‎

Lines changed: 0 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
#[cfg(feature = "rayon")]
2-
use crate::adsorption::fea_potential::calculate_fea_potential;
31
use crate::functional::HelmholtzEnergyFunctional;
4-
#[cfg(feature = "rayon")]
5-
use crate::geometry::Geometry;
62
use libm::tgamma;
73
use nalgebra::DVector;
84
use ndarray::{Array1, Array2, Axis as Axis_nd};
9-
#[cfg(feature = "rayon")]
10-
use quantity::Length;
115
use std::f64::consts::PI;
126
use std::ops::Deref;
137

@@ -52,20 +46,6 @@ pub enum ExternalPotential {
5246
epsilon2_k_ss: f64,
5347
rho_s: f64,
5448
},
55-
/// Free-energy averaged potential:
56-
#[cfg(feature = "rayon")]
57-
FreeEnergyAveraged {
58-
coordinates: Length<Array2<f64>>,
59-
sigma_ss: Array1<f64>,
60-
epsilon_k_ss: Array1<f64>,
61-
pore_center: [f64; 3],
62-
system_size: [Length; 3],
63-
n_grid: [usize; 2],
64-
cutoff_radius: Option<f64>,
65-
},
66-
67-
/// Custom potential
68-
Custom(Array2<f64>),
6949
}
7050

7151
/// Parameters of the fluid required to evaluate the external potential.
@@ -89,12 +69,7 @@ impl ExternalPotential {
8969
&self,
9070
z_grid: &Array1<f64>,
9171
fluid_parameters: &P,
92-
#[cfg_attr(not(feature = "rayon"), expect(unused_variables))] temperature: f64,
9372
) -> Array2<f64> {
94-
if let ExternalPotential::Custom(potential) = self {
95-
return potential.clone();
96-
}
97-
9873
// Allocate external potential
9974
let m = fluid_parameters.m();
10075
let mut ext_pot = Array2::zeros((m.len(), z_grid.len()));
@@ -197,36 +172,6 @@ impl ExternalPotential {
197172
* (2.0 * (sigma_sf[i] / z_grid).mapv(|x| x.powi(9))
198173
- 15.0 * (sigma_sf[i] / z_grid).mapv(|x| x.powi(3))))
199174
}
200-
#[cfg(feature = "rayon")]
201-
Self::FreeEnergyAveraged {
202-
coordinates,
203-
sigma_ss,
204-
epsilon_k_ss,
205-
pore_center,
206-
system_size,
207-
n_grid,
208-
cutoff_radius,
209-
} => {
210-
// combining rules
211-
let epsilon_k_sf =
212-
(fluid_parameters.epsilon_k_ff()[i] * epsilon_k_ss).map(|e| e.sqrt());
213-
let sigma_sf = (fluid_parameters.sigma_ff()[i] + sigma_ss) * 0.5;
214-
215-
calculate_fea_potential(
216-
z_grid,
217-
mi,
218-
coordinates,
219-
sigma_sf,
220-
epsilon_k_sf,
221-
pore_center,
222-
system_size,
223-
n_grid,
224-
temperature,
225-
Geometry::Cartesian,
226-
*cutoff_radius,
227-
)
228-
}
229-
_ => unreachable!(),
230175
});
231176
}
232177
ext_pot
@@ -238,12 +183,7 @@ impl ExternalPotential {
238183
r_grid: &Array1<f64>,
239184
pore_size: f64,
240185
fluid_parameters: &P,
241-
#[cfg_attr(not(feature = "rayon"), expect(unused_variables))] temperature: f64,
242186
) -> Array2<f64> {
243-
if let ExternalPotential::Custom(potential) = self {
244-
return potential.clone();
245-
}
246-
247187
// Allocate external potential
248188
let m = fluid_parameters.m();
249189
let mut ext_pot = Array2::zeros((m.len(), r_grid.len()));
@@ -363,36 +303,6 @@ impl ExternalPotential {
363303
* sigma_sf[i].powi(3)
364304
* *rho_s)
365305
}
366-
#[cfg(feature = "rayon")]
367-
Self::FreeEnergyAveraged {
368-
coordinates,
369-
sigma_ss,
370-
epsilon_k_ss,
371-
pore_center,
372-
system_size,
373-
n_grid,
374-
cutoff_radius,
375-
} => {
376-
// combining rules
377-
let epsilon_k_sf =
378-
(fluid_parameters.epsilon_k_ff()[i] * epsilon_k_ss).map(|e| e.sqrt());
379-
let sigma_sf = (fluid_parameters.sigma_ff()[i] + sigma_ss) * 0.5;
380-
381-
calculate_fea_potential(
382-
r_grid,
383-
mi,
384-
coordinates,
385-
sigma_sf,
386-
epsilon_k_sf,
387-
pore_center,
388-
system_size,
389-
n_grid,
390-
temperature,
391-
Geometry::Cylindrical,
392-
*cutoff_radius,
393-
)
394-
}
395-
_ => unreachable!(),
396306
});
397307
}
398308
ext_pot
@@ -404,12 +314,7 @@ impl ExternalPotential {
404314
r_grid: &Array1<f64>,
405315
pore_size: f64,
406316
fluid_parameters: &P,
407-
#[cfg_attr(not(feature = "rayon"), expect(unused_variables))] temperature: f64,
408317
) -> Array2<f64> {
409-
if let ExternalPotential::Custom(potential) = self {
410-
return potential.clone();
411-
}
412-
413318
// Allocate external potential
414319
let m = fluid_parameters.m();
415320
let mut ext_pot = Array2::zeros((m.len(), r_grid.len()));
@@ -553,36 +458,6 @@ impl ExternalPotential {
553458
* (2.0 / 5.0 * sum_n(10, r_grid, sigma_sf[i], pore_size)
554459
- sum_n(4, r_grid, sigma_sf[i], pore_size)))
555460
}
556-
#[cfg(feature = "rayon")]
557-
Self::FreeEnergyAveraged {
558-
coordinates,
559-
sigma_ss,
560-
epsilon_k_ss,
561-
pore_center,
562-
system_size,
563-
n_grid,
564-
cutoff_radius,
565-
} => {
566-
// combining rules
567-
let epsilon_k_sf =
568-
(fluid_parameters.epsilon_k_ff()[i] * epsilon_k_ss).map(|e| e.sqrt());
569-
let sigma_sf = (fluid_parameters.sigma_ff()[i] + sigma_ss) * 0.5;
570-
571-
calculate_fea_potential(
572-
r_grid,
573-
mi,
574-
coordinates,
575-
sigma_sf,
576-
epsilon_k_sf,
577-
pore_center,
578-
system_size,
579-
n_grid,
580-
temperature,
581-
Geometry::Spherical,
582-
*cutoff_radius,
583-
)
584-
}
585-
_ => unreachable!(),
586461
});
587462
}
588463
ext_pot

‎crates/feos-dft/src/adsorption/fea_potential.rs‎

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)