Skip to content

Commit

Permalink
[restructured contribution] adding bond-atom spherical decomposition
Browse files Browse the repository at this point in the history
  • Loading branch information
liam-o-marsh committed Oct 3, 2023
1 parent acd18cc commit 6582113
Show file tree
Hide file tree
Showing 11 changed files with 1,728 additions and 14 deletions.
2 changes: 1 addition & 1 deletion rascaline/src/calculators/bondatom_neighbor_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ mod tests {
use metatensor::Labels;

use crate::calculators::bondatom_neighbor_list::FullBANeighborList;
use crate::systems::test_utils::{test_systems, test_system};
use crate::systems::test_utils::{test_systems};
use crate::Calculator;

use super::{BANeighborList, HalfBANeighborList};
Expand Down
20 changes: 14 additions & 6 deletions rascaline/src/calculators/descriptors_by_systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ struct UnsafeArrayViewMut {
data: *mut f64,
}

impl UnsafeArrayViewMut{
fn as_arrayview(&self) -> ndarray::ArrayView<f64,ndarray::IxDyn> {
// SAFETY: we checked that the arrays do not overlap when creating
// `UnsafeArrayViewMut` in split_by_system
unsafe{ndarray::ArrayView::from_shape_ptr(self.shape.clone(), self.data)}
}
fn as_arrayview_mut(&mut self) -> ndarray::ArrayViewMut<f64,ndarray::IxDyn> {
// SAFETY: we checked that the arrays do not overlap when creating
// `UnsafeArrayViewMut` in split_by_system
unsafe{ndarray::ArrayViewMut::from_shape_ptr(self.shape.clone(), self.data)}
}
}

// SAFETY: `UnsafeArrayViewMut` can be transferred from one thread to another
unsafe impl Send for UnsafeArrayViewMut {}
// SAFETY: `UnsafeArrayViewMut` is Sync since there is no interior mutability
Expand Down Expand Up @@ -74,12 +87,7 @@ impl metatensor::Array for UnsafeArrayViewMut {
/// Extract an array stored in the `TensorBlock` returned by `split_tensor_map_by_system`
pub fn array_mut_for_system(array: metatensor::ArrayRefMut<'_>) -> ArrayViewMutD<'_, f64> {
let array = array.to_any_mut().downcast_mut::<UnsafeArrayViewMut>().expect("invalid array type");

// SAFETY: we checked that the arrays do not overlap when creating
// `UnsafeArrayViewMut` in split_by_system
return unsafe {
ArrayViewMutD::from_shape_ptr(array.shape.clone(), array.data)
};
array.as_arrayview_mut()
}

/// View inside a `TensorMap` corresponding to one system
Expand Down
2 changes: 2 additions & 0 deletions rascaline/src/calculators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ pub(crate) use self::descriptors_by_systems::{array_mut_for_system, split_tensor
pub mod soap;
pub use self::soap::{SphericalExpansionByPair, SphericalExpansionParameters};
pub use self::soap::SphericalExpansion;
pub use self::soap::{SphericalExpansionForBondType, SphericalExpansionForBondsParameters};
pub use self::soap::SphericalExpansionForBonds;
pub use self::soap::{SoapPowerSpectrum, PowerSpectrumParameters};
pub use self::soap::{SoapRadialSpectrum, RadialSpectrumParameters};

Expand Down
6 changes: 6 additions & 0 deletions rascaline/src/calculators/soap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ pub use self::cutoff::RadialScaling;
mod spherical_expansion_pair;
pub use self::spherical_expansion_pair::{SphericalExpansionByPair, SphericalExpansionParameters};

mod spherical_expansion_bondcentered_pair;
pub use self::spherical_expansion_bondcentered_pair::{SphericalExpansionForBondType, SphericalExpansionForBondsParameters};

mod spherical_expansion;
pub use self::spherical_expansion::SphericalExpansion;

mod spherical_expansion_bondcentered;
pub use self::spherical_expansion_bondcentered::SphericalExpansionForBonds;

mod power_spectrum;
pub use self::power_spectrum::{SoapPowerSpectrum, PowerSpectrumParameters};

Expand Down
Loading

0 comments on commit 6582113

Please sign in to comment.