5.1. Building Custom Interactive Solver¶
If you are just starting with MFiX, you could use the default solver installed with MFiX. It is possible to run most of the Tutorials with the default solver.
Note
Among the tutorials listed on the New Menu, only the tfm/silane_pyrolysis_2d case has UDFs and requires running with a custom solver to run correctly.
However, for some cases you may want to use a custom mfixsolver. For instance, when
running cases with UDFs (User Defined Functions, which are defined in Fortran
source files in the project directory), it is necessary to build a custom
solver. A custom solver is an mfixsolver
executable built in the project
directory, specific to that project. This includes projects with chemical
reactions, since those have UDFs.
5.1.1. Custom Solver From GUI¶
Press the (Build) button to display the Build Dialog box. Select appropriate compilation options, then press the “Build Solver” button. It may take a few minutes to compile. See Build Dialog for further details about compilation options. The “Build Command” of the build dialog will show the equivalent command for Building Custom Interactive Solver.
After building the custom solver, run a simulation by pressing (Run) to display the Run dialog. Select the mfixsolver file you have just built.
You can pause, unpause, stop, or get info from the solver.
5.1.2. Custom Solver From Command Line¶
For example, the tfm/silane_pyrolysis_2d
tutorial has UDFs and will not run with the
default solver.
> cd tutorials/tfm/silane_pyrolysis_2d/
> ls
SP2D.mfx usr0.f usr1.f usr_mod.f usr_rates.f
To build a custom solver for tfm/silane_pyrolysis_2d
:
> build_mfixsolver
...build output...
> ls *
build/ lib/ mfixsolver SP2D.mfx usr0.f usr0.o usr1.f usr_mod.f usr_rates.f
The build_mfixsolver
command creates a wrapper script
mfixsolver
, that runs the case-specific MFiX solver (which is
installed in the lib
directory).
The build
directory can be deleted, and the custom mfixsolver
will still run. However, leaving the build
directory will greatly
speed up rebuilds if you want to edit the UDFs and run
build_mfixsolver
again.
5.1.3. C++ Implementation of Interactive Solver¶
The interactive solver in MFiX 17.x was implemented in Fortran and Python. The
mfixsolver
executable is actually a Python script that runs the MFiX solver
as a Python extension module.
In MFiX 18.x there is an additional implementation of the interactive solver,
written in Fortran and C++ using the Crow web
framework, for which the mfixsolver
is a binary executable, like in
Building a Batch Solver. Both the Python and C++ interactive solvers are intended to
function the same at runtime, but depending on your platform, environment,
compiler, and compilation options, one might be more suitable than the other.
For instance, building an interactive solver with the Intel Fortran Compiler
ifort
only works with the C++ solver (not with the Python interactive
solver).
The C++ interactive solver is only available if “Enable Developer Tools” is checked in Settings.
To build the C++ interactive solver from the GUI, for “Interactive Support”, select “C++ implementation” on the Build dialog box.
To build the C++ interactive solver from the command line, run
build_mfixsolver
with the --cppmfix
option.
> cd tutorials/tfm/silane_pyrolysis_2d/
> build_mfixsolver --cppmfix
...build output...
> ls *
build/ mfixsolver SP2D.mfx usr0.f usr1.f usr_mod.f usr_rates.f