# Rigid Body Dynamics Simulation Contact Force

adamkovacs1126
Member

in Structures

Hi everyone,

I need to extract normal forces on a given contact in order to measure friction between the two parts. The simulation works just fine but I could not find any probes for this type in Rigid Dynamics (only in Transient Structural but I cannot get my simulation work somehow in that one).

Do you have any idea where I could set this probe up?

Thanks very much in advance,

Kind regards,

Adam

## Comments

Adam,

Currently, you can retrieve just the normal contact force in Rigid Dynamics.

Most useful measures are pre-existing in the rigid dynamics model, and can be accessed using other object “get” functions.(See help document here for further details: Mechanical users guide >> Rigid Dynamic Analysis >> Command Reference for Rigid Dynamics Systems >> The Rigid Dynamics Object Model). In the above commands "OutputContactForce" measure is used. This measure only contains the normal force.

One can use Python scripting language in a commands object to retrieve contact forces in Rigid Dynamics. But I don't know if you are aware of how to do this?

Regards,

Sandeep

First, thanks very much for your answer. The normal forces are exactly what I need on the given surfaces to calculate friction!

I did some python programming in the past but I have not used it for ANSYS yet, could you guide me with where to look if I want to learn to retrieve these contact forces? I will also look at the document you mentioned.

Thanks in advance and kind regards,

Adam

Hi Adam,

You can insert a python command snippet as shown:

and under the analysis system:

use the following commands to get the forces:

Regards,

Sandeep

Best Practices to post on the Student Community

I get an error editing the above post to paste the code snippet, but here is the snapshot of unavailable line in the for loop:

Regards,

Sandeep

Best Practices to post on the Student Community

Hi Sandeep,

many thanks for the whole script!! I am going to try it and let you know of the results!

When you have some time, please could you explain these lines so I can understand the basic method behind this script?

Thanks again,

Kind regards,

Adam

Adam,

It is fairly straightforward, you are basically extracting the forces and moment from the Contact Object. Then opening a file and writing all the extracted forces at each time into that file.

There is an enhancement request to do this via the GUI but until then, this is the way around.

P.S: If a post answers your original question, please mark it as a solution (‘Is Solution') so that it might help someone in the future. This will help reduce repetitive questions and help provide better support on this Forum.

Regards,

Sandeep

Hi Sandeep,

I tried to do everything as you said and I get the following errors:

I tried to clear the solution and solve it again but I got the same error messages. Is there anything I did wrong?

These are the scripts that I wrote following yours:

Script 1

Script 2

Of course I will mark your answer as solution, I am just waiting for mine to work so the discussion can be closed

Thanks again and kind regards,

Adam

Write everything in 1 line inside the 'for' loop for the command starting with "fich.write"

Thanks Sandeep,

I did what you said and now there are indeed no warnings and everything is ticked. I also found the excel file containing all the contact forces divided into X, Y and Z component. Does that mean that the magnitude of the NORMAL contact force for a given time is: F = sqrt(FX^2 + FY^2 + FZ^2)?

Thank you again and kind regards,

Adam

Hi Adam, yes.

Hi Sandeep,

sorry to bother you again, can you confirm that these output forces are NORMAL and that they are shown in [N] in the Excel file? My unit set shows N in Mechanical but the Excel file doesn't indicate it.

Thanks and kind regards,

Adam

Adam,

As far as I can tell, you are dealing with a force vector here. The magnitude doesn't always mean it is normal, it just gives you the magnitude of that vector. If you want to calculate the normal, first you need to calculate the normal unit vector, then the dot product of these 2 vectors i.e., n.F will give you the normal vector. Please revisit vector calculus once if you get a chance?

We are not writing the units into Excel, but they should be consistent with the units in Mechanical as the base parameters the force is being calculated off is from mechanical.

Regards,

Sandeep

Hi Sandeep,

thanks very much for your answer, I guess I just misunderstood your previous comments when I thought that ANSYS only measures the normal component of the contact forces. Is there any easy way I can find the normal unit vector for the given contact force or should I just take two point vector probes on one of the rigid bodies for all time steps to calculate the angle of contact and from that the normal vector? As we are talking about rotation about one axis, we can handle the problem as 2D:

Thanks again and kind regards,

Adam