Alternating Stress in ANSYS (Part 1: Principal Stress) : We Make Innovation Work
Alternating Stress in ANSYS (Part 1: Principal Stress) : We Make Innovation Work
Alternating Stress in ANSYS (Part 1: Principal Stress) : We Make Innovation Work
• Users may also ask for phase angle, φ associated with any result as follows:
• Calculating amplitudes and phases of solution quantities at nodes is a very fast and efficient
post-processing step.
We Make Innovation Work
www.padtinc.com
Harmonic Response Analysis: Amptlitude and Phase Response
• We’re going to focus on just the Full method in this discussion (although the same issue may
be extended to the mode-superposition case as well)
• So, ANSYS solves the equation below(15-67 from section 15 the MAPDL Theory Reference)...
• The complex results {u1}+i{u2} are stored in the result file for all result quantities, u. In other
words, a given result quantity will stored as a unique complex number at each node.
• After a run is complete, ANSYS calculates amplitudes according to the equations on slide 2.
But as we’ll see, certain complications appear to arise when calculating principal stress.
• In what follows, we
want to explore what
ANSYS might mean
by this in some detail
• Is the rule we
underlined in slide 2
being violated?
0 degrees S1 90 degrees S1
• A usual in situations like this, it’s helpful to go into MAPDL and have a look at the results file
directly. Let’s focus on our node of interest in WB (node number 2777)....
• One way to do this is to simply drag-and-drop a Mechanical APDL object from the toolbox
onto the setup cell of the harmonic analysis in the Project Schematic.
• Make sure to update both cells. Then right-click on the new Mechanical APDL Analysis cell
• Now, we want to review the stress results at the first stored frequency (set,,1, or 727.86 Hz)
• With the MAPDL gui: General Postproc->Read Results->By Time/Freq as shown below
• Summarizing these findings in a spreadsheet: We input all the component and principal
stress values as output in MAPDL, but the spreadsheet is calculating its own amplitudes
according to sqrt(Re(s1)^2+Im(s1)^2)
• The goal is to compare our amplitudes with what ANSYS is calculating
Spreadsheet estimates
match ANSYS
Spreadsheet estimates
DON’Tmatch ANSYS
• To begin a lengthy discussion, we’ll fast-forward and show you where we think the larger amplitudes
come from
• s2 amplitude remains unchanged (sort of)
Max Principal stress amplitude Middle Principal stress amplitude Minimum Principal stress amplitude
We Make Innovation Work *that’s actually NOT the procedure ANSYS is using. But we’re arguing it comes out the same
www.padtinc.com
Harmonic Response Analysis: A Problem with Principal Stress Amplitude
• But here, σ is the full complex stress tensor (or at least it should be), and ei are the corresponding
three column eigenvectors
𝝈𝝈 = 𝝈𝝈𝑅𝑅 + 𝒊𝒊 𝝈𝝈𝐼𝐼 (II)
where 𝝈𝝈𝑅𝑅 = Re(𝛔𝛔)
𝝈𝝈𝑰𝑰 = Im(𝛔𝛔)
• Fortunately, σR and σI are uncontroversial (our problem doesn’t lie there) and helpfully stored for us on
the result file. For node 2777, we’ve already obtained these components on slide 12
• We’re going to calculate the eigenstresses (I) ourselves –outside of ANSYS.
• Users can do this without too much trouble in a spreadsheet, using Cardano’s method or Vieta’s
substitution (see https://en.wikipedia.org/wiki/Cubic_equation )
• However, it’s even simpler in numerical software such as MATLAB, NumPy, or Mathematica. We’ll use
the latter
We Make Innovation Work
www.padtinc.com
Harmonic Response Analysis: Principal Stress as Eigenvalues
• Writing the full the complex stress tensor (II) for the real and imaginary stress components at node
2777 in Mathematica (using MPa units now) yields:
σ=
𝜆𝜆1 𝜎𝜎1
𝜆𝜆2 = = 𝜎𝜎2
𝜆𝜆3 𝜎𝜎3
• So, just solving the eigensystem (I) outside of ANSYS seems to verify the MAPDL amplitude result and
the Workbench “maximum over phase” result!
• This certainly is progress!
• But look carefully. Mathematica has reached this result with a different sorting scheme for the
eigenvalues than we appear to be using in ANSYS. It is a common mathematical convention to sort
eigenvalues by descending magnitude
ANSYS (MAPDL) principal stress values (MPa) principal stress values calculated in Mathematica (MPa)
• What’s happening here is that ANSYS is instead using the usual engineering convention to sort
principal stress components (real and imaginary values). Recall from your Solid Mechanics texts that
principal stresses are sorted according to numeric value (most tensile –or positive –to least)
• But when dealing with complex (oscillating) principal stresses, this leads to incorrect results!
• First, let’s state the convention clearly to see what’s wrong with it:
Principal stress are defined as the eigenstress values, sorted from most tensile to least, or
σ1>σ2>σ3
• The problem is that if we follow this convention meant for static systems (note that no mention of real
or imaginary values is made) with the complex components, we can’t ensure that the amplitudes also
follow the same convention --which is precisely what we’re seeing in the previous slide. But that last
condition is what we want for oscillating stresses
• So, it appears that in Workbench, when we plot principal stress by ‘set’ or ‘frequency’ set to ‘yes’ (see
slide 15), we’re getting the amplitude of the pre-sorted (according to the convention above) principal
stress components –only now sorted by descending amplitude (this is why plotting s1 this way is
actually giving us the s3 amplitude)!
• Now, the previous slide states that this is incorrect. How so?
• Well, the s1 and s3 solutions reported in this way are not eigenvalues of the complex stress tensor as
expressed by (I)!
• A quick way to show this is with the following check (ensuring the characteristic polynomial is zero):
det 𝑰𝑰 � 𝛌𝛌 = det
det 𝑰𝑰 � 𝛌𝛌 = det
• Now, the fact that one of the amplitude results has been disqualified (is not an actual solution) is a
good thing. We need to have one and only one unambiguous solution, and if we simply change the
convention articulated on slide 24, we have it.
• So, here’s the new principal stress convention (correct for oscillating systems) :
Principal stresses are defined as those eigenstresses which solve the eigensystem (I) and whose
magnitudes (amplitudes) are as follow: |σ1}>|σ2|>|σ3|
• But there’s a more immediate practical question: Can the ‘correct’ principal stress solution (according
to the convention above) always be recovered from the principal stresses found on the result file, or do
we have to calculate our own eigenstresses?
• We learned that the incorrect result followed from a mis-ordering of the principal stress components
according to a convention which only works in static situations. We fixed this simply by swapping the s1
and s3 imaginary components.
• Will it always be that easy*?
• Well, almost...
We Make Innovation Work *easy in the sense that we can easily obtain correct results in a macro
www.padtinc.com
Harmonic Response Analysis: Principal Stress as Eigenvalues
• If all we care about is the maximum principal stress, then the answer to the last question is “yes”.
• As we’ll see in a moment, we have a little more work to do if we care about ALL the principal stress values
• A simple fix for maximum principal stress (a macro) –one that at once reconciles the two methods of principal stress amplitude
evaluation, avoids re-calculating eigenstresses, AND avoids ‘sweeping’ to the find maximum values --involves simply re-ordering
the principal stress components of σ1 and σ3 (Re(σ1)>Re(σ3), Im(σ1)>Im(σ3)) such that their combined magnitude (|σ1| >|σ3|).
This is shown below for the example we’ve been using, and compared with the correct solution at right (the full complex
solution found externally)
• This swapping of the s1 and s3 values may be stated as an algorithm:
• Re(s1) = Max(wAbs(Re(s1)),wAbs(Re(s3))) and Im(s1)=Max(wAbs(Im(s1)),wAbs(Im(s3))) where wAbs is an absolute value
function which retains the sign of its argument (typically accomplished by tracking the index of the max element)
ANSYS principal stresses @ max. s1 node location in original ordering Typical eigenvalue solution of the complex stress tensor @ max s1
from left to right (descending value of components) node location, ordered correctly from left-to right (descending
amplitude magnitude)
1. 𝜎𝜎1 >0, 𝜎𝜎2 <0, 𝜎𝜎3 <0. (|σ2| may be >|σ1|. But |σ3|>|σ2|)
2. 𝜎𝜎1 >0, 𝜎𝜎2 >0, 𝜎𝜎3 >0. (|σ1|> |σ2|>|σ3|)
3. 𝜎𝜎1 >0, 𝜎𝜎2 >0, 𝜎𝜎3 <0. (|σ1|>|σ2|, but |σ3| may be >|σ1|)
4. 𝜎𝜎1 <0, 𝜎𝜎2 <0, 𝜎𝜎3 <0. (|σ3|> |σ2|>|σ1|)
• In the above, |σi| is the absolute value of the real and imaginary components –not necessarily the
entire complex eigenvalue (the implication being that sorting by absolute value of the components
is sufficient to guarantee a consistent sorting of the entire complex value)
• Thus, it’s clear that simply evaluating Re(σ1), Im(σ1)and Re(σ3), Im(σ3) is sufficient to ensure that the
algorithm outlined on the previous slide will always yield the maximum principal stress
We Make Innovation Work
www.padtinc.com
Harmonic Response Analysis: Principal Stress as Eigenvalues
• But this is NOT sufficient to guarantee that the s2 and s3 are the correct eigenstresses
• Reviewing the results of node 1 in the very same model shows that s2 and s3 aren’t right
after an S1/S3 swap
• Notice that |s3|>|s2|. This ordering violates both the static convention, and its
oscillatory counterpart
• But a similar comparison of s2 and d3 (and swap if necessary) will remedy this as well!
• Below, both the real and imaginary components s2 and s3 are swapped
• …and after the second swap |s1|>|s2|>|s3|.And this IS a solution of the eigensystem (I)
We Make Innovation Work
www.padtinc.com
Harmonic Response Analysis: Principal Stress as Eigenvalues
• For all the principal stresses to be correct, we have to re-order s1, s2, and s3 such that |s1|>|s2|>|s3|.
This can be achieved by sorting |Re(s1)|, |Re(s2)|,|Re(s3)|, and |Im(s1)|, |Im(s2)|, and |Im(s3)| in
descending order (and retaining their sign)
• Macros can be easily written to achieve this for a single nodal location
• There are only three values we must sort. This can be achieved by performing the swap operation twice
(ANSYS does not offer any functionality to efficiently sort rows of arrays)
• First swap s1 and s3 according to:
Re(s1) = Max(wAbs(Re(s1)),wAbs(Re(s3))) and Im(s1)=Max(wAbs(Im(s1)),wAbs(Im(s3)))
Re(s3) = Min(wAbs(Re(s1)),wAbs(Re(s3))) and Im(s3)=Min(wAbs(Im(s1)),wAbs(Im(s3)))
• Then swap s2 and s3 according to:
Re(s2) = Max(wAbs(Re(s2)),wAbs(Re(s3))) and Im(s2)=Max(wAbs(Im(s2)),wAbs(Im(s3)))
Re(s3) = Min(wAbs(Re(s2)),wAbs(Re(s3))) and Im(s3)=Min(wAbs(Im(s2)),wAbs(Im(s3)))
• Although simple in principle, the above algorithm can be somewhat cumbersome to write in APDL to
run efficiently for multiple nodal results (or an entire model). We therefore offer our own version to
readers as part of this blog article.
• mk_ps.mac: macro for sorting the principal stresses real and imaginary values such that the total
complex amplitudes |s1|>|s2|>|s3|. The sorted complex values are stored in the nx6 array “cps”.
The amplitude/phase counterpart of this array is called “aps”. In addition to the sorting, this macro
also calculates the maximum s1, s2, and s3 amplitudes for the currently active node set
• mk_harmpost.mac: macro loops through harmonic response frequencies, invokes the macros
above, and writes out a comma delimited file summarizing the maximum principal stresses and von
Mises stress for active node set for all frequencies
• mk_ampcalc.mac: auxiliary macro for calculating amplitude/phase from a complex results
Example Usage
• The summary file is stored in the Solver Files Directory and get re-created
every time a new solution is run
Example Usage
• To provide another example of how these macros may be used, edit the Mechanical APDL
session created earlier (slides 12 -13. Right-click and ‘Edit in Mechanical APDL’ to launch a new
session)
• Cut and paste the following lines into the command window to prep the environment:
fini !exit current processor
/psearch,_wb_userfiles_dir(1) !search user files folder for macros
/post1 !switch processor to general post-processor
/graphics,full !use full graphics rendering
mk_ps,1 ! invoke mk_ps macro for the first substep (frequency) on the results file)
Example Usage
• If successful, this should create two arrays (masked by active node number): One called
‘cps’, containing the complex principal stresses, in order of descending amplitude from left
to right
• The other is called ‘aps’, which contain the same quantities, but in amplitude/phase form
• To see these, go the top menu, Parameters->Array Parameters->Define/Edit…