Hello,
I am using version 3.14.1 of the OVITO library, with Python version 3.13.11, on a Windows operating system.
I am continuously applying an apply function to a data collection, while monitoring the execution time for each iteration. I’ve noticed that after a sufficient number of iterations, each operation begins to take longer. The image below shows how the execution time changes with the number of iterations.
Here is my code:
from ovito.io import import_file
from ovito.modifiers import ClusterAnalysisModifier
import numpy as np
import time
def main():
dump_file = "dump file which contains 4096 particles to be analyzed"
pipeline = import_file(dump_file)
pipeline_atoms = pipeline.compute()
particles = pipeline_atoms.particles.count
cluster_modifier = ClusterAnalysisModifier(cutoff=1.3, compute_gyration=True, sort_by_size=True, unwrap_particles=True, only_selected=True)
time_interval_between_iterations = []
start_time = time.time()
for iteration in range(3000):
# pipeline_atoms = pipeline.compute()
print(f"Iteration {iteration} number of particles: {pipeline_atoms.particles.count} {list(pipeline_atoms.particles.keys())}")
# randomly select 30% of the particles for clustering
selection = np.zeros(particles, dtype=bool)
selection[np.random.choice(particles, size=int(0.3 * particles), replace=False)] = True
pipeline_atoms.particles_.create_property("Selection", data=selection)
pipeline_atoms.apply(cluster_modifier)
rg_values = np.asarray(pipeline_atoms.tables["clusters"]["Radius of Gyration"][...], dtype=float)
current_time = time.time()
time_interval = current_time - start_time
time_interval_between_iterations.append(time_interval)
start_time = current_time
# plot the time intervals between iterations
import matplotlib.pyplot as plt
plt.plot(time_interval_between_iterations)
plt.xlabel("Iteration")
plt.ylabel("Time Interval (s)")
plt.title("Time Interval Between Iterations")
plt.show()
if __name__ == "__main__":
main()
# import ovito
# print(f"OVITO version: {ovito.version}")
Is this behavior expected?
Thank you in advance.
