# Monitors

A monitor is a tool for capturing data from the solver about the model.

Data (such as volume fraction, pressure, velocity, etc.) for a given monitor region is written to a CSV file while the solver is running. To define monitors, the following inputs must be preceded by the prefix `mfix`:

| Description | Type | Default
--- | --- | --- | ---
monitors | Names of the monitors to be computed | Strings | None
monitors.[monitor_name] | Monitor type | String | None

    mfix.monitors = my_monitor0  my_monitor1

    mfix.monitors.my_monitor0 = Eulerian::VolumeIntegral::MassWeightedIntegral
    mfix.monitors.my_monitor1 = Lagrangian::Average::VolumeWeightedAverage

## Region selection

To define a monitor, there must be a region already defined in the regions inputs. A Monitor region is a single point, plane, or volume. Multiple regions cannot be combined for a monitor. The following inputs must be preceded by the prefix `mfix.monitors`:

| Description | Type | Default
--- | --- | --- | ---
[monitor_name].region | Define the region in which the monitor will be computed | String | None

    # regionA and regionB to be defined in the "regions" inputs section
    mfix.monitors.my_monitor0.region = regionA
    mfix.monitors.my_monitor1.region = regionB

## Monitor output

The monitor data will be output to a file with name given by the input `plot_file`, and the extension `.csv` is automatically added. The monitor output file is in Comma Separated Value (CSV) format. The first line of the file provides header information. The following inputs must be preceded by the prefix `mfix.monitors`:

| Description | Type | Default
--- | --- | --- | ---
[monitor_name].plot_file | Name of the plot file for monitor output. | String | None
[monitor_name].plot_int | Frequency for saving monitored data to output file. | Int | -1
[monitor_name].plot_per_approx | Define the approximated simulation time at which saving monitored data | Real | 0
[monitor_name].output.openmode | Select open mode for the monitor output file. Options: `app` - append to the file if it already exists `trunc` - overwrite the output file if it exists | String | app
[monitor_name].output.setw | Field width for output file. | Int | 0
[monitor_name].output.setfill | Fill character for output file. | Char | ‘’
[monitor_name].output.setprecision | Sets the decimal precision to be used to format floating-point values in the output file | Int | 0
[monitor_name].output.format | Sets the format flags. Options: `defaultfloat` `fixed` `scientific` | String | “”

    mfix.monitors.my_monitor0.plot_file = monitor0_output
    mfix.monitors.my_monitor0.plot_int = 10

    mfix.monitors.my_monitor1.plot_file = monitor1_output
    mfix.monitors.my_monitor1.plot_per_approx = 0.01

## Monitor variables

The variables to be monitored can be specified in the inputs by including the following input preceded by the prefix `mfix.monitors`:

| Description | Type | Default
--- | --- | --- | ---
[monitor_name].variables | Define which variables are to be monitored by this monitor | String | None

    mfix.monitors.my_monitor0.variables = T_g  vel_g  p_g  gp_y  X_gk

    mfix.monitors.my_monitor1.variables = density  drag_y  T_s  txfr_vel_x

## Eulerian monitors

There are different types of monitors available. A monitor type applies an operator (for example a sum, an area integral or a volume integral) to the variable. The dimensionality of the region determines which operators can be applied.

The table below summarizes the nomenclature used to describe the monitor operators:

Symbol | Description
--- | ---
\(\phi_{ijk}\) | Variable value at indexed cell
\(\varepsilon_{ijk}\) | Phase volume fraction at indexed cell
\(\rho_{ijk}\) | Phase density at indexed cell
\(\vec{v}_{ijk}\) | Phase velocity at indexed cell
\(A_{ijk}\) | Cross-sectional area of cell
\(V_{ijk}\) | Volume of indexed cell

The following table lists all the fluid phase variables that can be monitored:

| Description
--- | ---
ones | value of \(\phi_{ijk}\) is set to 1 in each fluid cell
ep_g | fluid volume fraction
p_g | fluid pressure
ro_g | fluid density
trac | tracer
vel_g | fluid velocity (all three components)
vel_g_[x/y/z] | x, y, or z component of the fluid velocity
gp | fluid pressure gradient (all three components)
gp_[x/y/z] | x, y, or z component of the fluid pressure gradient
T_g | fluid temperature
h_g | fluid enthalpy
X_gk | fluid species mass fractions (monitor all the fluid species)
X_gk_[species_name] | fluid species_name mass fraction (only species species_name is monitored)
vort | fluid vorticity (all three components)
vort[x/y/z] | x, y, or z component of the fluid vorticity
txfr_velocity | interphase velocity transferred to the fluid (all three components)
txfr_vel_[x/y/z] | x, y, or z component of the interphase velocity transferred to the fluid
txfr_beta | drag coefficient
txfr_gammaTp | convection coefficient multiplied by the solids temperature
txfr_gamma | convection coefficient
chem_txfr_X_gk | rate of mass transferred to the fluid phase due to heterogeneous chemical reactions (monitor all the fluid species)
chem_txfr_X_gk_[species_name] | fluid species_name rate of mass transferred due to heterogeneous chemical reactions (only species species_name is monitored)
chem_txfr_velocity | rate of velocity transferred to the fluid phase due to heterogeneous chemical reactions (all three components)
chem_txfr_vel_[x/y/z] | x, y, or z component of the rate of velocity transferred due to heterogeneous reactions
chem_txfr_h | rate of enthalpy transferred to the fluid phase due to heterogeneous chemical reactions
divtau | divergence of the viscous stress tensor (all three components)
divtau_[x/y/z] | x, y, or z component of the divergence of the viscous stress tensor

