Update Compilation with Mutation authored by Alejandro  Alvarez's avatar Alejandro Alvarez
# Mutation++ Installation
Mutation++ is a library for is an open-source library developed at the von Karman Institute for Fluid Dynamics, designed to couple with conventional CFD codes to provide thermodynamic, transport, chemistry, and energy transfer properties associated with subsonic to hypersonic flows. (See the project in: https://sync.vki.ac.be/mpp/mutationpp)
First, we clone mutation++ directory:
`git clone https://sync.vki.ac.be/mpp/mutationpp.git mutation++`
The full installation is explained in:
https://sync.vki.ac.be/mpp/mutationpp/-/wikis/installation-guide
Once installed, make sure your installation is successful with
`checkmix air11`
and
`mppequil --help`
# Adding the environment variable
In order to compile CanoP with Mutation++, we add the following environment variable in your .bashrc:
`export MUTATIONPP_ROOT=$MPP_DIRECTORY/install`
run in your terminal `source ~/.bashrc` in order to take into account these changes.
# Compile with mutation
In your canoP `build` directory do:
`cmake ..; make`
If the compilation was successful, it should print:
`Found MUTATIONPP: path_to_mutation_lib/libmutation++.dylib`
# Example how to call mutation++ in your module
You need first to add mutation in you CMakeLists.txt of your module. One example is:
```
if (mutation++_FOUND)
target_link_libraries(name_of_module_2d
PRIVATE
mutation++::mutation++
)
endif()
```
Second, inside the `your_module/Solver.h`, you need to include the include file at the beginning of the file
```
#ifdef USE_MUTATIONPP
#include "mutation++/mutation++.h"
#endif
```
Also, you can define a pointer to your mixture in the public members of you solver:
```
#ifdef USE_MUTATIONPP
// transfort coefficient computation
Mutation::Mixture* m_mix;
#endif
```
Note the preprocessor directives in order to avoid having problems if you compile the code without mutation++.
In addition, you can initialise some of the options of your mixture through your settings.lua file, by adding the following in the `your_module/Solver.cpp`
```
#ifdef USE_MUTATIONPP
// Generate the default options for the He-H mixture
Mutation::MixtureOptions opts("He-H");
opts.setStateModel("EquilTP");
// Load the mixture with the new options
m_mix = new Mutation::Mixture(opts);
#endif
```
In this example, the He-H mixture is loaded and the stateModel is "EquilTP".
Once the mixture is initialised in the solver, you can call it in your iterator in order to obtain the transport coefficients. See the following example where we obtain the viscosity and the heavy thermal conductivity:
( This code would appear inside the iterator_yourmodule.cpp)
```
#ifdef USE_MUTATIONPP
double T=localTemperature;
double P=localPressure;
// We set the local temperature and pressure conditions
solver->m_mix->setState(&T,&P);
// With the pointer defined in the solver, we call the functions in mutation
const double hThermalCond = solver->m_mix->heavyThermalConductivity();
const double hThermalCond = solver->m_mix->viscosity();
#endif // USE_MUTATIONPP
```