From 527f94f3fdd087cb8d1462f58c0e6743f6de3ca8 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Tue, 27 Sep 2022 12:58:21 +0530 Subject: [PATCH 1/4] Fixed test_boundaries_elbow for both 22.2 and 23.1 --- tests/test_solvermode/test_boundaries.py | 65 ++++++++++++++++-------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/tests/test_solvermode/test_boundaries.py b/tests/test_solvermode/test_boundaries.py index ecb82c4a2ef..06d3addba42 100644 --- a/tests/test_solvermode/test_boundaries.py +++ b/tests/test_solvermode/test_boundaries.py @@ -36,16 +36,28 @@ def test_boundaries_elbow(load_mixing_elbow_mesh): assign_dict_val( solver_session.setup.boundary_conditions.velocity_inlet["cold-inlet"].t, 293.15 ) - assert { - "velocity_spec": "Magnitude, Normal to Boundary", - "frame_of_reference": "Absolute", - "vmag": D(0.4), - "p_sup": D(0), - "t": D(293.15), - "ke_spec": "Intensity and Hydraulic Diameter", - "turb_intensity": 0.05, - "turb_hydraulic_diam": {"constant": 1, "expression": "4 [in]"}, - } == solver_session.setup.boundary_conditions.velocity_inlet["cold-inlet"]() + if float(solver_session.get_fluent_version()[:-2]) < 23.0: + assert { + "velocity_spec": "Magnitude, Normal to Boundary", + "frame_of_reference": "Absolute", + "vmag": D(0.4), + "p_sup": D(0), + "t": D(293.15), + "ke_spec": "Intensity and Hydraulic Diameter", + "turb_intensity": 0.05, + "turb_hydraulic_diam": {"constant": 1, "expression": "4 [in]"}, + } == solver_session.setup.boundary_conditions.velocity_inlet["cold-inlet"]() + else: + assert { + "frame_of_reference": "Absolute", + "initial_gauge_pressure": {"option": "value", "value": 0}, + "ke_spec": "Intensity and Hydraulic Diameter", + "t": {"option": "value", "value": 293.15}, + "turb_hydraulic_diam": {"constant": 1, "expression": "4 [in]"}, + "turb_intensity": 0.05, + "velocity_spec": "Magnitude, Normal to Boundary", + "vmag": {"option": "value", "value": 0.4}, + } == solver_session.setup.boundary_conditions.velocity_inlet["cold-inlet"]() assign_dict_val( solver_session.setup.boundary_conditions.velocity_inlet["hot-inlet"].vmag, 1.2 ) @@ -58,16 +70,29 @@ def test_boundaries_elbow(load_mixing_elbow_mesh): assign_dict_val( solver_session.setup.boundary_conditions.velocity_inlet["hot-inlet"].t, 313.15 ) - assert { - "velocity_spec": "Magnitude, Normal to Boundary", - "frame_of_reference": "Absolute", - "vmag": D(1.2), - "p_sup": D(0), - "t": D(313.15), - "ke_spec": "Intensity and Hydraulic Diameter", - "turb_intensity": 0.05, - "turb_hydraulic_diam": {"expression": "1 [in]", "constant": 1}, - } == solver_session.setup.boundary_conditions.velocity_inlet["hot-inlet"]() + if float(solver_session.get_fluent_version()[:-2]) < 23.0: + assert { + "velocity_spec": "Magnitude, Normal to Boundary", + "frame_of_reference": "Absolute", + "vmag": D(1.2), + "p_sup": D(0), + "t": D(313.15), + "ke_spec": "Intensity and Hydraulic Diameter", + "turb_intensity": 0.05, + "turb_hydraulic_diam": {"expression": "1 [in]", "constant": 1}, + } == solver_session.setup.boundary_conditions.velocity_inlet["hot-inlet"]() + else: + assert { + "frame_of_reference": "Absolute", + "initial_gauge_pressure": {"option": "value", "value": 0}, + "ke_spec": "Intensity and Hydraulic Diameter", + "t": {"option": "value", "value": 313.15}, + "turb_hydraulic_diam": {"constant": 1, "expression": "1 [in]"}, + "turb_intensity": 0.05, + "velocity_spec": "Magnitude, Normal to Boundary", + "vmag": {"option": "value", "value": 1.2}, + } == solver_session.setup.boundary_conditions.velocity_inlet["hot-inlet"]() + solver_session.setup.boundary_conditions.pressure_outlet[ "outlet" ].turb_viscosity_ratio = 4 From e1cb562d5df88f7497494830c7e0f114c0cd9bbc Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Tue, 27 Sep 2022 13:33:20 +0530 Subject: [PATCH 2/4] Fix list comparision issue --- tests/test_pro/test_pro_cht.py | 13 +++------ tests/test_pro/test_pro_post.py | 34 ++++++++++++------------ tests/test_pro/test_pro_settings_pbcs.py | 2 +- tests/test_pro/test_pro_species.py | 2 +- tests/test_pro/test_pro_turbulence.py | 2 +- 5 files changed, 24 insertions(+), 29 deletions(-) diff --git a/tests/test_pro/test_pro_cht.py b/tests/test_pro/test_pro_cht.py index 4f0dff6c588..6d981bdfbb7 100644 --- a/tests/test_pro/test_pro_cht.py +++ b/tests/test_pro/test_pro_cht.py @@ -206,7 +206,7 @@ def test_pro_cht(launch_fluent_solver_3ddp_t2): solver.execute_tui( r"""/surface/iso-clip z-coordinate clip-z-coordinate solid_up:1 -101.8218025565147 -44. """ ) - assert solver.results.graphics.pathline["pathlines-1"].surfaces_list() == [ + assert sorted(solver.results.graphics.pathline["pathlines-1"].surfaces_list()) == [ "inlet", "inlet1", "inlet2", @@ -243,14 +243,9 @@ def test_pro_cht(launch_fluent_solver_3ddp_t2): "field": "temperature", "surfaces_list": ["inlet", "inlet1", "inlet2", "mid-plane-z", "outlet", "out1"], } - assert solver.results.graphics.contour["contour-temperature"].surfaces_list() == [ - "inlet", - "inlet1", - "inlet2", - "mid-plane-z", - "outlet", - "out1", - ] + assert sorted( + solver.results.graphics.contour["contour-temperature"].surfaces_list() + ) == ["inlet", "inlet1", "inlet2", "mid-plane-z", "out1", "outlet"] solver.execute_tui(r"""/display/surface-mesh clip-z-coordinate () """) solver.results.graphics.contour.add_to_graphics(object_name="contour-temperature") solver.results.graphics.contour["contour-temperature-manifold"] = {} diff --git a/tests/test_pro/test_pro_post.py b/tests/test_pro/test_pro_post.py index 72410db42ee..154d1b81a6c 100644 --- a/tests/test_pro/test_pro_post.py +++ b/tests/test_pro/test_pro_post.py @@ -6,7 +6,7 @@ @pytest.mark.solve @pytest.mark.fluent_231 -def test_pro_exp(launch_fluent_solver_3ddp_t2): +def test_pro_post(launch_fluent_solver_3ddp_t2): if not os.path.exists("out"): os.mkdir("out") solver = launch_fluent_solver_3ddp_t2 @@ -192,12 +192,12 @@ def test_pro_exp(launch_fluent_solver_3ddp_t2): "partitions": False, "overset": False, } - assert solver.results.graphics.mesh["mesh-1"].surfaces_list() == [ - "top", + assert sorted(solver.results.graphics.mesh["mesh-1"].surfaces_list()) == [ "bottom", + "front", "left", "right", - "front", + "top", ] solver.results.graphics.mesh.add_to_graphics(object_name="mesh-1") solver.results.graphics.mesh.display(object_name="mesh-1") @@ -215,14 +215,14 @@ def test_pro_exp(launch_fluent_solver_3ddp_t2): ], "field": "pressure", } - assert solver.results.graphics.contour["contour-1"].surfaces_list() == [ - "left", - "front", + assert sorted(solver.results.graphics.contour["contour-1"].surfaces_list()) == [ "bottom", "default-interior", - "top", - "symmetry", + "front", + "left", "right", + "symmetry", + "top", ] assert solver.results.graphics.contour["contour-1"].field() == "pressure" solver.results.graphics.contour.add_to_graphics(object_name="contour-1") @@ -255,12 +255,12 @@ def test_pro_exp(launch_fluent_solver_3ddp_t2): }, "shrink_factor": 0.5, } - assert solver.results.graphics.mesh["mesh-1"].surfaces_list() == [ - "top", + assert sorted(solver.results.graphics.mesh["mesh-1"].surfaces_list()) == [ "bottom", + "front", "left", "right", - "front", + "top", ] assert solver.results.graphics.mesh["mesh-1"].options() == { "nodes": False, @@ -284,23 +284,23 @@ def test_pro_exp(launch_fluent_solver_3ddp_t2): "surfaces_list": ["top", "bottom", "front", "left", "right"] } solver.results.graphics.pathline.display(object_name="pathlines-1") - assert solver.results.graphics.pathline["pathlines-1"].surfaces_list() == [ - "top", + assert sorted(solver.results.graphics.pathline["pathlines-1"].surfaces_list()) == [ "bottom", "front", "left", "right", + "top", ] solver.results.plot.xy_plot["xy-plot-1"] = {} solver.results.plot.xy_plot["xy-plot-1"] = { "surfaces_list": ["top", "bottom", "left", "right", "front"] } - assert solver.results.plot.xy_plot["xy-plot-1"].surfaces_list() == [ - "top", + assert sorted(solver.results.plot.xy_plot["xy-plot-1"].surfaces_list()) == [ "bottom", + "front", "left", "right", - "front", + "top", ] solver.results.plot.xy_plot.display(object_name="xy-plot-1") solver.results.scene["scene-1"] = {} diff --git a/tests/test_pro/test_pro_settings_pbcs.py b/tests/test_pro/test_pro_settings_pbcs.py index d94d1c0df14..7bbe8961634 100644 --- a/tests/test_pro/test_pro_settings_pbcs.py +++ b/tests/test_pro/test_pro_settings_pbcs.py @@ -6,7 +6,7 @@ @pytest.mark.solve @pytest.mark.fluent_231 -def test_pro_exp(launch_fluent_solver_3ddp_t2): +def test_pro_settings_pbcs(launch_fluent_solver_3ddp_t2): if not os.path.exists("out"): os.mkdir("out") solver = launch_fluent_solver_3ddp_t2 diff --git a/tests/test_pro/test_pro_species.py b/tests/test_pro/test_pro_species.py index f76ef776fa1..99828d2f1c8 100644 --- a/tests/test_pro/test_pro_species.py +++ b/tests/test_pro/test_pro_species.py @@ -6,7 +6,7 @@ @pytest.mark.solve @pytest.mark.fluent_231 -def test_pro_exp(launch_fluent_solver_2ddp_t2): +def test_pro_species(launch_fluent_solver_2ddp_t2): if not os.path.exists("out"): os.mkdir("out") solver = launch_fluent_solver_2ddp_t2 diff --git a/tests/test_pro/test_pro_turbulence.py b/tests/test_pro/test_pro_turbulence.py index 8472d410b68..9718ef38167 100644 --- a/tests/test_pro/test_pro_turbulence.py +++ b/tests/test_pro/test_pro_turbulence.py @@ -6,7 +6,7 @@ @pytest.mark.solve @pytest.mark.fluent_231 -def test_pro_exp(launch_fluent_solver_3ddp_t2): +def test_pro_turbulence(launch_fluent_solver_3ddp_t2): if not os.path.exists("out"): os.mkdir("out") solver = launch_fluent_solver_3ddp_t2 From c33fbc5e31c8a46c7ce2766946f7aa76447146ee Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Tue, 27 Sep 2022 20:28:04 +0530 Subject: [PATCH 3/4] Updated key to check for correct value --- tests/test_solvermode/test_boundaries.py | 65 ++++++++---------------- tests/util/solver.py | 12 +++++ 2 files changed, 33 insertions(+), 44 deletions(-) diff --git a/tests/test_solvermode/test_boundaries.py b/tests/test_solvermode/test_boundaries.py index 06d3addba42..0d2a4ceb441 100644 --- a/tests/test_solvermode/test_boundaries.py +++ b/tests/test_solvermode/test_boundaries.py @@ -4,6 +4,7 @@ import pytest from util.fixture_fluent import get_name_info +from util.solver import ApiNames as api_names from util.solver import SettingsValDict as D from util.solver import assign_settings_value_from_value_dict as assign_dict_val @@ -36,28 +37,16 @@ def test_boundaries_elbow(load_mixing_elbow_mesh): assign_dict_val( solver_session.setup.boundary_conditions.velocity_inlet["cold-inlet"].t, 293.15 ) - if float(solver_session.get_fluent_version()[:-2]) < 23.0: - assert { - "velocity_spec": "Magnitude, Normal to Boundary", - "frame_of_reference": "Absolute", - "vmag": D(0.4), - "p_sup": D(0), - "t": D(293.15), - "ke_spec": "Intensity and Hydraulic Diameter", - "turb_intensity": 0.05, - "turb_hydraulic_diam": {"constant": 1, "expression": "4 [in]"}, - } == solver_session.setup.boundary_conditions.velocity_inlet["cold-inlet"]() - else: - assert { - "frame_of_reference": "Absolute", - "initial_gauge_pressure": {"option": "value", "value": 0}, - "ke_spec": "Intensity and Hydraulic Diameter", - "t": {"option": "value", "value": 293.15}, - "turb_hydraulic_diam": {"constant": 1, "expression": "4 [in]"}, - "turb_intensity": 0.05, - "velocity_spec": "Magnitude, Normal to Boundary", - "vmag": {"option": "value", "value": 0.4}, - } == solver_session.setup.boundary_conditions.velocity_inlet["cold-inlet"]() + assert { + "velocity_spec": "Magnitude, Normal to Boundary", + "frame_of_reference": "Absolute", + "vmag": D(0.4), + api_names(solver_session).initial_gauge_pressure: D(0), + "t": D(293.15), + "ke_spec": "Intensity and Hydraulic Diameter", + "turb_intensity": 0.05, + "turb_hydraulic_diam": {"constant": 1, "expression": "4 [in]"}, + } == solver_session.setup.boundary_conditions.velocity_inlet["cold-inlet"]() assign_dict_val( solver_session.setup.boundary_conditions.velocity_inlet["hot-inlet"].vmag, 1.2 ) @@ -70,28 +59,16 @@ def test_boundaries_elbow(load_mixing_elbow_mesh): assign_dict_val( solver_session.setup.boundary_conditions.velocity_inlet["hot-inlet"].t, 313.15 ) - if float(solver_session.get_fluent_version()[:-2]) < 23.0: - assert { - "velocity_spec": "Magnitude, Normal to Boundary", - "frame_of_reference": "Absolute", - "vmag": D(1.2), - "p_sup": D(0), - "t": D(313.15), - "ke_spec": "Intensity and Hydraulic Diameter", - "turb_intensity": 0.05, - "turb_hydraulic_diam": {"expression": "1 [in]", "constant": 1}, - } == solver_session.setup.boundary_conditions.velocity_inlet["hot-inlet"]() - else: - assert { - "frame_of_reference": "Absolute", - "initial_gauge_pressure": {"option": "value", "value": 0}, - "ke_spec": "Intensity and Hydraulic Diameter", - "t": {"option": "value", "value": 313.15}, - "turb_hydraulic_diam": {"constant": 1, "expression": "1 [in]"}, - "turb_intensity": 0.05, - "velocity_spec": "Magnitude, Normal to Boundary", - "vmag": {"option": "value", "value": 1.2}, - } == solver_session.setup.boundary_conditions.velocity_inlet["hot-inlet"]() + assert { + "velocity_spec": "Magnitude, Normal to Boundary", + "frame_of_reference": "Absolute", + "vmag": D(1.2), + api_names(solver_session).initial_gauge_pressure: D(0), + "t": D(313.15), + "ke_spec": "Intensity and Hydraulic Diameter", + "turb_intensity": 0.05, + "turb_hydraulic_diam": {"expression": "1 [in]", "constant": 1}, + } == solver_session.setup.boundary_conditions.velocity_inlet["hot-inlet"]() solver_session.setup.boundary_conditions.pressure_outlet[ "outlet" diff --git a/tests/util/solver.py b/tests/util/solver.py index bd9e21b445c..79a334009aa 100644 --- a/tests/util/solver.py +++ b/tests/util/solver.py @@ -16,6 +16,18 @@ def assign_settings_value_from_value_dict(setting, value): setting.set_state({"option": "constant or expression", "constant": value}) +class ApiNames: + def __init__(self, session): + self.session = session + + @property + def initial_gauge_pressure(self): + if self.session.get_fluent_version() == "22.2.0": + return "p_sup" + else: + return "initial_gauge_pressure" + + def settings_value_from_value_dict(dict_value) -> bool: if "option" in dict_value: option = dict_value["option"] From d2a8a3e354644bc20a9948feeda4f7f3f4cc15e7 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Tue, 27 Sep 2022 20:51:29 +0530 Subject: [PATCH 4/4] Style fix --- tests/test_pro/test_pro_post.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_pro/test_pro_post.py b/tests/test_pro/test_pro_post.py index 1613f8def0e..dea110c8aba 100644 --- a/tests/test_pro/test_pro_post.py +++ b/tests/test_pro/test_pro_post.py @@ -227,7 +227,6 @@ def test_pro_post(launch_fluent_solver_3ddp_t2): } assert sorted(solver.results.graphics.contour["contour-1"].surfaces_list()) == [ - "bottom", "default-interior", "front",