IAP GITLAB

Excessive amount of `PROPOSAL::getMaxStepLength calculated a negative step length` warnings

This is related to do fix !484 (merged), and to the question

However, I wanted to open this issue to first discuss whether it is already unexpected that a particle below the energy cut is passed to proposal.

which I have raised in issue #563 (closed).

The problem is basically that with the current ProcessSequence (used for example in corsika.cpp), particles with energies below the defined ParticleCut can land on the stack. The reason for this is the following sequence of events:

  1. We have a particle with an energy above the ParticleCut. We extract it from the stack. We call getMaxStepLength for all continuous processes. proposal::ContinuousProcess::getMaxStepLength calculates the distance until the particle reaches an energy of 0.9999 * (E_cut + mass) (calculated here). In this case, this is determined to be the limiting process. Note that this 0.9999 factor has explicitly been chosen so that the particle will be removed by the ParticleCut.
  2. Due to the order we currently use in the ProcessSequence, we check the ParticleCut before applying the continuous losses. Since the initial particle energy was above the energy cut, it is not erased.
  3. We now apply the continuous energy losses. Since PROPOSAL has to recalculate the energy of the continuous losses given the step distance, we don't end up exactly at 0.9999 * (E_cut + mass), but at an energy that can even be slightly lower. (Side note: This recalculation would technically not be necessary because we have already calculated the energy at which we want to end up)
  4. This particle with a total energy E_total < 0.9999 * (E_cut + mass) < (E_cut + mass) is put back on the stack.
  5. We go back to the first step, i.e. extracting the particle from the stack and calling getMaxStepLength. However, proposal::ContinuousProcess::getMaxStepLength now tries to calculate the distance that our particle can propagate until it reaches an energy of 0.9999 * (E_cut + mass). Since the particle energy is already below this value, the returned distance is negative, causing the warning PROPOSAL::getMaxStepLength calculated a negative step length.

This sequence of events can cause an excessive amount of warning thrown by proposal::ContinuousProcess::getMaxStepLength, but now we understand why this is happening: Basically because we apply the particle cut after applying continuous energy losses, and because PROPOSAL is not 100% accurate with its calculations.

There are possible solutions for this problem:

  1. Change the order of the process sequence so that the ParticleCut is applied after calculating the continuous energy losses. This means changing it to something like make_sequence(stackInspect, hadronSequence, decaySequence, emCascade, emContinuous, cut, longprof, observationLevel)
  2. We could adapt proposal::ContinuousProcess::getMaxStepLength to accept particles with energies below the ParticleCut. One could just check whether a particle has an energy below 0.9999 * (E_cut + mass), and if it does, just return 0 instead of doing calculations and throwing a warning.

One could also apply both solutions.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information