Avoid tmgen multiplicities (->slowdown) in ScatteringSystem constructor
Former-commit-id: d4d20d3f019dee1765681d4b2f2fce95ea49fb37
This commit is contained in:
parent
e3834fdad7
commit
6233e1c210
|
@ -385,7 +385,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)
|
||||||
|
@ -417,7 +418,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