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

post_process uses full correlation, fix filter_atoms #284

Merged
merged 4 commits into from
Aug 23, 2024
Merged
Changes from 2 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
12 changes: 6 additions & 6 deletions janus_core/helpers/post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def compute_vaf(
use_velocities: bool = False,
fft: bool = False,
index: SliceLike = (0, None, 1),
filter_atoms: MaybeSequence[MaybeSequence[int]] = ((),),
filter_atoms: MaybeSequence[MaybeSequence[None | int]] = ((None),),
) -> NDArray[float64]:
"""
Compute the velocity autocorrelation function (VAF) of `data`.
Expand Down Expand Up @@ -238,9 +238,7 @@ def compute_vaf(
data = data[slice(*index)]

if use_velocities:
momenta = np.asarray(
[datum.get_momenta() / datum.get_masses() for datum in data]
)
momenta = np.asarray([datum.get_velocities() for datum in data])
else:
momenta = np.asarray([datum.get_momenta() for datum in data])

Expand All @@ -249,7 +247,7 @@ def compute_vaf(

# If filter_atoms not specified use all atoms
filter_atoms = [
atom if atom and atom[0] else range(n_atoms) for atom in filter_atoms
atom if atom[0] is not None else range(n_atoms) for atom in filter_atoms
]

used_atoms = {atom for atoms in filter_atoms for atom in atoms}
Expand All @@ -259,7 +257,9 @@ def compute_vaf(
np.asarray(
[
[
np.correlate(momenta[:, j, i], momenta[:, j, i], "same")
np.correlate(momenta[:, j, i], momenta[:, j, i], "full")[
n_steps - 1 :
]
for i in range(3)
]
for j in used_atoms
Expand Down
Loading