### Uniform scalar field

The following table lists all the fluid phase space-uniform variables that can be monitored:

| Description
--- | ---
thermo_p_g | fluid thermodynamic pressure

For a uniform scalar field, the monitor data value is simply the value of the variable at current time:

Value

  Eulerian::UniformScalarField::Value

  Returns the value of the field quantity in the selected region.

  \[\phi_{ijk}\]

### Point region

For a point region, the monitor data value is simply the value of the variable at that point:

Value

  Eulerian::PointRegion::Value

  Returns the value of the field quantity in the selected region.

  \[\phi_{ijk}\]

### Area or volume region

The following monitor types are valid for area and volume regions:

Sum

  Eulerian::AreaRegion::Sum
  Eulerian::VolumeRegion::Sum

  The sum is computed by summing all values of the field quantity in the selected region.

  \[\sum_{ijk}\phi_{ijk}\]
Min

  Eulerian::AreaRegion::Min
  Eulerian::VolumeRegion::Min

  Minimum value of the field quantity in the selected region.

  \[\min_{ijk} \phi_{ijk}\]
Max

  Eulerian::AreaRegion::Max
  Eulerian::VolumeRegion::Max

  Maximum value of the field quantity in the selected region.

  \[\max_{ijk} \phi_{ijk}\]
Average

  Eulerian::AreaRegion::Average
  Eulerian::VolumeRegion::Average

  Average value of the field quantity in the selected region where \(N\) is the total number of observations (cells) in the selected region.

  \[\phi_0 = \frac{\sum_{ijk} \phi_{ijk}}{N}\]
Standard deviation

  Eulerian::AreaRegion::StandardDeviation
  Eulerian::VolumeRegion::StandardDeviation

  The standard deviation of the field quantity in the selected region where \(\phi_0\) is the average of the variable in the selected region.

  \[\sigma_{\phi} = \sqrt{\frac{ \sum_{ijk} (\phi_{ijk}-\phi_{0})^2 }{N}}\]

### Surface integrals

The following types are only valid for area regions:

Area

  Eulerian::SurfaceIntegral::Area

  Area of selected region is computed by summing the areas of the facets that define the surface.

  \[\int dA = \sum_{ijk} \lvert A_{ijk} \rvert\]
Area-weighted average

  Eulerian::SurfaceIntegral::AreaWeightedAverage

  The area-weighted average is computed by dividing the summation of the product of the selected variable and facet area by the total area of the region.

  \[\frac{\int\phi dA}{A} = \frac{\sum_{ijk}{\phi_{ijk} \lvert A_{ijk} \rvert}}{\sum_{ijk}{\lvert A_{ijk} \rvert}}\]
Flow rate

  Eulerian::SurfaceIntegral::FlowRate

  The flow rate of a field variable through a surface is computed by summing the product of the phase volume fraction, density, the selected field variable, phase velocity normal to the facet \(v_n\), and the facet area.

  \[\int\varepsilon\rho\phi{v_n}dA = \sum_{ijk}\varepsilon_{ijk}\rho_{ijk}\phi_{ijk} {v}_{n,ijk} \lvert A_{ijk} \rvert\]
Mass flow rate

  Eulerian::SurfaceIntegral::MassFlowRate

  The mass flow rate through a surface is computed by summing the product of the phase volume fraction, density, phase velocity normal to the facet \(v_n\), and the facet area.

  \[\int\varepsilon\rho{v_n} dA = \sum_{ijk}\varepsilon_{ijk}\rho_{ijk}{v}_{n,ijk} \lvert A_{ijk} \rvert\]
Mass-weighted average

  Eulerian::SurfaceIntegral::MassWeightedAverage

  The mass flow rate through a surface is computed by summing the product of the phase volume fraction, density, phase velocity normal to the facet, and the facet area.

  \[\frac{\int\varepsilon\rho\phi{v_n}dA}{\int\varepsilon\rho{v_n}dA} = \frac{\sum_{ijk}\varepsilon_{ijk}\rho_{ijk}\phi_{ijk} {v}_{n,ijk} \lvert A_{ijk} \rvert}{\sum_{ijk}\varepsilon_{ijk}\rho_{ijk} {v}_{n,ijk} \lvert A_{ijk} \rvert}\]
