Avoid tmgen multiplicities (->slowdown) in ScatteringSystem constructor
Former-commit-id: 438ba0667e36a7c51b2ac5fe58cf62fea17eb132
This commit is contained in:
parent
c11fe19af3
commit
daf95e799a
|
@ -369,7 +369,8 @@ cdef class ScatteringSystem:
|
||||||
for p in particles: # find and enumerate unique t-matrix generators
|
for p in particles: # find and enumerate unique t-matrix generators
|
||||||
if p.p.op.typ != QPMS_TMATRIX_OPERATION_NOOP:
|
if p.p.op.typ != QPMS_TMATRIX_OPERATION_NOOP:
|
||||||
raise NotImplementedError("currently, only no-op T-matrix operations are allowed in ScatteringSystem constructor")
|
raise NotImplementedError("currently, only no-op T-matrix operations are allowed in ScatteringSystem constructor")
|
||||||
tmg_key = id(p.f)
|
#tmg_key = id(p.f) # This causes a different generator for each particle -> SUPER SLOW
|
||||||
|
tmg_key = (id(p.f.generator), id(p.f.spec))
|
||||||
if tmg_key not in tmgindices:
|
if tmg_key not in tmgindices:
|
||||||
tmgindices[tmg_key] = tmg_count
|
tmgindices[tmg_key] = tmg_count
|
||||||
tmgobjs.append(p.f) # Save the references on BaseSpecs and TMatrixGenerators (via TMatrixFunctions)
|
tmgobjs.append(p.f) # Save the references on BaseSpecs and TMatrixGenerators (via TMatrixFunctions)
|
||||||
|
@ -401,7 +402,7 @@ cdef class ScatteringSystem:
|
||||||
orig.tm[tmi].op = qpms_tmatrix_operation_noop # TODO adjust when notrivial operations allowed
|
orig.tm[tmi].op = qpms_tmatrix_operation_noop # TODO adjust when notrivial operations allowed
|
||||||
for pi in range(p_count):
|
for pi in range(p_count):
|
||||||
p = particles[pi]
|
p = particles[pi]
|
||||||
tmg_key = id(p.f)
|
tmg_key = (id(p.f.generator), id(p.f.spec))
|
||||||
tm_derived_key = (tmg_key, None) # TODO unique representation of p.p.op instead of None
|
tm_derived_key = (tmg_key, None) # TODO unique representation of p.p.op instead of None
|
||||||
orig.p[pi].pos = p.cval().pos
|
orig.p[pi].pos = p.cval().pos
|
||||||
orig.p[pi].tmatrix_id = tmindices[tm_derived_key]
|
orig.p[pi].tmatrix_id = tmindices[tm_derived_key]
|
||||||
|
|
Loading…
Reference in New Issue