Skip to content
Snippets Groups Projects
Commit 53eb19d8 authored by Martyn Gigg's avatar Martyn Gigg Committed by GitHub
Browse files

Merge pull request #19874 from mantidproject/19866_VelocityCrossCorrelations

Speed up VelocityCrossCorrelations
parents e740cf1f 1528b54a
No related branches found
No related tags found
No related merge requests found
...@@ -125,14 +125,11 @@ class VelocityCrossCorrelations(PythonAlgorithm): ...@@ -125,14 +125,11 @@ class VelocityCrossCorrelations(PythonAlgorithm):
# Initialise velocity arrray. Note that the first dimension is 2 elements shorter than the coordinate array. # Initialise velocity arrray. Note that the first dimension is 2 elements shorter than the coordinate array.
# Use finite difference methods to evaluate the time-derivative to 1st order # Use finite difference methods to evaluate the time-derivative to 1st order
# Shape: (# of particles) x (timesteps-2) x (# of spatial dimensions) # Shape: (# of particles) x (timesteps-2) x (# of spatial dimensions)
velocities=np.zeros((n_particles,n_timesteps-1,n_dimensions))
for i in range(n_particles): velocities=np.zeros((n_particles,n_timesteps-1,n_dimensions))
for j in range(n_timesteps-2): v1=scaled_coords[:,1:-1,:]-scaled_coords[:,:-2,:]-np.round(scaled_coords[:,1:-1,:]-scaled_coords[:,:-2,:])
# Unwrapping coordinates v2=scaled_coords[:,2:,:]-scaled_coords[:,1:-1,:]-np.round(scaled_coords[:,2:,:]-scaled_coords[:,1:-1,:])
v_temp1=scaled_coords[i,j+1]-scaled_coords[i,j]-np.round(scaled_coords[i,j+1]-scaled_coords[i,j]) velocities[:,:-1,:]=(v1+v2)/2.
v_temp2=scaled_coords[i,j+2]-scaled_coords[i,j+1]-np.round(scaled_coords[i,j+2]-scaled_coords[i,j+1])
velocities[i,j]=(v_temp1+v_temp2)/(2.0)
# Transform velocities (configuration array) back to Cartesian coordinates at each time step # Transform velocities (configuration array) back to Cartesian coordinates at each time step
velocities=np.array([[np.dot(box_size_tensors[j+1],np.transpose(velocities[i,j])) velocities=np.array([[np.dot(box_size_tensors[j+1],np.transpose(velocities[i,j]))
...@@ -141,7 +138,6 @@ class VelocityCrossCorrelations(PythonAlgorithm): ...@@ -141,7 +138,6 @@ class VelocityCrossCorrelations(PythonAlgorithm):
logger.information("Calculating velocity cross-correlations (resource intensive calculation)...") logger.information("Calculating velocity cross-correlations (resource intensive calculation)...")
start_time=time.time() start_time=time.time()
correlation_length=n_timesteps-1 correlation_length=n_timesteps-1
correlations=np.zeros((n_species,n_species,correlation_length)) correlations=np.zeros((n_species,n_species,correlation_length))
# Array for counting particle pairings # Array for counting particle pairings
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment