diff --git a/2025R2/rigid-bd-25-r2/actuator.md b/2025R2/rigid-bd-25-r2/actuator.md new file mode 100644 index 0000000000..9027ee4e4a --- /dev/null +++ b/2025R2/rigid-bd-25-r2/actuator.md @@ -0,0 +1,60 @@ +# Actuator + +The actuator is the base class for all +[Loads](load.md), +[Body Loads](bodyload.md), and +[Drivers](driver.md). + +ID table: `CS_Actuator` + +### Members + +`Condition` + +All actuators can be conditional. See +[Condition](condition.md) to create this condition. + +`AppliedValue` + +Measure that stores the evaluation of the actuator variable. Can be useful +when the applied value depends on a measure other than time. + +`EnergyMeasure` + +Measure that stores the energy generated by the actuator. + +### Member functions + +There are two ways to define the value of the load: using a variable, or by +defining a table of input measures (in which case a variable is defined +automatically). + +`SetVariable(variable)` + +`variable` is a list of input measures in table form. + +`SetInputMeasure(measure)` + +`measure` is typically the time measure object, but other measures can be used +as well. When using an expression to define a load variation, the measure must +have only one component (it cannot be a vector measure). The variation can be +defined by a constant, an expression, or a table. + +`SetConstantValues(value)` + +`value` is a Python float constant. See +[Relation](relation.md) object for defining a +constant. + +`SetTable(table)` + +`table` is a `CS_Table` . + +`SetFunc(string, is_degree)` + +`string` is similar to the expression used in the user interface to define a +joint condition by a function. Note that the literal variable is always called +`time`, even if you are using another measure as input. + +`is_degree` is a boolean argument. If the expression uses trigonometric +function, it specifies that the input variable should be expressed in degrees. diff --git a/2025R2/rigid-bd-25-r2/basis.md b/2025R2/rigid-bd-25-r2/basis.md new file mode 100644 index 0000000000..3cdd5671d0 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/basis.md @@ -0,0 +1,18 @@ +# Basis + +A basis is a material frame moving with a body. Each coordinate system has a +basis, but multiple coordinate systems can share the same basis. + +ID table: `CS_Basis` + +### Constructors + +`CS_Basis()` + +`CS_Basis(Angle1, Angle2, Angle3)` + +### Members + +double [,]`Matrix` + +Sets or gets function of the transformation matrix diff --git a/2025R2/rigid-bd-25-r2/body.md b/2025R2/rigid-bd-25-r2/body.md new file mode 100644 index 0000000000..f2a78eec02 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/body.md @@ -0,0 +1,86 @@ +# Body + +A body corresponds to a Part in the geometry node of the Mechanical tree, or +can be created by a command snippet. The preset `_bid` variable can be used to +find a corresponding body. + +ID table: `CS_Body` + +Example: + + MyBody = CS_Body.Find(_bid) + print MyBody.Name + +### Constructors + +`CS_Body()` + +`CS_Body(Id)` + +### Members + +`Name` + +Name of the body. + +`Origin` + +Origin Coordinate System of the body. This Coordinate System is the moving +coordinate system of one of the joints connected to the body. The choice of +this joint, called parent joint, is the result of an optimization that +minimizes the number of degrees of freedom of the system. + +`InertiaBodyCoordinateSystem` + +Inertia body coordinate system of the body. + +`BodyType` + +Type of body, values in `E_UnknownType`, `E_Ground`, `E_Rigid`, `E_CMS`, +`E_General`, `E_Fictitious`, `E_RigidLeaf`, `E_RigidSubModel`, `E_PointMass`, +`E_Beam` + +### Member functions + +`SetMassAndInertia(double mass, double Ixx, double Iyy, double Izz, double Ixy, double Iyz, double Ixz)` + +Overwrites the mass and inertia values of a body. + +`SetCenterOfMassAndOrientationAngles(double Xg, double Yg, double Zg, double +XYAngle, double YZAngle, double XZAngle) and +SetCenterOfMassAndOrientationMatrix(double Xg, double Yg, double Zg, double +mxx, double mxy, double mxz, double myx, double myy, double myz, double mzx, +double mzy, double mzz)` + +Overwrites the position of the center of mass and the orientation of the +inertia coordinate system. + +`SetVariableMassAndPrincipalInertia(CS_Variable mass, CS_Variable Ixx, +CS_Variable Iyy, CS_Variable Izz)` + +Overwrites the constant mass and principal inertia properties by variable +properties. During the solution process, the mass and inertia variation rate +needs to be evaluated. Therefore, only Point Table, Polynomial and Function +can be used to define the variation. Python user tables cannot be used to +define kinetic properties variations. You can make some of the properties +(mass, Ixx, Iyy and Izz) constants by using constant variables. + +**Note** +The principal axis needs to be defined when the principal inertia is being +assigned. If the body is created by a command, +`SetCenterOfMassAndOrientationAngles` or `SetCenterOfMassAndOrientationMatrix` +must be called before calling `SetVariableMassAndPrincipalInertia`. + +This function only applies to rigid bodies. + +**Note** +All quantities used in the solver must use a consistent unit system, which +sometimes differs from the user interface unit system. For example if the user +interface unit system is "mm,kg,N,s", the solver unit system will be +"mm,t,N,s". When using `SetMassAndInertia` or +`SetVariableMassAndPrincipalInertia`, the values of mass and inertia have to +be entered using the solver unit system. + +### Derived classes + +`CS_FlexibleBody` diff --git a/2025R2/rigid-bd-25-r2/bodycoordinatesystem.md b/2025R2/rigid-bd-25-r2/bodycoordinatesystem.md new file mode 100644 index 0000000000..5569543905 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/bodycoordinatesystem.md @@ -0,0 +1,61 @@ +# BodyCoordinateSystem + +The body coordinate system is used to connect a body to joints, hold the +center of mass, or define a load. See +[Joint](joint.md) or +[Body](body.md) to access existing coordinate +systems. Coordinate systems can also be created. + +ID table: `CS_BodyCoordinateSystem` + +### Constructors + + CS_BodyCoordinateSystem(body, type, xyz, basis) + +### Members + +[Basis](basis.md) + +### Member functions + +`RotateArrayThroughTimeToLocal(MeasureValues)` + +Rotates the transient values of a measure to a coordinate system. +`MeasureValues` is a python two-dimensional array, such as that coming out of +`FillValuesThroughTime` or `FillDerivativesThroughTime`. This function works +for 3D vectors such as relative translation between two coordinate systems or +6-D vectors such as forces/moments. + +`RotateArrayThroughTimeToGlobal(MeasureValues)` + +Rotates the transient values of a measure from a coordinate system to the +global coordinate system. + +`Type` + +Type of coordinate system, values in `E_Unknown`, `E_Ground`, `E_Part`, +`E_Joint`, `E_Inertia`, `E_BodyTransform`, `E_Contact`, `E_SplitJoint`. + +### Derived classes + +None + +### Example + + forceInGlobal=joint.GetForce() + + valuesInGlobal=forceInGlobal.FillValuesThroughTime() + + for i in range(0,valuesInGlobal.GetLength(0)): + print '{0:e} {1:e} {2:e} {3:e}'.format(valuesInGlobal[i,0], + valuesInGlobal[i,1],valuesInGlobal[i,2],valuesInGlobal[i,3]) + + mobileCS=joint.MobileCoordinateSystem + + valuesInLocal=valuesInGlobal.Clone() + + mobileCS.RotateArrayThroughTimeToLocal(valuesInLocal) + + for i in range(0,valuesInGlobal.GetLength(0)): + print '{0:e} {1:e} {2:e} {3:e}'.format(valuesInLocal[i,0], + valuesInLocal[i,1],valuesInLocal[i,2],valuesInLocal[i,3]) diff --git a/2025R2/rigid-bd-25-r2/bodyload.md b/2025R2/rigid-bd-25-r2/bodyload.md new file mode 100644 index 0000000000..afc6edf249 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/bodyload.md @@ -0,0 +1,41 @@ +# BodyLoad + +A body load is a load that is applied to all bodies in the system. Gravity or +global acceleration are body loads. + +The body load must implement a `GetAccelerationVector` method. This vector is +applied to the center of mass of each body. In order to maintain the energy +balance of the system, the body load must also implement a `ComputeEnergy` +method. + +### Example: Acceleration varying with time + + HalfTime = 1.0 + HalfAmplitude = 10.0 + + Env=CS_Environment.GetDefault() + Sys=Env.System + (ret,found,time) = Sys.FindOrCreateInternalMeasure(CS_Measure.E_MeasureType.E_Time) + + class MyBodyLoad(CS_UserBodyLoad): + def __init__(self): + CS_UserBodyLoad.__init__(self) + self.value = 0.0 + + def GetAccelerationVector(self,Mass,xyz,vel,bodyLoadForce): + values = time.Values + print 'MyBodyLoad::GetAccelerationVector' + bodyLoadForce[0] = 0.0 + bodyLoadForce[1] = 0.0 + bodyLoadForce[2] = Mass*HalfAmplitude*math.sin(values[0]*3.14/(2.*HalfTime)) + + def ComputeEnergy(self,Mass,xyz,vel): + print 'MBodyLoad::ComputeEnergy' + return 0.0 + + load=MyBodyLoad() + load.value = 10.0 + + Env=CS_Environment.GetDefault() + + Env.BodyLoads.Add(load) diff --git a/2025R2/rigid-bd-25-r2/breakable-joint.md b/2025R2/rigid-bd-25-r2/breakable-joint.md new file mode 100644 index 0000000000..6d1731a5d2 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/breakable-joint.md @@ -0,0 +1,63 @@ +# Breakable joint + +This example considers a breakable joint. A breakable joint is a joint that +cannot withstand an internal force higher than a given value. To create a +breakable joint: + +1. Get the joint by inserting a command on a planar joint: + + ``` + joint=CS_Joint.Find(_jid) + ``` + +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) + ``` + +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) + ``` + +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](condition.md) based on the joint + force measure norm. + +5. Retrieve the force on the joint: + + ``` + force=joint.GetForce() + ``` + +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) + ``` + +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 + ``` + +8. Finally, add the driver to the environment: + + ``` + Env.Drivers.Add(driver) + ``` diff --git a/2025R2/rigid-bd-25-r2/changelog.md b/2025R2/rigid-bd-25-r2/changelog.md new file mode 100644 index 0000000000..0b2a5213fc --- /dev/null +++ b/2025R2/rigid-bd-25-r2/changelog.md @@ -0,0 +1,5 @@ +# Changelog + +## Version 2025 R2 + +- No changes in this release. diff --git a/2025R2/rigid-bd-25-r2/cmsbody.md b/2025R2/rigid-bd-25-r2/cmsbody.md new file mode 100644 index 0000000000..4a7241fc1d --- /dev/null +++ b/2025R2/rigid-bd-25-r2/cmsbody.md @@ -0,0 +1,26 @@ +# CMSBody + +A CMSBody represents a condensed part in the Mechanical tree. + +### Constructors + +None + +### Members + +`CondensedPartId (read only)` + +The ID of the condensed part in the Mechanical tree. + +`PartIds (read only)` + +The vector of the IDs of the Mechanical parts that are used in the condensed +part. + +### Member functions + +None + +### Derived classes + +None diff --git a/2025R2/rigid-bd-25-r2/command-use.md b/2025R2/rigid-bd-25-r2/command-use.md new file mode 100644 index 0000000000..0e4db130d7 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/command-use.md @@ -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) diff --git a/2025R2/rigid-bd-25-r2/condition.md b/2025R2/rigid-bd-25-r2/condition.md new file mode 100644 index 0000000000..719f1665b3 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/condition.md @@ -0,0 +1,55 @@ +# Condition + +Condition causes a load or a joint condition to be active only under defined +circumstances. A condition is expressed in one of the following forms: + + 1. `MeasureComponent` operator `threshold` + + 1. `LeftThreshold` < `MeasureComponent` < `RightThreshold` + + 1. `LeftCondition` operator `RightCondition` + +### For case 1 + +* `MeasureComponent` is a scalar [Measure](measure.md). + +* `Operator` is one of the following math operators: + + * `E_GreaterThan` + * `E_LessThan` + * `E_DoubleEqual` + * `E_ExactlyEqual` + +* `Threshold` is the threshold value. + +**Note** +A condition cannot be shared between various actuators. For example, if two +joint conditions must be deactivated at the same time, two conditions must be +created. + +Example: + + DispCond = CS_Condition(CS_Condition.E_ConditionType.E_GreaterThan,DispX,0.1) + +### For case 2 + +* `MeasureComponent` is a scalar [Measure](measure.md). + +* `LeftThreshold` and `RightThreshold` are the bounds within which the condition will be true. + +Example: + + RangeCond = CS_Condition(DispX,0.0,0.1) + +### For case 3 + +* `LeftThreshold` and `RightThreshold` are two conditions (case 1, 2 or 3). + +* `Operator` is one of the following boolean operators: + + * `E_Or` + * `E_And` + +Example: + + BoolCond = CS_Condition(CS_Condition.E_ConditionType.E_Or, RangeCond, DispCond) diff --git a/2025R2/rigid-bd-25-r2/constraint-equation.md b/2025R2/rigid-bd-25-r2/constraint-equation.md new file mode 100644 index 0000000000..eba2165bf7 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/constraint-equation.md @@ -0,0 +1,72 @@ +# Constraint equation + +This example considers the gear mechanism shown below. + +![gear mechanism](./images/gds_cmdref_ex_constraint1.jpg) + +A relation is created between two revolute joints to simulate a gear with a +ratio 2 M. Commands are used to enforce the ratio of velocities between the +two wheels, and create a linear relation between rotational velocities, +defined by: + +(1)*ω 1 \+ (-2)*ω2 = 0 + +First, the joint objects are retrieved using their IDs: + + j1id = CS_Joint.Find(_jid) + j2id = CS_Joint.Find(_jid) + +![retrieving joint objects](./images/gds_cmdref_ex_constraint2.jpg) + +Next, the relationship between the two wheels is defined. The complete list of +commands is shown below. A description of these commands follows. + +![defining relationship](./images/gds_cmdref_ex_constraint3.jpg) + +1. A relation object is created and specified as a relation between velocities: + + ``` + rel=CS_Relation() + rel.MotionType=CS_Relation.E_MotionType.E_Velocity + ``` + +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.])) + ``` + +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.])) + ``` + +4. The first term of relation (1) X ω_1 is added to the relation object: + + ``` + rel.AddTerm(j1id,0,var1) + ``` + + The first argument is the joint object. The second argument defines the DOF + (degrees of freedom) of the joint that are involved in the relation. Here, `0` + represents the rotation, which is the joint's first and only DOF is the + rotation. + +5. The second term and right hand side are introduced in the same manner: + + ``` + rel.AddTerm(j2id,0,var2) + rel.SetVariable (varrhs) + ``` + +6. The relation is added to the list of relations: + + ``` + Env=CS_Environment.GetDefault() + Env.Relations.Add(rel) + ``` diff --git a/2025R2/rigid-bd-25-r2/contact.md b/2025R2/rigid-bd-25-r2/contact.md new file mode 100644 index 0000000000..2b7a098d8c --- /dev/null +++ b/2025R2/rigid-bd-25-r2/contact.md @@ -0,0 +1,27 @@ +# Contact + +A Contact corresponds to a contact pair between two bodies. + +Corresponding ID table: `CS_Contact` + +**Note** +If multiple contact objects have been defined between the same two bodies +(with different surfaces), the solver merges them into one single pair. In +that case, only one of the contact pairs exists and the call to +`CS_Contact.Find(_cid)` will fail for all contact objects other than the one +that was used to handle the pair of bodies. + +### Constants + +None + +### Members + +None + +### Member functions + +`GetOutputContactForce()` + +Retrieves a measure that contains the total contact force between the two +linked bodies. diff --git a/2025R2/rigid-bd-25-r2/contactdebugmask.md b/2025R2/rigid-bd-25-r2/contactdebugmask.md new file mode 100644 index 0000000000..0fa3f5eee2 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/contactdebugmask.md @@ -0,0 +1,62 @@ +# ContactDebugMask + +The ContactDebugMask object allows you to activate and customize the output of +contact points. It can also be used to modify the default behaviour of +contact. ContactDebugMask uses a set of switches that can be toggled on or +off. + +ID table: `CS_ContactDebugMask` + +### Constants + + E_DEBUG_Flag.E_None, + (*)E_DEBUG_Flag.E_Point1: point on the side 1 (contact) + E_DEBUG_Flag.E_Point2: point on the side 2 (target) + E_DEBUG_Flag.E_Normal: contact normal + E_DEBUG_Flag.E_Normal1: normal on side 1 (Reference) + E_DEBUG_Flag.E_Normal2: normal on side 2 (Target) + E_DEBUG_Flag.E_Violation: contact violation (rd.n = P1P2.n) + E_DEBUG_Flag.E_MaterialVelocity: material normal velocity (V2-V1).n + (*)E_DEBUG_Flag.E_TotalVelocity: total normal velocity (material velocity + sliding velocity) + E_DEBUG_Flag.E_EntityId1: geometric entity Id on side 1 (contact) + E_DEBUG_Flag.E_EntityId2: geometric entity Id on side 2 (target) + E_DEBUG_Flag.E_SurfaceId1: surface Id on side 1 (contact) + E_DEBUG_Flag.E_SurfaceId2: surface Id on side 2 (target) + (*)E_DEBUG_Flag.E_EntityType: type of geometric entities (vertex/edge/surface) + (*)E_DEBUG_Flag.E_GeometricStatus: status of the contact position and velocity (touching,separated,...) + E_DEBUG_Flag.E_Accepted: points that are finally kept + E_DEBUG_Flag.E_InconsistentPoint: points not consistent with rank analysis + E_DEBUG_Flag.E_ReceivedPoint: all points send by the contact + E_DEBUG_Flag.E_DeletedPoint: points deleted during Geometric Filtering + E_DEBUG_Flag.E_TrackedPoint: points successfully tracked + E_DEBUG_Flag.E_TrackedPointFailure: points that failed for tracking + E_DEBUG_Flag.E_NormalAngle: angle between normal (in degrees) + E_DEBUG_Flag.E_SlidingVelocity1: sliding velocity on side 1 (contact) in global coordinates + E_DEBUG_Flag.E_SlidingVelocity2: sliding velocity on side 2 (target) in global coordinates + E_DEBUG_Flag.E_FailSafeFilteringMode: adjust contact radius to accept at least one point + E_DEBUG_Flag.E_CheckIntegration: check consistency of integration between solver and contact + E_DEBUG_Flag.E_RankAnalysis: result from rank analysis + E_DEBUG_Flag.E_Transition: result from edge transitions analysis + (*)E_DEBUG_Flag.E_NewTimeStep: at beginning of time step + E_DEBUG_Flag.E_BeforeCorrection: before external loop of correction + E_DEBUG_Flag.E_BeforeCorrectionPlus: before geometric correction + E_DEBUG_Flag.E_All + +### Members + +None + +### Member functions + +`SetOn(E_DEBUG_Flag flag)` + + +Enable output of contact points information specified by flag. + +`SetOff(E_DEBUG_Flag flag)` + +Disable output of contact points information specified by flag. + +### Example + + CS_ContactDebugMask.SetOn(E_DEBUG_Flag.E_Accepted) diff --git a/2025R2/rigid-bd-25-r2/contactoptions.md b/2025R2/rigid-bd-25-r2/contactoptions.md new file mode 100644 index 0000000000..cec3df5f62 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/contactoptions.md @@ -0,0 +1,32 @@ +# ContactOptions + +The ContactOptions object allows you to customize the behaviour of a contact +server. ContactOptions uses a set of numerical values (real or integer) that +can be get or set. When used as a switch, 0 means off and 1 is on. + +### Constants + +None + +### Members + +`TimeOut` + +Time in second (=30.0 by default) + +`Verbose` + +Enable verbose mode in contact.out file (=0, disabled by default) + +`NumberOfThreads` + +Number of parallel threads used for contact detection (=2 by default) + +### Member functions + +None + +### Example + + cOpts=CS_ContactOptions() + cOpts.Verbose=1 diff --git a/2025R2/rigid-bd-25-r2/debugging-vs.md b/2025R2/rigid-bd-25-r2/debugging-vs.md new file mode 100644 index 0000000000..e28e8f3fd0 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/debugging-vs.md @@ -0,0 +1,32 @@ +# 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. + +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) + ``` + +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) + +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) + +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) + +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) + +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). + +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. diff --git a/2025R2/rigid-bd-25-r2/docfx.json b/2025R2/rigid-bd-25-r2/docfx.json new file mode 100644 index 0000000000..a94caacc6b --- /dev/null +++ b/2025R2/rigid-bd-25-r2/docfx.json @@ -0,0 +1,13 @@ +{ + "build": { + "globalMetadata": { + "title": "Command Reference for Rigid Dynamics Systems 2025 R2", + "summary": "", + "version": "2025 R2", + "product": "Rigid", + "programming language": "Python", + "product collection": "Structures", + "physics": "Multiphysics" + } + } +} \ No newline at end of file diff --git a/2025R2/rigid-bd-25-r2/driver.md b/2025R2/rigid-bd-25-r2/driver.md new file mode 100644 index 0000000000..e96542588c --- /dev/null +++ b/2025R2/rigid-bd-25-r2/driver.md @@ -0,0 +1,25 @@ +# Driver + +A driver is a position, velocity or acceleration, or translational or +rotational joint condition. Drivers derive from the [Actuator](actuator.md) class. + +Corresponding ID table: `CS_Actuator` + +### Constants + +`E_Acceleration`, `E_Position`, `E_Velocity` + +### Members + +None + +### Member functions + +`CS_Driver(CS_Joint joint, int[] components, E_MotionType driverMotionType)` + +Creation of a joint driver, on joint `joint`, degree of freedom `components`, +and with motion type `driverMotionType`. Note that the same driver can +prescribe more than one joint motion at the same time. This is useful if you +want to add the same condition to all components of a prescribed motion for +example. Components must be ordered, are zero based, and refer to the actual +free degrees of freedom of the joint. diff --git a/2025R2/rigid-bd-25-r2/environment.md b/2025R2/rigid-bd-25-r2/environment.md new file mode 100644 index 0000000000..abf7c8431c --- /dev/null +++ b/2025R2/rigid-bd-25-r2/environment.md @@ -0,0 +1,127 @@ +# Environment + +This is the top level of the Rigid Dynamics model. + +ID table: `CS_Environment` + +### Members + +`System` + +Corresponding system. + +Example: + + Env=CS_Environment.FindFirstNonNull() + Sys = Env.System + +`Ground` + +Ground body. + +Example: + + Env = CS_Environment.FindFirstNonNull() + Ground = Env.Ground + +`Loads` + +The vector of existing loads. This includes Springs that are considered by the +solver as loads, as well as force and torque joint conditions. + +Example: + + Xdof = 0 + Friction=CS_JointDOFLoad(PlanarJoint,Xdof) + Env.Loads.Add(Friction) + +`BodyLoads` + +The vector of Body Loads. + +Example: + + MyBodyLoad = CS_BodyLoad() + … + Env.BodyLoads.Add(MyBodyLoad) + +`Relations` + +The vector of external constraint equations. + +Example: + + rel3=CS_Relation() + rel3.MotionType=CS_Relation.E_MotionType.E_Velocity + + var30=CS_ConstantVariable() + var30.SetConstantValues(System.Array[float]([0.])) + + var31=CS_ConstantVariable() + var31.SetConstantValues(System.Array[float]([23.])) + + var32=CS_ConstantVariable() + var32.SetConstantValues(System.Array[float]([37.])) + + var33=CS_ConstantVariable() + var33.SetConstantValues(System.Array[float]([-60.+37.])) + + rel3.SetVariable(var30) + rel3.AddTerm(jp,0,var31) + rel3.AddTerm(js3,0,var32) + rel3.AddTerm(jps,0,var33) + + Env.Relations.Add(rel3) + +`Drivers` + +The vector of Displacements, Velocity and Acceleration joint conditions. + +`InitialConditions` + +The vector of Displacements, Velocity, and Acceleration joint conditions to be +used only at time=`0`. + +`PotentialEnergy` + +Gets the Potential Energy Measure. + +`KineticEnergy` + +Gets the Kinetic Energy Measure. + +`TotalEnergy` + +Gets the Total Energy Measure. + +`ActuatorEnergy` + +Gets the Actuator Energy Measure. + +`RestartTime` + +Specifies the starting time in a restart analysis + +### Member functions + +`FindFirstNonNull()`: + +Returns the first environment in the global list. The table usually contains +only one environment, thus it is a common way to access the current +environment. + +Example: + + Env=CS_Environment.FindFirstNonNull() + +`AlterSimulationEndTime(endTime)` + +Overwrites the end time of the simulation. + +`Solve()` + +Solves the current analysis. + +### Derived classes + +None diff --git a/2025R2/rigid-bd-25-r2/export-joint-forces.md b/2025R2/rigid-bd-25-r2/export-joint-forces.md new file mode 100644 index 0000000000..ed09af2bc8 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/export-joint-forces.md @@ -0,0 +1,97 @@ +# 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. + +First, the joint is retrieved by inserting the following command on the +corresponding joint in the tree: + + TopRevolute = CS_Joint.Find(_jid) + +Next, the commands object shown below is inserted in the result node. An +explanation of these commands follows. + +![export commands](./images/gds_cmdref_ex_joint_insert.png) + +1. Get measures from the joint: + + ``` + TopRevoluteRotation = TopRevolute.GetRotation() + ``` + +2. Extract transient values for this measure: + + ``` + TopRevoluteRotationValues=TopRevoluteRotation.FillValuesThroughTime() + ``` + +3. Get angle derivatives by extracting the time derivatives of the measure: + + ``` + TopRevoluteRotationDerivatives=TopRevoluteRotation.FillDerivativesThroughTime() + ``` + +4. Count the number of components of this array: + + ``` + nbValues = TopRevoluteRotationValues.GetLength(0) + ``` + +5. Open the ASCII output file: + + ``` + fich=open(r"TopRevoluteRotation.csv",'w') + fich.write('Time,Rotation,Velocity\n') + ``` + +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() + ``` + +7. Check if joint is « revert » or not: + + ``` + IsRevert = TopRevolute.IsRevert + if IsRevert: + fact = -1.0 + else: + fact = 1.0 + ``` + +8. Extract force measurements and write them to the file: + + ``` + TopRevoluteForce = TopRevolute.GetForce() + TRF=TopRevoluteForce.FillValuesThroughTime() + fich=open(r"TopRevoluteForce.csv",'w') + fich.write('Time,FX,FY,FZ,MX,MY,MZ\n') + for i in range(0,nbValues): + fich.write('{0:4.3f},{1:11.4e},{2:11.4e},{3:11.4e},{4:11.4e}, + {5:11.4e},{6:11.4e}\n'.format(TRF[i,0],fact*TRF[i,1], + fact*TRF[i,2],fact*TRF[i,3],fact*TRF[i,4],fact*TRF[i,5],fact*TRF[i,6])) + + fich.close() + ``` + +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) + else: + TopRevolute.ReferenceCoordinateSystem.RotateArrayThroughTimeToLocal(TRF) + + fich=open(r"TopRevoluteForceRotated.csv",'w') + fich.write('Time,FX,FY,FZ,MX,MY,MZ\n') + + for i in range(0,nbValues): + fich.write('{0:4.3f},{1:11.4e},{2:11.4e},{3:11.4e},{4:11.4e},{5:11.4e}, + {6:11.4e}\n'.format(TRF[i,0],fact*TRF[i,1],fact*TRF[i,2],fact*TRF[i,3], + fact*TRF[i,4],fact*TRF[i,5],fact*TRF[i,6])) + fich.close() + ``` diff --git a/2025R2/rigid-bd-25-r2/flexiblebody.md b/2025R2/rigid-bd-25-r2/flexiblebody.md new file mode 100644 index 0000000000..2e04b66b9d --- /dev/null +++ b/2025R2/rigid-bd-25-r2/flexiblebody.md @@ -0,0 +1,93 @@ +# Flexible Body + +A Flexible Body is used by RBD for bodies that have flexible behavior, for +instance a [CMSBody](cmsbody.md). + +### Constructors + +None. + +### Members + +`AlphaDamping` + +Uses a variable to define the amount of alpha Rayleigh damping (proportional +to the mass matrix) to be considered for the flexible body. The variable can +be either dependent or constant. + +Example: + + aFlexibleBody.AlphaDamping=100 + +Or equivalently: + + var=CS_Variable() + var.SetConstantValues(System.Array[float]([100.])) + aFlexibleBody.AlphaDamping=var + +`BetaDamping` + +Uses a variable to define the amount of beta Rayleigh damping (proportional to +the mass matrix) to be considered for the flexible body. The variable can be +either dependent or constant. + +Example: + + Env=CS_Environment.GetDefault() + Sys=Env.System + + array=System.Array.CreateInstance(float,4,2) + array[0,0]=0.0 + array[0,1]=5.e-6 + array[1,0]=0.05 + array[1,1]=5.e-6 + array[2,0]=0.051 + array[2,1]=1.e-4 + array[3,0]=0.1 + array[3,1]=1.e-4 + + table=CS_PointsTable(array) + + (err,found,time)=Sys.FindOrCreateInternalMeasure(CS_Measure.E_MeasureType.E_Time) + + var=CS_Variable() + var.AddInputMeasure(time) + var.SetTable(table) + + aFlexibleBody.BetaDamping = var + +`CMatrixScaleFactor` + +Define a factor to be used to multiply the default damping matrix. For +instance, with a [CMSBody](cmsbody.md), this matrix can be +created during the generation pass. When the damping matrix is generated for a +Condensed Part ([CMSBody](cmsbody.md)), it will be +automatically taken into account in the RBD use pass with a factor equal to +1.0. + +### Member functions + +`SetModalDamping(iDof, variable)` + +Define the amount of damping used for the degree of freedom specified by +`iDof` (index starts at 0). The variable can be either dependent or constant. + +`GetModalDamping(iDof)` + +Retrieve the damping variable defined for the degree of freedom `iDof` (index +starts at 0). + +`SetLoadVectorScaleFactor(iLV, variable)` + +Define a scale factor applied to the flexible body internal load specified by +`iLV` (index starts at 0). By default, the first load vector uses a constant +scale factor equal to 1.0. + +`GetLoadVectorScaleFactor(iLV, variable)` + +Retrieve the variable associated to the factor specified by `iLV` (index +starts at 0). + +### Derived classes + +`CS_CMSBody` diff --git a/2025R2/rigid-bd-25-r2/giltable.md b/2025R2/rigid-bd-25-r2/giltable.md new file mode 100644 index 0000000000..38faa465f1 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/giltable.md @@ -0,0 +1,130 @@ +# GILTable + +A general multi-input interpolated table based on an unstructured cloud of +points. + +Corresponding ID table: `CS_GILTable` + +### Member functions + +`CS_GILTable(sizeIn,sizeOut)` + +Creates a GIL table with `sizeIn` inputs and `sizeOut` outputs + +`CS_GILTable(sizeIn, sizeOut, filename, scale, separator, noHeader)` + +Creates a GIL table from a text file; `filename` is the name of the file +containing the points (typically a `.CSV` file). This file must be in ASCII +format, with one data point per row. Each row must contain `sizeIn` \+ +`sizeOut` columns. The columns must be separated by a character specified by +the argument `separator`. The default value of `separator` is `,`. `scale` is +an optional argument that scales all the output values. The default value, +used if the optional argument is not specified, is 1.0. `noHeader` is a +boolean, optional argument that should be `true` if there is no first row with +labels. + +Example file: + + Velocity, Deflection, Force + 0.,0.,10.0 + 100.,0.,200.0 + ... + +`AddInterpolationPoint(values)` + +Adds an interpolation point to the General Interpolation Table. `values` is a +one dimensional array of size `sizeIn`+`sizeOut`. The first `sizeIn` values in +array `values` corresponds to the values of the input variables. The following +`sizeOut` values in array `values` correspond to the output values. + +Example 1. Creation of a Nonlinear Stiffness Value That Depends on Spin +Velocity (Omega) and on Deflection (dY) + + VarForceY = CS_Variable(); + # + # Variable 0: spin + VarForceY.AddInputMeasure(SpinMeasure ) + # + # Variable 1: Y displacement + VarForceY.AddInputMeasure( TransY ) + # + # Create table with 2 input and 1 output + EvalY = CS_GILTable(2,1) + + Omega = -1.0 + dY = -1e-4 + stiff = -9.0 + + values=System.Array.CreateInstance(float,3) + + values[0] = Omega + values[1] = dY + values[2] = stiff + EvalY.AddInterpolationPoint( values ) + + Omega = 11.0 + dY = -1e-4 + stiff = -21.0 + values[0] = Omega + values[1] = dY + values[2] = stiff + EvalY.AddInterpolationPoint( values ) + … + +`AddInterpolationPointArray(values)` + +Adds a set of points to the General Interpolation Table. `values` is a two +dimensional array of size (`numberOfPoints`, `sizeIn`+`sizeOut`). On each row +of the array, first `sizeIn` values in array `values` corresponds to the +values of the input variables. The following `sizeOut` values in array +`values` correspond to the output values. Each row contains a single +interpolation point in the cloud of points. + +Example 2. Creation of a Nonlinear Force Value (F) That Depends on Deflection +(dX) + + ForceVariable = CS_Variable() + ForceVariable.AddInputMeasure( TransX ) + Evaluator = CS_GILTable( 1,1 ) + values = System.Array.CreateInstance( float, 6, 2 ) + dX = 0.0 + F = 0.0 + values[0,0] = dX + values[0,1] = F + + dX = 10.0 + F = 1.0 + values[1,0] = dX + values[1,1] = F + + dX = 30.0 + F = 2.0 + values[2,0] = dX + values[2,1] = F + + dX = 60.0 + F = 3.0 + values[3,0] = dX + values[3,1] = F + + dX = 90.0 + F = 4.0 + values[4,0] = dX + values[4,1] = F + + dX = 130.0 + F = 5.0 + values[5,0] = dX + values[5,1] = F + Evaluator.AddInterpolationPointArray( values ) + +`SetVerbosity(bVerbose)` + +If `bVerbose` is set to true, the GILTable will print the output value every +time it is evaluated. This can be used for debugging purposes, but it will +affect the performance if used on a table in a long simulation. + +### Limitations + +These tables can only be used to apply forces and moments, not for other joint +conditions or remote displacements. diff --git a/2025R2/rigid-bd-25-r2/images/ds_rbd_attach.png b/2025R2/rigid-bd-25-r2/images/ds_rbd_attach.png new file mode 100644 index 0000000000..96c2bef741 Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/ds_rbd_attach.png differ diff --git a/2025R2/rigid-bd-25-r2/images/ds_rbd_error.png b/2025R2/rigid-bd-25-r2/images/ds_rbd_error.png new file mode 100644 index 0000000000..d96781e1a3 Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/ds_rbd_error.png differ diff --git a/2025R2/rigid-bd-25-r2/images/ds_rbd_outline.png b/2025R2/rigid-bd-25-r2/images/ds_rbd_outline.png new file mode 100644 index 0000000000..f540d1dd56 Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/ds_rbd_outline.png differ diff --git a/2025R2/rigid-bd-25-r2/images/ds_rbd_sel_code_type.png b/2025R2/rigid-bd-25-r2/images/ds_rbd_sel_code_type.png new file mode 100644 index 0000000000..ba7fce7dcf Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/ds_rbd_sel_code_type.png differ diff --git a/2025R2/rigid-bd-25-r2/images/eqfeb08486-03aa-461f-b350-a745935a6dab.png b/2025R2/rigid-bd-25-r2/images/eqfeb08486-03aa-461f-b350-a745935a6dab.png new file mode 100644 index 0000000000..65620443d3 Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/eqfeb08486-03aa-461f-b350-a745935a6dab.png differ diff --git a/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_constraint1.jpg b/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_constraint1.jpg new file mode 100644 index 0000000000..42c0c20124 Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_constraint1.jpg differ diff --git a/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_constraint2.jpg b/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_constraint2.jpg new file mode 100644 index 0000000000..ff8b7c181d Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_constraint2.jpg differ diff --git a/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_constraint3.jpg b/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_constraint3.jpg new file mode 100644 index 0000000000..b6a041607f Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_constraint3.jpg differ diff --git a/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_damper_plot.jpg b/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_damper_plot.jpg new file mode 100644 index 0000000000..3855b19afb Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_damper_plot.jpg differ diff --git a/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_damper_win1.jpg b/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_damper_win1.jpg new file mode 100644 index 0000000000..9e5164db7d Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_damper_win1.jpg differ diff --git a/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_damper_win2.jpg b/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_damper_win2.jpg new file mode 100644 index 0000000000..ab4736ec48 Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_damper_win2.jpg differ diff --git a/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_joint_insert.png b/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_joint_insert.png new file mode 100644 index 0000000000..13e060f26f Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/gds_cmdref_ex_joint_insert.png differ diff --git a/2025R2/rigid-bd-25-r2/images/gds_cmdref_sp_stop_pic.jpg b/2025R2/rigid-bd-25-r2/images/gds_cmdref_sp_stop_pic.jpg new file mode 100644 index 0000000000..34b8bdd1ad Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/gds_cmdref_sp_stop_pic.jpg differ diff --git a/2025R2/rigid-bd-25-r2/images/gds_cmdref_sp_stop_results.jpg b/2025R2/rigid-bd-25-r2/images/gds_cmdref_sp_stop_results.jpg new file mode 100644 index 0000000000..f5012f07f0 Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/gds_cmdref_sp_stop_results.jpg differ diff --git a/2025R2/rigid-bd-25-r2/images/gds_cmdref_sp_stop_win.jpg b/2025R2/rigid-bd-25-r2/images/gds_cmdref_sp_stop_win.jpg new file mode 100644 index 0000000000..45949c220b Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/gds_cmdref_sp_stop_win.jpg differ diff --git a/2025R2/rigid-bd-25-r2/images/gds_rbdcmdref1.png b/2025R2/rigid-bd-25-r2/images/gds_rbdcmdref1.png new file mode 100644 index 0000000000..8f092e3e18 Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/gds_rbdcmdref1.png differ diff --git a/2025R2/rigid-bd-25-r2/images/gds_rbdcmdref2.png b/2025R2/rigid-bd-25-r2/images/gds_rbdcmdref2.png new file mode 100644 index 0000000000..f93f76007c Binary files /dev/null and b/2025R2/rigid-bd-25-r2/images/gds_rbdcmdref2.png differ diff --git a/2025R2/rigid-bd-25-r2/intro.md b/2025R2/rigid-bd-25-r2/intro.md new file mode 100644 index 0000000000..3b630314d7 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/intro.md @@ -0,0 +1,20 @@ +# Introduction + +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. + +- [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) + diff --git a/2025R2/rigid-bd-25-r2/iron-python-references.md b/2025R2/rigid-bd-25-r2/iron-python-references.md new file mode 100644 index 0000000000..53d114178b --- /dev/null +++ b/2025R2/rigid-bd-25-r2/iron-python-references.md @@ -0,0 +1,16 @@ +# 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 +writing commands for the solver. Ansys Workbench scripting is based on +IronPython, which is well integrated with the rest of the .NET Framework (on +Windows) and Mono CLR (on Linux). This makes all related libraries easily +available to Python programmers while maintaining compatibility with the +Python language. For more information on IronPython, see +. + +IronPython is compatible with existing Python scripts, but not all C-based +Python library modules are available under IronPython. Refer to the +[IronPython website](http://ironpython.net) for more information. For more +information on Python, including a standard language reference, see +. diff --git a/2025R2/rigid-bd-25-r2/jc-initial-velocity.md b/2025R2/rigid-bd-25-r2/jc-initial-velocity.md new file mode 100644 index 0000000000..2fec3ea210 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/jc-initial-velocity.md @@ -0,0 +1,64 @@ +# Joint condition: initial velocity + +This example shows how to impose an initial velocity to a joint. A velocity +driver (joint condition) is created using commands and added to the list of +initial conditions. During the transient solve, initial conditions are applied +only at t=0. + +The complete list of commands and their explanation follows. + + Joint=CS_Joint.Find(_jid) + driver=CS_Driver(Joint,System.Array[int]([0]),CS_Driver.E_MotionType.E_Velocity) + Env=CS_Environment.GetDefault() + Sys=Env.System + (ret,found,time) = Sys.FindOrCreateInternalMeasure(CS_Measure.E_MeasureType.E_Time) + driver.SetInputMeasure(time) + driver.SetConstantValues(System.Array[float]([-4.9033])) + Env.InitialConditions.Add(driver) + +1. The joint is retrieved using its ID(_jid): + + ``` + Joint=CS_Joint.Find(_jid) + ``` + +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 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 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. + +3. The default environment and corresponding system are retrieved: + + ``` + Env=CS_Environment.GetDefault() + Sys=Env.System + ``` + +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) + ``` + +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])) + ``` + +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) + ``` diff --git a/2025R2/rigid-bd-25-r2/jc-linear-feedback.md b/2025R2/rigid-bd-25-r2/jc-linear-feedback.md new file mode 100644 index 0000000000..9c1d4ef1ad --- /dev/null +++ b/2025R2/rigid-bd-25-r2/jc-linear-feedback.md @@ -0,0 +1,34 @@ +# 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: + +### Method 1 + +Obtain the velocity measure from the joint: + + joint = CS_Joint.Find(_jid) + vel=joint.GetVelocity() + +Next, modify an existing moment in order to use the velocity measure as its +input measure: + + Env=CS_Environment.FindFirstNonNull() + + ids=Env.DSToInternalIds[_jcid] + + load=CS_Actuator.Find(ids[0]) + load.SetInputMeasure(vel) + +### Method 2 + +Using this method, the load is created entirely using commands. These commands +are shown below. + + Env=CS_Environment.FindFirstNonNull() + + load=CS_JointDOFLoad(joint,0) + load.SetInputMeasure(vel) + load.SetFunc('0.1*(-2*acos(-1)-time)',0) + + Env.Loads.Add(load) diff --git a/2025R2/rigid-bd-25-r2/joint.md b/2025R2/rigid-bd-25-r2/joint.md new file mode 100644 index 0000000000..0fff79d8f6 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/joint.md @@ -0,0 +1,201 @@ +# Joint + +ID table: `CS_Joint` + +### Constants + +For the joint type (`E_JointType`): + +`E_2DSlotJoint`, `E_BushingJoint`, `E_CylindricalJoint`, `E_GeneralJoint`, +`E_FixedJoint`, `E_FreeJoint`, `E_PlanarJoint`, `E_PointOnCurveJoint`, +`E_RevoluteJoint`, `E_ScrewJoint`, `E_SingleRotationGeneralJoint`, +`E_SlotJoint`, `E_SphericalJoint`, `E_TranslationalJoint`, +`E_TwoRotationGeneralJoint`, `E_UniversalJoint`, + +### Members + +`Name` + +Name of the joint + +`ReferenceCoordinateSystem` + +Joint reference coordinate system + +Example: + + J1 = CS_Joint.Find(_jid) + CSR = J1.ReferenceCoordinateSystem + +`MovingCoordinateSystem` + +Joint moving coordinate system + +Example: + + J1 = CS_Joint.Find(_jid) + CSM = J1. MovingCoordinateSystem + +`Type` + +Joint type + +`IsRevert` + +The internal representation of the joint can use flipped reference and mobile +coordinate systems. In that case, all the joint results (for example, forces, +moments, rotation, velocities and acceleration) must be multiplied by -1 to go +from their internal representation to the user representation. As transient +values of joint measures are giving the internal representation, use this +`IsRevert` information to know if results should be negated. + +`AccelerationFromVelocitiesDerivatives` + +When extracting joint degrees of freedom on joints that return true, +accelerations should be done using the time derivatives of the joint velocity +measure. On joints that return false, joint DOF derivatives should be +extracted using the joint acceleration measure. It is important to check this +flag first. Use of the wrong method to query joint acceleration can result in +failure or incorrect results. + +Example: + + if Universal.AccelerationFromVelocitiesDerivatives: + UniversalAccelerationValues=UniversalVelocityM.FillDerivativesThroughTime() + else: + UniversalAcceleration = Universal.GetAcceleration() + UniversalAccelerationValues=UniversalAcceleration.FillValuesThroughTime() + +`Stops` + +Returns the list of the stops defined on the joint. + +### Member functions + +`GetVelocity()` + +Returns the joint velocity measure. The size of this measure is the number of +degrees of freedom of the joint. The derivatives of this measure give access +to the joint accelerations. + +`GetRotation()` + +Returns the joint rotation measure. The type of measure depends on the joint +number of rotational degrees of freedom (`E_1DRotationMeasure`, +`E_3DRotationMeasure`, `E_UniversalAngles`). These rotations components are +relative to the reference coordinate system of the joint. + +`GetTranslation()` + +Returns the joint translation measure. The length of this measure is the +number of translational degrees of freedom of the joint. The translation +components are expressed in the reference coordinate system of the joint. + +`GetForce()` + +Returns the joint force measure. The length of this measure is always 6 (3 +forces components, 3 torque component). This force measure is the total +force/moment, including constraint forces/moment, external forces/moment +applied to the joint, and joint internal forces/moment, such as elastic moment +in a revolute joint that has a stiffness on the Z rotation axis. The force +measure components are expressed in the global coordinate system. Note that +the sign convention is different from the sign convention used in the Joint +Probes in Mechanical. + +`GetAcceleration()` + +Returns the joint acceleration measures on the joints that are constraint +equations based. See the `AccelerationFromVelocitiesDerivatives` member to see +when this function should be used. + +Example: + + J1 = CS_Joint.Find(_jid) + jointRotation = J1.GetRotation() + jointVelocity = J1.GetVelocity() + jointAcceleration = J1.GetAcceleration() + jointForce = J1.GetForce() + +`SetFrictionVariable(var)` + +Replaces the constant value already given to the friction coefficient with the +expression given by `var`. + +Example: + + Joint = CS_Joint.Find(_jid) + Var = CS_Variable() + u0 = 0.1 + u1 = 0.2 + alpha = 0.5 + Var.SetFunc('u0+u1exp(-alpha*time)',0) + Var.AddInputMeasure(Joint.GetVelocity()) + Joint.SetFrictionVariable(Var) + +The command has no effect if no value for the friction coefficient has been +provided in the UI. For more information, see online help for Joint Friction. + +`SetFrictionTolerance(tol)` + +Sets the friction tolerance. + +Example: + + Joint = CS_Joint.Find(_jid) + Joint = Joint.SetFrictionTolerance(1e-4) + +### Derived classes + +On `SphericalJoint, SlotJoint, BushingJoint, FreeJoint, GeneralJoint`. + +##### Member function + +`AddStop(angle_max, restitution_factor)` + +Adds a spherical stop to a joint that has three rotations. A spherical stop +constrains the motion of the X and Y rotational degrees of freedom, to give to +the joint the behavior of a loose revolute joint, with a rotational gap. This +will allow easier handling of over-constrained systems and building higher +fidelity models without having to use contact. + +`angle_max` + +The angle between the reference coordinate system Zr axis and the moving +coordinate system Zm. Zr is the natural revolute axis. + +`restitution_factor` + +The restitution factor, similar to other joint stops. + +![](./images/gds_rbdcmdref1.png) + +##### On cylindrical joint + +`ReplaceByScrew(pitch)` + +Creates a relation between the translational and the rotational degrees of +freedom of a cylindrical joint. + +**Note** + +* The pitch is in the current length unit. Any stop and/or lock defined on the original cylindrical joint is not transferred to the screw joint. Similarly, any constraint equation defined on the original cylindrical joint is not converted and so will prevent a proper solution. +* The ReplaceByScrew command is deprecated. It is replaced by the [Screw Joint]() provided in the Mechanical UI. + +##### On bushing joint + +`GetBushingAngles()` + +Returns the measure of the joint angles. This measure is used to compute the +forces and torques developed in the joint. Note that this is only available +for post-processing operations, as the measure does not exist before the solve +has been performed. + +##### Creating new joints + +The following joint can be created by commands: + +`CS_GeneralJoint(from, to, FreeX, FreeY, FreeZ, FreeRX, FreeRY, FreeRZ)` + +Where `from` and `to` are of type `CS_BodyCoordinateSystem` and `Free*` are +integers where 0 is no available motion and nonzero is available motion. +Selecting two free rotations is not allowed. diff --git a/2025R2/rigid-bd-25-r2/jointdofload.md b/2025R2/rigid-bd-25-r2/jointdofload.md new file mode 100644 index 0000000000..71f1c98bfb --- /dev/null +++ b/2025R2/rigid-bd-25-r2/jointdofload.md @@ -0,0 +1,30 @@ +# JointDOFLoad + +JointDOFLoads are loads applied on a given degree of freedom of a joint. The +load is applied in the joint reference coordinate system. + +JointDOFLoad derives from [Load](load.md). + +### Constructor + + `CS_JointDOFLoad(joint,dof)` + +`joint` + +A joint object + +`dof` + +An integer that defines the joint degree of freedom to be included in the +term. The ordering of the degrees of freedom sets the translation degrees of +freedom first. The degrees of freedom numbering is zero based. For example, in +a slot joint, the translational degree of freedom is 0, while the third +rotational degree of freedom is 3. + +### Members + +None + +### Member functions + +None diff --git a/2025R2/rigid-bd-25-r2/load.md b/2025R2/rigid-bd-25-r2/load.md new file mode 100644 index 0000000000..987b8f7a94 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/load.md @@ -0,0 +1,15 @@ +# Load + +Loads derive from the [Actuator](actuator.md) +class. They are derived from various types of loads, such as the +`CS_JointDOFLoad`. + +Corresponding ID table: `CS_Actuator` + +### Members + +None + +### Member functions + +None diff --git a/2025R2/rigid-bd-25-r2/measure.md b/2025R2/rigid-bd-25-r2/measure.md new file mode 100644 index 0000000000..44b5b823e9 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/measure.md @@ -0,0 +1,227 @@ +# 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 +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 +computed at each time step (see component measure example below). + +ID table: `CS_Measure` + +### Constants + +For the measure type (`E_MeasureType`): + +`E_1DRotationJoint`, `E_3DRotationBody`, `E_3DRotationJoint`, +`E_Acceleration`, `E_ActuatorStatus`, `E_ActuatorEnergy`, +`E_AnsysJointForceAndTorque`, `E_AXPY`, `E_BodyAcceleration`, +`E_BodyIntertialBCSQuaternion`, `E_BodyRotation`, `E_BodyTranslation`, +`E_CenterOfGravity`, `E_Component`, `E_Constant`, `E_Contact`, +`E_ContactForce`, `E_ContactVelocity`, `E_Counter`, `E_Displacement`, +`E_Distance`, `E_DistanceDot`, `E_Divides`, `E_EigenValue`, +`E_DOFSensitivity`, `E_Dot`, `E_ElasticEnergy`, `E_Energy`, `E_EulerAngles`, +`E_ForceMagnitude`, `E_Forces`, `E_IntegratedOmega`, `E_JointAcceleration`, +`E_JointDOFFrictionCone`, `E_JointDriverForce`, `E_JointForce`, +`E_JointMBDVelocity`, `E_JointNormalForce`, `E_JointTranslation`, +`E_JointRotation`, `E_JointVelocity`, `E_KineticEnergy`, +`E_MassMomentsOfInertia`, `E_MeasureDotInDirectionOfLoad`, `E_Minus`, +`E_Modulus`, `E_Multiplies`, `E_Norm`, `E_Omega`, `E_OmegaDot`, +`E_OutputContactForce`, `E_Plus`, `E_PointOnCurveGeometryMeasure`, +`E_PointOnCurveJointSigmaMeasure`, `E_PointToPointRotation`, +`E_PointToPointRotationDot`, `E_Position`, `E_PotentialEnergy`, `E_RadialGap`, +`E_ReferenceEnergy`, `E_RelativeAcceleration`, `E_RelativePosition`, +`E_RelativeVelocity`, `E_RotationalRelativeDOF`, `E_RotationMatrix`, +`E_SphericalStop`, `E_StopVelocity`, `E_StopStatus`, `E_Time`, `E_TimeStep`, +`E_TranslationalJoint`, `E_UniversalAngles`, `E_UnknownType`, `E_User`, +`E_Velocity`, `E_Violation`, `E_XYZAnsysRotationAngles`, +`E_ZYXRotationAngles`, `E_AngularMomentum` + +### Members + +`Length` + +Number of components of the measure + +Example: + + nbValues = Measure.Length + +`Type` + +Measure type + +`CalculationMethod` + +A measure can use direct calculation or be time integrated. On a measure that +uses direct calculation, it is possible to retrieve the measure value through +time. On a measure that is time-integrated, both values and time derivatives +can be retrieved. + +`Name` + +Measure Name + +### Member functions + +`FillValuesThroughTime()` + +Returns a two dimensional array. This function is to be called after the +solution has been performed. The first dimension of the returned array is the +number of time values in the transient. The second dimension is the size of +the measure plus one. The first column contains the time values, while the +subsequent columns contain the corresponding measure values. + +Example: + + jointRotation = J1.GetRotation() + jointVelocity = J1.GetVelocity() + jointAcceleration = J1.GetAcceleration() + jointForce = J1.GetForce() + + jointRotationValues =jointRotation.FillValuesThroughTime() + jointVelocityValues =jointVelocity.FillValuesThroughTime() + jointAccelerationValues =jointAcceleration.FillValuesThroughTime() + jointForceValues =jointForce.FillValuesThroughTime() + + nbValues = jointRotationValues.GetLength(0) + + print jointRotation.Id + + print ' Time Rotation Velocity Acceleration' + for i in range(0,nbValues): + print jointRotationValues[i,0],jointRotationValues[i,1],jointVelocityValues[i,1],jointAccelerationValues[i,1] + + fich.close() + +`FillDerivativesThroughTime()` + +Returns a two dimensional array. This function is to be called after the +solution has been performed. The first dimension of the returned array is the +number of time values in the transient. The second dimension is the size of +the measure plus one: the first column contains the time values, while the +subsequent columns contain the corresponding measure derivatives. These +derivatives are available on measures that are time integrated. To know if a +measure is time integrated, use the `CalculationMethod` member. + +### Derived classes + +`CS_JointVelocityMeasure` + +Both translational and rotational joint velocities are expressed in the joint +reference coordinate system. The number of components is the number of +translational degrees of freedom plus the number of rotational degrees of +freedom. For example, the size of the joint velocity measure for a revolute +joint is 1. It contains the relative joint rotation velocity along the z axis +of the joint reference coordinate system. The size of the measure for a slot +joint is 4: one component for the relative translational velocity, and the 3 +components of the relative rotational velocity. The joint velocity measure can +be obtained from the joint using the `GetVelocity` function. Rotational +velocities are expressed in radians/second. + +`CS_JointAccelerationMeasure` + +Both translational and rotational joint accelerations are expressed in the +joint reference coordinate system. The number of components is the number of +translational degrees of freedom plus the number of rotational degrees of +freedom. The joint acceleration measure can be obtained from the joint using +the `GetAcceleration` function. + +`CS_JointRotationMeasure` + +* For revolute joints, cylindrical joints, or single rotation general joints, this measure has only one component: the relative angle between the reference and the moving coordinate system of the joint. Rotations are expressed in radians. + +* For slots, spherical joints, bushing joints, and 3 rotation vectors, this measure contains values that are not directly usable. + +* For universal joints, this measure contains the two joint axis rotational velocities. (The first one along the X axis of the reference coordinate system and the second along the Z axis of the moving coordinate system.) These angles are expressed in radians. + +`CS_JointTranslationMeasure` + +This measure contains only the joint relative translations, expressed in the +joint reference coordinate system. The joint translation measure can be +obtained from the joint using the `GetTranslation`function. + +`CS_JointForceMeasure` + +This measure contains the total forces and moment that develop in the joint. +This includes constraint forces, elastic forces, and external forces. The +joint velocity measure can be obtained from the joint using the +`GetForce`function. + +`CS_PositionMeasure` + +This measure allows for tracking of the position of a Body Coordinate System +over time. + +Example: + + CoMBCS = OneBody.InertiaBodyCoordinateSystem + Pos = CS_PositionMeasure(CoMBCS) + Env=CS_Environment.FindFirstNonNull() + Sys = Env.System + Sys.AddMeasure(Pos) + +`CS_ComponentMeasure` + +This measure allows the extraction of one component of an existing measure. +This component can be expressed in a non default coordinate system. A +component of -2 will compute the norm 2 of the vector of values of the +measure. + +Example: + + Planar = CS_Joint.Find(_jid) + Vel = Planar.GetVelocity() + Xglobaldirection = 0 + VelX = CS_ComponentMeasure(Vel,Xglobaldirection) + Sys.AddMeasure(VelX) + +`CS_AXPYMeasure` + +This measure allows a linear transformation from another measure with a +scaling factor and an offset. This can be useful to transform an internal +rotation measure that is expressed in radians to a measure in degrees used as +an input to a load calculation, for example. + +Example: + + Revolute = CS_Joint.Find(_jid) + Rot = Revolute.GetRotation() + RotInDegrees = CS_AXPYMeasure( Rot, 180.0/math.pi, 0. ) + Sys.AddMeasure(RotInDegrees) + +`CS_ModulusMeasure` + +This measure allows you to compute the floating point remainder of +value/modulus. + +Example: + + Revolute = CS_Joint.Find(_jid) + Rot = Revolute.GetRotation() + Rot02pi = CS_ModulusMeasure( Rot, 2.0*math.pi ) + Sys.AddMeasure(Rot02pi) + +`CS_OutputContactForceMeasure` + +This measure contains four 3D vectors: + +* Values 0 to 2 are the total contact force components between the two bodies, including the normal and tangential contributions. + +* Values 3 to 5 are the coordinates of the point where the interaction between the two bodies is reduced to a force; in other words, the total torque is zero. + +* Values 6 to 8 are the frictional force between the two bodies. + +* Values 9 to 11 are frictional moment components at the reduction point. + +`CS_AngularMomentumMeasure` + +This measure computes the Angular Momentum of a list of bodies. Its value is a +3D vector. + +Example: + + FlyWheel= CS_Body.Find(_bid) + FlyWheelAngularMomentumMeasure = CS_AngularMomentumMeasure() + FlyWheelAngularMomentumMeasure.AddBody(FlyWheel) + Sys.AddMeasure(FlyWheelAngularMomentumMeasure) diff --git a/2025R2/rigid-bd-25-r2/msolverdb.md b/2025R2/rigid-bd-25-r2/msolverdb.md new file mode 100644 index 0000000000..9ef932907e --- /dev/null +++ b/2025R2/rigid-bd-25-r2/msolverdb.md @@ -0,0 +1,39 @@ +# MSolverDB + +Solver database. The database is both the input and the results file to the +solver. It can be used to solve outside the Mechanical session (for example, +for co-simulation purposes) or to restart from a previous run. + +### Members + +`SetFileName(FileName)` + +Set the database file name. + +`SetDirectoryName(DirectoryName)` + +Set the database directory. + +`ReadDatabase()` + +Read the content of the database. + +`WriteDatabase()` + +Write the current database to a file. + +`DeleteDatabase()` + +Delete the database. + +`CloseDatabase()` + +Close the database file. + +`OpenDatabase()` + +Open the database file and reads the database content table. + +`Dispose()` + +Clear the content of the database and free memory used by the database. diff --git a/2025R2/rigid-bd-25-r2/non-linear-spring.md b/2025R2/rigid-bd-25-r2/non-linear-spring.md new file mode 100644 index 0000000000..e5f55418c8 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/non-linear-spring.md @@ -0,0 +1,59 @@ +# 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 +shown below. A description of these commands follows. + +![Mechanical UI](./images/gds_cmdref_ex_damper_win1.jpg) + +1. Retrieve the spring object using its ID: + + ``` + Spring=CS_Actuator.Find(_sid) + ``` + +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) + + # + # LENGTH transition values + spring_table[0,0]=0. + spring_table[1,0]=50. + spring_table[2,0]=60. + spring_table[3,0]=100. + spring_table[4,0]=140. + spring_table[5,0]=150. + spring_table[6,0]=200. + # + # Spring Stiffness + spring_table[0,1]=-100000. + spring_table[1,1]=-10000. + spring_table[2,1]=-1000. + spring_table[3,1]=0. + spring_table[4,1]=1000. + spring_table[5,1]=10000. + spring_table[6,1]=100000. + stiffness = CS_PointsTable(spring_table) + spring.SetTable(stiffness) + ``` + + 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](pointstable.md) assigned to the spring, as + shown below. + + ![points table plot](./images/gds_cmdref_ex_damper_plot.jpg) + + Each spring object in the Mechanical GUI is actually a combination of a spring + and a damper. The `GetDamper` method enables you to retrieve the damper object + on a given spring, as shown below. + + ![spring and damper combination](./images/gds_cmdref_ex_damper_win2.jpg) + +3. Introduce a table to define a non-linear force velocity relation: + + ``` + Damper=spring.GetDamper() + ``` diff --git a/2025R2/rigid-bd-25-r2/pointstable.md b/2025R2/rigid-bd-25-r2/pointstable.md new file mode 100644 index 0000000000..ce62665ed6 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/pointstable.md @@ -0,0 +1,36 @@ +# PointsTable + +Corresponding ID table: `CS_PointsTable` + +### Member functions + +`CS_PointsTable( tab )` + +`tab` is a two dimensional array where the first column contains the input +values and the second column contains the corresponding output values. + +Example: + + tab = System.Array.CreateInstance(float,6,2) + tab[0,0]=-100. + tab[1,0]=-8. + tab[2,0]=-7.9 + tab[3,0]= 7.9 + tab[4,0]= 8. + tab[5,0]= 100. + + tab[0,1]=1.0 + tab[1,1]=1.0 + tab[2,1]=0.1 + tab[3,1]=0.1 + tab[4,1]=1.0 + tab[5,1]=1.0 + Table = CS_PointsTable(tab); + +![stiffness chart](./images/gds_rbdcmdref2.png) + +Here, the output (shown as Stiffness in the chart above) varies in a linear, +piece-wise manner. For values of input less than -8.0 or greater than 8.0, the +output is equal to 1.0. For values between -7.9 and +7.9, the output is 0.1. +The transition is linear between -8.0 and -7.9, and as well between +7.9 and ++8.0. diff --git a/2025R2/rigid-bd-25-r2/polynomialtable.md b/2025R2/rigid-bd-25-r2/polynomialtable.md new file mode 100644 index 0000000000..8dbcb43158 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/polynomialtable.md @@ -0,0 +1,40 @@ +# PolynomialTable + +Corresponding ID: `CS_PolynomialTable` + +Create a polynomial relation between `sizeIn` inputs and `sizeOut` outputs +using the following function: + +![polynomial function](./images/eqfeb08486-03aa-461f-b350-a745935a6dab.png) + +Where i denotes the index of input and goes from 1 to n (`sizeIn`), j denotes +the index of output (from 1 to `sizeOut`). + +### Member functions + +`CS_PolynomialTable()` + +Creates an empty polynomial table. + +`Initialize(constant)` + +Specialized for 1x1 table. Initializes the table to be a 1 input, 1 output +table, and sets the constant term (constant is a float value). + +`Initialize(sizeIn,sizeOut,constantValues)` + +(generic version) Initializes the table with `sizeIn` inputs and `sizeOut` +outputs and sets the constant terms. `sizeIn` and `sizeOut` are two integer +values, and `constantValues` is an array of `sizeOut` float values. + +`AddTerm(coefficient,order)` + +Specialized for 1x1 table. Adds one monomial term to the table. The +coefficient is a float value and order is an integer value giving the power of +the input. + +`AddTerm(coefficients,orders)` + +(generic version) Adds one monomial term to the table. The coefficients are +given by a `sizeOut` float array and the power for each input by an array of +`sizeIn` integers. diff --git a/2025R2/rigid-bd-25-r2/rbd-command-library.md b/2025R2/rigid-bd-25-r2/rbd-command-library.md new file mode 100644 index 0000000000..d4f0c42203 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/rbd-command-library.md @@ -0,0 +1,33 @@ +# Rigid Dynamics command objects library + +The following Rigid Dynamics command objects are available: + +- [Actuator](actuator.md) +- [Basis](basis.md) +- [Body](body.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) +- [FlexibleBody](flexiblebody.md) +- [GILTable](giltable.md) +- [Joint](joint.md) +- [JointDOFLoad](jointdofload.md) +- [Load](load.md) +- [Measure](measure.md) +- [MSolverDB](msolverdb.md) +- [PointsTable](pointstable.md) +- [PolynomialTable](polynomialtable.md) +- [Relation](relation.md) +- [Spring](spring.md) +- [SolverOptions](solveroptions.md) +- [System](system.md) +- [Table](table.md) +- [UserTable](usertable.md) +- [Variable](variable.md) + diff --git a/2025R2/rigid-bd-25-r2/rbd-object-model.md b/2025R2/rigid-bd-25-r2/rbd-object-model.md new file mode 100644 index 0000000000..052fcaf2b0 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/rbd-object-model.md @@ -0,0 +1,45 @@ +# 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 +associated with an environment object in the Mechanical tree. Many +environments can exist on the same model. The model is called the System in +the Rigid Dynamics Object model. The system contains the physical +representation of the model, and the environment contains the representation +of a given simulation done on the model. This means that Bodies and Joints +belong to the systems, and Joint Conditions or Loads are available on the +environment. + +You can access an object using its unique ID, which is the same ID used by +Mechanical. Global object tables help you to access an object for which you +have an ID. + +For example, a Joint with the ID `_jid` can be accessed using the following +call: + + Joint= CS_Joint.Find(_jid) + +`CS_xxx` is the table of all `xxx` type objects. + +If the ID of an object is not known, or if only one occurrence of the object +exists in the object model, query the object table to find the first +occurrence of a given object type. This is explained in the following example: + + Environment = CS_Environment.FindFirstNonNull() + +`GetId()` + +This call returns the object ID. + +`GetName()` + +This call returns the object name. + +`SetName(name)` + +This call sets or changes the object name. + +Some objects have to be created by calling the object constructor. For +example, to create a constant variable: + + Var = CS_ConstantVariable() diff --git a/2025R2/rigid-bd-25-r2/relation.md b/2025R2/rigid-bd-25-r2/relation.md new file mode 100644 index 0000000000..f7ef892bf0 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/relation.md @@ -0,0 +1,71 @@ +# Relation + +The relation object enables you to write constraint equations between degrees +of freedom of the model. For example, two independent lines of shaft can be +coupled using a relation between their rotational velocities. + +If you have a gear coupling between two shafts where the second shaft rotates +twice as fast as the first one, you can write the following equation: + +2.0 X Ω1 + Ω2 = 0 + +where Ω1 and Ω2 are joint rotational velocities. + +This relation contains two terms and a constant right hand side equal to zero. + +The first term (2 X Ω1) can be described using the following information: + +* A joint selection + +* A joint degree of freedom selection + +* The nature of motion that is used in the equation (joint velocities, which is the most common case). For convenience, the nature of motion upon which the constraint equation is formulated is considered as being shared by all the terms in the relation. + +This information defines Ω1 + +* The factor 2.0 in the equation can be described by a constant variable, whose value is 2.0 + +ID table: `CS_Actuator` + +The coefficients of the relation can be constant or variable; however, the use +of non-constant coefficients is limited to relations between velocities and +relations between accelerations. If non-constant coefficients are used for +relations between positions, the solution will not proceed. + +### Constants + +`E_Acceleration`, `E_Position`, `E_Velocity` + +### Members + +None + +### Member functions + +`SetRelationType(type)` + +Type of relation, with type selected in the previous enumeration. + +`AddTerm(joint, dof, variable)` + +Adds a term to the equation. + +`joint` + +A joint object + +`dof` + +An integer that defines the joint degree of freedom to be included in the +term. The ordering of the degrees of freedom sets the translation degrees of +freedom first, and that the degrees of freedom numbering is zero based. For +example the translational degrees of freedom in a slot joint is `0`, while the +third rotational degree of freedom is `3`. + +`variable` + +A variable object + +`SetVariable(variable)` + +Sets the right hand side of the relation. "variable" is a variable object. diff --git a/2025R2/rigid-bd-25-r2/solveroptions.md b/2025R2/rigid-bd-25-r2/solveroptions.md new file mode 100644 index 0000000000..06f71d5ef1 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/solveroptions.md @@ -0,0 +1,75 @@ +# SolverOptions + +The SolverOptions object allows you to customize the behaviour of the RBD +solver. The option uses a group of numerical values (real or integer) that can +be get or set. When used as a switch, 0 means off and 1 is on. + +Corresponding ID table: `CS_SolverOptions` + +### Constants + +None + +### Member functions + +`VelocityToleranceFactor` + +Multiplicative factor used to determine zero velocity tolerance (=100.0 by +default); + +`ContactRadiusFactor` + +Contact radius factor used in contact failsafe mode (=2.0 by default); + +`MaximumNumberOfCorrectionAttempts` + +Number of external loops for geometric correction (=2 by default)); + +`FrictionForShock` + +Enable friction for shock solve (=0, disabled by default); + +`MaximumNumberOfDiagnostics` + +Number of diagnostics messages given in Mechanical UI (=10 by default); + +`InactiveTouchingInDynamics` + +Prevent inactive contact pair from being violated (=1, enabled by default); + +`DisablePolygonEvent` + +Disable polygon event for contact (=0, active by default); + +`PrintDynamicSystem` + +Print the dynamics system (=0 by default); + +`PurgeGST` + +Purge GST file every n steps (=0, never by default); + +`PrintErrorEstimation` + +Force output of error estimation (=0, disabled by default); + +`ExportXLSFileForCMS` + +Export generalized coordinates for CMS bodies in a CSV file (=0, disabled by +default) + +`HandlePOCTransitionsWithEnergyMinimization` + +When point on curve joints are used, different solutions (depending on the +topology) may be found when crossing curve connections. Furthermore, these +solutions do not guarantee the conservation of the kinetic energy at the +transition. To remedy this issue, this option makes the transitions using a +method that minimizes the kinetic energy in a way similar to the assembly +process using the inertia matrix. +This solution works well for explicit time integration schemes, but it is not +guaranteed for implicit ones. (=0, disabled by default) + +Example: + + sOpts=CS_SolverOptions() + sOpts.ExportXLSFileForCMS=1 diff --git a/2025R2/rigid-bd-25-r2/spherical-stop.md b/2025R2/rigid-bd-25-r2/spherical-stop.md new file mode 100644 index 0000000000..bab8dd224a --- /dev/null +++ b/2025R2/rigid-bd-25-r2/spherical-stop.md @@ -0,0 +1,22 @@ +# Spherical stop + +This example describes the implementation of a spherical stop. A spherical +stop is a joint that has 3 rotations (joints include spherical, slot, bushing, +free and general joints). This specific type of stop creates a limit to the +angle between the z-axis of the reference frame and the z-axis of the moving +frame. This functionality is available using the following command: + + AddStop(angle_max, restitution_factor) + +For example, to add a spherical stop for an angle value equal to 0.45 radians +and a restitution factor equal to 1.0, the following command would be issued: + + Joint.AddStop(0.45,1.0) + +An example of the model and the results of this command are shown below. + +![Mechanical UI](./images/gds_cmdref_sp_stop_win.jpg) + +![model](./images/gds_cmdref_sp_stop_pic.jpg) + +![output](./images/gds_cmdref_sp_stop_results.jpg) diff --git a/2025R2/rigid-bd-25-r2/spring.md b/2025R2/rigid-bd-25-r2/spring.md new file mode 100644 index 0000000000..01aa420c27 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/spring.md @@ -0,0 +1,46 @@ +# Spring + +Corresponding ID table: `CS_Actuator` + +### Members + +None + +### Member functions + +`ToggleCompressionOnly()` + +Calling this function on a translational spring will make the spring develop +elastic forces only if its length is less than the spring free length. The +free length has to be defined in the regular spring properties. + +`ToggleTensionOnly()` + +Calling this function on a translational spring will make the spring develop +elastic forces only if its length is greater than the free length of spring. +The free length has to be defined in the regular spring properties. + +`SetLinearSpringProperties(system, stiffness, freeLength)` + +Enables you to overwrite the stiffness and free length of a translational +spring. This can be useful to parameterize these properties. For example, +system is the system object, stiffness and free length are the double +precision values of stiffness and free length. + +`SetNonLinearSpringProperties(table_id)` + +Enables you to replace the constant stiffness of a spring with a table of ID +`table_id` that gives the force as a function of the elongation of the spring. +The table gives the relation between the force and the relative position of +the two ends. + +`GetDamper()` + +The user interface has stiffness and damping properties of the spring. +Internally, the Spring is made of two objects; a spring and a damper. This +function enables you to access the internal damper using the Spring object in +the GUI. + +### Derived classes + +None diff --git a/2025R2/rigid-bd-25-r2/system.md b/2025R2/rigid-bd-25-r2/system.md new file mode 100644 index 0000000000..cca2f3ef94 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/system.md @@ -0,0 +1,43 @@ +# System + +Corresponding ID table: `CS_System` + +### Members + +`Bodies` + +Gets the list of bodies. + +`Joints` + +Gets the list of joints. + +### Member functions + +`AddBody(body)` + +Adds a body to the system. + +`AddJoint(joint)` + +Adds a joint to the system. + +`PrintTopology()` + +Prints the topology of the systems (parent/child relation). + +`AddMeasure(measure)` + +Adds a measure to the system, to be calculated during the simulation. This +function must be called prior to solving so that the measure values through +time can be retrieved. + +`(istat,found,measure)=FindOrCreateInternalMeasure( MeasureType)` + +Extracts an existing global measure on the system. Supported measure types +are: E_Energy, E_PotentialEnergy, E_ElasticEnergy, E_KineticEnergy, and +E_Time. + +### Derived Cclasses + +None diff --git a/2025R2/rigid-bd-25-r2/table.md b/2025R2/rigid-bd-25-r2/table.md new file mode 100644 index 0000000000..0837b00913 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/table.md @@ -0,0 +1,25 @@ +# Table + +A table is the base class for Points Tables, Polynomial Tables, User Tables, +and GIL Tables. + +ID table: `CS_Table` + +### Members + +None + +### Member functions + +`Evaluate(In, Out)` + +Allows evaluating a table in Python. In and Out are arrays of float, with +sizes corresponding to the table input and output sizes. This function can be +called from a user table for example. + +`Dispose()` + +Explicit destruction of the table. This explicit destructor should be used +only when the table hasn't been assigned to an actuator. When the table is +assigned to an actuator, the actuator is calling this destructor. Omitting to +call this destructor can cause the evaluation of the results to fail. diff --git a/2025R2/rigid-bd-25-r2/toc.yml b/2025R2/rigid-bd-25-r2/toc.yml new file mode 100644 index 0000000000..5982405ae8 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/toc.yml @@ -0,0 +1,90 @@ +- name: Introduction + href: intro.md +- name: IronPython references + href: iron-python-references.md +- name: The Rigid Dynamics object model + href: rbd-object-model.md +- name: Rigid Dynamics command objects library + href: rbd-command-library.md + items: + - name: Actuator + href: actuator.md + - name: Basis + href: basis.md + - name: Body + href: body.md + - name: BodyCoordinateSystem + href: bodycoordinatesystem.md + - name: BodyLoad + href: bodyload.md + - name: CMSBody + href: cmsbody.md + - name: Condition + href: condition.md + - name: Contact + href: contact.md + - name: ContactDebugMask + href: contactdebugmask.md + - name: ContactOptions + href: contactoptions.md + - name: Driver + href: driver.md + - name: Enviroment + href: environment.md + - name: FlexibleBody + href: flexiblebody.md + - name: GILTable + href: giltable.md + - name: Joint + href: joint.md + - name: JointDOFLoad + href: jointdofload.md + - name: Load + href: load.md + - name: Measure + href: measure.md + - name: MSolverDB + href: msolverdb.md + - name: PointsTable + href: pointstable.md + - name: PolynomialTable + href: polynomialtable.md + - name: Relation + href: relation.md + - name: SolverOptions + href: solveroptions.md + - name: Spring + href: spring.md + - name: System + href: system.md + - name: Table + href: table.md + - name: UserTable + href: usertable.md + - name: Variable + href: variable.md +- name: Command use examples + href: command-use.md + items: + - name: Constraint equation + href: constraint-equation.md + - name: Joint condition - initial velocity + href: jc-initial-velocity.md + - name: Joint condition - control using linear feedback + href: jc-linear-feedback.md + - name: Non-linear spring damper + href: non-linear-spring.md + - name: Spherical stop + href: spherical-stop.md + - name: Export of joint forces + href: export-joint-forces.md + - name: Breakable joint + href: breakable-joint.md +- name: Debugging RBD commands with Visual Studio + href: debugging-vs.md +- name: Using RBD commands with Excel + href: using-commands-excel.md +- name: Using RBD commands from the IronPython console + href: using-commands-console.md +- name: Changelog + href: changelog.md diff --git a/2025R2/rigid-bd-25-r2/usertable.md b/2025R2/rigid-bd-25-r2/usertable.md new file mode 100644 index 0000000000..6740aec3b0 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/usertable.md @@ -0,0 +1,31 @@ +# UserTable + +A user table is a function with `i` input values and `o` output values, with +an evaluator that is defined in IronPython, allowing complex variation, or +even evaluation performed outside the solver. + +Example: + + LeftVarCoefX = CS_Variable(); + + # input 0,1,2 of the variable + LeftVarCoefX.AddInputMeasure( LeftRelTrans ) + + # input 3 to 8 of the variable + LeftVarCoefX.AddInputMeasure( LeftRelVelo ) + + class XForceTable(CS_UserTable): + def __init__(self,sizeIn,sizeOut): + CS_UserTable.__init__(self,sizeIn,sizeOut) + + def Evaluate(self,In,Out): + TX = In[0] + VX = In[3] + + Force = 1000.0*TX + Out[0] = Force + print 'ForceX = {0:e}'.format(Out[0]) + return 0 + + LeftForceTableX = XForceTable( 9, 1 ) + LeftVarCoefX.SetTable( LeftForceTableX ) diff --git a/2025R2/rigid-bd-25-r2/using-commands-console.md b/2025R2/rigid-bd-25-r2/using-commands-console.md new file mode 100644 index 0000000000..f7ac47149d --- /dev/null +++ b/2025R2/rigid-bd-25-r2/using-commands-console.md @@ -0,0 +1,59 @@ +# Using RBD commands from the IronPython console + +It is possible to use any RBD commands you would use during a +simulation from the IronPython console, outside of the simulation environment. +The following command snippets and instructions provide a demonstration of +this capability: + +You can access the IronPython console by clicking the File > Scripting > Open +Command Window menu item. + +The following code snippets load the RBD command module into IronPython: + + import clr + import os + import Ansys + import sys + + clr.AddReference('Ans.Utilities') + ver=Ansys.Utilities.ApplicationConfiguration.DefaultConfiguration.VersionInfo.VersionString + + awp_root=os.getenv('AWP_ROOT'+ver) + sys.path.Add(awp_root+r'\aisol\bin\winx64') + clr.AddReference('Ans.MotionSolver.MSolverLib.CSMotion') + + from Ans.MotionSolver.MSolverLib.CSMotion import * + +You can read an already-solved rigid body dynamics model using the following +code: + + dbIn=CS_MSolverDB() + dbIn.SetFileName(GetProjectDirectory()+'/TestRestart_files/dp0/SYS/MECH/file.mbd') + dbIn.OpenDataBase(0) + dbIn.ReadDB() + dbIn.Dispose() + +The environment and system objects are accessed in the following way: + + environment=CS_Environment.GetDefault() + system=environment.System + +It is now possible to alter properties of the simulation. For example, you +could modify the end time and restart from 0.5 s: + + environment.AlterSimulationEndTime(2.0) + environment.RestartTime=0.5 + environment.Solve() + +Once you have made your changes, make use the following code snippet to save +the modified database: + + dbOut=CS_MSolverDB() + dbOut.SetFileName(GetProjectDirectory()+'/TestRestart_files/dp0/SYS/MECH/file.mbd') + dbOut.OpenDataBase(1) + dbOut.WriteDB() + dbOut.Dispose() + +**Note** +You cannot restart a Rigid Dynamics analysis using this procedure if the model +has contact or a Point On Curve joint, or if there are multiple load steps. diff --git a/2025R2/rigid-bd-25-r2/using-commands-excel.md b/2025R2/rigid-bd-25-r2/using-commands-excel.md new file mode 100644 index 0000000000..f200c852ea --- /dev/null +++ b/2025R2/rigid-bd-25-r2/using-commands-excel.md @@ -0,0 +1,73 @@ +# Using RBD commands with Excel + +It is possible to call Microsoft Office Excel from an RBD command to read and +write data to and from Excel. If Excel is available, RBD will automatically +detect and load the Excel interopt. If Excel is detected, the solver output +will contain the following lines at the beginning. + + Processing Python commands + import base modules and macros + Microsoft.Office.Interop.Excel is loaded + Ans.Customize.Misc interop is not available + ready to process commands + +The Excel application is initiated using: + + excel=Microsoft.Office.Interop.Excel.ApplicationClass() + excel.Visible=True + excel.DisplayAlerts=False + +Use the following line to open an Excel file: + + workbook=excel.Workbooks.Open(r"E:\RBD\MODELS\COMMANDES\EXCEL\Excel_v160_files\Velocity.xlsx") + ws=workbook.Worksheets[1] + +To read data from the current worksheet, use the following: + + xlrange = ws.Range["A2", "B66"] + values=xlrange.Value2 + +Before using the values in an RBD script, it may be necessary to convert them +to real values: + + realValues=System.Array.CreateInstance(float,2,values.GetLength(0)) + for i in range(0,values.GetLength(0)): + print '{0:e} {1:e}'.format(values[i,0],values[i,1]) + realValues[0,i]=values[i,0].real + realValues[1,i]=values[i,1].real + +Similarly, it is possible to write values to the current worksheet. The +following sequence of commands shows how to create a new worksheet and write +the joint force in the new worksheet: + + # retrieve joint force measure + force=joint.GetForce() + + # obtain time values for this measure + values=force.FillValuesThroughTime() + + # create a new worksheet + ws2=workbook.Worksheets.Add() + ws2.Name='Reaction forces' + + len=values.GetLength(0) + + cell=ws2.Range["A1"] + cell.Value2='Time' + cell=ws2.Range["B1"] + cell.Value2='Fx' + cell=ws2.Range["C1"] + cell.Value2='Fy' + cell=ws2.Range["D1"] + cell.Value2='Fz' + cell=ws2.Range["E1"] + cell.Value2='Mx' + cell=ws2.Range["F1"] + cell.Value2='My' + cell=ws2.Range["G1"] + cell.Value2='Mz' + + # put values into the new worksheet + end="G"+str(1+len) + cells=ws2.Range("A2",end) + cells.Value2=values diff --git a/2025R2/rigid-bd-25-r2/variable.md b/2025R2/rigid-bd-25-r2/variable.md new file mode 100644 index 0000000000..f83d024d63 --- /dev/null +++ b/2025R2/rigid-bd-25-r2/variable.md @@ -0,0 +1,56 @@ +# Variable + +A variable is an n-dimensional vector quantity that varies over time. It is +used to define the variation of a load or a joint condition, or to express the +coefficients in a relation between degrees of freedom. For convenience, the +solver allows the creation of constant variables, where only the value of the +constant has to be provided. More complex variables can be built using a +function variable. A function variable is a function of input, where input is +given by a [measure](measure.md) and function is +described by a table. In some cases, you are able to replace the table or the +measure of an internal variable as used in a joint condition. + +ID table: `CS_Variable` + +### Members + +None + +### Member functions + +`SetConstantValues(value)` + +`value` is an array, whose size is equal to the size of the table. To create a +constant scalar variable, the value can be defined as shown in the following +example: + +`value = System.Array[float]([1.0])` + +`System`, `Array`, and `float` are part of the Python language. The result of +this is an array of size one, containing the value 1.0. + +`AddInputMeasure(measure)` + +`measure` is a measure object. The same variable can have more than one +measure. The input variable of the variable is formed by the values of the +input measure in the order that they have been added to the list of input +measures. + +`SetTable(table)` + +`table` is a CS_PointsTable. + +`SetFunc(string, is_degree)` + +`string` is similar to the expression used in the user interface to define a +joint condition by a function. Note that the literal variable is always called +"time", even if you are using another measure as input. "is_degree" is a +boolean argument. If the expression uses a trigonometric function, it +specifies that the input variable should be expressed in degrees. + +**Note** +Variables cannot be shared by different actuators. + +### Derived classes + +`ConstantVariable`