Random Vibration Analysis

In this example, using the support files, you will open a Random Vibration analysis in Mechanical and execute a series of scripts to solve and complete an entire analysis. First, you must prepare certain aspects of the analysis on the Workbench Project Schematic. This example begins in the Workbench application. It requires you to download the following Ansys DesignModeler and python files.

  • Mechanical_Random_Vibration_Example012_Geometry.agdb

  • Mechanical_Random_Vibration_Example012_Script.py

These files are available here.

Procedure

The following procedure assumes you understand how to add a system in Workbench and make changes to system cells and properties as well as saving the support files to a known location.

  1. Add a Modal analysis to the Project Schematic.

  2. Right-click the Solution cell of the Modal analysis and select Transfer Date To New > Random Vibration. This links the two necessary systems.

  3. This analysis requires a new material. Double-click the Engineering Data cell of the Modal analysis to open the Engineering Data workspace.

  4. Right-click Structural Steel material and select Duplicate.

  5. Double-click the new field and rename the material "Rod_Mat."

  6. Set the Density to 0.1 Kg/m3.

  7. Open the Isotropic Elasticity property and set the following values:

    • Young's Modulus = 2E+8 Pa

    • Poisson's Ratio = 0

  8. Return to the Project Schematic and select the Geometry cell of the Modal system. Right-click and select Properties.

  9. Under the Basic Geometry Options group of the properties, activate the Named Selections property.

  10. Right-click the Geometry cell and select Import Geometry > Browse and select the Mechanical_Random_Vibration_Example012_Geometry.agdb file.

  11. Right-click the Model cell and select Edit. This action launches the Mechanical application.

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

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

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

Scripts Illustrated

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

# Scenario 1 Store main Tree Object items
MODEL = Model
GEOMETRY = Model.Geometry
ROD1 = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'Rod1'][0]
BLOCK1 = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'Block1'][0]
ROD2 = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'Rod2'][0]
BLOCK2 = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'Block2'][0]
ROD3 = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'Rod3'][0]
BLOCK3 = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'Block3'][0]

MATERIALS = MODEL.Materials
MATERIAL_RM = [i for i in MATERIALS.GetChildren[Ansys.ACT.Automation.Mechanical.Material](True) if i.Name == 'Rod_Mat'][0]
MATERIAL_SS = [i for i in MATERIALS.GetChildren[Ansys.ACT.Automation.Mechanical.Material](True) if i.Name == 'Structural Steel'][0]

COORDINATE_SYSTEMS = Model.CoordinateSystems
GLOBAL_COORDINATE_SYSTEM = [i for i in COORDINATE_SYSTEMS.GetChildren[Ansys.ACT.Automation.Mechanical.CoordinateSystem](True) if i.Name == 'Global Coordinate System'][0]

MESH = Model.Mesh

NAMED_SELECTIONS = ExtAPI.DataModel.Project.Model.NamedSelections
NS_BLOCK_SIDES = [i for i in NAMED_SELECTIONS.GetChildren[Ansys.ACT.Automation.Mechanical.NamedSelection](True) if i.Name == 'NS_Block_Sides'][0]
NS_ROD_SIDES = [i for i in NAMED_SELECTIONS.GetChildren[Ansys.ACT.Automation.Mechanical.NamedSelection](True) if i.Name == 'NS_Rod_Sides'][0]
NS_BASE = [i for i in NAMED_SELECTIONS.GetChildren[Ansys.ACT.Automation.Mechanical.NamedSelection](True) if i.Name == 'NS_Base'][0]
NS_BLOCK_ROD_SIDES = [i for i in NAMED_SELECTIONS.GetChildren[Ansys.ACT.Automation.Mechanical.NamedSelection](True) if i.Name == 'NS_Block_Rod_Sides'][0]
NS_BLOCK1_SIDES = [i for i in NAMED_SELECTIONS.GetChildren[Ansys.ACT.Automation.Mechanical.NamedSelection](True) if i.Name == 'NS_Block1_Side_Faces'][0]
NS_BLOCK2_SIDES = [i for i in NAMED_SELECTIONS.GetChildren[Ansys.ACT.Automation.Mechanical.NamedSelection](True) if i.Name == 'NS_Block2_Side_Faces'][0]
NS_BLOCK3_SIDES = [i for i in NAMED_SELECTIONS.GetChildren[Ansys.ACT.Automation.Mechanical.NamedSelection](True) if i.Name == 'NS_Block3_Side_Faces'][0]
NS_BLOCK1_VERTEX = [i for i in NAMED_SELECTIONS.GetChildren[Ansys.ACT.Automation.Mechanical.NamedSelection](True) if i.Name == 'Block1_Vertex'][0]
NS_BLOCK2_VERTEX = [i for i in NAMED_SELECTIONS.GetChildren[Ansys.ACT.Automation.Mechanical.NamedSelection](True) if i.Name == 'Block2_Vertex'][0]
NS_BLOCK3_VERTEX = [i for i in NAMED_SELECTIONS.GetChildren[Ansys.ACT.Automation.Mechanical.NamedSelection](True) if i.Name == 'Block3_Vertex'][0]

