A problem about modifying gas viscosity by UDF


I’m doing some calculation about gas reaction in fluidized bed, and I want to modify the gas viscosity by this formula:


yi is mole fraction of species i, and Mi is molecular weight of i.

I think that the sentence ‘INCLUDE ‘species.inc’’ should be added into usr_properties.f since I need to use the data of each species. However, when I compile the solver, an error is reported:

D:\Conda\envs\mfix-21.4\share\mfix\src\model\usr_properties.f:166: Error: Can’t open included file ‘species.inc’
mingw32-make.exe[2]: *** [model\CMakeFiles\mfixcore.dir\build.make:7103: model/CMakeFiles/mfixcore.dir/usr_properties.f.obj] Error 1
mingw32-make.exe[2]: *** Waiting for unfinished jobs…
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:182: model/CMakeFiles/mfixcore.dir/all] Error 2
mingw32-make.exe: *** [Makefile:135: all] Error 2

                 BUILD FAILED


So I want to know how to call the data of each species in usr_properties.f ? And this is my file:
usr_properties.f (35.8 KB)
NH3_O2_N2_udf.mfx (22.9 KB)
usr_rates.f (1.2 KB)

P.S. I just want to test the viscosity so I set the rate of chemistry as 0 (I’m not sure whether the included file ‘species.inc’ is related to this).

How are you building the solver? If you use the GUI and click “Build solver”, or use the “build_mfixsolver” script, the species.inc file will be automatically generated. It can be found in the build subdirectory.

There is a script rxn_preproc.py which generates it, but this step is automated.

species.inc defines a set of integer variables, so that you can refer to species and equations by name rather than by index. For your case, the generated file looks like this

!This file was generated by /home/cgw/Work/NETL/mfix/model/cmake/rxn_preproc.py
!from /tmp/u/NH3_O2_N2_udf.mfx on Wed Feb 23 07:09:36 2022
!Edit at your own risk!!!
      INTEGER, PARAMETER :: O2 = 2
      INTEGER, PARAMETER :: N2 = 3
      INTEGER, PARAMETER :: Reaction_1 = 1

Thank you for your suggestion!

I found that I made a mistake. I need to copy usr_properties.f to my directory, rather than modify it in envs\mfix-21.4\share\mfix\src\model. Now it works. Thank you again!

1 Like

Right, all changes should be made in the project directory, never in share\mfix\src. Files in the project directory always take priority over the files in source. Maybe we need to make this clearer in the documentation. The built-in editor in the GUI will copy files to the project dir for editing.

– Charles