Float invalid operation in wrap pow - negative mass fraction

Hello,developers!
I’m running the following case,when I change the ratio of methane and oxygen passed in, I get a “float invalid operation in wrap pow” error.This error wouldn’t have occurred before when 0.2 CH4 and 0.8 O2 were passed through the gas, was it because of the excess oxygen?But how do I study the effects of excess air coefficients?
Can you help me check what is wrong with my case?Thank you very much!



OCAC-0426.mfx (24.0 KB)
usr_rates.f (3.6 KB)
usr_rates_des.f (7.4 KB)

Running on Linux gives better error information (we only get one level of stack trace on Windows)

Backtrace for this error:

#0 wrap_pow at xpow.c:70
#1 usr_rates at wangjing/usr_rates.f:77
#2 rrates0 at rrates0.f:181
...

Line 77 of your code:

    77	      EP_g(IJK) * (c_O2**1.3) * (c_CH4**0.2)

One of the exponentials c_O2**1.3 or c_CH4**0.2 is causing trouble. Using the debugger:

(gdb) p c_O2
$8 = <optimized out>
(gdb) p c_CH4
$9 = <optimized out>

The temporary variables c_02 and c_CH4 have been optimized away by the compiler, but we can see a few lines above:

      c_O2 = (RO_g(IJK) * X_g(IJK,O2))/MW_g(O2)

      c_CH4 = (RO_g(IJK) * X_g(IJK,CH4))/MW_g(CH4)

So,

(gdb) p (RO_g(IJK) * X_g(IJK,O2))/MW_g(O2)
$10 = 0.0050817876443430285

(gdb) p (RO_g(IJK) * X_g(IJK,CH4))/MW_g(CH4)
$11 = -4.016515149766889e-07

There’s your problem - the c_CH4 has gone negative, and you are trying to take a fractional power. Maybe add a check before line 77 and limit the values to 0 if they are negative. And in general you will have a better experience with writing and debugging UDFs if you have access to Linux.

Hi, I add a check before line 77 and limit the values to 0 if they are negative(as shown in the figure),but a new problem has arisen:Unphysical field variables detected on one or more processes.What’s this about?Thank you!
image

If you look in the console you will see more info:

Error from check_data_30.f:672
Fatal Error: Unphysical field variables detected.
     I      J      K
     8      8      2      X_G(6) =  -0.2512E-05 <   0.000
    10      8      2      X_G(6) =  -0.2506E-05 <   0.000
     8      9      2      X_G(6) =  -0.2893E-05 <   0.000
     9      9      2      X_G(6) =  -0.2894E-05 <   0.000
    10      9      2      X_G(6) =  -0.2899E-05 <   0.000
     6     10      2      X_G(6) =  -0.2654E-05 <   0.000
    11     10      2      X_G(6) =  -0.1810E-05 <   0.000
    12     12      2      X_G(6) =  -0.8874E-06 <   0.000
     8     13      2      X_G(6) =  -0.2923E-05 <   0.000
...

Looking at the file build/species.inc in the project directory shows

      INTEGER, PARAMETER :: CH4 = 6

so X_G(6) is the mass fraction for CH4, which has become negative and unphysical.

Thanks, I add another check and limit the values to 0 if they are negative(as shown in the figure),but it still happens that the mass fraction of methane is less than 0. Why is that?
bc8533ccdc80d3731e0ca4bcd19b82e

Maybe you are overconsuming CH4. Please double check your reaction rates.
We have data checks that are supposed to clip the species values between 0 and 1, so we need to see why this isn’t applied here.

You can also try with the stiff solver to see if this makes a difference.