Get forces and moments from connection using APDL
Get forces and moments from connection using APDL
(OP)
Hi
Is it possible to extract force and moment reactions from contacts using APDL?
First I need to say that I'm new to APDL, and only have basic knowledge of other programming languages. Here's a more descriptive explanation of what I'm trying to achieve and what I've done so far (no final script, so have not tried to run anything).
We have models with bolts that are split and have bonded connections at desired cross sections. Normally we insert force and moment reaction probes for each connection, then make a plot and copy paste from this to Excel to process the data further. If possible we'd like to get these values using a command block to minimize the setup work and hopefully minimize the risk of possible errors in the extraction.
So far I've added a command block at each connection to get a meaningful definition to identify them. The code follows the following definition:
The definition is made up of three parts:
In the extraction command block (placed under solution) I define some parameter:
The I start to make the loops:
This is how far I've come so far. I don't know if this is the best way to make the extraction?
I haven't been able thought to find out how to get the values from the contacts using the *GET command. Reading through the manual hasn't helped me getting the answer.
Finally I'll of course also need a file creation (*CFOPEN) and write command (*VWRITE) to make the file to import the results in Excel, but I'm not quite there yet. I was guessing that I could make the script without and make a readout in the results of the command block to see, if I was getting the right results, before adding more to the script. Still need to figure out how to extract the reactions from the contacts though. Hoping someone can help with this. Preferably with a good explanation, as I'm having a hard time getting to know APDL, as I don't find it very intuitive.
I've got the book: Introduction to the ANSYS Parametric Design Language (APDL) but haven't found it too helpful in learning the language. Are there any good tutorials around for a beginner to start learning APDL?
Thanks in advance!
Is it possible to extract force and moment reactions from contacts using APDL?
First I need to say that I'm new to APDL, and only have basic knowledge of other programming languages. Here's a more descriptive explanation of what I'm trying to achieve and what I've done so far (no final script, so have not tried to run anything).
We have models with bolts that are split and have bonded connections at desired cross sections. Normally we insert force and moment reaction probes for each connection, then make a plot and copy paste from this to Excel to process the data further. If possible we'd like to get these values using a command block to minimize the setup work and hopefully minimize the risk of possible errors in the extraction.
So far I've added a command block at each connection to get a meaningful definition to identify them. The code follows the following definition:
CODE -->
BB_1_1 = _cid
The definition is made up of three parts:
- BB which indicates that it's a Bottom Bolt
- The first 1 is the bolt number
- The last 1 is the cross section number for that bolt
In the extraction command block (placed under solution) I define some parameter:
CODE -->
Prefix = 'BB_' ! Prefix used before numbers in command block @ connections NoB = 3 ! Number of bolts NoS = 3 ! Number of sections pr. bolt ExtS = 3 ! Time at which to do first extraction ExtF = 6 ! Time at which to do last extraction Increment = 1 ! Time increment between extraction points (will usually be 1) ! NAMING OF EXTRACTED LOAD CASES ! Named based on ExtS, Increment and ExtF with prefix LC. ! If ExtS = 3, Increment = 1 and ExtS = 6, then naming should LC3 = 'Load case 1' ! be LC3 = '', LC4 = '' ... LC6 = '' (name of load case LC4 = 'Load case 2' ! between ''). LC5 = 'Load case 3' LC6 = 'Load case 4'
The I start to make the loops:
CODE
*DO,i,ExtS,ExtF,Increment ! Loop for load cases
SET,NEAR, , , ,i, , , ! Sets the load step to read data from
LCNo = chrval(i) ! Current load step as character
LC = strcat('LC',LCNo) ! Current load case name
*DO,j,1,NoB ! Loop for each bolt
BNo = chrval(j) ! Current bolt number as character
BNoP = strcat(Prefix,BNo) ! Creates prefix for each individual bolt
*DO,k,1,NoS ! Loop for each section of current bolt
SNo = chrval(k) ! Bolt section as character
BS = strcat(BNoP,'_',SNo) ! Full bolt and section definition
*GET,Fx,BS ! Get value from connection This is how far I've come so far. I don't know if this is the best way to make the extraction?
I haven't been able thought to find out how to get the values from the contacts using the *GET command. Reading through the manual hasn't helped me getting the answer.
Finally I'll of course also need a file creation (*CFOPEN) and write command (*VWRITE) to make the file to import the results in Excel, but I'm not quite there yet. I was guessing that I could make the script without and make a readout in the results of the command block to see, if I was getting the right results, before adding more to the script. Still need to figure out how to extract the reactions from the contacts though. Hoping someone can help with this. Preferably with a good explanation, as I'm having a hard time getting to know APDL, as I don't find it very intuitive.
I've got the book: Introduction to the ANSYS Parametric Design Language (APDL) but haven't found it too helpful in learning the language. Are there any good tutorials around for a beginner to start learning APDL?
Thanks in advance!





RE: Get forces and moments from connection using APDL
Instead of BB_1_1 = _cid, use BB_1_1 = cid in your contact command snippets.
Your idea for your macro is forming nicely. In your /POST1 command snippet, use these commands:
FSUM
SPOINT
*GET, my_fx, fsum, 0, item, fx for force extraction.
A critical point to read up in FSUM is "the nodal force and moment contributions of the selected elements attached to the node set".
Kind regards,
Jason
RE: Get forces and moments from connection using APDL
Thanks for your guidance. I've had some time to look at things further, but am still having some trouble.
The underscore before cid was taken from a script that someone else have made, that does something similar to what I want. I haven't been able to find out if it makes a difference though, as I haven't been able to select the contact elements for further processing. I've found this site (Link) that tells about the APDL script equivalent to a contact reaction probe. Using ESEL to select the contact elements doesn't seem to work though. Everything seems to be working up to and including the last *DO statement, with a little adjustment, as it's apparently only possible to concatenate two strings with the STRCAT command. Hence, I've changed the last parameter definition to:
CODE -->
After this I've entered:
CODE -->
This just produces a warning saying: Specified range of 0 to 0 is not permitted. The ESEL command is ignored..
It seems to me like, the BS definition doesn't produce the right link to the definition made in the command blocks at the contacts. BS is correctly defined as equals BS_j_i. Looking through the Post Output I can't seem to find the BS parameter being redefined for each loop. Is some extra code needed for this to happen? The loops otherwise seem to work and values seem to be found for each "bolt section". Same values are found for each loop, as the ESEL command doesn't work.
To match moment reaction probes, I need to find the centroid as the summation point. I'm not sure how this is done. I found a reference to KSUM, but this is a pre-processing command, and doesn't work in my case. Unless I have to find the centroid coordinates in the command blocks at the connections. I've tried using ETABLE, but can't verify if this is a viable option, as the ESEL command doesn't select the desired elements. The commands if used so far are:
CODE -->
Once again thanks in advance.
RE: Get forces and moments from connection using APDL
It sounds like you're going down a different rabbit hole. Here's my thinking...
Command block at Contact Object to identify it.
CODE --> script
Command block at Solution to extract forces and moments.
CODE --> script
Kind regards,
Jason
RE: Get forces and moments from connection using APDL
I've got the command block at the contact.
I've tried simplifying my solution code, but am still unable to get the ESEL command to work. Keep getting the warning: Specified range of 0 to 0 is not permitted. The ESEL command is ignored.
I've even tried making a new command block only containing the code you've presented above. This gives the same warning.
Thanks for the code to get the centroid. I'll look further into this to understand it better. It seems very simple, but I hadn't stumbled upon those commands.
I'm going on holiday, but will look at the code (and hopefully and answer) when I get back.
Thanks for all your help so far.