Skip to content

Commit

Permalink
Merge pull request #48 from matteobecchi/devel
Browse files Browse the repository at this point in the history
Solving issue #25
  • Loading branch information
andrewtarzia authored Nov 28, 2024
2 parents c43918c + e514d6d commit 30a857f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 66 deletions.
99 changes: 45 additions & 54 deletions src/dynsight/_internal/soapify/saponify.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
from collections import abc

import h5py
import SOAPify

Expand All @@ -18,9 +16,9 @@ def saponify_trajectory(
soapoutputchunkdim: int = 100,
soapnjobs: int = 1,
soapatommask: str | None = None,
centersmask: abc.Iterable | None = None, # type: ignore[type-arg]
centersmask: list[int] | None = None,
soap_respectpbc: bool = True,
soapkwargs: dict | None = None, # type: ignore[type-arg]
soapkwargs: dict[str, Any] | None = None,
usesoapfrom: SOAPify.engine.KNOWNSOAPENGINES = "dscribe",
dooverride: bool = False,
verbose: bool = True,
Expand All @@ -37,55 +35,48 @@ def saponify_trajectory(
Parameters:
trajcontainer:
Container of trajectory.
trajFname (str):
The name of the hdf5 file in wich the trajectory is stored
trajectoryGroupPath (str):
the path of the group that contains the trajectory in trajFname
soapoutcontainer (str):
the name of the hdf5 file that will contain the ouput or the SOAP
analysis.
exportDatasetName (str):
the name of the dataset that will contain the SOAP results,
it will be saved in the group called "SOAP"
soapoutputchunkdim (int, optional):
The dimension of the chunck of data in the SOAP results dataset.
Defaults to 100.
soapnjobs (int, optional):
the number of concurrent SOAP calculations (option passed to the
desired SOAP engine). Defaults to 1.
soapatommask (str, optional):
the symbols of the atoms whose SOAP fingerprint will be calculated
(option passed to the desired SOAP engine). Defaults to None.
centersmask:
Mask.
soaprcut (float, optional):
The file/group that contains the trajectory.
soapoutcontainer:
The file/group that will store the SOAP results.
soaprcut:
The cutoff for local region in angstroms. Should be bigger than 1
angstrom (option passed to the desired SOAP engine).
Defaults to 8.0.
soapnmax (int, optional):
soapnmax:
The number of radial basis functions (option passed to the desired
SOAP engine). Defaults to 8.
soaplmax (int, optional):
soaplmax:
The maximum degree of spherical harmonics (option passed to the
desired SOAP engine). Defaults to 8.
soap_respectpbc (bool, optional):
soapoutputchunkdim:
The dimension of the chunck of data in the SOAP results dataset.
Defaults to 100.
soapnjobs:
the number of concurrent SOAP calculations (option passed to the
desired SOAP engine). Defaults to 1.
soapatommask:
the symbols of the atoms whose SOAP fingerprint will be calculated
(option passed to the desired SOAP engine). Defaults to None.
centersmask:
the indexes of the atoms whose SOAP fingerprint will be calculated
(option passed to the desired SOAP engine). Defaults to None.
soap_respectpbc:
Determines whether the system is considered to be periodic
(option passed to the desired SOAP engine). Defaults to True.
soapkwargs (dict, optional):
additional keyword arguments to be passed to the SOAP engine.
Defaults to {}.
usesoapfrom (KNOWNSOAPENGINES, optional):
usesoapfrom:
This string determines the selected SOAP engine for the
calculations.
Defaults to "dscribe".
dooverride (bool, optional):
dooverride:
if False will raise and exception if the user ask to override an
already existing DataSet. Defaults to False.
verbose (bool, optional):
verbose:
regulates the verbosity of the step by step operations.
Defaults to True.
usetype (str,optional):
usetype:
The precision used to store the data. Defaults to "float64".
"""
SOAPify.saponifyTrajectory(
Expand Down Expand Up @@ -116,9 +107,9 @@ def saponify_multiple_trajectories(
soapoutputchunkdim: int = 100,
soapnjobs: int = 1,
soapatommask: list[str] | None = None,
centersmask: abc.Iterable | None = None, # type: ignore[type-arg]
centersmask: list[int] | None = None,
soap_respectpbc: bool = True,
soapkwargs: dict | None = None, # type: ignore[type-arg]
soapkwargs: dict[str, Any] | None = None,
usesoapfrom: SOAPify.engine.KNOWNSOAPENGINES = "dscribe",
dooverride: bool = False,
verbose: bool = True,
Expand All @@ -136,50 +127,50 @@ def saponify_multiple_trajectories(
:func:`SOAPify.engine.getSoapEngine`)
Parameters:
trajcontainers (h5py.Group|h5py.File):
The file/group that contains the trajectories
soapoutcontainers (h5py.Group|h5py.File):
The file/group that will store the SOAP results
soaprcut (float):
trajcontainers:
The file/group that contains the trajectories.
soapoutcontainers:
The file/group that will store the SOAP results.
soaprcut:
The cutoff for local region in angstroms. Should be bigger than 1
angstrom (option passed to the desired SOAP engine).
Defaults to 8.0.
soapnmax (int):
soapnmax:
The number of radial basis functions (option passed to the desired
SOAP engine). Defaults to 8.
soaplmax (int):
soaplmax:
The maximum degree of spherical harmonics (option passed to the
desired SOAP engine). Defaults to 8.
soapoutputchunkdim (int, optional):
soapoutputchunkdim:
The dimension of the chunck of data in the SOAP results dataset.
Defaults to 100.
soapnjobs (int, optional):
soapnjobs:
the number of concurrent SOAP calculations (option passed to the
desired SOAP engine). Defaults to 1.
soapatommask (list[str], optional):
soapatommask:
the symbols of the atoms whose SOAP fingerprint will be calculated
(option passed to getSoapEngine). Defaults to None.
centersmask (Iterable, optional):
centersmask:
the indexes of the atoms whose SOAP fingerprint will be calculated
(option passed getSoapEngine). Defaults to None.
soap_respectpbc (bool, optional):
soap_respectpbc:
Determines whether the system is considered to be periodic (option
passed to the desired SOAP engine). Defaults to True.
soapkwargs (dict, optional):
soapkwargs:
additional keyword arguments to be passed to the selected SOAP
engine.
Defaults to {}.
usesoapfrom (KNOWNSOAPENGINES, optional):
usesoapfrom:
This string determines the selected SOAP engine for the
calculations.
Defaults to "dscribe".
dooverride (bool, optional):
dooverride:
if False will raise and exception if the user ask to override an
already existing DataSet. Defaults to False.
verbose (bool, optional):
verbose:
regulates the verbosity of the step by step operations.
Defaults to True.
usetype (str,optional):
usetype:
The precision used to store the data. Defaults to "float64".
"""
Expand Down
25 changes: 13 additions & 12 deletions src/dynsight/_internal/soapify/utilities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
import h5py
Expand All @@ -9,18 +9,18 @@


def fill_soap_vector_from_dscribe(
soapfromdscribe: np.ndarray, # type: ignore[type-arg]
soapfromdscribe: np.ndarray[float, Any],
lmax: int,
nmax: int,
atomtypes: list | None = None, # type: ignore[type-arg]
atomicslices: dict | None = None, # type: ignore[type-arg]
) -> np.ndarray: # type: ignore[type-arg]
"""Returns the SOAP power spectrum from dsribe results.
atomtypes: list[str] | None = None,
atomicslices: dict[str, Any] | None = None,
) -> np.ndarray[float, Any]:
"""Returns the SOAP power spectrum from dscribe results.
With also the symmetric part explicitly stored, see the note in
https://singroup.github.io/dscribe/1.2.x/tutorials/descriptors/soap.html
No controls are implemented on the shape of the soapFromdscribe vector.
No controls are implemented on the shape of the soapfromdscribe vector.
Parameters:
soapfromdscribe:
Expand All @@ -30,13 +30,14 @@ def fill_soap_vector_from_dscribe(
nmax:
the n_max specified in the calculation.
atomtypes:
Needs docs.
the list of atomic species. Defaults to None.
atomicslices:
Needs docs.
the slices of the SOAP vector relative to the atomic species
combinations. Defaults to None.
Returns:
numpy.ndarray:
The full soap spectrum, with the symmetric part sored explicitly
The full soap spectrum, with the symmetric part sorted explicitly.
"""
return SOAPify.fillSOAPVectorFromdscribe(
soapFromdscribe=soapfromdscribe,
Expand All @@ -47,10 +48,10 @@ def fill_soap_vector_from_dscribe(
)


def get_soap_settings(fitsetdata: h5py.Dataset) -> dict: # type: ignore[type-arg]
def get_soap_settings(fitsetdata: h5py.Dataset) -> dict[str, Any]:
"""Gets the settings of the SOAP calculation.
you can feed directly this output to :func:`fillSOAPVectorFromdscribe`
You can feed directly this output to :func:`fillSOAPVectorFromdscribe`
Parameters:
fitsetdata:
Expand Down

0 comments on commit 30a857f

Please sign in to comment.