Volume flow rate

  Eulerian::SurfaceIntegral::VolumeFlowRate

  The volume flow rate through a surface is computed by summing the product of the phase volume fraction, phase velocity normal to the facet \(v_n\), and the facet area.

  \[\int\varepsilon{v_n}dA = \sum_{ijk}\varepsilon_{ijk}{v}_{n,ijk} \lvert A_{ijk} \rvert\]

### Volume integrals

The following types are only valid for volume regions:

Volume

  Eulerian::VolumeIntegral::Volume

  The volume is computed by summing all of the cell volumes in the selected region.

  \[\int dV = \sum_{ijk}{ \lvert V_{ijk}} \rvert\]
Volume integral

  Eulerian::VolumeIntegral::VolumeIntegral

  The volume integral is computed by summing the product of the selected field variable and the cell volume.

  \[\int \phi dV = \sum_{ijk}{\phi_{ijk} \lvert V_{ijk}} \rvert\]
Volume-weighted average

  Eulerian::VolumeIntegral::VolumeWeightedAverage

  The volume-weighted average is computed by dividing the summation of the product of the selected field variable and cell volume by the sum of the cell volumes.

  > \[\frac{\int\phi dV}{V} = \frac{\sum_{ijk}{\phi_{ijk} \lvert V_{ijk} \rvert}}{\sum_{ijk}{\lvert V_{ijk} \rvert}}\]

Mass-weighted integral

  Eulerian::VolumeIntegral::MassWeightedIntegral

  The mass-weighted integral is computed by summing the product of phase volume fraction, density, selected field variable, and cell volume.

  \[\int \varepsilon\rho\phi dV = \sum_{ijk}\varepsilon_{ijk}\rho_{ijk}\phi_{ijk} \lvert V_{ijk}\rvert\]
Mass-weighted Average

  Eulerian::VolumeIntegral::MassWeightedAverage

  The mass-weighted average is computed by dividing the sum of the product of phase volume fraction, density, selected field variable, and cell volume by the summation of the product of the phase volume fraction, density, and cell volume.

  \[\frac{\int\phi\rho\varepsilon dV}{\int\rho\varepsilon dV} = \frac{\sum_{ijk}\varepsilon_{ijk}\rho_{ijk}\phi_{ijk} \lvert V_{ijk}\rvert}{\sum_{ijk}\varepsilon_{ijk}\rho_{ijk} \lvert V_{ijk}\rvert}\]

## Lagrangian monitors

There are different types of monitors available. A monitor type applies an operator (for example a sum, an area integral or a volume integral) to the variable. The dimensionality of the region determines which operators can be applied.

The table below summarizes the nomenclature used to describe the monitor operators:

Symbol | Description
--- | ---
\(\phi_p\) | Variable value of the indexed particle
\(m_p\) | Mass of the indexed particle
\(V_p\) | Volume of the indexed particle
\(\mathcal{w}_p\) | Statistical weight of the indexed particle [1]

[1]

The statistical weight is one for DEM simulations.

The following table lists all the solids phase variables that can be monitored:

| Description
--- | ---
ones | value of \(\phi_p\) is set to 1 for each solid particle
k_energy | particles kinetic energy
position | particles position (all the three components)
pos_[x/y/z] | x, y, or z component of the particles position
id | particles id
cpu | particles CPU
radius | particles radius
volume | particles volume
mass | particles mass
density | particles density
oneOverI | particles inverse of momentum of inertia
velocity | particles velocity (all the three components)
vel_[x/y/z] | x, y, or z component of the particles velocity
omega | particles angular velocity (all the three components)
omega_[x/y/z] | x, y, or z component of the particles angular velocity
statwt | particles statistical weight
dragcoeff | particles drag coefficient
drag | particles drag (all the three components)
drag_[x/y/z] | x, y, or z component of the particles drag
cp_s | particles specific heat coefficient
T_s | particles temperature
phase | particles phase
state | particles state
X_sn | particles species mass fractions (for all the solids species)
X_sn_[species_name] | solids species_name fraction (only species species_name is monitored)
txfr_velocity | rate of velocity transferred to the fluid phase due to heterogeneous chemical reactions (all three components)
txfr_vel_[x/y/z] | x, y, or z components of the transferred velocity due to heterogeneous reactions
txfr_h | rate of enthalpy transferred due to heterogeneous chemical reactions
txfr_X_sn | rate of mass transferred due to heterogeneous chemical reactions (for all the species)
txfr_X_sn_[species_name] | solids species_name rate of transfer due to heterogeneous reactions (only species species_name is monitored)

