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
16 changes: 8 additions & 8 deletions 2024R2_Test/rigid-bd-24-r2/breakable-joint.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,39 @@ breakable joint:

joint=CS_Joint.Find(_jid)

1. Create a joint condition to prescribe zero velocity on the two translational degrees of freedom:
2. Create a joint condition to prescribe zero velocity on the two translational degrees of freedom:

driver=CS_Driver(Joint,System.Array[int]([0,1]),CS_Driver.E_MotionType.E_Velocity)

1. Define the value of the velocity, then retrieve the time measure:
3. Define the value of the velocity, then retrieve the time measure:

Env=CS_Environment.GetDefault()
Sys=Env.System
(ret,found,time)=Sys.FindOrCreateInternalMeasure(CS_Measure.E_MeasureType.E_Time)

1. Define the time as variable, and use constant values for the two components:
4. Define the time as a variable, and use constant values for the two components:

driver.SetInputMeasure(time)
driver.SetConstantValues(System.Array[float]([0.,0.]))

Next, make the driver only active if the force in the joint is less than a
maximum threshold of 3N. To do that, create a Condition based on the joint
maximum threshold of 3N. To do that, create a [Condition](condition.md) based on the joint
force measure norm.

1. Retrieve the force on the joint:
5. Retrieve the force on the joint:

force=joint.GetForce()

1. Create a component measure, that is the norm 2 of the force. To be computed at each time step, this measure has to be added to the system.
6. Create a component measure, that is the norm 2 of the force. To be computed at each time step, this measure has to be added to the system.

norm=CS_ComponentMeasure(force,-2)
Sys.AddMeasure(norm)

1. Now, create the condition and assign it to the driver:
7. Now, create the condition and assign it to the driver:

cond=CS_Condition(CS_Condition.E_ConditionType.E_LessThan,norm,3.0)
driver.Condition=cond

1. Finally, add the driver to the environment:
8. Finally, add the driver to the environment:

Env.Drivers.Add(driver)
17 changes: 17 additions & 0 deletions 2024R2_Test/rigid-bd-24-r2/command-use.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Command use examples

The following command use examples are included in this section:

[Constraint equation](constraint-equation.md)

[Joint condition: initial velocity](jc-initial-velocity.md)

[Joint condition: control using linear feedback](jc-linear-feedback.md)