MODAL = DataModel.AnalysisByName("Modal")
ANALYSIS_SETTINGS_MODAL = MODAL.AnalysisSettings
SOLUTION_MODAL = MODAL.Solution

PSD = DataModel.AnalysisByName("Random Vibration")
ANALYSIS_SETTINGS_PSD = PSD.AnalysisSettings
SOLUTION_PSD = PSD.Solution

# Scenario 2 Set Display Unit
ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardMKS

# Scenario 3 Set Brick Integration Scheme for all bodies
GEOMETRY.Activate()
GEOMETRY.ElementControl = ElementControl.Manual

ROD1.Activate()
ROD1.BrickIntegrationScheme = BrickIntegrationScheme.Full

BLOCK1.Activate()
BLOCK1.BrickIntegrationScheme = BrickIntegrationScheme.Full

ROD2.Activate()
ROD2.BrickIntegrationScheme = BrickIntegrationScheme.Full

BLOCK2.Activate()
BLOCK2.BrickIntegrationScheme = BrickIntegrationScheme.Full

ROD3.Activate()
ROD3.BrickIntegrationScheme = BrickIntegrationScheme.Full

BLOCK3.Activate()
BLOCK3.BrickIntegrationScheme = BrickIntegrationScheme.Full

# Scenario 4 Assign material to Rod bodies
ROD1.Activate()
ROD1.Material = MATERIAL_RM.Name

ROD2.Activate()
ROD2.Material = MATERIAL_RM.Name

ROD3.Activate()
ROD3.Material = MATERIAL_RM.Name

# Scenario 5 Add local Coordinate System and Remote Point
COORDINATE_SYSTEMS.Activate()
COORDINATE_SYSTEM = COORDINATE_SYSTEMS.AddCoordinateSystem()
COORDINATE_SYSTEM.OriginLocation = NS_BLOCK1_SIDES

MODEL.Activate()
REMOTE_POINT = MODEL.AddRemotePoint()
REMOTE_POINT.Location = NS_BLOCK2_SIDES
REMOTE_POINT.Behavior=LoadBehavior.Deformable

# Scenario 6 Define global mesh size and generate mesh
MESH.Activate()
MESH.ElementSize = Quantity('0.105 [m]')
MESH.GenerateMesh()

# Scenario 7 Define Analysis Settings for Modal system
# Modify Analysis Settings of Modal to find first three modes only
ANALYSIS_SETTINGS_MODAL.Activate()
ANALYSIS_SETTINGS_MODAL.MaximumModesToFind = 3

# Scenario 8 Define boundary conditions for Modal system
MODAL.Activate()
FIXED_SUPPORT = MODAL.AddFixedSupport()
FIXED_SUPPORT.Location = NS_BASE

MODAL.Activate()
FRICTIONLESS_SUPPORT = MODAL.AddFrictionlessSupport()
FRICTIONLESS_SUPPORT.Location = NS_BLOCK_ROD_SIDES

