Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bond environments: bond-atom neighbouring #240

Open
wants to merge 3 commits into
base: system-with-data
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions python/rascaline/rascaline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
SortedDistances,
SphericalExpansion,
SphericalExpansionByPair,
SphericalExpansionForBonds,
)
from .log import set_logging_callback # noqa
from .profiling import Profiler # noqa
Expand All @@ -29,4 +30,5 @@
"SortedDistances",
"SphericalExpansion",
"SphericalExpansionByPair",
"SphericalExpansionForBonds",
]
51 changes: 51 additions & 0 deletions python/rascaline/rascaline/calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,57 @@ def __init__(
super().__init__("spherical_expansion_by_pair", json.dumps(parameters))


class SphericalExpansionForBonds(CalculatorBase):
"""A SOAP-like spherical expansion coefficients for bond-centered environments
In other words, the spherical expansion of the neighbor density function centered
on the center of a bond,
'after' rotating the system so that the bond is aligned with the z axis.

This is not rotationally invariant, and as such you should use some
not-implemented-here matheatical trick
similar to what SOAP (the :py:class:`SoapPowerSpectrum` class) uses.

Most hyperparameters are identical to that of the regulat spherical expansion:
:ref:`documentation <spherical-expansion>`.

the few changes to this are:

- "cutoff" renamed to "third_cutoff"
- "bond_cutoff" which expresses how the pairs of atoms used for the 'bonds' are
chosen.
- "center_atomS_weight" (caps only used for emphasis): the weight multiplier
for the coefficients of the self interactions
(where the neighboring atom is one of the pair's atoms).
"""

def __init__(
self,
bond_cutoff,
third_cutoff,
max_radial,
max_angular,
atomic_gaussian_width,
center_atoms_weight,
radial_basis,
cutoff_function,
radial_scaling=None,
):
parameters = {
"cutoffs": [bond_cutoff, third_cutoff],
"max_radial": max_radial,
"max_angular": max_angular,
"atomic_gaussian_width": atomic_gaussian_width,
"center_atoms_weight": center_atoms_weight,
"radial_basis": radial_basis,
"cutoff_function": cutoff_function,
}

if radial_scaling is not None:
parameters["radial_scaling"] = radial_scaling

super().__init__("spherical_expansion_for_bonds", json.dumps(parameters))


class SoapRadialSpectrum(CalculatorBase):
"""Radial spectrum of Smooth Overlap of Atomic Positions (SOAP).

Expand Down
2 changes: 1 addition & 1 deletion python/rascaline/rascaline/systems/pyscf.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def types(self):
return self._types

def positions(self):
return pyscf.data.nist.BOHR * self._frame.atom_coords()
return self._frame.atom_coords("angstrom")

def cell(self):
if self.is_periodic:
Expand Down
2 changes: 2 additions & 0 deletions rascaline/src/calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ use crate::calculators::{SphericalExpansionByPair, SphericalExpansionParameters}
use crate::calculators::SphericalExpansion;
use crate::calculators::{SoapPowerSpectrum, PowerSpectrumParameters};
use crate::calculators::{SoapRadialSpectrum, RadialSpectrumParameters};
use crate::calculators::{SphericalExpansionForBonds, SphericalExpansionForBondsParameters};
use crate::calculators::{LodeSphericalExpansion, LodeSphericalExpansionParameters};
type CalculatorCreator = fn(&str) -> Result<Box<dyn CalculatorBase>, Error>;

Expand Down Expand Up @@ -581,6 +582,7 @@ static REGISTERED_CALCULATORS: Lazy<BTreeMap<&'static str, CalculatorCreator>> =
add_calculator!(map, "spherical_expansion", SphericalExpansion, SphericalExpansionParameters);
add_calculator!(map, "soap_radial_spectrum", SoapRadialSpectrum, RadialSpectrumParameters);
add_calculator!(map, "soap_power_spectrum", SoapPowerSpectrum, PowerSpectrumParameters);
add_calculator!(map, "spherical_expansion_for_bonds", SphericalExpansionForBonds, SphericalExpansionForBondsParameters);

add_calculator!(map, "lode_spherical_expansion", LodeSphericalExpansion, LodeSphericalExpansionParameters);
return map;
Expand Down
Loading
Loading