diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b9b6bb43913..0f7c4f17e937 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,7 +92,7 @@ jobs: docs_build: name: Build Documentation - runs-on: ubuntu-latest + runs-on: self-hosted steps: - uses: actions/checkout@v2 @@ -113,8 +113,8 @@ jobs: - name: Install OS packages run: | - sudo apt update - sudo apt install pandoc libegl1 + sudo apt-get update + sudo apt-get install pandoc libegl1 make xvfb libfontconfig1 libxrender1 libxkbcommon-x11-0 -y - name: Cache pip uses: actions/cache@v2 @@ -153,6 +153,7 @@ jobs: - name: Build Documentation run: | + sudo rm -rf /home/ansys/.local/share/ansys_fluent_core/examples/* pip install -r requirements_docs.txt xvfb-run make -C doc html touch doc/_build/html/.nojekyll diff --git a/Makefile b/Makefile index 1ade7c853e24..81c707574060 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ install-pyvistaqt-requirements: @sudo apt install libegl1 -y docker-pull: + @docker image rm -f ghcr.io/pyansys/pyfluent:latest @docker pull ghcr.io/pyansys/pyfluent:latest test-import: diff --git a/examples/00-fluent/exhaust_system.py b/examples/00-fluent/exhaust_system.py index 2db50381ee35..10b71a8a7f7c 100644 --- a/examples/00-fluent/exhaust_system.py +++ b/examples/00-fluent/exhaust_system.py @@ -50,7 +50,7 @@ # Start Fluent in double precision running on 2 processors session = pyfluent.launch_fluent( - meshing_mode=True, precision="double", processor_count=2 + meshing_mode=True, precision="double", processor_count=4 ) ############################################################################### diff --git a/examples/00-fluent/mixing_elbow.py b/examples/00-fluent/mixing_elbow.py index ca890feb3519..595653b50be1 100644 --- a/examples/00-fluent/mixing_elbow.py +++ b/examples/00-fluent/mixing_elbow.py @@ -48,7 +48,7 @@ import_filename = examples.download_file("mixing_elbow.pmdb", "pyfluent/mixing_elbow") session = pyfluent.launch_fluent( - meshing_mode=True, precision="double", processor_count=2 + meshing_mode=True, precision="double", processor_count=4 ) ############################################################################### diff --git a/examples/01-parametric/parametric_static_mixer_1.py b/examples/01-parametric/parametric_static_mixer_1.py index 614b2d6fc43f..e0e536d7e358 100755 --- a/examples/01-parametric/parametric_static_mixer_1.py +++ b/examples/01-parametric/parametric_static_mixer_1.py @@ -1,197 +1,197 @@ -""".. _ref_parametric_static_mixer_1: - -Parametric Study Workflow ------------------------------- -This example for executing a parametric study workflow -performs these steps: - -- Reads a case file and data file -- Creates input and output parameters -- Instantiates a design point study -- Accesses and modifies the input parameters of - the base design point (DP) -- Updates the current DP -- Accesses output parameters of the base DP -- Creates, updates, and deletes more DPs -- Creates, renames, and deletes parametric studies -""" - -############################################################################ -from pathlib import Path - -import pandas as pd - -import ansys.fluent.core as pyfluent -from ansys.fluent.core import examples -from ansys.fluent.parametric import ParametricStudy - -############################################################################ -# Launch Fluent in 3D and double precision - -session = pyfluent.launch_fluent(precision="double", processor_count=2) - -############################################################################ -# Enable the settings API (Beta) - -root = session.get_settings_root() - -############################################################################ -# Read the hopper/mixer case - -import_filename = examples.download_file( - "Static_Mixer_main.cas.h5", "pyfluent/static_mixer" -) - -session.tui.solver.file.read_case(case_file_name=import_filename) - -############################################################################ -# Set number of iterations to 100 - -session.tui.solver.solve.set.number_of_iterations("100") - -############################################################################ -# Create input parameters after enabling parameter creation in the TUI: -# Parameter values: -# Inlet1: velocity (inlet1_vel) 5 m/s and temperature (inlet1_temp) at 300 K -# Inlet2: velocity (inlet2_vel) 10 m/s and temperature (inlet2_temp) at 350 K - -session.tui.solver.define.parameters.enable_in_TUI("yes") - -session.tui.solver.define.boundary_conditions.set.velocity_inlet( - "inlet1", (), "vmag", "yes", "inlet1_vel", 5, "quit" -) -session.tui.solver.define.boundary_conditions.set.velocity_inlet( - "inlet1", (), "temperature", "yes", "inlet1_temp", 300, "quit" -) - -session.tui.solver.define.boundary_conditions.set.velocity_inlet( - "inlet2", (), "vmag", "yes", "no", "inlet2_vel", 10, "quit" -) -session.tui.solver.define.boundary_conditions.set.velocity_inlet( - "inlet2", (), "temperature", "yes", "no", "inlet2_temp", 350, "quit" -) - -########################################################################### -# Create output parameters using report definitions - -root.solution.report_definitions.surface["outlet-temp-avg"] = {} -root.solution.report_definitions.surface[ - "outlet-temp-avg" -].report_type = "surface-areaavg" -root.solution.report_definitions.surface["outlet-temp-avg"].field = "temperature" -root.solution.report_definitions.surface["outlet-temp-avg"].surface_names = ["outlet"] - -root.solution.report_definitions.surface["outlet-vel-avg"] = {} -root.solution.report_definitions.surface[ - "outlet-vel-avg" -].report_type = "surface-areaavg" -root.solution.report_definitions.surface["outlet-vel-avg"].field = "velocity-magnitude" -root.solution.report_definitions.surface["outlet-vel-avg"].surface_names = ["outlet"] - -session.tui.solver.define.parameters.enable_in_TUI("yes") -session.tui.solver.define.parameters.output_parameters.create( - "report-definition", "outlet-temp-avg" -) -session.tui.solver.define.parameters.output_parameters.create( - "report-definition", "outlet-vel-avg" -) - -########################################################################### -# Enable convergence condition check - -session.tui.solver.solve.monitors.residual.criterion_type("0") - -########################################################################### -# Write case with all the settings in place -case_path = str(Path(pyfluent.EXAMPLES_PATH) / "Static_Mixer_Parameters.cas.h5") -session.tui.solver.file.write_case(case_path) - -########################################################################### -# Instantiate a parametric study from a Fluent session - -study_1 = ParametricStudy(root.parametric_studies).initialize() - -########################################################################### -# Access and modify input parameters of base DP - -input_parameters_update = study_1.design_points["Base DP"].input_parameters -input_parameters_update["inlet1_vel"] = 15 -study_1.design_points["Base DP"].input_parameters = input_parameters_update - -########################################################################### -# Update current design point - -study_1.update_current_design_point() - -########################################################################### -# Change value of specific design points - -design_point_1 = study_1.add_design_point() -design_point_1_input_parameters = study_1.design_points["DP1"].input_parameters -design_point_1_input_parameters["inlet1_temp"] = 450 -design_point_1_input_parameters["inlet1_vel"] = 30 -design_point_1_input_parameters["inlet2_vel"] = 20 -study_1.design_points["DP1"].input_parameters = design_point_1_input_parameters - -########################################################################### -# Add another design point with different values of the input parameters - -design_point_2 = study_1.add_design_point() -design_point_2_input_parameters = study_1.design_points["DP2"].input_parameters -design_point_2_input_parameters["inlet1_temp"] = 500 -design_point_2_input_parameters["inlet1_vel"] = 45 -design_point_2_input_parameters["inlet2_vel"] = 30 -study_1.design_points["DP2"].input_parameters = design_point_2_input_parameters - -########################################################################## -# Duplicate design points - -design_point_3 = study_1.duplicate_design_point(design_point_2) - -######################################################################### -# Update all design points for study 1 - -study_1.update_all_design_points() - -######################################################################### -# Export design point table as a CSV table - -design_point_table = str( - Path(pyfluent.EXAMPLES_PATH) / "design_point_table_study_1.csv" -) -study_1.export_design_table(design_point_table) - -######################################################################### -# Display CSV table as a pandas dataframe - -data_frame = pd.read_csv(design_point_table) -print(data_frame) - -########################################################################## -# Delete design points - -study_1.delete_design_points([design_point_1, design_point_2]) - -########################################################################## -# Create a new parametric study by duplicating the current one - -study_2 = study_1.duplicate() - -######################################################################### -# Rename the newly created parametric study -# Currently affected by issue # 249, hence commented out - -# study_2.rename("New Study") - -######################################################################### -# Delete the old parametric study -# Currently affected by issue #249, hence commented out - -# study_1.delete() - -######################################################################### -# Save parametric project - -project_filepath = str(Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study.flprj") - -session.tui.solver.file.parametric_project.save_as(project_filepath) +""".. _ref_parametric_static_mixer_1: + +Parametric Study Workflow +------------------------------ +This example for executing a parametric study workflow +performs these steps: + +- Reads a case file and data file +- Creates input and output parameters +- Instantiates a design point study +- Accesses and modifies the input parameters of + the base design point (DP) +- Updates the current DP +- Accesses output parameters of the base DP +- Creates, updates, and deletes more DPs +- Creates, renames, and deletes parametric studies +""" + +############################################################################ +from pathlib import Path + +import pandas as pd + +import ansys.fluent.core as pyfluent +from ansys.fluent.core import examples +from ansys.fluent.parametric import ParametricStudy + +############################################################################ +# Launch Fluent in 3D and double precision + +session = pyfluent.launch_fluent(precision="double", processor_count=4) + +############################################################################ +# Enable the settings API (Beta) + +root = session.get_settings_root() + +############################################################################ +# Read the hopper/mixer case + +import_filename = examples.download_file( + "Static_Mixer_main.cas.h5", "pyfluent/static_mixer" +) + +session.tui.solver.file.read_case(case_file_name=import_filename) + +############################################################################ +# Set number of iterations to 100 + +session.tui.solver.solve.set.number_of_iterations("100") + +############################################################################ +# Create input parameters after enabling parameter creation in the TUI: +# Parameter values: +# Inlet1: velocity (inlet1_vel) 5 m/s and temperature (inlet1_temp) at 300 K +# Inlet2: velocity (inlet2_vel) 10 m/s and temperature (inlet2_temp) at 350 K + +session.tui.solver.define.parameters.enable_in_TUI("yes") + +session.tui.solver.define.boundary_conditions.set.velocity_inlet( + "inlet1", (), "vmag", "yes", "inlet1_vel", 5, "quit" +) +session.tui.solver.define.boundary_conditions.set.velocity_inlet( + "inlet1", (), "temperature", "yes", "inlet1_temp", 300, "quit" +) + +session.tui.solver.define.boundary_conditions.set.velocity_inlet( + "inlet2", (), "vmag", "yes", "no", "inlet2_vel", 10, "quit" +) +session.tui.solver.define.boundary_conditions.set.velocity_inlet( + "inlet2", (), "temperature", "yes", "no", "inlet2_temp", 350, "quit" +) + +########################################################################### +# Create output parameters using report definitions + +root.solution.report_definitions.surface["outlet-temp-avg"] = {} +root.solution.report_definitions.surface[ + "outlet-temp-avg" +].report_type = "surface-areaavg" +root.solution.report_definitions.surface["outlet-temp-avg"].field = "temperature" +root.solution.report_definitions.surface["outlet-temp-avg"].surface_names = ["outlet"] + +root.solution.report_definitions.surface["outlet-vel-avg"] = {} +root.solution.report_definitions.surface[ + "outlet-vel-avg" +].report_type = "surface-areaavg" +root.solution.report_definitions.surface["outlet-vel-avg"].field = "velocity-magnitude" +root.solution.report_definitions.surface["outlet-vel-avg"].surface_names = ["outlet"] + +session.tui.solver.define.parameters.enable_in_TUI("yes") +session.tui.solver.define.parameters.output_parameters.create( + "report-definition", "outlet-temp-avg" +) +session.tui.solver.define.parameters.output_parameters.create( + "report-definition", "outlet-vel-avg" +) + +########################################################################### +# Enable convergence condition check + +session.tui.solver.solve.monitors.residual.criterion_type("0") + +########################################################################### +# Write case with all the settings in place +case_path = str(Path(pyfluent.EXAMPLES_PATH) / "Static_Mixer_Parameters.cas.h5") +session.tui.solver.file.write_case(case_path) + +########################################################################### +# Instantiate a parametric study from a Fluent session + +study_1 = ParametricStudy(root.parametric_studies).initialize() + +########################################################################### +# Access and modify input parameters of base DP + +input_parameters_update = study_1.design_points["Base DP"].input_parameters +input_parameters_update["inlet1_vel"] = 15 +study_1.design_points["Base DP"].input_parameters = input_parameters_update + +########################################################################### +# Update current design point + +study_1.update_current_design_point() + +########################################################################### +# Change value of specific design points + +design_point_1 = study_1.add_design_point() +design_point_1_input_parameters = study_1.design_points["DP1"].input_parameters +design_point_1_input_parameters["inlet1_temp"] = 450 +design_point_1_input_parameters["inlet1_vel"] = 30 +design_point_1_input_parameters["inlet2_vel"] = 20 +study_1.design_points["DP1"].input_parameters = design_point_1_input_parameters + +########################################################################### +# Add another design point with different values of the input parameters + +design_point_2 = study_1.add_design_point() +design_point_2_input_parameters = study_1.design_points["DP2"].input_parameters +design_point_2_input_parameters["inlet1_temp"] = 500 +design_point_2_input_parameters["inlet1_vel"] = 45 +design_point_2_input_parameters["inlet2_vel"] = 30 +study_1.design_points["DP2"].input_parameters = design_point_2_input_parameters + +########################################################################## +# Duplicate design points + +design_point_3 = study_1.duplicate_design_point(design_point_2) + +######################################################################### +# Update all design points for study 1 + +study_1.update_all_design_points() + +######################################################################### +# Export design point table as a CSV table + +design_point_table = str( + Path(pyfluent.EXAMPLES_PATH) / "design_point_table_study_1.csv" +) +study_1.export_design_table(design_point_table) + +######################################################################### +# Display CSV table as a pandas dataframe + +data_frame = pd.read_csv(design_point_table) +print(data_frame) + +########################################################################## +# Delete design points + +study_1.delete_design_points([design_point_1, design_point_2]) + +########################################################################## +# Create a new parametric study by duplicating the current one + +study_2 = study_1.duplicate() + +######################################################################### +# Rename the newly created parametric study +# Currently affected by issue # 249, hence commented out + +# study_2.rename("New Study") + +######################################################################### +# Delete the old parametric study +# Currently affected by issue #249, hence commented out + +# study_1.delete() + +######################################################################### +# Save parametric project + +project_filepath = str(Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study.flprj") + +session.tui.solver.file.parametric_project.save_as(project_filepath) diff --git a/examples/01-parametric/parametric_static_mixer_2.py b/examples/01-parametric/parametric_static_mixer_2.py index d7393ceb9e7d..3395518573dd 100755 --- a/examples/01-parametric/parametric_static_mixer_2.py +++ b/examples/01-parametric/parametric_static_mixer_2.py @@ -1,64 +1,64 @@ -""".. _ref_parametric_static_mixer_2: - -Parametric Project-Based Workflow ----------------------------------------------------- -This example for executing a parametric project-based workflow -performs these steps: - -- Instantiates a parametric study from a Fluent session -- Reads the previously saved project ``- static_mixer_study.flprj`` -- Saves the current project -- Saves the current project to a different file name -- Exports the current project -- Archives the current project -- Exits the parametric project-based workflow -""" - -######################################################################### -from pathlib import Path - -import ansys.fluent.core as pyfluent -from ansys.fluent.parametric import ParametricProject - -######################################################################### -# Launch Fluent and enable the settings API (Beta) - -session = pyfluent.launch_fluent(precision="double", processor_count=2) -root = session.get_settings_root() - -######################################################################### -# Read the previously saved project - static_mixer_study.flprj - -project_filepath_read = str(Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study.flprj") - -proj = ParametricProject( - root.file.parametric_project, - root.parametric_studies, - project_filepath_read, -) - -######################################################################### -# Save the current project - -proj.save() - -######################################################################### -# Save the current project to a different file name - -project_filepath_save_as = str( - Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_save_as.flprj" -) -proj.save_as(project_filepath=project_filepath_save_as) - -######################################################################### -# Export the current project - -project_filepath_export = str( - Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_export.flprj" -) -proj.export(project_filepath=project_filepath_export) - -######################################################################### -# Archive the current project - -proj.archive() +""".. _ref_parametric_static_mixer_2: + +Parametric Project-Based Workflow +---------------------------------------------------- +This example for executing a parametric project-based workflow +performs these steps: + +- Instantiates a parametric study from a Fluent session +- Reads the previously saved project ``- static_mixer_study.flprj`` +- Saves the current project +- Saves the current project to a different file name +- Exports the current project +- Archives the current project +- Exits the parametric project-based workflow +""" + +######################################################################### +from pathlib import Path + +import ansys.fluent.core as pyfluent +from ansys.fluent.parametric import ParametricProject + +######################################################################### +# Launch Fluent and enable the settings API (Beta) + +session = pyfluent.launch_fluent(precision="double", processor_count=4) +root = session.get_settings_root() + +######################################################################### +# Read the previously saved project - static_mixer_study.flprj + +project_filepath_read = str(Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study.flprj") + +proj = ParametricProject( + root.file.parametric_project, + root.parametric_studies, + project_filepath_read, +) + +######################################################################### +# Save the current project + +proj.save() + +######################################################################### +# Save the current project to a different file name + +project_filepath_save_as = str( + Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_save_as.flprj" +) +proj.save_as(project_filepath=project_filepath_save_as) + +######################################################################### +# Export the current project + +project_filepath_export = str( + Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_export.flprj" +) +proj.export(project_filepath=project_filepath_export) + +######################################################################### +# Archive the current project + +proj.archive() diff --git a/examples/01-parametric/parametric_static_mixer_3.py b/examples/01-parametric/parametric_static_mixer_3.py index 75f99fda3eb2..bd2d1ac292b7 100755 --- a/examples/01-parametric/parametric_static_mixer_3.py +++ b/examples/01-parametric/parametric_static_mixer_3.py @@ -1,83 +1,83 @@ -""".. _ref_parametric_static_mixer_3: - -Parametric Session Workflow ----------------------------------------------- -This example for executing a parametric session workflow performs these steps: - -- Launches a parametric session using the hopper/mixer case file -- Prints the input parameters of the current parametric session -- Accesses the current study of the current parametric session -- Creates a new study in a parametric session -- Renames this newly created study -- Creates a new parametric session using the flprj saved earlier -""" - -######################################################################### -from pathlib import Path - -import pandas as pd - -import ansys.fluent.core as pyfluent -from ansys.fluent.parametric import ParametricSession - -######################################################################### -# Launch parametric session using the hopper/mixer case File -# This case file contains pre-created input and output parameters - -case_path = str(Path(pyfluent.EXAMPLES_PATH) / "Static_Mixer_Parameters.cas.h5") - -session = ParametricSession(case_filepath=case_path) - -######################################################################### -# Print the input parameters of the current parametric session. - -session.studies["Static_Mixer_Parameters-Solve"].design_points[ - "Base DP" -].input_parameters - -######################################################################### -# Access the current study of the current parametric session - -study_1 = session.studies["Static_Mixer_Parameters-Solve"] - -input_parameters_update = study_1.design_points["Base DP"].input_parameters -input_parameters_update["inlet1_vel"] = 15 -study_1.design_points["Base DP"].input_parameters = input_parameters_update - -design_point_1 = study_1.add_design_point() -design_point_1_input_parameters = study_1.design_points["DP1"].input_parameters -design_point_1_input_parameters["inlet1_temp"] = 323 -design_point_1_input_parameters["inlet1_vel"] = 33 -design_point_1_input_parameters["inlet2_vel"] = 25 -study_1.design_points["DP1"].input_parameters = design_point_1_input_parameters - -######################################################################### -# In this parametric project create a new study - -study_2 = session.new_study() - -######################################################################### -# Update all design points -study_2.update_all_design_points() - -######################################################################### -# Export design point table as a CSV table - -design_point_table_study_2 = str( - Path(pyfluent.EXAMPLES_PATH) / "design_point_table_study_2.csv" -) -study_2.export_design_table(design_point_table_study_2) - -######################################################################### -# Display CSV table as a pandas dataframe - -data_frame = pd.read_csv(design_point_table_study_2) -print(data_frame) - -######################################################################### -# Access a new parametric session using the flprj saved earlier - -project_session_filepath = str( - Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_save_as.flprj" -) -new_session = ParametricSession(project_filepath=project_session_filepath) +""".. _ref_parametric_static_mixer_3: + +Parametric Session Workflow +---------------------------------------------- +This example for executing a parametric session workflow performs these steps: + +- Launches a parametric session using the hopper/mixer case file +- Prints the input parameters of the current parametric session +- Accesses the current study of the current parametric session +- Creates a new study in a parametric session +- Renames this newly created study +- Creates a new parametric session using the flprj saved earlier +""" + +######################################################################### +from pathlib import Path + +import pandas as pd + +import ansys.fluent.core as pyfluent +from ansys.fluent.parametric import ParametricSession + +######################################################################### +# Launch parametric session using the hopper/mixer case File +# This case file contains pre-created input and output parameters + +case_path = str(Path(pyfluent.EXAMPLES_PATH) / "Static_Mixer_Parameters.cas.h5") + +session = ParametricSession(case_filepath=case_path) + +######################################################################### +# Print the input parameters of the current parametric session. + +session.studies["Static_Mixer_Parameters-Solve"].design_points[ + "Base DP" +].input_parameters + +######################################################################### +# Access the current study of the current parametric session + +study_1 = session.studies["Static_Mixer_Parameters-Solve"] + +input_parameters_update = study_1.design_points["Base DP"].input_parameters +input_parameters_update["inlet1_vel"] = 15 +study_1.design_points["Base DP"].input_parameters = input_parameters_update + +design_point_1 = study_1.add_design_point() +design_point_1_input_parameters = study_1.design_points["DP1"].input_parameters +design_point_1_input_parameters["inlet1_temp"] = 323 +design_point_1_input_parameters["inlet1_vel"] = 33 +design_point_1_input_parameters["inlet2_vel"] = 25 +study_1.design_points["DP1"].input_parameters = design_point_1_input_parameters + +######################################################################### +# In this parametric project create a new study + +study_2 = session.new_study() + +######################################################################### +# Update all design points +study_2.update_all_design_points() + +######################################################################### +# Export design point table as a CSV table + +design_point_table_study_2 = str( + Path(pyfluent.EXAMPLES_PATH) / "design_point_table_study_2.csv" +) +study_2.export_design_table(design_point_table_study_2) + +######################################################################### +# Display CSV table as a pandas dataframe + +data_frame = pd.read_csv(design_point_table_study_2) +print(data_frame) + +######################################################################### +# Access a new parametric session using the flprj saved earlier + +project_session_filepath = str( + Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_save_as.flprj" +) +new_session = ParametricSession(project_filepath=project_session_filepath) diff --git a/examples/02-postprocessing/post_processing_exhaust_manifold.py b/examples/02-postprocessing/post_processing_exhaust_manifold.py index b2b7ca0f69dd..5e282cb88f32 100644 --- a/examples/02-postprocessing/post_processing_exhaust_manifold.py +++ b/examples/02-postprocessing/post_processing_exhaust_manifold.py @@ -36,7 +36,7 @@ filename="manifold_solution.dat.h5", directory="pyfluent/exhaust_manifold" ) -session = pyfluent.launch_fluent(precision="double", processor_count=2) +session = pyfluent.launch_fluent(precision="double", processor_count=4) root = session.get_settings_root() session.tui.solver.file.read_case(case_file_name=import_case)