Skip to content

Commit

Permalink
New tests added (#795)
Browse files Browse the repository at this point in the history
  • Loading branch information
akulshre-qa authored Aug 29, 2022
1 parent 95991d2 commit a0ae26c
Show file tree
Hide file tree
Showing 8 changed files with 522 additions and 1 deletion.
133 changes: 133 additions & 0 deletions tests/test_solvermode/test_controls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import pytest


@pytest.mark.integration
@pytest.mark.quick
@pytest.mark.setup
def test_controls(load_mixing_elbow_mesh):
solver = load_mixing_elbow_mesh
solver.setup.models.multiphase.models = "vof"
assert solver.setup.models.multiphase.models() == "vof"
solver.setup.general.gravity = {"enable": True, "components": [0.0, 0.0, -9.81]}
assert solver.setup.general.gravity.components() == [0, 0, -9.81]
solver.setup.general.solver.time = "steady"
assert solver.setup.general.solver.time() == "steady"
solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.coupled_parameters.coarsening_parameters.laplace_coarsening = (
True
)
assert solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.coupled_parameters.coarsening_parameters() == {
"max_coarse_levels": 40,
"coarsen_by_interval": 8,
"conservative_coarsening": False,
"aggressive_coarsening": False,
"laplace_coarsening": True,
}
solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.coupled_parameters.coarsening_parameters.max_coarse_levels = (
45
)
assert (
solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.coupled_parameters.coarsening_parameters.max_coarse_levels()
== 45
)
solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.coupled_parameters.coarsening_parameters = {
"max_coarse_levels": 48,
"coarsen_by_interval": 9,
"conservative_coarsening": True,
"aggressive_coarsening": True,
"laplace_coarsening": True,
}
assert (
solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.coupled_parameters.coarsening_parameters.max_coarse_levels()
== 48
)
assert (
solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.coupled_parameters.coarsening_parameters.coarsen_by_interval()
== 9
)
assert (
solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.coupled_parameters.coarsening_parameters.conservative_coarsening()
== True
)
assert (
solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.coupled_parameters.coarsening_parameters.aggressive_coarsening()
== True
)
solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.scalar_parameters.fixed_cycle_parameters.max_cycle = (
300
)
assert (
solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.scalar_parameters.fixed_cycle_parameters.max_cycle()
== 300
)
solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.scalar_parameters.fixed_cycle_parameters = {
"pre_sweeps": 1,
"post_sweeps": 2,
"max_cycle": 350,
}
assert solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.scalar_parameters.fixed_cycle_parameters() == {
"pre_sweeps": 1,
"post_sweeps": 2,
"max_cycle": 350,
}
solver.solution.methods.p_v_coupling.flow_scheme = "Coupled"
assert solver.solution.methods.p_v_coupling.flow_scheme() == "Coupled"
solver.solution.methods.p_v_coupling.coupled_form = True
assert solver.solution.methods.p_v_coupling.coupled_form() == True
solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.scalar_parameters.smoother_type = (
"gauss-seidel"
)
assert (
solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.scalar_parameters.smoother_type()
== "gauss-seidel"
)
assert solver.solution.controls.pseudo_time_explicit_relaxation_factor() == {
"global_dt_pseudo_relax": {
"turb-viscosity": 1.0,
"body-force": 1.0,
"k": 0.75,
"omega": 0.75,
"mp": 0.5,
"density": 1.0,
}
}
solver.solution.controls.pseudo_time_explicit_relaxation_factor = {
"global_dt_pseudo_relax": {"turb-viscosity": 0.9, "body-force": 0.8}
}
assert solver.solution.controls.pseudo_time_explicit_relaxation_factor() == {
"global_dt_pseudo_relax": {
"turb-viscosity": 0.9,
"body-force": 0.8,
"k": 0.75,
"omega": 0.75,
"mp": 0.5,
"density": 1.0,
}
}
solver.solution.methods.p_v_coupling.flow_scheme = "SIMPLE"
solver.solution.controls.under_relaxation = {"pressure": 0.9}
solver.solution.controls.under_relaxation = {"density": 0.9}
assert solver.solution.controls.under_relaxation() == {
"mom": 0.7,
"turb-viscosity": 1,
"density": 0.9,
"omega": 0.8,
"mp": 0.5,
"body-force": 1.0,
"pressure": 0.9,
"k": 0.8,
}
solver.solution.controls.under_relaxation = {
"body-force": 0.7,
"density": 0.75,
"mom": 0.8,
}
assert solver.solution.controls.under_relaxation() == {
"mom": 0.8,
"turb-viscosity": 1,
"density": 0.75,
"omega": 0.8,
"mp": 0.5,
"body-force": 0.7,
"pressure": 0.9,
"k": 0.8,
}
49 changes: 49 additions & 0 deletions tests/test_solvermode/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,52 @@ def test_solver_import_mixingelbow(load_mixing_elbow_mesh):
solver_session.scheme_eval.scheme_eval('(units/quantity-info "length")')[-1]
== "in"
)
solver_session.setup.general.solver.time.get_attr("allowed-values")
solver_session.setup.general.solver.time = "unsteady-2nd-order"
solver_session.setup.general.solver.time = "unsteady-1st-order"
solver_session.setup.general.solver.time = "unsteady-2nd-order-bounded"
solver_session.setup.general.solver.time = "steady"

