﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	notify_on_close	platform	project
778	changing coordinates very slow for large structures	Tristan Croll	Tom Goddard	"It would seem that in large structures (i.e. over 100k atoms), moving any atom(s) triggers something rather expensive. It's making ISOLDE almost unusably slow in large constructs, even when the fraction I'm simulating is tiny. As a simple demo:


{{{
import numpy
from time import time
class MoveTimer:
    
    def __init__(self, session, cycles, indices, model):
        self.start_time = time()
        self.counter = 0
        self.max_cycles = cycles
        self.session = session
        self.atoms = model.atoms[indices]
        self.model = model
        self.length = len(self.atoms)
        self.times = numpy.empty(cycles)
        self.handler = session.triggers.add_handler('new frame', self.time_change_coords)
    def time_change_coords(self,*_):
        if self.counter >= self.max_cycles:
            print('Updating coordinates for {} atoms in a structure with {} total atoms took {:0.4f} +/- {:0.4f} seconds per frame'
                    .format(self.length, len(self.model.atoms), self.times.mean(), self.times.std()))
            self.session.triggers.remove_handler(self.handler)
        else:
            self.times[self.counter] = time() - self.start_time
            self.start_time = time()
            targets = numpy.random.rand(self.length, 3)*50
            self.atoms.coords = targets
            self.counter += 1


indices = numpy.array([i for i in range(100,110)])
m0 = {model with 184,550 atoms, displayed in stick representation with simple lighting}
m1 = {model with 5133 atoms, identical representation}
MoveTimer(session, 50, indices, m0)
> Updating coordinates for 10 atoms in a structure with 184550 total atoms took 0.2716 +/- 0.0444 seconds per frame

MoveTimer(session, 50, indices, m1)
> Updating coordinates for 10 atoms in a structure with 5133 total atoms took 0.0356 +/- 0.0095 seconds per frame

indices = numpy.array([10], numpy.int)
MoveTimer(session, 50, indices, m0)
Updating coordinates for 1 atoms in a structure with 184550 total atoms took 0.2829 +/- 0.0444 seconds

MoveTimer(session, 50, indices, m1)
Updating coordinates for 1 atoms in a structure with 5133 total atoms took 0.0343 +/- 0.0084 seconds

}}}

If I hide everything but the single mobile atom:

{{{
MoveTimer(session, 50, indices, m0)
> Updating coordinates for 1 atoms in a structure with 184550 total atoms took 0.1864 +/- 0.0460 seconds per frame

MoveTimer(session, 50, indices, m0)
> Updating coordinates for 1 atoms in a structure with 5133 total atoms took 0.0310 +/- 0.0046 seconds per frame

}}}

In fact, even if all atoms are hidden:

{{{
Updating coordinates for 1 atoms in a structure with 184550 total atoms took 0.1346 +/- 0.0383 seconds per frame
Updating coordinates for 1 atoms in a structure with 5133 total atoms took 0.0283 +/- 0.0074 seconds per frame
}}}

"	defect	closed	major		Graphics		fixed		Tristan Croll pett@…				all	ChimeraX
