Skip to content

Reordering of loops to better utilize lookup table in higher order flat chamber calculation

Eskil Vik requested to merge feature/better-lu-in-high-order-flatchamber into master

In flatchamber.py, the procedure to calculate the impedances for higher orders currently (i.e. before this MR) follows this structure:

loop over planes
    loop over m,n
        loop over frequencies
            reset lookup table
            calculate impedance

This structure is not ideal, as there is a lookup table used for parts of the calculation (memorycontainer memory), which needs to be reset at every new frequency, but is independent of plane and m,n. Thus the lookup table is reset frequently, vastly limiting its usefulness.

This merge request implements this structure instead:

loop over frequencies
    reset lookup table
    loop over planes
        loop over m,n
            calculate impedance

With this change, the entries in the lookup table can be (and are) retrieved many more times before they are wiped. This dramatically speeds up the calculation. Details will be provided in a thread below.


Some other changes or notes:

  • Implement some basic memory safety checks in flat.cc, since for (very) high orders the lookup table may now come close to filling up to capacity. Basically checks if the container has reached capacity before adding new entries, and doesn't add more if it is full.
  • Calculation of layer properties was also moved to the outermost loop, since that also depends only on frequency, not plane or powers.
  • Some extra logic had to be added for tasks that should happen once per combination of layer and powers, but not for each frequency, was done correctly. This is mostly done in the if i==0: code block in flatchamber.py
  • The memory safety was added to the pure C++, but otherwise all important changes have been done to only the python module.

This is aimed to solve issue 8: #8 (closed)

This branch is branches from the features/new-installation-procedure branch instead of master, so the most sensible thing to do is to wait until after MR7 is merged before reviewing this.

Merge request reports