Coupled Field Modal Analysis

In this example, using the support files, you will insert a Coupled Field Modal analysis object into an undefined Mechanical session and execute a sequence of python journal commands that will define and solve the analysis.

This example begins in the Mechanical application. It requires you to download the following Ansys DesignModeler and python files.

  • Coupled_Field_Modal_Example.agdb

  • Coupled_Field_Modal_Example.py

  • Coupled_Field_Modal_Example_Mat1.xml

These files are available here.

Procedure

  1. Open Workbench and insert a Coupled Field Modal system into the Project Schematic.

  2. Double-click the Engineering Data cell to open the workspace.

  3. Select File > Import Engineering Data, navigate to the proper folder location and select Coupled_Field_Modal_Example_Mat1.xml.

  4. Return to the Project tab.

  5. Right-click the Geometry cell and select Import Geometry > Browse and then navigate to the proper folder location and select Coupled_Field_Modal_Example.agdb.

  6. Open Mechanical: right-click the Model cell and select Edit.

  7. Select the Automation tab and select the Scripting option to open the Mechanical Scripting pane.

  8. Select the Open Script option ( ) from the Editor toolbar. Navigate to the proper folder location and select Coupled_Field_Modal_Example.py.

  9. Select the Run Script option ( ) from the Editor toolbar.

Scripts Illustrated

In this example, the python file automatically performs the following actions:

# Scenario 1 Set up the Tree Object Items
GEOMETRY = Model.Geometry
COORDINATE_SYSTEM = Model.CoordinateSystems
CONNECTIONS = Model.Connections
MESH = Model.Mesh
COUPLED_FIELD_MODAL = ExtAPI.DataModel.AnalysisByName("Coupled Field Modal")
ANALYSIS_SETTINGS = COUPLED_FIELD_MODAL.AnalysisSettings
SOLUTION = COUPLED_FIELD_MODAL.Solution

# Scenario 2 Set up the Unit Systems
ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardMKS

# Scenario 3 Assign Material Properties
CUBE = GEOMETRY.Children[0].Children[0]
CUBE.Assignment = 'PZT4'

# Scenario 4 Define Named Selections
SYMM_Y = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'symm_y'][0]
SYMM_X = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'symm_x'][0]
VER_EDGES_N = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'ver_edges'][0]
HOR_EDGES_N = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'hor_edges'][0]
TOP_FACE_N = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'top'][0]
BOT_FACE_N = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'bottom'][0]

# Scenario 5 Insert Symmetry
SYMMETRY = Model.AddSymmetry()
SYMMETRY_REGION01 = SYMMETRY.AddSymmetryRegion()
SYMMETRY_REGION01.Location = SYMM_Y
SYMMETRY_REGION01.SymmetryNormal = SymmetryNormalType.YAxis
SYMMETRY_REGION02 = SYMMETRY.AddSymmetryRegion()
SYMMETRY_REGION02.Location = SYMM_X
SYMMETRY_REGION02.SymmetryNormal = SymmetryNormalType.XAxis

# Scenario 6 Define Mesh Settings
EDGE_SIZING1 = MESH.AddSizing()
EDGE_SIZING1.Location = VER_EDGES_N
EDGE_SIZING1.Type = SizingType.NumberOfDivisions
EDGE_SIZING1.NumberOfDivisions = 4
EDGE_SIZING2 = MESH.AddSizing()
EDGE_SIZING2.Location = HOR_EDGES_N
EDGE_SIZING2.Type = SizingType.NumberOfDivisions
EDGE_SIZING2.NumberOfDivisions = 2
MESH.GenerateMesh()

# Scenario 7 Define Analysis Settings
ANALYSIS_SETTINGS.MaximumModesToFind = 10
ANALYSIS_SETTINGS.LimitSearchToRange = True
ANALYSIS_SETTINGS.SearchRangeMinimum = Quantity('50000[Hz]')
ANALYSIS_SETTINGS.SearchRangeMaximum = Quantity('150000[Hz]')
ANALYSIS_SETTINGS.SolverType = SolverType.Direct

# Scenario 8 Insert Load and Boundary Conditions
VOLTAGE_GROUND1 = COUPLED_FIELD_MODAL.AddVoltageGround()
VOLTAGE_GROUND1.Location = TOP_FACE_N
VOLTAGE_GROUND2 = COUPLED_FIELD_MODAL.AddVoltageGround()
VOLTAGE_GROUND2.Location = BOT_FACE_N

# Scenario 9 Insert Results
TOTAL_DEFORMATION1 = SOLUTION.AddTotalDeformation()
TOTAL_DEFORMATION1.Mode = 2
TOTAL_DEFORMATION2 = SOLUTION.AddTotalDeformation()
TOTAL_DEFORMATION2.Mode = 5

# Scenario 10 Solve and review the Result
SOLUTION.Solve(True)

TOTAL_DEFORMATION1.ReportedFrequency.Value
TOTAL_DEFORMATION2.ReportedFrequency.Value

Summary

This example demonstrates how scripting in Mechanical can be used to automate your actions.