# solver.setup.general.gravity = {"gravity": True, "y_component": -9.81}
# solver.mesh.scale(x_scale=0.001, y_scale=0.001, z_scale=0.001)
solver_session.setup.general.solver.type.get_attr("allowed-values")
solver_session.setup.general.solver.type = "density-based-implicit"
assert solver_session.setup.general.solver.type() == "density-based-implicit"
solver_session.setup.general.solver.type = "density-based-explicit"
assert solver_session.setup.general.solver.type() == "density-based-explicit"
solver_session.setup.general.solver.type = "pressure-based"
assert solver_session.setup.general.solver.type() == "pressure-based"

solver_session.file.auto_save.data_frequency = 10
assert solver_session.file.auto_save.data_frequency() == 10
solver_session.file.auto_save.case_frequency = "each-time"
assert solver_session.file.auto_save.case_frequency() == "each-time"
solver_session.file.auto_save.root_name = "file_auto_save"
assert solver_session.file.auto_save.root_name() == "file_auto_save"
solver_session.setup.reference_values.compute(from_zone_name="outlet")


@pytest.mark.quick
@pytest.mark.setup
def test_disk_2d_setup(load_disk_mesh):
session = load_disk_mesh
assert session._root.get_attr("active?")
assert session.check_health() == "SERVING"
###
assert not session.setup.models.energy.enabled()
assert session.scheme_eval.scheme_eval("(case-valid?)")
session.tui.mesh.check()
assert session.setup.general.solver.two_dim_space.get_attr("allowed-values") == [
"swirl",
"axisymmetric",
"planar",
]
assert session.setup.general.solver.two_dim_space() == "planar"
session.setup.general.solver.two_dim_space = "axisymmetric"
assert session.setup.general.solver.two_dim_space() == "axisymmetric"
session.setup.general.solver.two_dim_space = "swirl"
assert session.setup.general.solver.two_dim_space() == "swirl"
session.setup.general.solver.two_dim_space = "planar"
assert session.setup.general.solver.two_dim_space() == "planar"
# Bug 682773
# session.setup.general.gravity = {"gravity": True, "x_component": -9.81}
71 changes: 71 additions & 0 deletions tests/test_solvermode/test_initialization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import pytest
from util.fixture_fluent import download_input_file


@pytest.mark.quick
@pytest.mark.setup
def test_initialize(launch_fluent_solver_3ddp_t2):
solver = launch_fluent_solver_3ddp_t2
input_type, input_name = download_input_file("pyfluent/wigley_hull", "wigley.msh")
solver.file.read(file_type=input_type, file_name=input_name)
solver.parallel.partition.set.use_laplace_smoothing = True
solver.parallel.partition.method(partition_method="metis", count=2)
solver.setup.materials.database.copy_by_name(type="fluid", name="air")
solver.setup.materials.database.copy_by_name(type="fluid", name="water-liquid")
solver.setup.models.multiphase.models = "vof"
solver.setup.general.gravity = {"enable": True, "components": [0.0, 0.0, -9.81]}
solver.setup.general.solver.time = "steady"
solver.execute_tui("/define/models/multiphase/vof-sub-models yes no ")
solver.execute_tui(
"/define/phases/set-domain-properties/change-phases-names? water air "
)
solver.setup.boundary_conditions.pressure_inlet["inflow"].phase["mixture"] = {
"open_channel": True,
"direction_spec": "Direction Vector",
"vmag": 1.452,
"ht_bottom": -0.941875,
"turb_intensity": 0.01,
"turb_viscosity_ratio": 1,
}
solver.setup.boundary_conditions.pressure_outlet["outflow"].phase["mixture"] = {
"open_channel": True,
"ht_bottom": -0.941875,
"den_spec": "From Free Surface Level",
"direction_spec": "Normal to Boundary",
"turb_intensity": 0.01,
"turb_viscosity_ratio": 1,
"p_backflow_spec_gen": "Static Pressure",
}

solver.solution.methods.p_v_coupling.flow_scheme = "Coupled"
solver.solution.methods.p_v_coupling.coupled_form = True
solver.solution.controls.advanced.multi_grid.algebraic_mg_controls.coupled_parameters.coarsening_parameters.laplace_coarsening = (
True
)
solver.solution.initialization.open_channel_auto_init = {
"boundary_thread": 3,
"flat_init": True,
}
assert solver.solution.initialization.open_channel_auto_init() == {
"boundary_thread": 3,
"flat_init": True,
}
# solver.solution.initialization.hybrid_initialize()
# solver.exit()


