Error related to solid + gas -> solid + gas reaction

Hello, I am working on a
solid A + gas B → solid C + gas D reaction with the attached .zip file.
My goal is to just run the program to see the concentration evolution of each species.
So, I wrote a very simple usr_rates.f and it compiles successfully.
However, when I run the program, It says that it encountered an invalid memory reference error.
(It indicates that there is a problem with usr_rates.f and I don’t understand it)

I deleted any if - endif block to simplify the code.
Despite being the simplest modification, I don’t understand where the error is stemming from.
I guess this is due to the phases, but I am not sure if I have to use usr_rates_des.f file because the example for solid - fluid reaction was written in the usr_rates.f file in the User Guide.

Could you give me some advice? (5.8 MB)

Please review 4.13.1. Chemical Reactions Setup — MFiX 22.1 documentation

Hi Jinny. In the zipfile you uploaded, I see that mfixsolver is a symbolic link to another directory. /home/jinny/FINAL_DATA/FIXED_rate/CASE12

So it looks like you may have been attempting to use a solver you compiled for a different case? Since there are Fortran files in this project directory, you need to build the solver to match these sources. I have no idea what is in FINAL_DATA/FIXED_rate/CASE12 so we can’t help you debug that.

However, building this solver for this case does result in a segfault as you said. If you may have gotten a core dump. The problem is here:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f377ee9e86f in usr_rates (ijk=376, rates=...) at /tmp/FIXED/usr_rates.f:41
41	      ReactionRates(IJK, Reaction_1) = RATES(Reaction_1)

(gdb) print rates
$1 = <error reading variable>

(gdb) whatis rates
type = real(kind=8) (*)

(gdb) up
#1  0x00007f377f0860ea in rrates0 () at /home/cgw/Work/NETL/mfix/model/rrates0.f:181

(gdb) whatis rates
type = real(kind=8) (0)

The array RATES is allocatable but has never been allocated.

This is because the variable nrr (number of reaction rates) is set to 0.

Try settting this to 1 (or the number of reactions you define).

There is another, possibly better way to save reaction rates without having to use the nrr keyword (which, as Jeff reminds me, is deprecated).

You can save reaction rates as VTK cell data, in the Output/VTK pane:

(Unfortunately this isn’t yet covered in the online manual, we need to add a few chapters! But the online tutorials show examples of creating and using VTK outputs)

Hello cgw, thank you so much for your kind help!

1 Like