# Scenario 9 Add results for Modal system
# Add Total Deformation results in Modal analysis for each modes
SOLUTION_MODAL.Activate()
TOTAL_DEFORMATION_MODAL = SOLUTION_MODAL.AddTotalDeformation() 
TOTAL_DEFORMATION_MODAL.Mode = 1

TOTAL_DEFORMATION2_MODAL = SOLUTION_MODAL.AddTotalDeformation() 
TOTAL_DEFORMATION2_MODAL.Mode = 2

TOTAL_DEFORMATION2_MODAL = SOLUTION_MODAL.AddTotalDeformation() 
TOTAL_DEFORMATION2_MODAL.Mode = 3

# Scenario 10  Define Analysis Settings for Random Vibration system
# Modify Analysis Settings of Random Vibration to enable Velocity Acceleration calculations and add Damping
ANALYSIS_SETTINGS_PSD.Activate()
ANALYSIS_SETTINGS_PSD.CalculateVelocity = True
ANALYSIS_SETTINGS_PSD.CalculateAcceleration = True

ANALYSIS_SETTINGS_PSD.ConstantDamping=ConstantDampingType.Manual
ANALYSIS_SETTINGS_PSD.ConstantDampingRatio = 0
ANALYSIS_SETTINGS_PSD.StiffnessCoefficient = 0.0028

# Scenario 11 Add PSD Acceleration for Random Vibration system 
PSD.Activate()
PSD_ACCELERATION = PSD.AddPSDAcceleration()
PSD_ACCELERATION.BoundaryCondition = PSDBoundaryConditionSelectionType.AllFixedSupports
PSD_ACCELERATION.LoadData.Inputs[0].DiscreteValues = [Quantity("1.e-003 [Hz]"), Quantity("1000 [Hz]")]
PSD_ACCELERATION.LoadData.Output.DiscreteValues = [Quantity("0.62832 [(m sec^-2)^2 Hz^-1]"), Quantity("0.62832 [(m sec^-2)^2 Hz^-1]")]
PSD_ACCELERATION.Direction = NormalOrientationType.XAxis

# Scenario 12 Add regular and probe results for PSD analysis
SOLUTION_PSD.Activate()
DIRECTIONAL_DEFORMATION_PSD = SOLUTION_PSD.AddDirectionalDeformation()
DIRECTIONAL_DEFORMATION_PSD.NormalOrientation=NormalOrientationType.XAxis
DIRECTIONAL_DEFORMATION_PSD.ScaleFactor = ScaleFactorType.Sigma1

DIRECTIONAL_VELOCITY_PSD = SOLUTION_PSD.AddDirectionalVelocityPSD()
DIRECTIONAL_VELOCITY_PSD.NormalOrientation=NormalOrientationType.XAxis
DIRECTIONAL_VELOCITY_PSD.ScaleFactor = ScaleFactorType.Sigma2

DIRECTIONAL_ACCELERATION_PSD = SOLUTION_PSD.AddDirectionalAccelerationPSD()
DIRECTIONAL_ACCELERATION_PSD.NormalOrientation=NormalOrientationType.XAxis
DIRECTIONAL_ACCELERATION_PSD.ScaleFactor = ScaleFactorType.Sigma3

NORMAL_ELASTIC_STRAIN_PSD = SOLUTION_PSD.AddNormalElasticStrain()
NORMAL_ELASTIC_STRAIN_PSD.NormalOrientation=NormalOrientationType.XAxis
NORMAL_ELASTIC_STRAIN_PSD.ScaleFactor = ScaleFactorType.Sigma1

NORMAL_STRESS_PSD = SOLUTION_PSD.AddNormalStress()
NORMAL_STRESS_PSD.NormalOrientation=NormalOrientationType.XAxis
NORMAL_STRESS_PSD.ScaleFactor = ScaleFactorType.Sigma1

SOLUTION_PSD.Activate()
RESPONSE_PSD_PROBE = SOLUTION_PSD.AddResponsePSD()
RESPONSE_PSD_PROBE.LocationMethod = LocationDefinitionMethod.CoordinateSystem
RESPONSE_PSD_PROBE.CoordinateSystemSelection=COORDINATE_SYSTEM
RESPONSE_PSD_PROBE.Reference=ResultRelativityType.Relative
RESPONSE_PSD_PROBE.ResultType = ProbeResultType.DeformationProbe
RESPONSE_PSD_PROBE.ResultSelection=ProbeDisplayFilter.XAxis

