.. _build-custom: ================================== Building Custom Interactive Solver ================================== If you are just starting with MFiX, you could use the :ref:`default solver ` installed with MFiX. It is possible to run most of the :ref:`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 :ref:`chemical reactions `, since those have UDFs. .. _build-custom-gui: Custom Solver From GUI ---------------------- Press the |build| (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 :ref:`build-dialog` for further details about compilation options. The "Build Command" of the build dialog will show the equivalent command for :ref:`build-custom`. After building the custom solver, run a simulation by pressing |play| (Run) to display the :ref:`run-dialog`. Select the mfixsolver file you have just built. You can pause, unpause, stop, or get info from the solver. .. _build-custom-cmdline: Custom Solver From Command Line ------------------------------- For example, the ``tfm/silane_pyrolysis_2d`` tutorial has UDFs and will not run with the default solver. .. code-block:: shell > 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``: .. code-block:: shell > 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. 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 :ref:`build-batch`. 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 :ref:`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. .. code-block:: shell > 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 .. include:: /icons.rst