[Non-linear spring damper](non-linear-spring.md#)

[Spherical stop](spherical-stop.md)

[Export of joint forces](export-joint-forces.md)

[Breakable joint](breakable-joint.md)
10 changes: 5 additions & 5 deletions 2024R2_Test/rigid-bd-24-r2/constraint-equation.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ commands is shown below. A description of these commands follows.
rel=CS_Relation()
rel.MotionType=CS_Relation.E_MotionType.E_Velocity

1. The constant coefficients that appear in the relation are created. The first constant term is created by:
2. The constant coefficients that appear in the relation are created. The first constant term is created by:

var1=CS_ConstantVariable()
var1.SetConstantValues(System.Array[float]([1.]))

1. The second coefficient and constant right hand side are created by:
3. The second coefficient and constant right hand side are created by:

var2=CS_ConstantVariable()
var2.SetConstantValues(System.Array[float]([-2.]))
varrhs=CS_ConstantVariable()
varrhs.SetConstantValues(System.Array[float]([0.]))

1. The first term of relation (1) X ω_1 is added to the relation object:
4. The first term of relation (1) X ω_1 is added to the relation object:

rel.AddTerm(j1id,0,var1)

Expand All @@ -49,12 +49,12 @@ The first argument is the joint object. The second argument defines the DOF
represents the rotation, which is the joint's first and only DOF is the
rotation.

1. The second term and right hand side are introduced in the same manner:
5. The second term and right hand side are introduced in the same manner:

rel.AddTerm(j2id,0,var2)
rel.SetVariable (varrhs)

1. The relation is added to the list of relations:
6. The relation is added to the list of relations:

Env=CS_Environment.GetDefault()
Env.Relations.Add(rel)
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# Debugging RBD Commands with Visual Studio
# Debugging RBD commands with Visual Studio

You can debug RBD command snippets Using Microsoft Visual Studio. This allows
you to execute commands line by line and review variable values.
you to execute commands line-by-line and review variable values.

1. To begin, insert the following lines before the commands snippet you want to debug. (Note that if there are several commands snippet, they are executed in the order they appear in the Mechanical tree.)
1. To begin, insert the following lines before the command snippet you wish to debug. Note that if there are several command snippets, they are executed in the order they appear in the Mechanical tree.

from System import Diagnostics
Diagnostics.Debug.Assert(0)

1. Begin the solve. When the solution begins, the following warning dialog appears. Do not close this dialog. The dialog will pause the solver and allow you to attach the Visual Studio debugger and set breakpoints.
2. Begin the solve. When the solution begins, the following warning dialog appears. Do not close this dialog. The dialog will pause the solver and allow you to attach the Visual Studio debugger and set breakpoints.

![rbd error](./images/ds_rbd_error.png)

1. In Visual Studio, select Attach To Process... from the DEBUG menu. In the Select Code Type dialog, select Managed, then click OK.
3. In Visual Studio, select Attach To Process... from the DEBUG menu. In the Select Code Type dialog, select Managed, then click OK.

![select code type](./images/ds_rbd_sel_code_type.png)

1. In the Attach to Process dialog, select the RBD solver process (Ansys.solvers.RBD.exe), then click Attach.
4. In the Attach to Process dialog, select the RBD solver process (Ansys.solvers.RBD.exe), then click Attach.

![attach solver process](./images/ds_rbd_attach.png)

1. Once Visual Studio is attached to the RBD solver, open the script file in Visual Studio. To locate script files, in Mechanical, right-click the Solution object and select Open Solver Files Directory.
5. Once Visual Studio is attached to the RBD solver, open the script file in Visual Studio. To locate script files, in Mechanical, right-click the Solution object and select Open Solver Files Directory.

![locate scripts](./images/ds_rbd_outline.png)

1. In the solver files directory, commands are written to two python files: `filepre.py` and `filepost.py`. `filepre.py` contains the commands that are executed before solve (all command snippets except those at solution level). `filepost.py` is executed after the solve (only command snippets at solution level).
6. In the solver files directory, commands are written to two python files: `filepre.py` and `filepost.py`. `filepre.py` contains the commands that are executed before solve (all command snippets except those at solution level). `filepost.py` is executed after the solve (only command snippets at solution level).

Open the desired file in Visual Studio. You can insert breakpoints as desired
and click Ignore on the warning dialog to resume the solve.
7. Open the desired file in Visual Studio. You can insert breakpoints as desired
and click Ignore on the warning dialog to resume the solve.
2 changes: 1 addition & 1 deletion 2024R2_Test/rigid-bd-24-r2/driver.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Driver

A driver is a position, velocity or acceleration, or translational or
rotational joint condition. Drivers derive from the Actuator class.
rotational joint condition. Drivers derive from the [Actuator](actuator.md) class.

Corresponding ID table: `CS_Actuator`

Expand Down
18 changes: 9 additions & 9 deletions 2024R2_Test/rigid-bd-24-r2/export-joint-forces.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Export of joint forces

In this example joint forces are extracted in the local coordinate system,
rotated into the global coordinate system, and written into an ASCII File
rotated into the global coordinate system, and written into an ASCII File.

First, the joint is retrieved by inserting the following command on the
corresponding joint in the tree:
Expand All @@ -17,39 +17,39 @@ explanation of these commands follows.

TopRevoluteRotation = TopRevolute.GetRotation()

1. Extract transient values for this measure:
2. Extract transient values for this measure:

TopRevoluteRotationValues=TopRevoluteRotation.FillValuesThroughTime()

1. Get angle derivatives by extracting the time derivatives of the measure:
3. Get angle derivatives by extracting the time derivatives of the measure:

TopRevoluteRotationDerivatives=TopRevoluteRotation.FillDerivativesThroughTime()

1. Count the number of components of this array:
4. Count the number of components of this array:

nbValues = TopRevoluteRotationValues.GetLength(0)

1. Open the ASCII output file:
5. Open the ASCII output file:

fich=open(r"TopRevoluteRotation.csv",'w')
fich.write('Time,Rotation,Velocity\n')

1. Loop over all time values, and write values:
6. Loop over all time values, and write values:

for i in range(0,nbValues):
fich.write('{0:4.3f},{1:11.4e},{2:11.4e}\n'.format(TopRevoluteRotationValues[i,0],
TopRevoluteRotationValues[i,1],TopRevoluteRotationDerivatives[i,1]))
fich.close()

1. Check if joint is « revert » or not:
7. Check if joint is « revert » or not:

IsRevert = TopRevolute.IsRevert
if IsRevert:
fact = -1.0
else:
fact = 1.0

1. Extract Force Measure and write them into the file:
8. Extract force measurements and write them to the file:

TopRevoluteForce = TopRevolute.GetForce()
TRF=TopRevoluteForce.FillValuesThroughTime()
Expand All @@ -62,7 +62,7 @@ explanation of these commands follows.

fich.close()

1. Get the joint reference coordinate system, and rotate the forces from the global coordinate system to the joint coordinate system:
9. Get the joint reference coordinate system, and rotate the forces from the global coordinate system to the joint coordinate system:

if IsRevert:
TopRevolute.MobileCoordinateSystem.RotateArrayThroughTimeToLocal(TRF)
Expand Down
25 changes: 25 additions & 0 deletions 2024R2_Test/rigid-bd-24-r2/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Introduction

[IronPython references](iron-python-references.md)

[The Rigid Dynamics object model](rbd-object-model.md)

[Rigid Dynamics command objects library](rbd-command-library.md)

[Command use examples](command-use.md)

[Debugging RBD commands with Visual Studio](debugging-vs.md)

[Using RBD commands with Excel](using-commands-excel.md)

[Using RBD commands from the IronPython console](using-commands-console.md)

The Rigid Dynamics solver uses an object-based approach that uses Python-based
commands that follow Python syntax. This section explains this approach and
the role of Python in rigid body commands. It also provides a library of
commands for Rigid Body Dynamics (RBD) analyses (arranged by parent object) and examples
of command usage.

An add-on is provided to facilitate the creation of complex joint and body
loads that would otherwise require using Python command snippets. You can find
information about how to load and use the add-on in the online help.
2 changes: 1 addition & 1 deletion 2024R2_Test/rigid-bd-24-r2/iron-python-references.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# IronPython References
# IronPython references

Rigid Dynamics uses an object-based approach, so it is useful to have
experience with object oriented programming and the Python language when
Expand Down
22 changes: 11 additions & 11 deletions 2024R2_Test/rigid-bd-24-r2/jc-initial-velocity.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,33 @@ The complete list of commands and their explanation follows.

Joint=CS_Joint.Find(_jid)

1. A velocity driver (imposed velocity) is created on this joint:
2. A velocity driver (imposed velocity) is created on this joint:

driver=CS_Driver(Joint,System.Array[int]([0]),CS_Driver.E_MotionType.E_Velocity)

The driver constructor takes the joint instance as the first argument. The
second argument is an array of integer that defines which DOFs are active. The
second argument is an array of integers that defines which DOFs are active. The
physical meaning of these integers is dependent of the joint. For instance, if
the underlying joint is a translation joint, 0 is the translation along x. But
if the joint is revolute, 0 now is the rotation along z axis. Similarly, for a
cylindrical joint, 0 is is the translation along z, and 1 is the rotation. The
last argument gives the type of driver here velocity. Drivers can be one of
three types: position, velocity, or acceleration:
the underlying joint is a translation joint, 0 is the translation along the x-axis. But
if the joint is revolute, 0 is now the rotation about the z-axis. Similarly, for a
cylindrical joint, 0 is is the translation along the z-axis, and 1 is the rotation. The
last argument gives the type of driver (here velocity). Drivers can be one of
three types: position, velocity, or acceleration.

1. The default environment and corresponding system are retrieved
3. The default environment and corresponding system are retrieved:

Env=CS_Environment.GetDefault()
Sys=Env.System

1. This command returns an instance on an internal measure. It is often used to obtain the instance of the time measure:
4. This command returns an instance of an internal measure. It is often used to obtain the instance of the time measure:

(ret,found,time) = Sys.FindOrCreateInternalMeasure(CS_Measure.E_MeasureType.E_Time)

1. The time measure is specified as the input measure for the driver and a constant value is given to the driver. As the driver may be applied to several components of the joint, the values are given as an array of float:
5. The time measure is specified as the input measure for the driver and a constant value is given to the driver. As the driver may be applied to several components of the joint, the values are given as an array of floats:

driver.SetInputMeasure(time)
driver.SetConstantValues(System.Array[float](../[-4.9033]))

1. The driver is added to the list of initial conditions. Consequently, it will be active only at t=0 and will give an initial velocity to the joint:
6. The driver is added to the list of initial conditions. Consequently, it will be active only at t=0 and will give an initial velocity to the joint:

Env.InitialConditions.Add(driver)
4 changes: 2 additions & 2 deletions 2024R2_Test/rigid-bd-24-r2/jc-linear-feedback.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Joint Condition: Control Using Linear Feedback
# Joint condition: control using linear feedback

In this example, an existing load is modified to apply a torque proportional
to the joint velocity. Two Methods are discussed:
to the joint velocity. Two methods are discussed:

### Method 1

Expand Down
2 changes: 1 addition & 1 deletion 2024R2_Test/rigid-bd-24-r2/measure.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Measure

Most useful measures are pre-existing in the Rigid Dynamics model, and can be
accessed using other object "get" functions. Additional measures can be
accessed using other object get functions. Additional measures can be
created before solving for use in custom post-processing or as input values
for joint conditions. For example, measures can be created to express
conditions. In this case, the measure must be added to the system to be
Expand Down
8 changes: 4 additions & 4 deletions 2024R2_Test/rigid-bd-24-r2/non-linear-spring.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Non-linear Spring Damper
# Non-linear spring damper

This example shows how the behavior of a spring can be altered to introduce a
non-linear force-displacement relationship. The complete list of commands is
Expand All @@ -10,7 +10,7 @@ shown below. A description of these commands follows.

Spring=CS_Actuator.Find(_sid)

1. Create an array of real values and fill it with the pairs of values (elongation, force):
2. Create an array of real values and fill it with the pairs of values (elongation, force):

Spring_table=System.Array.CreateInstance(float,7,2)

Expand Down Expand Up @@ -40,7 +40,7 @@ shown below. A description of these commands follows.

In this command, `7` represents the number of rows and `2` for the number of
columns. The first column gives elongation and the second, the corresponding
force value. This command generates a PointsTable assigned to the spring, as
force value. This command generates a [PointsTable](pointstable.md) assigned to the spring, as
shown below.

![points table plot](./images/gds_cmdref_ex_damper_plot.jpg)
Expand All @@ -51,6 +51,6 @@ on a given spring, as shown below.

![spring and damper combination](./images/gds_cmdref_ex_damper_win2.jpg)

1. Introduce a table is to define a non-linear force velocity relation:
3. Introduce a table to define a non-linear force velocity relation:

Damper=spring.GetDamper()
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Rigid Dynamics Command Objects Library
# Rigid Dynamics command objects library

The following Rigid Dynamics command objects are available:

[Actuator](actuator.md)
[Basis](basis.md)
[Body](body.md)
[Body Coordinate System](bodycoordinatesystem.md)
[Body Load](bodyload.md)
[BodyCoordinateSystem](bodycoordinatesystem.md)
[BodyLoad](bodyload.md)
[CMSBody](cmsbody.md)
[Condition](condition.md)
[Contact](contact.md)
[ContactDebugMask](contactdebugmask.md)
[ContactOptions](contactoptions.md)
[Driver](driver.md)
[Environment](environment.md)
[Flexible Body](flexiblebody.md)
[FlexibleBody](flexiblebody.md)
[GILTable](giltable.md)
[Joint](joint.md)
[JointDOFLoad](jointdofload.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The Rigid Dynamics Object Model
# The Rigid Dynamics object model

In the Rigid Dynamics object-based approach, the Environment is the top level
object that allows access to all other underlying objects. The environment is
Expand Down
Loading