RESPONSE_PSD_PROBE2 = SOLUTION_PSD.AddResponsePSD()
RESPONSE_PSD_PROBE2.LocationMethod = LocationDefinitionMethod.RemotePoint
RESPONSE_PSD_PROBE2.RemotePointSelection = REMOTE_POINT
RESPONSE_PSD_PROBE2.Reference=ResultRelativityType.Relative
RESPONSE_PSD_PROBE2.ResultType = ProbeResultType.DeformationProbe
RESPONSE_PSD_PROBE2.ResultSelection=ProbeDisplayFilter.XAxis

SOLUTION_PSD.Activate()
SEL=ExtAPI.SelectionManager.AddSelection(NS_BLOCK3_VERTEX)
RS_PSD_TOOL = PSD.Solution.AddResponsePSDTool()
CLRSEL = ExtAPI.SelectionManager.ClearSelection()

RESPONSE_PSD_PROBE3 = RS_PSD_TOOL.Children[0]
RESPONSE_PSD_PROBE3.Name="Response PSD 3"
RESPONSE_PSD_PROBE3.Reference=ResultRelativityType.Relative
RESPONSE_PSD_PROBE3.ResultType = ProbeResultType.DeformationProbe
RESPONSE_PSD_PROBE3.ResultSelection=ProbeDisplayFilter.XAxis

# Scenario 13 Solve and review results
PSD.Activate()
PSD.Solve(True)

SOLUTION_MODAL.Activate()
FREQUENCY = MODAL.GetResultsData()

MODAL_FREQ_1ST = FREQUENCY.ListTimeFreq[0]
MODAL_FREQ_2ND = FREQUENCY.ListTimeFreq[1]
MODAL_FREQ_3RD = FREQUENCY.ListTimeFreq[2]

DIRECTIONAL_DEFORMATION_PSD.Activate()
MAX_X_AXIS_DEF_PSD = DIRECTIONAL_DEFORMATION_PSD.Maximum.Value

DIRECTIONAL_VELOCITY_PSD.Activate()
MIN_X_AXIS_VEL_PSD = DIRECTIONAL_VELOCITY_PSD.Minimum.Value
MAX_X_AXIS_VEL_PSD = DIRECTIONAL_VELOCITY_PSD.Maximum.Value

DIRECTIONAL_ACCELERATION_PSD.Activate()
MIN_X_AXIS_ACC_PSD = DIRECTIONAL_ACCELERATION_PSD.Minimum.Value
MAX_X_AXIS_ACC_PSD = DIRECTIONAL_ACCELERATION_PSD.Maximum.Value

NORMAL_ELASTIC_STRAIN_PSD.Activate()
MAX_X_AXIS_STRAIN_PSD = NORMAL_ELASTIC_STRAIN_PSD.Maximum.Value

NORMAL_STRESS_PSD.Activate()
MAX_X_AXIS_STRESS_PSD = NORMAL_STRESS_PSD.Maximum.Value

RESPONSE_PSD_PROBE.Activate()
RMS_VALUE_RES_PSD = RESPONSE_PSD_PROBE.RMSValue.Value
EXP_FREQ_RES_PSD = RESPONSE_PSD_PROBE.ExpectedFrequency.Value

RESPONSE_PSD_PROBE2.Activate()
RMS_VALUE_RES_PSD2 = RESPONSE_PSD_PROBE2.RMSValue.Value
EXP_FREQ_RES_PSD2 = RESPONSE_PSD_PROBE2.ExpectedFrequency.Value

RESPONSE_PSD_PROBE3.Activate()
RMS_VALUE_RES_PSD3 = RESPONSE_PSD_PROBE3.RMSValue.Value
EXP_FREQ_RES_PSD3 = RESPONSE_PSD_PROBE3.ExpectedFrequency.Value

Summary

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