.. _non_dim_input:

.. currentmodule:: flow360

Non-Dimensional Inputs
======================

Most input variables in the Flow360 Python API accept dimensional values and non-dimensionalization is automatically performed during the preprocessing. 
However, there are still input variables defined using string expression that only accept non-dimensional values, such as :py:class:`AngleExpression`, :py:class:`HeatFlux`, etc. 
In this section, we demonstrate how to compute the non-dimensional value for these input variables.

Theoretically, the reference values for non-dimensionalization can be arbitrary as long as the resulting equations are identical to the original ones, 
but in practice, the reference values are usually selected based on some typical parameters of problems and flow characteristics to avoid confusion.
The following table shows the usage of reference values to obtain the non-dimensional input variables:

.. _tab_non_dim_input:
.. csv-table:: Usage of reference values for non-dimensional inputs in Flow360
   :file: Tables/nondim_input.csv
   :widths: 10,10,60
   :header-rows: 1
   :delim: @

.. note::

   1. In the above table, all reference values can be accessed through Python API as shown in the :ref:`Reference Variable Table <table_ref_value>`. 
   2. To demonstrate how to perform non-dimensionalization on these variables, we use the predefined :ref:`operating_condition <code_ref_value_operating_condition>` and :ref:`reference_geometry <code_ref_value_reference_geometry>` to obtain these reference values.

.. _non_dim_omega:

Example: Convert RPM to non-dimensional rotating speed :code:`omega`
--------------------------------------------------------------------

The RPM determines the angular speed, from it we can calculate the non-dimensional :code:`omega` used in defining the :py:class:`AngleExpression`.

.. math::
    \text{omega} = \frac{\omega}{C_\infty/L_\text{gridUnit}}.

Assume the RPM = 800, the non-dimensional :code:`omega_radians` value then becomes:

.. code-block:: python
   :linenos:

   speed_of_sound = operating_condition.thermal_state.speed_of_sound
   omega = 800 * fl.u.rpm / (speed_of_sound / project.length_unit)
   omega_radians = omega.to(fl.u.rad).value


.. _non_dim_volumetric_heat_source:

Example: Compute non-dimensional :py:attr:`~Solid.volumetric_heat_source`
----------------------------------------------------------------------------------------------------

For conjugate heat transfer simulations, the non-dimensional heat sources (:py:attr:`~Solid.volumetric_heat_source`) of a solid zone are found from the dimensional :math:`Q_s` as:

.. math::

   \text{volumetricHeatSource}= \frac{Q_s}{Q_{ref}} = \frac{Q_s L_{gridUnit}}{\rho_{\infty} C_{\infty}^3}


Assume the :math:`Q_s=10\;\text{W}/\text{m}^3`, the non-dimensional :code:`volumetric_heat_source` value can be obtained as:

.. code-block:: python
   :linenos:

   speed_of_sound = operating_condition.thermal_state.speed_of_sound
   density = operating_condition.thermal_state.density
   Q_s = 10 * fl.u.W / fl.u.m**3
   volumetric_heat_source = Q_s * project.length_unit / (density * speed_of_sound ** 3).value

.. _non_dim_heat_flux:

Example: Compute non-dimensional :py:class:`HeatFlux`
----------------------------------------------------------------------------------------------------
The non-dimensional heat flux for a wall boundary condition can be calculated by dividing the dimensional heat flux :math:`q` by the reference value:

.. math::

   \text{heatFlux} = \frac{q}{q_{ref}} = \frac{q}{\rho_{\infty} C_{\infty}^3}

Assume the :math:`q=10\;\text{W}/\text{s}^2`, the non-dimensional :code:`heat_flux` value can be obtained as:

.. code-block:: python
   :linenos:

   speed_of_sound = operating_condition.thermal_state.speed_of_sound
   density = operating_condition.thermal_state.density
   q = 10 * fl.u.W / fl.u.m**2
   heat_flux = q / (density * speed_of_sound ** 3).value