From db9ad63356abaf12cd1d63be5794fbecd13e80b5 Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Thu, 31 Mar 2022 18:16:44 -0400 Subject: [PATCH 01/21] Add 3 examples for Parametric Workflows --- doc/source/conf.py | 4 + .../parametric_static_mixer_1.py | 228 ++++++++++++++++++ .../parametric_static_mixer_2.py | 73 ++++++ .../parametric_static_mixer_3.py | 80 ++++++ 4 files changed, 385 insertions(+) create mode 100755 examples/01-parametric/parametric_static_mixer_1.py create mode 100755 examples/01-parametric/parametric_static_mixer_2.py create mode 100755 examples/01-parametric/parametric_static_mixer_3.py diff --git a/doc/source/conf.py b/doc/source/conf.py index 577fa34ba7bd..29b8ce2b7ec0 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -112,6 +112,10 @@ def _start_or_stop_fluent_container(gallery_conf, fname, when): if fname in ["mixing_elbow_settings_api.py", "mixing_elbow_tui_api.py"]: args = ["3ddp", "-t4", "-meshing"] + elif fname in ["parametric_static_mixer_1.py", + "parametric_static_mixer_2.py", + "parametric_static_mixer_3.py"]: + args = ["3ddp", "-t4"] subprocess.run([sys.executable, _START_FLUENT_FILE] + args) elif when == "after": subprocess.run([sys.executable, _STOP_FLUENT_FILE]) diff --git a/examples/01-parametric/parametric_static_mixer_1.py b/examples/01-parametric/parametric_static_mixer_1.py new file mode 100755 index 000000000000..e5eb72495498 --- /dev/null +++ b/examples/01-parametric/parametric_static_mixer_1.py @@ -0,0 +1,228 @@ +""" +.. _ref_parametric_static_mixer_1: + +Parametric study workflow +---------------------------------------------- +In this example we perform the following steps to +execute a parametric study workflow +- Read a case and data file. +- Create input and output parameters. +- Instantiate design point study +- Access and Modify the input parameters of base design point (DP). +- Update the current design point. +- Access output parameters of the base DP +- Create, update and delete more design points. +- Create, rename and delete parametric studies + +""" + +############################################################################ +# Import the pyfluent module +import ansys.fluent.core as pyfluent + +# Import the path module +from pathlib import Path + +############################################################################ + +# Launch Fluent in 3-D and double precision +s = pyfluent.launch_fluent(precision="double", processor_count=4) + +############################################################################ + +# Enable the settings API + +root = s.get_settings_root() + +############################################################################ + +# Read the hopper/mixer Case + +from ansys.fluent.core import examples + + +import_filename = examples.download_file( + "Static_Mixer_main.cas.h5", "pyfluent/static_mixer" +) + + +s.tui.solver.file.read_case(case_file_name=import_filename) + +############################################################################ + +# Set number of iterations to 1000 to ensure convergence +s.tui.solver.solve.set.number_of_iterations("1000") +############################################################################ + +# 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 + +s.tui.solver.define.parameters.enable_in_TUI("yes") + +s.tui.solver.define.boundary_conditions.set.velocity_inlet( + "inlet1", (), "vmag", "yes", "inlet1_vel", 5, "quit" +) +s.tui.solver.define.boundary_conditions.set.velocity_inlet( + "inlet1", (), "temperature", "yes", "inlet1_temp", 300, "quit" +) + +s.tui.solver.define.boundary_conditions.set.velocity_inlet( + "inlet2", (), "vmag", "yes", "no", "inlet2_vel", 10, "quit" +) +s.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" +] + +s.tui.solver.define.parameters.enable_in_TUI("yes") +s.tui.solver.define.parameters.output_parameters.create( + "report-definition", "outlet-temp-avg" +) +s.tui.solver.define.parameters.output_parameters.create( + "report-definition", "outlet-vel-avg" +) + +########################################################################### + +# Enable convergence condition check + +s.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" +) +s.tui.solver.file.write_case(case_path) + +########################################################################### +# Parametric study workflow + +# Import the parametric study module + +from ansys.fluent.parametric import ParametricStudy + +########################################################################### + +# Instantiate a parametric study from a Fluent session + +study1 = ParametricStudy(root.parametric_studies).initialize() + +########################################################################### + +# Access and modify input parameters of base DP +ip = study1.design_points["Base DP"].input_parameters +ip["inlet1_vel"] = 15 +study1.design_points["Base DP"].input_parameters = ip + +########################################################################### + +# Update current design point +study1.update_current_design_point() + +########################################################################### + +# Change value of specific design points + +dp1 = study1.add_design_point() +dp1_ip = study1.design_points["DP1"].input_parameters +dp1_ip["inlet1_temp"] = 450 +dp1_ip["inlet1_vel"] = 30 +dp1_ip["inlet2_vel"] = 20 +study1.design_points["DP1"].input_parameters = dp1_ip + +########################################################################### + +# Add another design point with different values of the input parameters + +dp2 = study1.add_design_point() +dp2_ip = study1.design_points["DP2"].input_parameters +dp2_ip["inlet1_temp"] = 500 +dp2_ip["inlet1_vel"] = 45 +dp2_ip["inlet2_vel"] = 30 +study1.design_points["DP2"].input_parameters = dp2_ip + +########################################################################## + +# Duplicate design points + +dp3 = study1.duplicate_design_point(dp2) + +######################################################################### + +# Update all design points for study 1 + +study1.update_all_design_points() + +######################################################################### + +# Export design point table as a CSV table +dp_table = str(Path(pyfluent.EXAMPLES_PATH) / "dp_table_study1.csv") + +study1.export_design_table(dp_table) + +######################################################################### + +# Display CSV table as pandas dataframe +import pandas as pd +df = pd.read_csv(dp_table) +print(df) + +########################################################################## + +# Delete design points + +study1.delete_design_points([dp1, dp2]) + +########################################################################## + +# Create a new parametric study by duplicating the current one +study2 = study1.duplicate() + +######################################################################### + +# Rename the newly create parametric study + +# study2.rename("New Study") + +######################################################################### + +# Delete the old parametric study + +# study1.delete() + +######################################################################### + +# Save parametric project + +proj_path = str(Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study.flprj") + +s.tui.solver.file.parametric_project.save_as(proj_path) diff --git a/examples/01-parametric/parametric_static_mixer_2.py b/examples/01-parametric/parametric_static_mixer_2.py new file mode 100755 index 000000000000..e821caa475c9 --- /dev/null +++ b/examples/01-parametric/parametric_static_mixer_2.py @@ -0,0 +1,73 @@ +""" +.. _ref_parametric_static_mixer_2: + +Parametric project workflow +---------------------------------------------- +In this example we perform the following steps to +execute a parametric project based workflow +- Instantiate a parametric study from a Fluent session +- Read the previously saved project - static_mixer_study.flprj +- Save the current project +- Save the current project as a different file name +- Export the current project +- Archive the current project +- Exit the parametric project workflow + +""" + +######################################################################### + +# Parametric project workflow + +######################################################################### + +# Import the parametric project module and the parametric study module +from ansys.fluent.parametric import ParametricProject + +############################################################################ +# Import the pyfluent module and path +import ansys.fluent.core as pyfluent +from pathlib import Path + +######################################################################### + +# Launch Fluent and enable the settings API +s = pyfluent.launch_fluent(precision="double", processor_count=4) +root = s.get_settings_root() + +######################################################################### + +# Read the previously saved project - static_mixer_study.flprj +proj_path_read = str(Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study.flprj") + +proj = ParametricProject( + root.file.parametric_project, + root.parametric_studies, + proj_path_read +) + +######################################################################### + +# Save the current project +proj.save() + +######################################################################### + +# Save the current project as a different file name +proj_path_sa = str( + Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_save_as.flprj" +) +proj.save_as(project_filepath=proj_path_sa) + +######################################################################### + +# Export the current project +proj_path_exp = str( + Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_export.flprj" +) +proj.export(project_filepath=proj_path_exp) + +######################################################################### + +# 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 new file mode 100755 index 000000000000..483e3caedfcc --- /dev/null +++ b/examples/01-parametric/parametric_static_mixer_3.py @@ -0,0 +1,80 @@ +""" +.. _ref_parametric_static_mixer_3: + +Parametric session workflow +---------------------------------------------- +In this example we perform the following steps to +execute a parametric session workflow +- Launch parametric session using the hopper/mixer Case File +- Print the input parameters of the current parametric session. +- Access the current study of the current parametric session +- Create a new study in a parametric session +- Rename this newly created study +- Create a new parametric session using the flprj saved earlier + +""" + +######################################################################### + +# Parametric session workflow +# Import the parametric session workflow + +from ansys.fluent.parametric import ParametricSession + +############################################################################ +# Import the pyfluent module and path +import ansys.fluent.core as pyfluent +from pathlib import Path + +######################################################################### + +# 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" +) + +s1 = ParametricSession(case_filepath=case_path) + +######################################################################### + +# Print the input parameters of the current parametric session. + +s1.studies["Static_Mixer_Parameters-Solve"].design_points[ + "Base DP" +].input_parameters + +######################################################################### + +# Access the current study of the current parametric session + +study1_session = s1.studies["Static_Mixer_Parameters-Solve"] + +ip = study1_session.design_points["Base DP"].input_parameters +ip["inlet1_vel"] = 15 +study1_session.design_points["Base DP"].input_parameters = ip + +dp1 = study1_session.add_design_point() +dp1_ip = study1_session.design_points["DP1"].input_parameters +dp1_ip["inlet1_temp"] = 323 +dp1_ip["inlet1_vel"] = 33 +dp1_ip["inlet2_vel"] = 25 +study1_session.design_points["DP1"].input_parameters = dp1_ip + +######################################################################### + +# In this parametric project create a new study +study2_session = s1.new_study() + +######################################################################### + +# Update all design points +study2_session.update_all_design_points() + +######################################################################### + +# Access a new parametric session using the flprj saved earlier +proj_path_sa = str( + Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_save_as.flprj" +) +s2 = ParametricSession(project_filepath=proj_path_sa) From 309a986032c8db75b935a7b1e8cb675fd132cbe4 Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Thu, 31 Mar 2022 18:26:54 -0400 Subject: [PATCH 02/21] Add 3 examples for Parametric Workflows indentation change --- doc/source/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 29b8ce2b7ec0..21b07d10f6dd 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -112,10 +112,10 @@ def _start_or_stop_fluent_container(gallery_conf, fname, when): if fname in ["mixing_elbow_settings_api.py", "mixing_elbow_tui_api.py"]: args = ["3ddp", "-t4", "-meshing"] - elif fname in ["parametric_static_mixer_1.py", + elif fname in ["parametric_static_mixer_1.py", "parametric_static_mixer_2.py", "parametric_static_mixer_3.py"]: - args = ["3ddp", "-t4"] + args = ["3ddp", "-t4"] subprocess.run([sys.executable, _START_FLUENT_FILE] + args) elif when == "after": subprocess.run([sys.executable, _STOP_FLUENT_FILE]) From 0355bf42022aaf5ad1356979b4f70587e65aace2 Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Thu, 31 Mar 2022 19:14:35 -0400 Subject: [PATCH 03/21] remove pandas dataframe display --- examples/01-parametric/parametric_static_mixer_1.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/01-parametric/parametric_static_mixer_1.py b/examples/01-parametric/parametric_static_mixer_1.py index e5eb72495498..29b76ad3324d 100755 --- a/examples/01-parametric/parametric_static_mixer_1.py +++ b/examples/01-parametric/parametric_static_mixer_1.py @@ -192,9 +192,9 @@ ######################################################################### # Display CSV table as pandas dataframe -import pandas as pd -df = pd.read_csv(dp_table) -print(df) +# import pandas as pd +# df = pd.read_csv(dp_table) +# print(df) ########################################################################## From 78ce69df38f2b03f02aa32bc1f10e21c6796061a Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Mon, 4 Apr 2022 12:15:19 +0530 Subject: [PATCH 04/21] Disable archive operation as it is failing in server --- examples/01-parametric/parametric_static_mixer_2.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/examples/01-parametric/parametric_static_mixer_2.py b/examples/01-parametric/parametric_static_mixer_2.py index e821caa475c9..e937bb52ec35 100755 --- a/examples/01-parametric/parametric_static_mixer_2.py +++ b/examples/01-parametric/parametric_static_mixer_2.py @@ -66,8 +66,3 @@ Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_export.flprj" ) proj.export(project_filepath=proj_path_exp) - -######################################################################### - -# Archive the current project -proj.archive() From f5731d0a1461e1f540fe24eedccf19b04526536c Mon Sep 17 00:00:00 2001 From: sujal-tipnis <97630067+sujal-tipnis@users.noreply.github.com> Date: Mon, 4 Apr 2022 12:17:56 -0400 Subject: [PATCH 05/21] Update examples/01-parametric/parametric_static_mixer_1.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- .../parametric_static_mixer_1.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/01-parametric/parametric_static_mixer_1.py b/examples/01-parametric/parametric_static_mixer_1.py index 29b76ad3324d..2e55ce3f027e 100755 --- a/examples/01-parametric/parametric_static_mixer_1.py +++ b/examples/01-parametric/parametric_static_mixer_1.py @@ -1,18 +1,19 @@ """ .. _ref_parametric_static_mixer_1: -Parametric study workflow ----------------------------------------------- -In this example we perform the following steps to -execute a parametric study workflow -- Read a case and data file. -- Create input and output parameters. -- Instantiate design point study -- Access and Modify the input parameters of base design point (DP). -- Update the current design point. -- Access output parameters of the base DP -- Create, update and delete more design points. -- Create, rename and delete parametric studies +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 b0e0cc8302e779aac6f2f7601a1989c7a218e40c Mon Sep 17 00:00:00 2001 From: sujal-tipnis <97630067+sujal-tipnis@users.noreply.github.com> Date: Mon, 4 Apr 2022 12:18:10 -0400 Subject: [PATCH 06/21] Update examples/01-parametric/parametric_static_mixer_1.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- examples/01-parametric/parametric_static_mixer_1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/01-parametric/parametric_static_mixer_1.py b/examples/01-parametric/parametric_static_mixer_1.py index 2e55ce3f027e..18da25dd8d7e 100755 --- a/examples/01-parametric/parametric_static_mixer_1.py +++ b/examples/01-parametric/parametric_static_mixer_1.py @@ -26,7 +26,8 @@ ############################################################################ -# Launch Fluent in 3-D and double precision +# Launch Fluent in 3D and double precision + s = pyfluent.launch_fluent(precision="double", processor_count=4) ############################################################################ From 0c5f7710d1b2eabfb79cd0c31c63778d4a52d82a Mon Sep 17 00:00:00 2001 From: sujal-tipnis <97630067+sujal-tipnis@users.noreply.github.com> Date: Mon, 4 Apr 2022 12:18:17 -0400 Subject: [PATCH 07/21] Update examples/01-parametric/parametric_static_mixer_1.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- examples/01-parametric/parametric_static_mixer_1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/01-parametric/parametric_static_mixer_1.py b/examples/01-parametric/parametric_static_mixer_1.py index 18da25dd8d7e..bcc40541733a 100755 --- a/examples/01-parametric/parametric_static_mixer_1.py +++ b/examples/01-parametric/parametric_static_mixer_1.py @@ -38,7 +38,8 @@ ############################################################################ -# Read the hopper/mixer Case +# Read the hopper/mixer case + from ansys.fluent.core import examples From 87e8fb443a285c723fb61613f6d0fa6027c3ebea Mon Sep 17 00:00:00 2001 From: sujal-tipnis <97630067+sujal-tipnis@users.noreply.github.com> Date: Mon, 4 Apr 2022 12:18:26 -0400 Subject: [PATCH 08/21] Update examples/01-parametric/parametric_static_mixer_1.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- examples/01-parametric/parametric_static_mixer_1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/01-parametric/parametric_static_mixer_1.py b/examples/01-parametric/parametric_static_mixer_1.py index bcc40541733a..37afe25052bd 100755 --- a/examples/01-parametric/parametric_static_mixer_1.py +++ b/examples/01-parametric/parametric_static_mixer_1.py @@ -194,7 +194,8 @@ ######################################################################### -# Display CSV table as pandas dataframe +# Display CSV table as a pandas dataframe + # import pandas as pd # df = pd.read_csv(dp_table) # print(df) From 17362ee8ea072df0b82504bbd1cccb5a6d96204d Mon Sep 17 00:00:00 2001 From: sujal-tipnis <97630067+sujal-tipnis@users.noreply.github.com> Date: Mon, 4 Apr 2022 12:18:34 -0400 Subject: [PATCH 09/21] Update examples/01-parametric/parametric_static_mixer_1.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- examples/01-parametric/parametric_static_mixer_1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/01-parametric/parametric_static_mixer_1.py b/examples/01-parametric/parametric_static_mixer_1.py index 37afe25052bd..5495c3ba8b45 100755 --- a/examples/01-parametric/parametric_static_mixer_1.py +++ b/examples/01-parametric/parametric_static_mixer_1.py @@ -213,7 +213,8 @@ ######################################################################### -# Rename the newly create parametric study +# Rename the newly created parametric study + # study2.rename("New Study") From 8b7a951eb29244dd8d19f05b4c2de543f4601c04 Mon Sep 17 00:00:00 2001 From: sujal-tipnis <97630067+sujal-tipnis@users.noreply.github.com> Date: Mon, 4 Apr 2022 12:18:44 -0400 Subject: [PATCH 10/21] Update examples/01-parametric/parametric_static_mixer_2.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- .../parametric_static_mixer_2.py | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/examples/01-parametric/parametric_static_mixer_2.py b/examples/01-parametric/parametric_static_mixer_2.py index e937bb52ec35..4415f68e3fe8 100755 --- a/examples/01-parametric/parametric_static_mixer_2.py +++ b/examples/01-parametric/parametric_static_mixer_2.py @@ -1,17 +1,18 @@ """ .. _ref_parametric_static_mixer_2: -Parametric project workflow ----------------------------------------------- -In this example we perform the following steps to -execute a parametric project based workflow -- Instantiate a parametric study from a Fluent session -- Read the previously saved project - static_mixer_study.flprj -- Save the current project -- Save the current project as a different file name -- Export the current project -- Archive the current project -- Exit the parametric project workflow +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 90d47d1441e420a45722c13c31d8c84c6d8fdf1d Mon Sep 17 00:00:00 2001 From: sujal-tipnis <97630067+sujal-tipnis@users.noreply.github.com> Date: Mon, 4 Apr 2022 12:18:59 -0400 Subject: [PATCH 11/21] Update examples/01-parametric/parametric_static_mixer_2.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- examples/01-parametric/parametric_static_mixer_2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/01-parametric/parametric_static_mixer_2.py b/examples/01-parametric/parametric_static_mixer_2.py index 4415f68e3fe8..2956a7f85598 100755 --- a/examples/01-parametric/parametric_static_mixer_2.py +++ b/examples/01-parametric/parametric_static_mixer_2.py @@ -54,7 +54,8 @@ ######################################################################### -# Save the current project as a different file name +# Save the current project to a different file name + proj_path_sa = str( Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_save_as.flprj" ) From 5f9abe3e42f8d57c2850e9f2dddc37234b0acc36 Mon Sep 17 00:00:00 2001 From: sujal-tipnis <97630067+sujal-tipnis@users.noreply.github.com> Date: Mon, 4 Apr 2022 12:19:23 -0400 Subject: [PATCH 12/21] Update examples/01-parametric/parametric_static_mixer_3.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- .../parametric_static_mixer_3.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/01-parametric/parametric_static_mixer_3.py b/examples/01-parametric/parametric_static_mixer_3.py index 483e3caedfcc..e070f41a3ddb 100755 --- a/examples/01-parametric/parametric_static_mixer_3.py +++ b/examples/01-parametric/parametric_static_mixer_3.py @@ -1,16 +1,17 @@ """ .. _ref_parametric_static_mixer_3: -Parametric session workflow +Parametric Session Workflow ---------------------------------------------- -In this example we perform the following steps to -execute a parametric session workflow -- Launch parametric session using the hopper/mixer Case File -- Print the input parameters of the current parametric session. -- Access the current study of the current parametric session -- Create a new study in a parametric session -- Rename this newly created study -- Create a new parametric session using the flprj saved earlier +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 ab0f965e24e2d5daf32b8db7bb21278ada58beea Mon Sep 17 00:00:00 2001 From: sujal-tipnis <97630067+sujal-tipnis@users.noreply.github.com> Date: Mon, 4 Apr 2022 12:21:39 -0400 Subject: [PATCH 13/21] Update examples/01-parametric/parametric_static_mixer_2.py Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- examples/01-parametric/parametric_static_mixer_2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/01-parametric/parametric_static_mixer_2.py b/examples/01-parametric/parametric_static_mixer_2.py index 2956a7f85598..b172db20e369 100755 --- a/examples/01-parametric/parametric_static_mixer_2.py +++ b/examples/01-parametric/parametric_static_mixer_2.py @@ -18,7 +18,8 @@ ######################################################################### -# Parametric project workflow +# Parametric project-based workflow + ######################################################################### From 6759a775f2b6906d69163a427e087cf62293ab29 Mon Sep 17 00:00:00 2001 From: sujal-tipnis <97630067+sujal-tipnis@users.noreply.github.com> Date: Mon, 4 Apr 2022 12:23:35 -0400 Subject: [PATCH 14/21] Update examples/01-parametric/parametric_static_mixer_1.py Co-authored-by: Dan Williams --- examples/01-parametric/parametric_static_mixer_1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/01-parametric/parametric_static_mixer_1.py b/examples/01-parametric/parametric_static_mixer_1.py index 5495c3ba8b45..2759e2119c5a 100755 --- a/examples/01-parametric/parametric_static_mixer_1.py +++ b/examples/01-parametric/parametric_static_mixer_1.py @@ -32,7 +32,8 @@ ############################################################################ -# Enable the settings API +# Enable the settings API (Beta) + root = s.get_settings_root() From 027c028e11bf0cd5a1e99e8ffaf0078f3724481f Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Mon, 4 Apr 2022 14:52:16 -0400 Subject: [PATCH 15/21] made formatting changes to the script --- .../parametric_static_mixer_1.py | 118 ++++++++---------- .../parametric_static_mixer_2.py | 35 +++--- .../parametric_static_mixer_3.py | 43 +++---- requirements_docs.txt | 1 + 4 files changed, 87 insertions(+), 110 deletions(-) diff --git a/examples/01-parametric/parametric_static_mixer_1.py b/examples/01-parametric/parametric_static_mixer_1.py index 2759e2119c5a..c71ca2ba1803 100755 --- a/examples/01-parametric/parametric_static_mixer_1.py +++ b/examples/01-parametric/parametric_static_mixer_1.py @@ -3,84 +3,78 @@ Parametric Study Workflow ------------------------------ -This example for executing a parametric study workflow performs these steps: +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) +- 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 - """ ############################################################################ # Import the pyfluent module import ansys.fluent.core as pyfluent +############################################################################ # Import the path module from pathlib import Path ############################################################################ - # Launch Fluent in 3D and double precision -s = pyfluent.launch_fluent(precision="double", processor_count=4) +session = pyfluent.launch_fluent(precision="double", processor_count=4) ############################################################################ - # Enable the settings API (Beta) - -root = s.get_settings_root() +root = session.get_settings_root() ############################################################################ - # Read the hopper/mixer case - from ansys.fluent.core import examples - import_filename = examples.download_file( "Static_Mixer_main.cas.h5", "pyfluent/static_mixer" ) - -s.tui.solver.file.read_case(case_file_name=import_filename) +session.tui.solver.file.read_case(case_file_name=import_filename) ############################################################################ - # Set number of iterations to 1000 to ensure convergence -s.tui.solver.solve.set.number_of_iterations("1000") -############################################################################ +session.tui.solver.solve.set.number_of_iterations("1000") + +############################################################################ # 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 -s.tui.solver.define.parameters.enable_in_TUI("yes") +session.tui.solver.define.parameters.enable_in_TUI("yes") -s.tui.solver.define.boundary_conditions.set.velocity_inlet( +session.tui.solver.define.boundary_conditions.set.velocity_inlet( "inlet1", (), "vmag", "yes", "inlet1_vel", 5, "quit" ) -s.tui.solver.define.boundary_conditions.set.velocity_inlet( +session.tui.solver.define.boundary_conditions.set.velocity_inlet( "inlet1", (), "temperature", "yes", "inlet1_temp", 300, "quit" ) -s.tui.solver.define.boundary_conditions.set.velocity_inlet( +session.tui.solver.define.boundary_conditions.set.velocity_inlet( "inlet2", (), "vmag", "yes", "no", "inlet2_vel", 10, "quit" ) -s.tui.solver.define.boundary_conditions.set.velocity_inlet( +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"] = {} @@ -105,130 +99,118 @@ "outlet" ] -s.tui.solver.define.parameters.enable_in_TUI("yes") -s.tui.solver.define.parameters.output_parameters.create( +session.tui.solver.define.parameters.enable_in_TUI("yes") +session.tui.solver.define.parameters.output_parameters.create( "report-definition", "outlet-temp-avg" ) -s.tui.solver.define.parameters.output_parameters.create( +session.tui.solver.define.parameters.output_parameters.create( "report-definition", "outlet-vel-avg" ) ########################################################################### - # Enable convergence condition check -s.tui.solver.solve.monitors.residual.criterion_type("0") +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" ) -s.tui.solver.file.write_case(case_path) +session.tui.solver.file.write_case(case_path) ########################################################################### # Parametric study workflow - # Import the parametric study module from ansys.fluent.parametric import ParametricStudy ########################################################################### - # Instantiate a parametric study from a Fluent session study1 = ParametricStudy(root.parametric_studies).initialize() ########################################################################### - # Access and modify input parameters of base DP -ip = study1.design_points["Base DP"].input_parameters -ip["inlet1_vel"] = 15 -study1.design_points["Base DP"].input_parameters = ip -########################################################################### +input_parameters_update = study1.design_points["Base DP"].input_parameters +input_parameters_update["inlet1_vel"] = 15 +study1.design_points["Base DP"].input_parameters = input_parameters_update +########################################################################### # Update current design point + study1.update_current_design_point() ########################################################################### - # Change value of specific design points -dp1 = study1.add_design_point() -dp1_ip = study1.design_points["DP1"].input_parameters -dp1_ip["inlet1_temp"] = 450 -dp1_ip["inlet1_vel"] = 30 -dp1_ip["inlet2_vel"] = 20 -study1.design_points["DP1"].input_parameters = dp1_ip +design_point_1 = study1.add_design_point() +design_point_1_input_parameters = study1.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 +study1.design_points["DP1"].input_parameters = design_point_1_input_parameters ########################################################################### - # Add another design point with different values of the input parameters -dp2 = study1.add_design_point() -dp2_ip = study1.design_points["DP2"].input_parameters -dp2_ip["inlet1_temp"] = 500 -dp2_ip["inlet1_vel"] = 45 -dp2_ip["inlet2_vel"] = 30 -study1.design_points["DP2"].input_parameters = dp2_ip +design_point_2 = study1.add_design_point() +design_point_2_input_parameters = study1.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 +study1.design_points["DP2"].input_parameters = design_point_2_input_parameters ########################################################################## - # Duplicate design points -dp3 = study1.duplicate_design_point(dp2) +design_point_3 = study1.duplicate_design_point(design_point_2) ######################################################################### - # Update all design points for study 1 study1.update_all_design_points() ######################################################################### - # Export design point table as a CSV table -dp_table = str(Path(pyfluent.EXAMPLES_PATH) / "dp_table_study1.csv") +dp_table = str(Path(pyfluent.EXAMPLES_PATH) / "dp_table_study1.csv") study1.export_design_table(dp_table) ######################################################################### - # Display CSV table as a pandas dataframe -# import pandas as pd -# df = pd.read_csv(dp_table) -# print(df) +import pandas as pd -########################################################################## +df = pd.read_csv(dp_table) +print(df) +########################################################################## # Delete design points -study1.delete_design_points([dp1, dp2]) +study1.delete_design_points([design_point_1, design_point_2]) ########################################################################## - # Create a new parametric study by duplicating the current one + study2 = study1.duplicate() ######################################################################### - # Rename the newly created parametric study - # study2.rename("New Study") ######################################################################### - # Delete the old parametric study # study1.delete() ######################################################################### - # Save parametric project -proj_path = str(Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study.flprj") +project_filepath = str( + Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study.flprj" +) -s.tui.solver.file.parametric_project.save_as(proj_path) +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 b172db20e369..83efe4bb59b5 100755 --- a/examples/01-parametric/parametric_static_mixer_2.py +++ b/examples/01-parametric/parametric_static_mixer_2.py @@ -3,7 +3,8 @@ Parametric Project-Based Workflow ---------------------------------------------------- -This example for executing a parametric project-based workflow performs these steps: +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`` @@ -17,55 +18,51 @@ """ ######################################################################### - # Parametric project-based workflow - ######################################################################### - # Import the parametric project module and the parametric study module + from ansys.fluent.parametric import ParametricProject ############################################################################ # Import the pyfluent module and path + import ansys.fluent.core as pyfluent from pathlib import Path ######################################################################### +# Launch Fluent and enable the settings API (Beta) -# Launch Fluent and enable the settings API -s = pyfluent.launch_fluent(precision="double", processor_count=4) -root = s.get_settings_root() +session = pyfluent.launch_fluent(precision="double", processor_count=4) +root = session.get_settings_root() ######################################################################### - # Read the previously saved project - static_mixer_study.flprj -proj_path_read = str(Path(pyfluent.EXAMPLES_PATH) / "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, - proj_path_read + 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 -proj_path_sa = str( +project_filepath_save_as = str( Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_save_as.flprj" ) -proj.save_as(project_filepath=proj_path_sa) +proj.save_as(project_filepath=project_filepath_save_as) ######################################################################### - # Export the current project -proj_path_exp = str( + +project_filepath_export = str( Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_export.flprj" ) -proj.export(project_filepath=proj_path_exp) +proj.export(project_filepath=project_filepath_export) diff --git a/examples/01-parametric/parametric_static_mixer_3.py b/examples/01-parametric/parametric_static_mixer_3.py index e070f41a3ddb..a94e12b0d06f 100755 --- a/examples/01-parametric/parametric_static_mixer_3.py +++ b/examples/01-parametric/parametric_static_mixer_3.py @@ -16,7 +16,6 @@ """ ######################################################################### - # Parametric session workflow # Import the parametric session workflow @@ -24,58 +23,56 @@ ############################################################################ # Import the pyfluent module and path + import ansys.fluent.core as pyfluent from pathlib import Path ######################################################################### - -# Launch parametric session using the hopper/mixer Case File +# 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" ) -s1 = ParametricSession(case_filepath=case_path) +session = ParametricSession(case_filepath=case_path) ######################################################################### - # Print the input parameters of the current parametric session. -s1.studies["Static_Mixer_Parameters-Solve"].design_points[ +session.studies["Static_Mixer_Parameters-Solve"].design_points[ "Base DP" ].input_parameters ######################################################################### - # Access the current study of the current parametric session -study1_session = s1.studies["Static_Mixer_Parameters-Solve"] +study1 = session.studies["Static_Mixer_Parameters-Solve"] -ip = study1_session.design_points["Base DP"].input_parameters +ip = study1.design_points["Base DP"].input_parameters ip["inlet1_vel"] = 15 -study1_session.design_points["Base DP"].input_parameters = ip +study1.design_points["Base DP"].input_parameters = ip -dp1 = study1_session.add_design_point() -dp1_ip = study1_session.design_points["DP1"].input_parameters -dp1_ip["inlet1_temp"] = 323 -dp1_ip["inlet1_vel"] = 33 -dp1_ip["inlet2_vel"] = 25 -study1_session.design_points["DP1"].input_parameters = dp1_ip +design_point_1 = study1.add_design_point() +design_point_1_input_parameters = study1.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 +study1.design_points["DP1"].input_parameters = design_point_1_input_parameters ######################################################################### - # In this parametric project create a new study -study2_session = s1.new_study() -######################################################################### +study2 = session.new_study() +######################################################################### # Update all design points -study2_session.update_all_design_points() +study2.update_all_design_points() ######################################################################### - # Access a new parametric session using the flprj saved earlier -proj_path_sa = str( + +project_filepath_session = str( Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_save_as.flprj" ) -s2 = ParametricSession(project_filepath=proj_path_sa) +session_new = ParametricSession(project_filepath=project_filepath_session) diff --git a/requirements_docs.txt b/requirements_docs.txt index 21c8ab136485..c8d091e20b23 100644 --- a/requirements_docs.txt +++ b/requirements_docs.txt @@ -11,3 +11,4 @@ sphinx-gallery==0.10.1 sphinx-notfound-page==0.8 sphinxcontrib-websupport==1.2.4 sphinxemoji==0.2.0 +pandas==1.4.1 \ No newline at end of file From a910289bcb8d3163a5b04ca184961205899e9df5 Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Mon, 4 Apr 2022 14:54:56 -0400 Subject: [PATCH 16/21] fixed style --- examples/01-parametric/parametric_static_mixer_2.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/01-parametric/parametric_static_mixer_2.py b/examples/01-parametric/parametric_static_mixer_2.py index 83efe4bb59b5..141178ebfc8a 100755 --- a/examples/01-parametric/parametric_static_mixer_2.py +++ b/examples/01-parametric/parametric_static_mixer_2.py @@ -40,10 +40,14 @@ ######################################################################### # Read the previously saved project - static_mixer_study.flprj -project_filepath_read = str(Path(pyfluent.EXAMPLES_PATH) / "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 + root.file.parametric_project, + root.parametric_studies, + project_filepath_read, ) ######################################################################### From 3ac1c3e9fe205b8148a5192f3dbc82fe79bc6376 Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Mon, 4 Apr 2022 16:50:30 -0400 Subject: [PATCH 17/21] minor variable name changes --- .../parametric_static_mixer_1.py | 8 ++++--- .../parametric_static_mixer_2.py | 2 ++ .../parametric_static_mixer_3.py | 22 ++++++++++++++++--- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/examples/01-parametric/parametric_static_mixer_1.py b/examples/01-parametric/parametric_static_mixer_1.py index c71ca2ba1803..33b3b57df9ba 100755 --- a/examples/01-parametric/parametric_static_mixer_1.py +++ b/examples/01-parametric/parametric_static_mixer_1.py @@ -175,15 +175,17 @@ ######################################################################### # Export design point table as a CSV table -dp_table = str(Path(pyfluent.EXAMPLES_PATH) / "dp_table_study1.csv") -study1.export_design_table(dp_table) +design_point_table = str( + Path(pyfluent.EXAMPLES_PATH) / "design_point_table_study1.csv" +) +study1.export_design_table(design_point_table) ######################################################################### # Display CSV table as a pandas dataframe import pandas as pd -df = pd.read_csv(dp_table) +df = pd.read_csv(design_point_table) print(df) ########################################################################## diff --git a/examples/01-parametric/parametric_static_mixer_2.py b/examples/01-parametric/parametric_static_mixer_2.py index 141178ebfc8a..04e05c98630e 100755 --- a/examples/01-parametric/parametric_static_mixer_2.py +++ b/examples/01-parametric/parametric_static_mixer_2.py @@ -70,3 +70,5 @@ Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_export.flprj" ) proj.export(project_filepath=project_filepath_export) + + diff --git a/examples/01-parametric/parametric_static_mixer_3.py b/examples/01-parametric/parametric_static_mixer_3.py index a94e12b0d06f..b5408a14b7c9 100755 --- a/examples/01-parametric/parametric_static_mixer_3.py +++ b/examples/01-parametric/parametric_static_mixer_3.py @@ -49,9 +49,9 @@ study1 = session.studies["Static_Mixer_Parameters-Solve"] -ip = study1.design_points["Base DP"].input_parameters -ip["inlet1_vel"] = 15 -study1.design_points["Base DP"].input_parameters = ip +input_parameters_update = study1.design_points["Base DP"].input_parameters +input_parameters_update["inlet1_vel"] = 15 +study1.design_points["Base DP"].input_parameters = input_parameters_update design_point_1 = study1.add_design_point() design_point_1_input_parameters = study1.design_points["DP1"].input_parameters @@ -69,6 +69,22 @@ # Update all design points study2.update_all_design_points() +######################################################################### +# Export design point table as a CSV table + +design_point_table_study2 = str( + Path(pyfluent.EXAMPLES_PATH) / "design_point_table_study2.csv" +) +study2.export_design_table(design_point_table_study2) + +######################################################################### +# Display CSV table as a pandas dataframe + +import pandas as pd + +df = pd.read_csv(design_point_table_study2) +print(df) + ######################################################################### # Access a new parametric session using the flprj saved earlier From 87ec17c690d515dd10f5c7606f98a8466311d62a Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Mon, 4 Apr 2022 16:53:23 -0400 Subject: [PATCH 18/21] minor style change --- examples/01-parametric/parametric_static_mixer_2.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/01-parametric/parametric_static_mixer_2.py b/examples/01-parametric/parametric_static_mixer_2.py index 04e05c98630e..bef3ebc23bf5 100755 --- a/examples/01-parametric/parametric_static_mixer_2.py +++ b/examples/01-parametric/parametric_static_mixer_2.py @@ -69,6 +69,4 @@ project_filepath_export = str( Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_export.flprj" ) -proj.export(project_filepath=project_filepath_export) - - +proj.export(project_filepath=project_filepath_export) \ No newline at end of file From b297bac4af36d8ad7e64f71ca17d23e8f593839b Mon Sep 17 00:00:00 2001 From: Mainak Kundu <94432368+mkundu1@users.noreply.github.com> Date: Tue, 5 Apr 2022 11:21:22 +0530 Subject: [PATCH 19/21] Re-enable project archive (#259) --- examples/01-parametric/parametric_static_mixer_2.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/01-parametric/parametric_static_mixer_2.py b/examples/01-parametric/parametric_static_mixer_2.py index bef3ebc23bf5..9a42c4e60c80 100755 --- a/examples/01-parametric/parametric_static_mixer_2.py +++ b/examples/01-parametric/parametric_static_mixer_2.py @@ -69,4 +69,9 @@ project_filepath_export = str( Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_export.flprj" ) -proj.export(project_filepath=project_filepath_export) \ No newline at end of file +proj.export(project_filepath=project_filepath_export) + +######################################################################### +# Archive the current project + +proj.archive() From 2722eab88abc68633fd6e402cd881c025fdb3efe Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Tue, 5 Apr 2022 13:56:33 -0400 Subject: [PATCH 20/21] make variable name changes --- .../parametric_static_mixer_1.py | 40 ++++++++++--------- .../parametric_static_mixer_3.py | 30 +++++++------- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/examples/01-parametric/parametric_static_mixer_1.py b/examples/01-parametric/parametric_static_mixer_1.py index 33b3b57df9ba..e335c6a369d8 100755 --- a/examples/01-parametric/parametric_static_mixer_1.py +++ b/examples/01-parametric/parametric_static_mixer_1.py @@ -128,85 +128,87 @@ ########################################################################### # Instantiate a parametric study from a Fluent session -study1 = ParametricStudy(root.parametric_studies).initialize() +study_1 = ParametricStudy(root.parametric_studies).initialize() ########################################################################### # Access and modify input parameters of base DP -input_parameters_update = study1.design_points["Base DP"].input_parameters +input_parameters_update = study_1.design_points["Base DP"].input_parameters input_parameters_update["inlet1_vel"] = 15 -study1.design_points["Base DP"].input_parameters = input_parameters_update +study_1.design_points["Base DP"].input_parameters = input_parameters_update ########################################################################### # Update current design point -study1.update_current_design_point() +study_1.update_current_design_point() ########################################################################### # Change value of specific design points -design_point_1 = study1.add_design_point() -design_point_1_input_parameters = study1.design_points["DP1"].input_parameters +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 -study1.design_points["DP1"].input_parameters = design_point_1_input_parameters +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 = study1.add_design_point() -design_point_2_input_parameters = study1.design_points["DP2"].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 -study1.design_points["DP2"].input_parameters = design_point_2_input_parameters +study_1.design_points["DP2"].input_parameters = design_point_2_input_parameters ########################################################################## # Duplicate design points -design_point_3 = study1.duplicate_design_point(design_point_2) +design_point_3 = study_1.duplicate_design_point(design_point_2) ######################################################################### # Update all design points for study 1 -study1.update_all_design_points() +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_study1.csv" + Path(pyfluent.EXAMPLES_PATH) / "design_point_table_study_1.csv" ) -study1.export_design_table(design_point_table) +study_1.export_design_table(design_point_table) ######################################################################### # Display CSV table as a pandas dataframe import pandas as pd -df = pd.read_csv(design_point_table) -print(df) +data_frame = pd.read_csv(design_point_table) +print(data_frame) ########################################################################## # Delete design points -study1.delete_design_points([design_point_1, design_point_2]) +study_1.delete_design_points([design_point_1, design_point_2]) ########################################################################## # Create a new parametric study by duplicating the current one -study2 = study1.duplicate() +study_2 = study_1.duplicate() ######################################################################### # Rename the newly created parametric study +# Currently affected by issue # 249, hence commented out # study2.rename("New Study") ######################################################################### # Delete the old parametric study +# Currently affected by issue #249, hence commented out -# study1.delete() +# study_1.delete() ######################################################################### # Save parametric project diff --git a/examples/01-parametric/parametric_static_mixer_3.py b/examples/01-parametric/parametric_static_mixer_3.py index b5408a14b7c9..c47b6fe03970 100755 --- a/examples/01-parametric/parametric_static_mixer_3.py +++ b/examples/01-parametric/parametric_static_mixer_3.py @@ -47,48 +47,48 @@ ######################################################################### # Access the current study of the current parametric session -study1 = session.studies["Static_Mixer_Parameters-Solve"] +study_1 = session.studies["Static_Mixer_Parameters-Solve"] -input_parameters_update = study1.design_points["Base DP"].input_parameters +input_parameters_update = study_1.design_points["Base DP"].input_parameters input_parameters_update["inlet1_vel"] = 15 -study1.design_points["Base DP"].input_parameters = input_parameters_update +study_1.design_points["Base DP"].input_parameters = input_parameters_update -design_point_1 = study1.add_design_point() -design_point_1_input_parameters = study1.design_points["DP1"].input_parameters +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 -study1.design_points["DP1"].input_parameters = design_point_1_input_parameters +study_1.design_points["DP1"].input_parameters = design_point_1_input_parameters ######################################################################### # In this parametric project create a new study -study2 = session.new_study() +study_2 = session.new_study() ######################################################################### # Update all design points -study2.update_all_design_points() +study_2.update_all_design_points() ######################################################################### # Export design point table as a CSV table -design_point_table_study2 = str( - Path(pyfluent.EXAMPLES_PATH) / "design_point_table_study2.csv" +design_point_table_study_2 = str( + Path(pyfluent.EXAMPLES_PATH) / "design_point_table_study_2.csv" ) -study2.export_design_table(design_point_table_study2) +study2.export_design_table(design_point_table_study_2) ######################################################################### # Display CSV table as a pandas dataframe import pandas as pd -df = pd.read_csv(design_point_table_study2) -print(df) +data_frame = pd.read_csv(design_point_table_study_2) +print(data_frame) ######################################################################### # Access a new parametric session using the flprj saved earlier -project_filepath_session = str( +project_session_filepath = str( Path(pyfluent.EXAMPLES_PATH) / "static_mixer_study_save_as.flprj" ) -session_new = ParametricSession(project_filepath=project_filepath_session) +new_session = ParametricSession(project_filepath=project_session_filepath) From 44ae87f1f334c08f5ce4ab428877075395604ffd Mon Sep 17 00:00:00 2001 From: "U-ANSYS\\stipnis" Date: Tue, 5 Apr 2022 14:07:19 -0400 Subject: [PATCH 21/21] make variable name changes(2) --- examples/01-parametric/parametric_static_mixer_1.py | 2 +- examples/01-parametric/parametric_static_mixer_3.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/01-parametric/parametric_static_mixer_1.py b/examples/01-parametric/parametric_static_mixer_1.py index e335c6a369d8..af7c9e5fd06e 100755 --- a/examples/01-parametric/parametric_static_mixer_1.py +++ b/examples/01-parametric/parametric_static_mixer_1.py @@ -202,7 +202,7 @@ # Rename the newly created parametric study # Currently affected by issue # 249, hence commented out -# study2.rename("New Study") +# study_2.rename("New Study") ######################################################################### # Delete the old parametric study diff --git a/examples/01-parametric/parametric_static_mixer_3.py b/examples/01-parametric/parametric_static_mixer_3.py index c47b6fe03970..7bc3f9cce5c3 100755 --- a/examples/01-parametric/parametric_static_mixer_3.py +++ b/examples/01-parametric/parametric_static_mixer_3.py @@ -75,7 +75,7 @@ design_point_table_study_2 = str( Path(pyfluent.EXAMPLES_PATH) / "design_point_table_study_2.csv" ) -study2.export_design_table(design_point_table_study_2) +study_2.export_design_table(design_point_table_study_2) ######################################################################### # Display CSV table as a pandas dataframe