From 08e49ce3c0b34695797074031a747caf1bd89c62 Mon Sep 17 00:00:00 2001 From: Jess Sia <144711134+ansjsia@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:19:38 -0500 Subject: [PATCH] Add test for species transport model (#2280) Test the following features of the species transport model: - Turning on the species transport model - Checking the mixtures object command list - Creating a custom mixture with custom species (using the TUI) - Copying an existing mixture - Reassigning a cellzone material to a different mixture - Deleting an existing mixture This test should be updated as the settings API is expanded to cover all functionality pertaining to the species transport model. --- tests/test_solvermode/test_species_model.py | 72 +++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 tests/test_solvermode/test_species_model.py diff --git a/tests/test_solvermode/test_species_model.py b/tests/test_solvermode/test_species_model.py new file mode 100644 index 00000000000..a109339afca --- /dev/null +++ b/tests/test_solvermode/test_species_model.py @@ -0,0 +1,72 @@ +import pytest + + +@pytest.mark.setup +@pytest.mark.fluent_version(">=24.1") +def test_change_create_mixture(load_mixing_elbow_mesh): + solver_session = load_mixing_elbow_mesh + + # Test turning on species transport model + species_mdl = solver_session.setup.models.species.model + + assert species_mdl.option() == "off" + species_mdl.option = "species-transport" + assert species_mdl.option() == "species-transport" + + # Test command names list + materials = solver_session.setup.materials + assert sorted(materials.mixture.command_names) == sorted( + [ + "delete", + "list", + "list_properties", + "make_a_copy", + ] + ) + + # Test change/creating a mixture with custom species from template + custom_species_1 = materials.fluid.create("custom-species-1") + custom_species_2 = materials.fluid.create("custom-species-2") + solver_session.tui.define.materials.change_create( + "mixture-template", # Change/create mixture-template + "custom-mixture", # Rename to `custom-mixture` + "yes", # Change mixture species + "2", # Set number of species to 2 + custom_species_1.name(), # Set species 1 + custom_species_2.name(), # Set species 2 + "0", # No surface species + "0", # No site species + "no", # Do not change density + "no", # Do not change specific heat + "no", # Do not change thermal conductivity + "no", # Do not change viscosity + "no", # Do not change mass diffusivity + "no", # Do not change speed of sound + "yes", # Overwrite mixture-template + ) + assert "custom-mixture" in materials.mixture.keys() + assert "mixture-template" not in materials.mixture.keys() + + # Test that mixture contains correct species + mix_species = solver_session.setup.materials.mixture[ + "custom-mixture" + ].species.volumetric_species.keys() + assert "custom-species-1" in mix_species + assert "custom-species-2" in mix_species + + # Test copying a mixture + materials.mixture.make_a_copy( + from_="custom-mixture", + to="custom-mixture-copy", + ) + assert "custom-mixture-copy" in materials.mixture.keys() + + # Test changing cellzone mixture + elbow_zone = solver_session.setup.cell_zone_conditions.fluid["elbow-fluid"] + assert elbow_zone.material() == "custom-mixture" + elbow_zone.material = "custom-mixture-copy" + assert elbow_zone.material() == "custom-mixture-copy" + + # Test deleting a mixture + materials.mixture.delete(name_list=["custom-mixture"]) + assert "custom-mixture" not in materials.mixture.keys()