Skip to content

Commit 6582113

Browse files
committed
[restructured contribution] adding bond-atom spherical decomposition
1 parent acd18cc commit 6582113

File tree

11 files changed

+1728
-14
lines changed

11 files changed

+1728
-14
lines changed

rascaline/src/calculators/bondatom_neighbor_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ mod tests {
759759
use metatensor::Labels;
760760

761761
use crate::calculators::bondatom_neighbor_list::FullBANeighborList;
762-
use crate::systems::test_utils::{test_systems, test_system};
762+
use crate::systems::test_utils::{test_systems};
763763
use crate::Calculator;
764764

765765
use super::{BANeighborList, HalfBANeighborList};

rascaline/src/calculators/descriptors_by_systems.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ struct UnsafeArrayViewMut {
2222
data: *mut f64,
2323
}
2424

25+
impl UnsafeArrayViewMut{
26+
fn as_arrayview(&self) -> ndarray::ArrayView<f64,ndarray::IxDyn> {
27+
// SAFETY: we checked that the arrays do not overlap when creating
28+
// `UnsafeArrayViewMut` in split_by_system
29+
unsafe{ndarray::ArrayView::from_shape_ptr(self.shape.clone(), self.data)}
30+
}
31+
fn as_arrayview_mut(&mut self) -> ndarray::ArrayViewMut<f64,ndarray::IxDyn> {
32+
// SAFETY: we checked that the arrays do not overlap when creating
33+
// `UnsafeArrayViewMut` in split_by_system
34+
unsafe{ndarray::ArrayViewMut::from_shape_ptr(self.shape.clone(), self.data)}
35+
}
36+
}
37+
2538
// SAFETY: `UnsafeArrayViewMut` can be transferred from one thread to another
2639
unsafe impl Send for UnsafeArrayViewMut {}
2740
// SAFETY: `UnsafeArrayViewMut` is Sync since there is no interior mutability
@@ -74,12 +87,7 @@ impl metatensor::Array for UnsafeArrayViewMut {
7487
/// Extract an array stored in the `TensorBlock` returned by `split_tensor_map_by_system`
7588
pub fn array_mut_for_system(array: metatensor::ArrayRefMut<'_>) -> ArrayViewMutD<'_, f64> {
7689
let array = array.to_any_mut().downcast_mut::<UnsafeArrayViewMut>().expect("invalid array type");
77-
78-
// SAFETY: we checked that the arrays do not overlap when creating
79-
// `UnsafeArrayViewMut` in split_by_system
80-
return unsafe {
81-
ArrayViewMutD::from_shape_ptr(array.shape.clone(), array.data)
82-
};
90+
array.as_arrayview_mut()
8391
}
8492

8593
/// View inside a `TensorMap` corresponding to one system

rascaline/src/calculators/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ pub(crate) use self::descriptors_by_systems::{array_mut_for_system, split_tensor
9696
pub mod soap;
9797
pub use self::soap::{SphericalExpansionByPair, SphericalExpansionParameters};
9898
pub use self::soap::SphericalExpansion;
99+
pub use self::soap::{SphericalExpansionForBondType, SphericalExpansionForBondsParameters};
100+
pub use self::soap::SphericalExpansionForBonds;
99101
pub use self::soap::{SoapPowerSpectrum, PowerSpectrumParameters};
100102
pub use self::soap::{SoapRadialSpectrum, RadialSpectrumParameters};
101103

rascaline/src/calculators/soap/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ pub use self::cutoff::RadialScaling;
1212
mod spherical_expansion_pair;
1313
pub use self::spherical_expansion_pair::{SphericalExpansionByPair, SphericalExpansionParameters};
1414

15+
mod spherical_expansion_bondcentered_pair;
16+
pub use self::spherical_expansion_bondcentered_pair::{SphericalExpansionForBondType, SphericalExpansionForBondsParameters};
17+
1518
mod spherical_expansion;
1619
pub use self::spherical_expansion::SphericalExpansion;
1720

21+
mod spherical_expansion_bondcentered;
22+
pub use self::spherical_expansion_bondcentered::SphericalExpansionForBonds;
23+
1824
mod power_spectrum;
1925
pub use self::power_spectrum::{SoapPowerSpectrum, PowerSpectrumParameters};
2026

0 commit comments

Comments
 (0)