Rigid Dynamics: Joint Specification

In this example, using the support files, you will insert a Rigid Dynamics analysis object into an undefined Mechanical session and execute a sequence of python journal commands that will specify a joint type and all of its required definitions, and results, and then solve the analysis.

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

  • Mechanical_RBD_Joint_Example.agdb

  • Mechanical_RBD_Joint_Example.py

These files are available here.

Procedure

  1. Open Mechanical directly without importing a geometry or specifying an analysis type. This can be done through Start Menu.

  2. From the Analysis drop-down menu of the Insert group on the Home tab, insert a Rigid Dynamics system into the tree.

  3. Select the Geometry object and select the Attach Geometry option from the Geometry group on the Geometry Context tab. Navigate to the proper folder location and select Mechanical_RBD_Joint_Example.agdb.

     

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

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

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

Scripts Illustrated

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

# Section 1 - Set up the Tree Object Items

connections = Model.Connections
transient_rbd = Model.Analyses[0]
analysis_settings = transient_rbd.Children[0]
solution = transient_rbd.Solution

# Section 2 - Define the Named Selections

ns_body_1 = DataModel.GetObjectsByName("NS_Body_1")[0]
ns_body_2 = DataModel.GetObjectsByName("NS_Body_2")[0]
ns_face_1 = DataModel.GetObjectsByName("NS_Face_1")[0]
ns_face_2 = DataModel.GetObjectsByName("NS_Face_2")[0]
ns_face_3 = DataModel.GetObjectsByName("NS_Face_3")[0]
ns_face_4 = DataModel.GetObjectsByName("NS_Face_4")[0]
ns_face_5 = DataModel.GetObjectsByName("NS_Face_5")[0]

# Section 3 - Delete the contact

contact = connections.Children[0].Children[0]
contact.Delete()

# Section 4 - Define the Fixed Joint

fixed_joint = connections.AddJoint()
fixed_joint.ConnectionType=JointScopingType.BodyToGround
fixed_joint.Type = JointType.Fixed
fixed_joint.MobileLocation = ns_face_1

# Section 5 - Define the General Joint

general_joint = connections.AddJoint()
general_joint.ConnectionType=JointScopingType.BodyToBody
general_joint.Type = JointType.General
general_joint.ReferenceLocation = ns_face_2
general_joint.MobileLocation = ns_face_3

# Section 6 - Define the DOF of the General Joint

general_joint.TranslationX=FixedOrFree.Free
general_joint.TranslationY=FixedOrFree.Fixed
general_joint.TranslationZ=FixedOrFree.Fixed
general_joint.Rotations=JointRotationDOFType.FreeY

# Section 7 - Define the Worksheet Properties of the General Joint

worksheet = general_joint.BushingWorksheet
worksheet.SetBushingStiffnessPerUnitX(0, 200)
worksheet.SetBushingDampingPerUnitX(0, 10)

# Section 8 - Define the Frictional Parameters of the General Joint

general_joint.FrictionCoefficient = 0.1
general_joint.Radius = Quantity("1e-2[m]")

# Section 9 - Orientate the General Joint Reference Coordinate System

reference_coordinate_system = general_joint.ReferenceCoordinateSystem
reference_coordinate_system.PrimaryAxis=CoordinateSystemAxisType.PositiveXAxis
reference_coordinate_system.PrimaryAxisDefineBy=CoordinateSystemAlignmentType.GlobalX
reference_coordinate_system.SecondaryAxis=CoordinateSystemAxisType.PositiveZAxis
reference_coordinate_system.SecondaryAxisDefineBy=CoordinateSystemAlignmentType.GlobalZ

# Section 10 - Insert Standard Earth Gravity
 
gravity = transient_rbd.AddEarthGravity()
gravity.Direction=GravityOrientationType.PositiveXAxis

# Section 11 - Define the Joint Probe Results

joint_total_force = solution.AddJointProbe()
joint_total_force.BoundaryConditionSelection = general_joint
joint_total_force.ResultType=ProbeResultType.ForceReaction

joint_elastic_force = solution.AddJointProbe()
joint_elastic_force.BoundaryConditionSelection = general_joint
joint_elastic_force.ResultType=ProbeResultType.ElasticForce

joint_damping_force = solution.AddJointProbe()
joint_damping_force.BoundaryConditionSelection = general_joint
joint_damping_force.ResultType=ProbeResultType.DampingForce

joint_relative_velocity = solution.AddJointProbe()
joint_relative_velocity.BoundaryConditionSelection = general_joint
joint_relative_velocity.ResultType=ProbeResultType.VelocityProbe
joint_relative_velocity.ResultSelection=ProbeDisplayFilter.XAxis

# Section 12 - Set up the Unit Systems

ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardMKS
ExtAPI.Application.ActiveAngleUnit = AngleUnitType.Radian
ExtAPI.Application.ActiveAngularVelocityUnit=AngularVelocityUnitType.RadianPerSecond

# Section 13 - Solve the System and Define the Results

solution.Solve(True) 

joint_total_force_maximum = joint_total_force.MaximumTotal.Value
joint_elastic_force_final_total = joint_elastic_force.Total.Value
joint_elastic_force_final_x_axis = joint_elastic_force.XAxis.Value
joint_damping_force_maximum_total = joint_damping_force.MaximumTotal.Value
joint_relative_velocity_maximum_x = joint_relative_velocity.MaximumXAxis.Value
joint_elastic_force_maximum_total = joint_elastic_force.MaximumTotal.Value

Summary

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