@pytest.mark.quick
@pytest.mark.setup
def test_fmg_initialize(launch_fluent_solver_3ddp_t2):
solver = launch_fluent_solver_3ddp_t2
input_type, input_name = download_input_file(
"pyfluent/vki_turbine", "vki_turbine.cas.gz"
)
solver.file.read(file_type=input_type, file_name=input_name)
solver.execute_tui("(rpsetvar 'fmg-init/reorder? #f) ")
solver.mesh.check()
solver.solution.initialization.standard_initialize()
solver.solution.initialization.fmg_initialize = True
# assert solver.solution.initialization.fmg_initialize() == True
solver.execute_tui("(benchmark '(iterate 2)) ")
# solver.solution.initialization.hybrid_initialize()
37 changes: 37 additions & 0 deletions tests/test_solvermode/test_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,40 @@ def test_solver_material(load_mixing_elbow_mesh):
"water-liquid"
in solver_session.setup.cell_zone_conditions.fluid["elbow-fluid"].material()
)

solver_session.setup.materials.database.copy_by_name(type="fluid", name="air")
solver_session.setup.cell_zone_conditions.fluid["elbow-fluid"].material = "air"
assert (
"air"
in solver_session.setup.cell_zone_conditions.fluid["elbow-fluid"].material()
)
assert (
"air"
in solver_session.setup.cell_zone_conditions.fluid["elbow-fluid"].material()
)
assert solver_session.setup.materials.child_names == [
"database",
"fluid",
"solid",
"mixture",
"inert_particle",
"droplet_particle",
"combusting_particle",
"particle_mixture",
]
assert solver_session.setup.materials.database.get_active_command_names() == [
"copy_by_formula",
"copy_by_name",
"list_materials",
"list_properties",
]

solver_session.setup.materials.database.copy_by_formula(
type="fluid", formula="c2h6"
)

solver_session.setup.cell_zone_conditions.fluid["elbow-fluid"].material = "ethane"
assert (
"ethane"
in solver_session.setup.cell_zone_conditions.fluid["elbow-fluid"].material()
)
60 changes: 60 additions & 0 deletions tests/test_solvermode/test_methods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import pytest


@pytest.mark.quick
@pytest.mark.setup
def test_methods(load_mixing_elbow_mesh):
solver = load_mixing_elbow_mesh
solver.setup.models.multiphase.models = "vof"
solver.setup.general.gravity = {"enable": True, "components": [0.0, 0.0, -9.81]}
solver.setup.general.solver.time = "steady"
solver.solution.methods.p_v_coupling.flow_scheme = "Coupled"
solver.solution.methods.p_v_coupling.coupled_form = False
assert solver.solution.methods.p_v_coupling() == {
"flow_scheme": "Coupled",
"coupled_form": False,
}
solver.solution.methods.discretization_scheme = {"pressure": "presto!"}
assert solver.solution.methods.discretization_scheme() == {
"mom": "second-order-upwind",
"omega": "second-order-upwind",
"mp": "compressive",
"pressure": "presto!",
"k": "second-order-upwind",
}
solver.solution.methods.gradient_scheme = "least-square-cell-based"
assert solver.solution.methods.gradient_scheme() == "least-square-cell-based"
solver.solution.methods.warped_face_gradient_correction.enable(
enable=True, gradient_correction_mode="fast-mode"
)
solver.solution.methods.warped_face_gradient_correction.enable(
enable=False, gradient_correction_mode="fast-mode"
)
solver.solution.methods.expert.numerics_pbns.velocity_formulation = "relative"
assert (
solver.solution.methods.expert.numerics_pbns.velocity_formulation()
== "relative"
)
solver.solution.methods.expert.numerics_pbns = {
"implicit_bodyforce_treatment": True,
"velocity_formulation": "absolute",
"physical_velocity_formulation": True,
"disable_rhie_chow_flux": True,
"presto_pressure_scheme": False,
"first_to_second_order_blending": 2.0,
}
assert solver.solution.methods.expert.numerics_pbns() == {
"implicit_bodyforce_treatment": True,
"velocity_formulation": "absolute",
"physical_velocity_formulation": True,
"disable_rhie_chow_flux": True,
"presto_pressure_scheme": False,
"first_to_second_order_blending": 2.0,
}
solver.solution.methods.expert.numerics_pbns.presto_pressure_scheme = True
assert solver.solution.methods.expert.numerics_pbns.presto_pressure_scheme() == True
solver.solution.methods.gradient_scheme = "green-gauss-node-based"
assert solver.solution.methods.gradient_scheme() == "green-gauss-node-based"
solver.solution.methods.warped_face_gradient_correction.enable(
enable=True, gradient_correction_mode="memory-saving-mode"
)
Loading

0 comments on commit a0ae26c

Please sign in to comment.