# Expanding 'compute\_entropy' in entropy.mako

**URL:** <https://pyfr.discourse.group/t/expanding-compute-entropy-in-entropy-mako/1086>\
**Category:** Bugs\
**Created:** [10 May 2024 12:35 UTC](https://pyfr.discourse.group/t/expanding-compute-entropy-in-entropy-mako/1086 "2024-05-10T12:35:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nnunn](https://avatars.discourse-cdn.com/v4/letter/n/c89c15/32.png) [@nnunn](https://pyfr.discourse.group/u/nnunn)\
**Post date:** [10 May 2024 12:35 UTC](https://pyfr.discourse.group/t/expanding-compute-entropy-in-entropy-mako/1086/1 "2024-05-10T12:35:03Z")

</div>

# Nature of bug

When ‘shock-capturing’ == ‘entropy-filter’, it looks like e\_func is not defined when expanding the macros for internal and boundary interfaces.

So when entropy.mako gets expanded, e\_func is neither ‘numerical’ nor ‘physical’,

> <https://github.com/PyFR/PyFR/blob/e2ff43c161548822d9e71cb0b4bdfce1dbb720dd/pyfr/solvers/euler/kernels/entropy.mako#L14>

In this case, neither line 13 nor 15 is included for calculating entropy.

Here is an example of the generated code:

```auto
  // Compute entropy for boundary state
  fpdtype_t p, d, entmin_rhs;
  {
    d = ur[0];
    fpdtype_t rcpd_ = 1.0f/d;
    fpdtype_t E_ = ur[3];

    // Compute the pressure
    p = 0.3999999999999999f*(E_ - 0.5f*rcpd_*(((ur[1])*(ur[1]) + (ur[2])*(ur[2]))));

    // Compute numerical or specific physical entropy
                           <-- empty line, entmin_rhs not calculated
  }

  // Compute face minima (reduce with atomics)
  entmin_lhs = entmin_rhs;

  atomic_min_fpdtype(&entmin_lhs_v[entmin_lhs_vix[X_IDX]], entmin_lhs);

```

“entmin\_rhs” is left uninitialized, and then assigned to “entmin\_lhs”.

Changing the [elif] to [else] at

> <https://github.com/PyFR/PyFR/blob/e2ff43c161548822d9e71cb0b4bdfce1dbb720dd/pyfr/solvers/euler/kernels/entropy.mako#L14>

seems to be a quick fix?

# PyFR information

- PyFR version: cloned May 6 2024
- OS: Windows 11
- System description: Threadripper + (3 x RTX 3090 Ti)
- Compiler and version: Visual Studio 2022
- Backend: cuda 12.1

---

<div class="post-metadata">

**Author:** ![tdzanic](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@tdzanic](https://pyfr.discourse.group/u/tdzanic)\
**Post date:** [10 May 2024 23:10 UTC](https://pyfr.discourse.group/t/expanding-compute-entropy-in-entropy-mako/1086/2 "2024-05-10T23:10:09Z")

</div>

This seems to be a bug in the BC interface kernels (although not in the internal interface kernels to my knowledge). I pushed a fix to [Bug fix in entropy filter functional choice for BCs. by tarikdzanic · Pull Request #417 · PyFR/PyFR · GitHub](https://github.com/PyFR/PyFR/pull/417).
