Units

Contents

4.2. Units#

Most of the Python API inputs are required to be dimensional. User can provide the units per input or use a unit system to let it automatically handle unit inference.

Note

There are exceptions where the input is expected to be non-dimensional. These are most notably the string expressions (for example initial_condition) since they are directly executed inside the solver where everything is non-dimensional. When composing expressions user should bear in mind that the input and output variables are all non-dimensional.

For example to set the physical time step as 0.01 seconds, user can provide the input as:

from flow360 import u
my_time_stepping = fl.Unsteady(step_size=0.01 * u.s)

Note

As mentioned in the previous note, expressions are non-dimensional or have hardcoded unit. For example the following expression indicates the initial condition for fluid density will be 1.5 times of the density of the fluid at its given operating condition:

fluid_model = fl.Fluid(initial_condition=fl.NavierStokesInitialCondition(rho="1.5"))

Another example is when setting the rotation angle expression. It is assumed that the angle expression results in radians which can not be customized by the user:

rotation_mode = fl.Fluid(
    volumes=fl.Cylinder(
        name="my_cyl",
        outer_radius=0.5 * u.cm,
        height=1 * u.km,
        axis=(0, 0, 1),
        center=(0, 0, 0)*u.mile,
    ),
    spec=fl.AngleExpression("5 * t"),
)

This means that the rotation angle (in radians) will be 5 times the non-dimensional time step.

For a full list of usable units, please refer to the documentation page of unyt package.

To see how Flow360 performs non-dimensionalization, please refer to the Nondimensional Inputs in our documentation.

To avoid obfuscation, some of the compound units are listed below:

Table 4.2.1 Units used in Flow360 Python API#

Unit name

Dimension

Example unit

PressureType

\(M^{1} L^{-1} T^{-2}\)

u.Pa

ViscosityType

\(M^{1} L^{-1} T^{-1}\)

u.Pa*u.s

PowerType

\(M^{1} L^{2} T^{-3}\)

u.W

MomentType

\(M^{1} L^{2} T^{-2}\)

u.N*u.m

HeatFluxType

\(M^{1} T^{-3}\)

u.W / u.m**2

HeatSourceType

\(M^{1} L^{-1} T^{-3}\)

u.W / u.m**3

SpecificHeatCapacityType

\(L^{2} T^{-2} Θ^{-1}\)

u.J / (u.kg*u.K)

ThermalConductivityType

\(M^{1} L^{1} T^{-3} Θ^{-1}\)

u.W / (u.m*u.K)

MassFlowRateType

\(M^{1} T^{-1}\)

u.kg / u.s

Unit System#

Unit system provides convenience to the user to handle unit inference. User can define a unit system context and Flow360 API can automatically assign units to any input that lacks an explicit unit specification.

For example the following two code snippets are equivalent:

from flow360 import u

meshing_defaults = fl.MeshingDefaults(
    boundary_layer_first_layer_thickness=0.0001 * u.m,
    surface_max_edge_length=0.0001 * u.m,
    curvature_resolution_angle=30 * u.deg,
)
from flow360 import u

with fl.SI_unit_system:
    meshing_defaults = fl.MeshingDefaults(
        boundary_layer_first_layer_thickness=0.0001 * u.m,
        surface_max_edge_length=0.0001,
        curvature_resolution_angle=30 * u.deg,
    )

Notice how in the second example we did not specify any unit for surface_max_edge_length but since we constructed the model under the SI_unit_system context, Flow360 API automatically inferred the unit for surface_max_edge_length as meter.

Warning

Even though all unit systems provide default unit for angle, we will NOT add units to angle type inputs. This is because the default for angle type is not deemed universal and may vary depending on the user’s conception.

For example, the following code snippet will not work because we are missing unit for curvature_resolution_angle:

from flow360 import u

with fl.SI_unit_system:
    meshing_defaults = fl.MeshingDefaults(
        boundary_layer_first_layer_thickness=0.0001 * u.m,
        surface_max_edge_length=0.0001,
        curvature_resolution_angle=30,
    )

The default units for each unit system are as follows:

Table 4.2.2 Units system available in Flow360 Python API#

Unit system

Length

Time

Mass

Temperature

fl.SI_unit_system

u.m

u.s

u.kg

u.K

fl.imperial_unit_system

u.ft

u.s

u.lb

u.degF

fl.CGS_unit_system

u.cm

u.s

u.g

u.K