Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- "max_line_length=180,retain_line_breaks=true,retain_line_breaks_single=true"

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.12.0
rev: 26.1.0
hooks:
- id: black

Expand Down
1 change: 0 additions & 1 deletion fluent-mechanical/wf_fm_01_fluent.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@

""" # noqa: D400, D415


# Perform required imports
# ------------------------
# Perform required imports, which includes downloading the mesh file from the
Expand Down
72 changes: 24 additions & 48 deletions fluent-mechanical/wf_fm_02_mechanical.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ def display_image(image_name):
# -----------------------------------
#

mechanical.run_python_script(
"""
mechanical.run_python_script("""
ExtAPI.Graphics.Camera.SetSpecificViewOrientation(
Ansys.Mechanical.DataModel.Enums.ViewOrientationType.Iso
)
Expand All @@ -175,16 +174,14 @@ def display_image(image_name):
settings_720p.Width = 1280
settings_720p.Height = 720
settings_720p.CurrentGraphicsDisplay = False
"""
)
""")

###############################################################################
# Import geometry
# ---------------
#

mechanical.run_python_script(
"""
mechanical.run_python_script("""
import os
geometry_import_group = Model.GeometryImportGroup
geometry_import = geometry_import_group.AddGeometryImport()
Expand All @@ -204,8 +201,7 @@ def display_image(image_name):
ExtAPI.Graphics.ExportImage(
os.path.join(project_directory, "geometry.png"), image_export_format, settings_720p
)
"""
)
""")

# Download the geometry image and display it
mechanical.download(files=os.path.join(project_directory, "geometry.png"), target_dir=OUTPUT_DIR)
Expand All @@ -217,8 +213,7 @@ def display_image(image_name):
# Import material, assign it to the bodies and create Named Selections
# --------------------------------------------------------------------
#
mechanical.run_python_script(
"""
mechanical.run_python_script("""
materials = ExtAPI.DataModel.Project.Model.Materials
materials.Import(material_path)
materials.RefreshMaterials()
Expand Down Expand Up @@ -255,15 +250,13 @@ def display_image(image_name):
EM_OUTER_SURFACE_NS = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == "em_outer_surface"][
0
]
"""
)
""")

###############################################################################
# Set up the mesh and generate
# ----------------------------
#
mechanical.run_python_script(
"""
mechanical.run_python_script("""
MESH = Model.Mesh

MESH.UseAdaptiveSizing = True
Expand All @@ -278,8 +271,7 @@ def display_image(image_name):
ExtAPI.Graphics.ExportImage(
os.path.join(project_directory, "mesh.png"), image_export_format, settings_720p
)
"""
)
""")

# Download the mesh image and display it
mechanical.download(files=os.path.join(project_directory, "mesh.png"), target_dir=OUTPUT_DIR)
Expand All @@ -291,8 +283,7 @@ def display_image(image_name):
# ---------------------------------------------------------------
#

mechanical.run_python_script(
"""
mechanical.run_python_script("""
Model.AddTransientThermalAnalysis()

# Store all main tree nodes as variables
Expand Down Expand Up @@ -475,23 +466,19 @@ def display_image(image_name):
group_list = [External_Convection_Load_1, External_Convection_Load_2, External_Convection_Load_3]
grouping_folder = Tree.Group(group_list)
tree_grouping_folder_70 = DataModel.GetObjectsByName("New Folder")
"""
)
""")

###############################################################################
# Use the output from Fluent to import the temperature and HTC data
# -----------------------------------------------------------------
#
# Add imported convection
result = mechanical.run_python_script(
"""
result = mechanical.run_python_script("""
Imported_Load_Group = TRANS_THERM.AddImportedLoadExternalData()
imported_load_group_61=Imported_Load_Group
imported_convection_62 = Imported_Load_Group.AddImportedConvection()
"""
)
result = mechanical.run_python_script(
"""
""")
result = mechanical.run_python_script("""
external_data_files = Ansys.Mechanical.ExternalData.ExternalDataFileCollection()
external_data_files.SaveFilesWithProject = False

Expand Down Expand Up @@ -604,11 +591,9 @@ def display_image(image_name):
)

imported_load_group_61.ImportExternalDataFiles(external_data_files)
"""
)
""")

result = mechanical.run_python_script(
"""
result = mechanical.run_python_script("""
table = imported_load_group_61.Children[0].GetTableByName("Film Coefficient")
numofsteps = 15
Film_Coeff = [
Expand Down Expand Up @@ -638,20 +623,17 @@ def display_image(image_name):
imported_convection_62.Location = selection
imported_load_id = imported_convection_62.ObjectId
imported_load = DataModel.GetObjectById(imported_load_id)
"""
)
""")

mechanical.run_python_script(
"""
mechanical.run_python_script("""
imported_load.ImportLoad()

Tree.Activate([imported_load])
ExtAPI.Graphics.Camera.SetFit()
ExtAPI.Graphics.ExportImage(
os.path.join(project_directory, "imported_temperature.png"), image_export_format, settings_720p
)
"""
)
""")
mechanical.download(
files=os.path.join(project_directory, "imported_temperature.png"), target_dir=OUTPUT_DIR
)
Expand All @@ -662,8 +644,7 @@ def display_image(image_name):
# Solve and post-process the results
# ----------------------------------
#
mechanical.run_python_script(
"""
mechanical.run_python_script("""
# Insert results objects

Temp = TRANS_THERM_SOLN.AddTemperature()
Expand All @@ -683,8 +664,7 @@ def display_image(image_name):
ExtAPI.Graphics.ExportImage(
os.path.join(project_directory, "temperature.png"), image_export_format, settings_720p
)
"""
)
""")

# Download the temperature image and display it
mechanical.download(files=os.path.join(project_directory, "temperature.png"), target_dir=OUTPUT_DIR)
Expand All @@ -696,8 +676,7 @@ def display_image(image_name):
# Setup Structural Analysis
# -------------------------
#
mechanical.run_python_script(
"""
mechanical.run_python_script("""
Model.AddStaticStructuralAnalysis()

# Define analysis settings
Expand Down Expand Up @@ -756,15 +735,13 @@ def display_image(image_name):
Fixed_Support = STAT_STRUC.AddFixedSupport()
selection = NS_GRP.Children[3]
Fixed_Support.Location = selection
"""
)
""")

###############################################################################
# Solve and post-process the results
# ----------------------------------
#
mechanical.run_python_script(
"""
mechanical.run_python_script("""
SOLN = STAT_STRUC.Solution

TOT_DEF1 = SOLN.AddTotalDeformation()
Expand Down Expand Up @@ -803,8 +780,7 @@ def display_image(image_name):
ExtAPI.Graphics.ExportImage(
os.path.join(project_directory, "plastic_strain.png"), image_export_format, settings_720p
)
"""
)
""")

# Download the results images to local directory
mechanical.download(files=os.path.join(project_directory, "deformation.png"), target_dir=OUTPUT_DIR)
Expand Down
1 change: 1 addition & 0 deletions geometry-mechanical-dpf/wf_gmd_03_dpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
and analyze them.

""" # noqa: D400, D415

import os
from pathlib import Path

Expand Down
1 change: 0 additions & 1 deletion geometry-mesh/wf_gm_01_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

""" # noqa: D400, D415


import os
from pathlib import Path

Expand Down
Loading