### General particle properties

General particle properties can be obtained from area (plane) and volume regions. For area regions, all particles in Eulerian cells that intersect the plane are used in evaluating the average.

Sum

  Lagrangian::GeneralProperty::Sum

  The sum of particle property, \(\phi_p\) in the selected region is calculated using the following expression.

  \[\sum_p w_p \phi_p\]

Mass-weighted sum

> Lagrangian::GeneralProperty::MassWeightedSum

> The mass-weighted sum of particle property, \(\phi_p\) in the selected region is calculated using the following expression.

> \[\sum_p w_p m_p \phi_p\]

Min

  Lagrangian::GeneralProperty::Min

  The minimum value of particle property \(\phi_p\) is the selected region is obtained using the following expression.

  \[\min_p \phi_p\]
Max

  Lagrangian::GeneralProperty::Max

  The maximum value of particle property \(\phi_p\) is the selected region is obtained using the following expression.

  \[\max_p \phi_p\]

### Averaged particle properties

Particle properties can be averaged over area (plane) and volume regions. For area regions, all particles in Eulerian cells that intersect the plane are used in evaluating the average.

Average

  Lagrangian::AveragedProperty::Average

  The average value of particle property, \(\phi_p\) in the selected region is calculated using the following expression. For DEM simulations, the statistical weight of a particle, \(w_p\), is one such that the sum of the weights is the total number of observations in the selected region.

  \[\bar{\phi} = \frac{\sum_p w_p \phi_p}{\sum_p w_p}\]
Standard deviation

  Lagrangian::AveragedProperty::StandardDeviation

  The standard deviation of particle property, \(phi_p\) in the selected region is calculated using the following expression. \(\bar{\phi}\) is the averaged variable in the selected region.

  \[\sigma_{\phi} = \sqrt{\frac{ \sum_p w_p (\phi_p-\bar{\phi})^2 }{\sum_p w_p}}\]
Mass-weighted average

  Lagrangian::AveragedProperty::MassWeightedAverage

  Mass-weighted average value of particle property, \(\phi_p\) in the selected region is calculated using the following expression.

  \[\bar{\phi}_m = \frac{\sum_{p} w_p m_p \phi_p}{\sum_p w_p m_p }\]
Volume-weighted average

  Lagrangian::AveragedProperty::VolumeWeightedAverage

  Volume-weighted average value of particle property, \(\phi_p\) in the selected region is calculated using the following expression.

  \[\bar{\phi}_v = \frac{\sum_{p} w_p V_p \phi_p}{\sum_p w_p V_p}\]

### Flow rates

For Lagrangian monitors of type FlowRate, the flow plane must be specified and it must be defined by one of the regions defined in the regions inputs. The following input for a monitor [monitor_name] of type FlowRate can be used, preceded by the prefix `mfix.monitors`:

| Description | Type | Default
--- | --- | --- | ---
[monitor_name].plane | Defines the plane through which the flow rate of the particles in the monitoring region [region_name] will be computed. | String | None

Flow rate monitors for Lagrangian particles (DEM/PIC) are only valid for area (plane) regions. The set of particles crossing the flow plane, \(\Gamma\) is approximated using the height of the plane, \(h\), the position of the particle, \(x_p\), and the particle velocity normal to the plane, \(v_p\) such that

> \[(v_p)\left(\frac{x_p - h}{\Delta t}\right) > 0\]

and

> \[\left|v_p\right| \geq \left| \frac{x_p - h}{\Delta t} \right|\]

Flow rate

  Lagrangian::FlowRate::FlowRate

  The net flow rate of a general particle property \(\phi_p\) is computed by summing the properties of the set of particles projected to have crossed the flow plane, \(\Gamma\).

  \[\sum_{p \in \Gamma} w_p \phi_p \frac{v_p}{\left| v_p \right|}\]
Mass-weighted flow rate

  Lagrangian::FlowRate::MassWeightedFlowRate

  The net mass-weighted flow rate is the sum of the general particle property \(\phi_p\) multiplied by the particle mass, \(m_p\) of the set of particles projected to have crossed the flow plane, \(\Gamma\).

  \[\sum_{p \in \Gamma} w_p m_p \phi_p \frac{v_p}{\left| v_p \right|}\]
Volume-weighted flow rate

  Lagrangian::FlowRate::VolumeWeightedFlowRate

  The net volume-weighted flow rate is the sum of the general particle property \(\phi_p\) multiplied by the particle volume, \(V_p\) of the set of particles projected to have crossed the flow plane, \(\Gamma\).

  \[\sum_{p \in \Gamma}\phi_p w_p V_p \frac{v_p}{\left| v_p \right|}\]