How to output a variable with only one value per time step?
Hello, everyone. I have a problem when using a two-fluid model to simulate a fluidized bed. I want to output a value related to particle volume fraction in the binary particle system, which is like standard deviation, meaning that a “standard deviation” will be calculated for each time step. I failed to output this “standard deviation”.
I tried outputting in write_usr1.f , and I didn’t think there was any logical problem. However, when I ran the case, it still reported an error and displayed float invalid . It looks like there is a problem with the ep_s , and I don’t know the reason for this issue or how it can be resolved.
May I ask if you can help me solve this difficulty? Looking forward to your help and reply. Thank you.
My case and f file are as follows. test.mfx (9.7 KB) write_usr1.f (3.5 KB)
It looks like this is happening in cell IJK=1 which is a corner cell, and is not used. If you add a line
IF (.NOT. FLUID_AT(IJK)) CYCLE
to your IJK loop, the problem goes away.
I also suggest you fix the code indentation so the program structure is more visible. This is easy to do if you use a Fortran-aware editor or a tool like fprettify which you can install easily with pip install fprettify
Here’s a cleaned-up version of the file: write_usr1.f (3.7 KB)
Note that it’s also slightly more efficient to open the file once in write_usr0.f and close it in usr3.f instead of opening/closing for every write, as you are doing. But the overhead is probably not observable, at the rate you are writing.
See 10. User-Defined Functions — MFiX 24.4 documentation