Modify bisection algorithm in EOS_Omni's nuc_eos

Create issue
Issue #1195 closed
Erik Schnetter created an issue

EOS_Omni's nuc_eos routines use a bisection method to find the temperature for a given internal energy. This bisects on the temperature T. I suggest to bisect on log T instead, which is a more natural operation.

For example, if the temperature range is [1...1000] in some units, then bisecting in T will examine the sequence 500, 250, 125, ..., and will thus perform many table lookups until (say) T=10 is reached. Bisecting in log T will find this result much faster.


Comments (6)

  1. Ian Hinder
    • removed comment

    Is this because we expect the typical temperatures found on the grid to be more uniformly distributed in log T than in T? Why is this? If performance of this operation is a concern, could information from neighbouring points or previous timelevels be used to accelerate it? [Speaking as a non-expert!]

  2. Frank Löffler
    • removed comment

    Wouldn't it work best if we would bisect not on any real-type variable, but on the index space of the table (of course always looking at that variable in question at the index you are currently at)? That would make it independent of how that variable is distributed within the table. I only had a glance at the patch but it seems to include a lot of calls to log that haven't been there before, and which might mean a performance hit (which might or might not be counter-acted by a different walk through the table).

  3. Erik Schnetter reporter
    • removed comment

    Christian Ott tells me that he is currently re-designing part of this algorithm anyway. We should therefore wait before modifying the code.

    Ian: Yes, the reason is that the temperature is more evenly distributed in log T than in T.

    This routine is a generic EOS table lookup routine, and doesn't know anything about past timelevels or neighbouring points. This routine already uses log T for many operations. It only goes to great lengths to switch back to T, apply the bisection step, and then switch back to log T. My argument is that this additional complication is not necessary, and likely even slows down convergence.

    Frank: This routine is not a generic bisection routine. It is supposed to find the temperature corresponding to a particular internal energy, since the EOS table is provided in terms of log T, while the code passes in the internal energy.

    I did not add calls to log, I removed them. If you go to, then the green lines are added, not the red ones.

  4. Log in to comment