Skip to content

Commit

Permalink
Adding gifs (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
dipinknair authored Nov 1, 2023
1 parent 130c054 commit e0871ee
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
Binary file added doc/source/_static/basic/Topo_opitimized.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/source/_static/basic/Valve.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 20 additions & 10 deletions examples/basic/topology_optimization_cantilever_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,9 @@

# Embed Mechanical and set global variables
app = mech.App(version=232)
globals().update(mech.global_variables(app))
globals().update(mech.global_variables(app, True))
print(app)

from Ansys.ACT.Automation.Mechanical import *
from Ansys.ACT.Interfaces.Common import *
from Ansys.ACT.Mechanical.Fields import *
from Ansys.Mechanical.DataModel.Enums import *
from Ansys.Mechanical.DataModel.MechanicalEnums import *


def display_image(image_name):
path = os.path.join(os.path.join(cwd, image_name))
Expand Down Expand Up @@ -140,12 +134,13 @@ def display_image(image_name):

########
# Solve
# ~~~~~

TOPO_OPT_SLN = TOPO_OPT.Solution
TOPO_OPT_SLN.Solve(True)
assert str(TOPO_OPT_SLN.Status) == "Done", "Solution status is not 'Done'"

###############################
##########
# Results
# ~~~~~~~

Expand All @@ -164,9 +159,24 @@ def display_image(image_name):
)
display_image("topo_opitimized_smooth.png")

##########################################################################
# Review the results
###################################################################################
# Export animation
animation_export_format = (
Ansys.Mechanical.DataModel.Enums.GraphicsAnimationExportFormat.GIF
)
settings_720p = Ansys.Mechanical.Graphics.AnimationExportSettings()
settings_720p.Width = 1280
settings_720p.Height = 720

TOPO_DENS.ExportAnimation(
os.path.join(cwd, "Topo_opitimized.gif"), animation_export_format, settings_720p
)

#######################################
# .. image:: /_static/basic/Topo_opitimized.gif

#####################
# Review the results

# Print topology density results
print("Topology Density Results")
Expand Down
5 changes: 4 additions & 1 deletion examples/basic/valve.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ def display_image(image_name):
stress.ExportAnimation(
os.path.join(cwd, "Valve.gif"), animation_export_format, settings_720p
)
display_image("Valve.gif")

############################################
# .. image:: /_static/basic/Valve.gif


# Save project
app.save(os.path.join(cwd, "Valve.mechdat"))
Expand Down

0 comments on commit e0871ee

Please sign in to comment.