Quantity#
>>> import ansys.fluent.core.quantity as q
>>> velocity_1 = q.Quantity(20.2, "m s^-1")
>>> velocity_1
Quantity (20.2, "m s^-1")
>>> velocity_2 = q.Quantity(30.2, dimensions=[0.0, 1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
>>> velocity_2
Quantity (30.2, "m s^-1")
>>> velocity_3 = q.Quantity(40.2, quantity_map={"Velocity": 1.0})
>>> velocity_3
Quantity (40.2, "m s^-1")
>>> velocity_1.value
20.2
>>> velocity_1.unit
'm s^-1'
>>> velocity_1.is_dimensionless()
False
>>> velocity_1.get_dimensions_list()
[0.0, 1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
>>> velocity_1.to("ft s^-1")
Quantity (66.2729658792651, "ft s^-1")
>>> velocity_1 ** 2
Quantity (408.03999999999996, "m^2 s^-2")
>>> velocity_2 + velocity_1
Quantity (50.4, "m s^-1")
>>> velocity_2 - velocity_1
Quantity (10.0, "m s^-1")
>>> velocity_2 * velocity_1
Quantity (610.04, "m^2 s^-2")
>>> velocity_2 / velocity_1
Quantity (1.495049504950495, "")
>>> velocity_3 > velocity_1
True
>>> velocity_3 >= velocity_2
True
>>> velocity_1 < velocity_2
True
>>> velocity_1 <= velocity_3
True
>>> velocity_1 == velocity_2
False
>>> velocity_1 != velocity_3
True
Module for creating quantities in terms of real values with units.
Classes:
|
Dimension of unit. |
|
This class instantiates physical quantities using their real values and units. |
|
Unit postprocessing. |
|
Unit systems. |
Exceptions:
|
Custom quantity errors. |
Functions:
|
Separate multiplier from unit terms. |
|
SI conversion factor. |
|
Get SI unit from dimensions. |
|
Get unit from quantity map. |
|
Checks if it is a temperature. |
|
Remove multiplier. |
- class ansys.fluent.core.quantity.Dimension(unit_str)#
Bases:
object
Dimension of unit.
Methods:
__init__
(unit_str)Dimension properties.
as_dict
()Dimension map.
- __init__(unit_str)#
Dimension properties.
- Parameters:
- unit_str: str
Unit of quantity
- as_dict()#
Dimension map.
- class ansys.fluent.core.quantity.Quantity(real_value, unit_str=None, quantity_map=None, dimensions=None)#
Bases:
float
This class instantiates physical quantities using their real values and units. All the instances of this class are converted to base SI units system to have consistency in all arithmetic operations.
- Returns:
Quantity
instance.
- Attributes:
- value: Real value
Value of quantity is stored as float.
- unit: Unit string
Unit of quantity is stored as string.
Methods
get_dimensions_list()
Extracts dimensions from unit.
is_dimensionless()
Determines type of quantity.
to(to_unit)
Converts to given unit string.
Methods:
__init__
(real_value[, unit_str, ...])Quantity using unit string, quantity map or dimensions.
Dimensions list.
Determines whether quantity is dimensionsless or not.
to
(to_unit_str)Convert quantity to desired unit.
validate_matching_dimensions
(other)Validate dimensions of quantities.
Attributes:
Dimensions of quantity.
Quantity type.
Unit of quantity.
Value of quantity.
- __init__(real_value, unit_str=None, quantity_map=None, dimensions=None)#
Quantity using unit string, quantity map or dimensions.
- Parameters:
- real_value: float
Value of quantity
- unit_str: str
Unit of quantity
- quantity_map: dict
Map of quantity and it’s unit
- dimensions: list
array of dimensions
- property dimension#
Dimensions of quantity.
- get_dimensions_list()#
Dimensions list.
- is_dimensionless()#
Determines whether quantity is dimensionsless or not.
- to(to_unit_str)#
Convert quantity to desired unit.
- Parameters:
- to_unit_str: str
Desired unit of conversion
- Returns:
- temp_quantity:
Quantity
Instance of converted quantity
- temp_quantity:
- property type#
Quantity type.
- property unit#
Unit of quantity.
- validate_matching_dimensions(other)#
Validate dimensions of quantities.
- property value#
Value of quantity.
- exception ansys.fluent.core.quantity.QuantityError(from_unit, to_unit)#
Bases:
ValueError
Custom quantity errors.
- __init__(from_unit, to_unit)#
Quantity errors with custom messages.
- Parameters:
- from_unit: str
Unit of quantity
- to_unit: str
Desired conversion unit
- class ansys.fluent.core.quantity.Unit(unit_str)#
Bases:
object
Unit postprocessing.
Methods:
__init__
(unit_str)Unit properties.
Attributes:
Offset power.
SI factor.
SI offset.
SI unit.
User unit.
- __init__(unit_str)#
Unit properties.
- Parameters:
- unit_str: str
Unit of quantity
- property offset_power#
Offset power.
- property si_factor#
SI factor.
- property si_offset#
SI offset.
- property si_unit#
SI unit.
- property user_unit#
User unit.
- class ansys.fluent.core.quantity.UnitSystem(unit_sys)#
Bases:
object
Unit systems.
Methods:
__init__
(unit_sys)Basic unit systems.
Base units.
convert
(quantity)Convert to a system.
- __init__(unit_sys)#
Basic unit systems.
- Parameters:
- unit_sys: str
System name
- base_units()#
Base units.
- ansys.fluent.core.quantity.filter_multiplier(unit_str, predicate=None)#
Separate multiplier from unit terms.
- Parameters:
- unit_str
str
Unit of quantity.
- predicate
Performs multiplier filtering.
- unit_str
- Returns:
matched
A multiplier
- ansys.fluent.core.quantity.get_si_conversion_factor(unit_str)#
SI conversion factor.
- Parameters:
- unit_str
str
To get required conversion factor
- unit_str
- Returns:
conversion_map
A conversion map.
- ansys.fluent.core.quantity.get_si_unit_from_dim(dim_list)#
Get SI unit from dimensions.
- ansys.fluent.core.quantity.get_unit_from_map(quantity_map_from_settings_api)#
Get unit from quantity map.
- Parameters:
- quantity_map_from_settings_api: dict
Map of quantity and it’s unit
- Returns:
- unit:
str
Unit of quantity using quantity map
- unit:
- ansys.fluent.core.quantity.is_temperature_quantity(dim_obj)#
Checks if it is a temperature.