diff --git a/examples/advanced_simulations/aerodynamics/airfoils/2D_30p30n.py b/examples/advanced_simulations/aerodynamics/airfoils/2D_30p30n.py index b7eadd2b8..8d828ae58 100644 --- a/examples/advanced_simulations/aerodynamics/airfoils/2D_30p30n.py +++ b/examples/advanced_simulations/aerodynamics/airfoils/2D_30p30n.py @@ -74,9 +74,9 @@ reference_geometry=fl.ReferenceGeometry( moment_center=[0.25, 0, 0], moment_length=[1, 1, 1], area=0.01 ), - operating_condition=fl.operating_condition_from_mach_reynolds( + operating_condition=fl.AerospaceCondition.from_mach_reynolds( mach=0.17, - reynolds=1.71e06, + reynolds_mesh_unit=1.71e06, project_length_unit=1 * fl.u.m, temperature=288.16, alpha=8.5 * fl.u.deg, diff --git a/examples/advanced_simulations/aerodynamics/airfoils/2D_crm.py b/examples/advanced_simulations/aerodynamics/airfoils/2D_crm.py index 73067696b..7e809b866 100644 --- a/examples/advanced_simulations/aerodynamics/airfoils/2D_crm.py +++ b/examples/advanced_simulations/aerodynamics/airfoils/2D_crm.py @@ -74,9 +74,9 @@ reference_geometry=fl.ReferenceGeometry( moment_center=[0.25, 0, 0], moment_length=[1, 1, 1], area=0.01 ), - operating_condition=fl.operating_condition_from_mach_reynolds( + operating_condition=fl.AerospaceCondition.from_mach_reynolds( mach=0.2, - reynolds=5e6, + reynolds_mesh_unit=5e6, project_length_unit=1 * fl.u.m, temperature=272.1, alpha=16 * fl.u.deg, diff --git a/examples/advanced_simulations/aerodynamics/airfoils/2D_gaw2.py b/examples/advanced_simulations/aerodynamics/airfoils/2D_gaw2.py index 0031ca128..b8992d2bc 100644 --- a/examples/advanced_simulations/aerodynamics/airfoils/2D_gaw2.py +++ b/examples/advanced_simulations/aerodynamics/airfoils/2D_gaw2.py @@ -74,9 +74,9 @@ reference_geometry=fl.ReferenceGeometry( moment_center=[0.25, 0, 0], moment_length=[1, 1, 1], area=0.01 ), - operating_condition=fl.operating_condition_from_mach_reynolds( + operating_condition=fl.AerospaceCondition.from_mach_reynolds( mach=0.13, - reynolds=2.2e06, + reynolds_mesh_unit=2.2e06, project_length_unit=1 * fl.u.m, temperature=288.16, alpha=4 * fl.u.deg, diff --git a/examples/advanced_simulations/aerodynamics/user_defined_dynamics/udd_alpha_controller.py b/examples/advanced_simulations/aerodynamics/user_defined_dynamics/udd_alpha_controller.py index d8dd8d37f..f6f95bfcb 100644 --- a/examples/advanced_simulations/aerodynamics/user_defined_dynamics/udd_alpha_controller.py +++ b/examples/advanced_simulations/aerodynamics/user_defined_dynamics/udd_alpha_controller.py @@ -16,8 +16,8 @@ moment_center=[0, 0, 0], moment_length=[1.47601, 0.80167, 1.47601], ), - operating_condition=fl.operating_condition_from_mach_reynolds( - reynolds=11.72e6, + operating_condition=fl.AerospaceCondition.from_mach_reynolds( + reynolds_mesh_unit=11.72e6, mach=0.84, project_length_unit=0.80167 * fl.u.m, temperature=297.78, diff --git a/examples/advanced_simulations/turbomachinery/periodic_BC.py b/examples/advanced_simulations/turbomachinery/periodic_BC.py index 089b2ab07..53ba93d85 100644 --- a/examples/advanced_simulations/turbomachinery/periodic_BC.py +++ b/examples/advanced_simulations/turbomachinery/periodic_BC.py @@ -29,9 +29,9 @@ normal=[1, 0, 0], origin=[294.65, 0, 0] * fl.u.m, ) - operating_condition = fl.operating_condition_from_mach_reynolds( + operating_condition = fl.AerospaceCondition.from_mach_reynolds( mach=0.13989, - reynolds=3200, + reynolds_mesh_unit=3200, project_length_unit=1 * fl.u.m, temperature=298.25 * fl.u.K, ) diff --git a/examples/basic_simulations/steady/steady_3D_cylinder.py b/examples/basic_simulations/steady/steady_3D_cylinder.py index 96a605603..7292d42b4 100644 --- a/examples/basic_simulations/steady/steady_3D_cylinder.py +++ b/examples/basic_simulations/steady/steady_3D_cylinder.py @@ -25,8 +25,8 @@ reference_geometry=fl.ReferenceGeometry( area=340, moment_center=[0, 0, 0], moment_length=[1, 1, 1] ), - operating_condition=fl.operating_condition_from_mach_reynolds( - reynolds=5, mach=0.1, project_length_unit=fl.u.m + operating_condition=fl.AerospaceCondition.from_mach_reynolds( + reynolds_mesh_unit=5, mach=0.1, project_length_unit=fl.u.m ), time_stepping=fl.Steady(), models=[ diff --git a/examples/basic_simulations/unsteady/unsteady_2D_cylinder.py b/examples/basic_simulations/unsteady/unsteady_2D_cylinder.py index 5f3f8c112..7d1de4440 100644 --- a/examples/basic_simulations/unsteady/unsteady_2D_cylinder.py +++ b/examples/basic_simulations/unsteady/unsteady_2D_cylinder.py @@ -16,8 +16,8 @@ reference_geometry=fl.ReferenceGeometry( area=20, moment_center=[0, 0, 0], moment_length=[1, 1, 1] ), - operating_condition=fl.operating_condition_from_mach_reynolds( - reynolds=50, mach=0.1, project_length_unit=fl.u.m + operating_condition=fl.AerospaceCondition.from_mach_reynolds( + reynolds_mesh_unit=50, mach=0.1, project_length_unit=fl.u.m ), models=[ fl.Fluid( diff --git a/examples/post_processing/field_data/volumetric_and_surface.py b/examples/post_processing/field_data/volumetric_and_surface.py index 8e0b2b8e3..73e58dc1a 100644 --- a/examples/post_processing/field_data/volumetric_and_surface.py +++ b/examples/post_processing/field_data/volumetric_and_surface.py @@ -21,8 +21,8 @@ moment_center=[0, 0, 0], moment_length=[1.47602, 0.801672958512342, 1.47602], ), - operating_condition=fl.operating_condition_from_mach_reynolds( - reynolds=14.6e6, mach=0.84, alpha=3.06 * fl.u.deg, project_length_unit=fl.u.m + operating_condition=fl.AerospaceCondition.from_mach_reynolds( + reynolds_mesh_unit=14.6e6, mach=0.84, alpha=3.06 * fl.u.deg, project_length_unit=fl.u.m ), time_stepping=fl.Steady( max_steps=500, CFL=fl.RampCFL(initial=5, final=200, ramp_steps=100) diff --git a/examples/post_processing/monitoring/monitors.py b/examples/post_processing/monitoring/monitors.py index 547c4e56a..a60971984 100644 --- a/examples/post_processing/monitoring/monitors.py +++ b/examples/post_processing/monitoring/monitors.py @@ -14,8 +14,8 @@ moment_center=[0, 0, 0], moment_length=[1.47602, 0.801672958512342, 1.47602], ), - operating_condition=fl.operating_condition_from_mach_reynolds( - reynolds=14.6e6, mach=0.84, alpha=3.06 * fl.u.deg, project_length_unit=fl.u.m + operating_condition=fl.AerospaceCondition.from_mach_reynolds( + reynolds_mesh_unit=14.6e6, mach=0.84, alpha=3.06 * fl.u.deg, project_length_unit=fl.u.m ), time_stepping=fl.Steady(max_steps=500), models=[ diff --git a/examples/tutorials/notebooks/notebook_tutorial_2D_crm.ipynb b/examples/tutorials/notebooks/notebook_tutorial_2D_crm.ipynb index 86a461c15..08cc3015e 100644 --- a/examples/tutorials/notebooks/notebook_tutorial_2D_crm.ipynb +++ b/examples/tutorials/notebooks/notebook_tutorial_2D_crm.ipynb @@ -14,7 +14,7 @@ "\n", "We will walk through all the steps such as importing modules, creating a project and assigning simulation parameters.\n", "\n", - "Additionally, we will use the function `fl.operating_condition_from_mach_reynolds()`, which is often utilized when running workshop cases and allows us to define operating conditions using mach and reynolds number.\n", + "Additionally, we will use the function `fl.AerospaceCondition.from_mach_reynolds()`, which is often utilized when running workshop cases and allows us to define operating conditions using mach and reynolds number.\n", "\n", "In order to get a closer look at how we describe each parameter, we will first split the simulation parameters into smaller parts, which will be assembled later on." ] @@ -906,7 +906,7 @@ "metadata": {}, "source": [ "### Operating condition\n", - "Next up is the definition of flow conditions with the help of `fl.operating_condition_from_mach_reynolds()` function, which does not require knowledge of air properties in desired conditions and instead allows the usage of mach number in conjunction with reynolds number. This is particularly useful for conducting workshop cases as we can easily simulate flow conditions for different values of reynolds number. Viscosity as well as density are going to be automatically calculated based on input parameters." + "Next up is the definition of flow conditions with the help of `fl.AerospaceCondition.from_mach_reynolds()` function, which does not require knowledge of air properties in desired conditions and instead allows the usage of mach number in conjunction with reynolds number. This is particularly useful for conducting workshop cases as we can easily simulate flow conditions for different values of reynolds number. Viscosity as well as density are going to be automatically calculated based on input parameters." ] }, { @@ -948,9 +948,9 @@ "with fl.SI_unit_system:\n", " operating_condition_params = fl.SimulationParams(\n", " # Create operating conditions using mach and reynolds number\n", - " operating_condition=fl.operating_condition_from_mach_reynolds(\n", + " operating_condition=fl.AerospaceCondition.from_mach_reynolds(\n", " mach=0.2,\n", - " reynolds=5e6,\n", + " reynolds_mesh_unit=5e6,\n", " temperature=272.1,\n", " alpha=16 * fl.u.deg,\n", " beta=0 * fl.u.deg,\n", diff --git a/flow360/component/simulation/operating_condition/operating_condition.py b/flow360/component/simulation/operating_condition/operating_condition.py index bb56002dc..831a7d8ae 100644 --- a/flow360/component/simulation/operating_condition/operating_condition.py +++ b/flow360/component/simulation/operating_condition/operating_condition.py @@ -244,7 +244,7 @@ class AerospaceConditionCache(Flow360BaseModel): """[INTERNAL] Cache for AerospaceCondition inputs""" mach: Optional[pd.NonNegativeFloat] = None - reynolds: Optional[pd.PositiveFloat] = None + reynolds_mesh_unit: Optional[pd.PositiveFloat] = None project_length_unit: Optional[LengthType.Positive] = None alpha: Optional[AngleType] = None beta: Optional[AngleType] = None @@ -379,7 +379,7 @@ def from_mach( def from_mach_reynolds( cls, mach: pd.PositiveFloat, - reynolds: pd.PositiveFloat, + reynolds_mesh_unit: pd.PositiveFloat, project_length_unit: LengthType.Positive, alpha: Optional[AngleType] = 0 * u.deg, beta: Optional[AngleType] = 0 * u.deg, @@ -397,10 +397,12 @@ def from_mach_reynolds( ---------- mach : NonNegativeFloat Freestream Mach number (must be non-negative). - reynolds : PositiveFloat - Freestream Reynolds number defined with mesh unit (must be positive). + reynolds_mesh_unit : PositiveFloat + Freestream Reynolds number scaled to mesh unit (must be positive). + For example if the mesh unit is 1 mm, the reynolds_mesh_unit should be + equal to a Reynolds number that has the characteristic length of 1 mm. project_length_unit: LengthType.Positive - Project length unit. + Project length unit used to compute the density (must be positive). alpha : AngleType, optional Angle of attack. Default is 0 degrees. beta : AngleType, optional @@ -419,9 +421,9 @@ def from_mach_reynolds( ------- Example usage: - >>> condition = operating_condition_from_mach_reynolds( + >>> condition = fl.AerospaceCondition.from_mach_reynolds( ... mach=0.85, - ... reynolds=1e6, + ... reynolds_mesh_unit=1e6, ... project_length_unit=1 * u.mm, ... temperature=288.15 * u.K, ... alpha=2.0 * u.deg, @@ -441,7 +443,7 @@ def from_mach_reynolds( velocity = mach * material.get_speed_of_sound(temperature) density = ( - reynolds + reynolds_mesh_unit * material.get_dynamic_viscosity(temperature) / (velocity * project_length_unit) ) diff --git a/tests/simulation/framework/test_multi_constructor_model.py b/tests/simulation/framework/test_multi_constructor_model.py index 2b5670119..0ff60d397 100644 --- a/tests/simulation/framework/test_multi_constructor_model.py +++ b/tests/simulation/framework/test_multi_constructor_model.py @@ -54,7 +54,7 @@ def get_aerospace_condition_using_from_mach(): def get_aerospace_condition_using_from_mach_reynolds(): return AerospaceCondition.from_mach_reynolds( mach=0.8, - reynolds=1e6, + reynolds_mesh_unit=1e6, project_length_unit=u.m, alpha=5 * u.deg, temperature=290 * u.K, diff --git a/tests/simulation/params/test_simulation_params.py b/tests/simulation/params/test_simulation_params.py index b2905971a..36f510f00 100644 --- a/tests/simulation/params/test_simulation_params.py +++ b/tests/simulation/params/test_simulation_params.py @@ -346,7 +346,7 @@ def test_subsequent_param_with_different_unit_system(): def test_mach_reynolds_op_cond(): condition = AerospaceCondition.from_mach_reynolds( mach=0.2, - reynolds=5e6, + reynolds_mesh_unit=5e6, temperature=288.15 * u.K, alpha=2.0 * u.deg, beta=0.0 * u.deg, @@ -357,7 +357,7 @@ def test_mach_reynolds_op_cond(): condition = AerospaceCondition.from_mach_reynolds( mach=0.2, - reynolds=5e6, + reynolds_mesh_unit=5e6, temperature=288.15 * u.K, alpha=2.0 * u.deg, beta=0.0 * u.deg, @@ -369,7 +369,7 @@ def test_mach_reynolds_op_cond(): with pytest.raises(ValueError, match="Input should be greater than 0"): condition = AerospaceCondition.from_mach_reynolds( mach=0.2, - reynolds=0, + reynolds_mesh_unit=0, temperature=288.15 * u.K, project_length_unit=u.m, ) diff --git a/tests/simulation/translator/utils/tutorial_2dcrm_param_generator.py b/tests/simulation/translator/utils/tutorial_2dcrm_param_generator.py index 508d81098..7f145b333 100644 --- a/tests/simulation/translator/utils/tutorial_2dcrm_param_generator.py +++ b/tests/simulation/translator/utils/tutorial_2dcrm_param_generator.py @@ -26,7 +26,7 @@ def get_2dcrm_tutorial_param(): ), operating_condition=AerospaceCondition.from_mach_reynolds( mach=0.2, - reynolds=5e6, + reynolds_mesh_unit=5e6, temperature=272.1 * u.K, alpha=16 * u.deg, beta=0 * u.deg, @@ -54,7 +54,7 @@ def get_2dcrm_tutorial_param_deg_c(): ), operating_condition=AerospaceCondition.from_mach_reynolds( mach=0.2, - reynolds=5e6, + reynolds_mesh_unit=5e6, temperature=-1.05 * u.degC, alpha=16 * u.deg, beta=0 * u.deg, @@ -82,7 +82,7 @@ def get_2dcrm_tutorial_param_deg_f(): ), operating_condition=AerospaceCondition.from_mach_reynolds( mach=0.2, - reynolds=5e6, + reynolds_mesh_unit=5e6, temperature=30.11 * u.degF, alpha=16 * u.deg, beta=0 * u.deg,