# How to plot: Max. shear stress

**URL:** <https://forum.itascainternational.com/t/how-to-plot-max-shear-stress/1024>\
**Category:** 3DEC\
**Tags:** suggestions\
**Created:** [May 6, 2023, 2:25pm UTC](https://forum.itascainternational.com/t/how-to-plot-max-shear-stress/1024 "2023-05-06T14:25:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![VijayKiranKota](https://avatars.discourse-cdn.com/v4/letter/v/c4cdca/32.png) [@VijayKiranKota](https://forum.itascainternational.com/u/VijayKiranKota)\
**Post date:** [May 6, 2023, 2:25pm UTC](https://forum.itascainternational.com/t/how-to-plot-max-shear-stress/1024/1 "2023-05-06T14:25:40Z")

</div>

How can I generate a plot of the maximum shear stress using plot blocks in 3DEC v5.2, similar to the way displacement contours or maximum principal stress plots are created?

Max. shear stress = Max of (|sig1 - sig2|, |sig2 - sig3|, |sig3 - sig1|) / 2

![image](https://canada1.discourse-cdn.com/flex031/uploads/itasca/original/1X/548f75c1af3c6554b498e18e1fa8741fae7c371c.png)

---

<div class="post-metadata">

**Author:** ![jhazzard](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jhazzard](https://forum.itascainternational.com/u/jhazzard)\
**Post date:** [May 7, 2023, 7:09pm UTC](https://forum.itascainternational.com/t/how-to-plot-max-shear-stress/1024/2 "2023-05-07T19:09:52Z")

</div>

This is built in to version 7. In 5.2, you could calculate for each zone and store as an extra variable and plot that.

---

<div class="post-metadata">

**Author:** ![VijayKiranKota](https://avatars.discourse-cdn.com/v4/letter/v/c4cdca/32.png) [@VijayKiranKota](https://forum.itascainternational.com/u/VijayKiranKota)\
**Post date:** [May 7, 2023, 8:15pm UTC](https://forum.itascainternational.com/t/how-to-plot-max-shear-stress/1024/3 "2023-05-07T20:15:47Z")

</div>

Alright. Thanks for your prompt reply @jhazzard.

---

<div class="post-metadata">

**Author:** ![VijayKiranKota](https://avatars.discourse-cdn.com/v4/letter/v/c4cdca/32.png) [@VijayKiranKota](https://forum.itascainternational.com/u/VijayKiranKota)\
**Post date:** [May 9, 2023, 9:30pm UTC](https://forum.itascainternational.com/t/how-to-plot-max-shear-stress/1024/4 "2023-05-09T21:30:03Z")

</div>

Hi @jhazzard and 3DEC Team,  
I would like to follow up on my previous message and share the code I have written to store the maximum shear stress values in the vertex extra. Unfortunately, the calculated values do not match the expected results. I kindly request your assistance in verifying the code for any potential issues.  
Many thanks,  
Vijay Kiran Kota

Here is the code:

_ **Function to extrapolate zone stresses to gridpoint extra variable** _  
_Vertex extra 1: Maximum principal stress, s1 (positive compression)_  
_Vertex extra 2: Intermediate principal stress, s2 (positive compression)_  
_Vertex extra 3: Minimum principal stress, s3 (positive compression)_  
_Vertex extra 4: Maximum Shear Stress, Max. SS (positive compression)_

```
def plot_stress *; first initialize to 0*
local bi = block_head
loop while bi # 0
  local gpi = b_gp(bi)
  loop while gpi # 0
    gp_extra(gpi,1) = 0.0 ; s1
    gp_extra(gpi,2) = 0.0 ; s2                                      
    gp_extra(gpi,3) = 0.0 ; s3
    gp_extra(gpi,4) = 0.0 ; MaxSS
    gpi = gp_next(gpi)
   end_loop
   bi = b_next(bi)
   end_loop

  ; Calculation of Max. shear stress
        
  local Max_SS = zdiff1
  if zdiff2 > Max_SS then
  Max_SS = zdiff2
  end_if
  if zdiff3 > Max_SS then
  Max_SS = zdiff3
  end_if

    loop local zgp (1,4)
    gpi = z_gp(zi,zgp)
    gp_extra(gpi,1) = gp_extra(gpi,1) + zs1
    gp_extra(gpi,2) = gp_extra(gpi,2) + zs2 		    	  
    gp_extra(gpi,3) = gp_extra(gpi,3) + zs3
    gp_extra(gpi,4) = gp_extra(gpi,4) + Max_SS
  end_loop
  zi = z_next(zi)
end_loop
bi = b_next(bi) 
end_loop
end 
@plot_stress

```

---

<div class="post-metadata">

**Author:** ![msepu](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@msepu](https://forum.itascainternational.com/u/msepu)\
**Post date:** [May 10, 2023, 1:00pm UTC](https://forum.itascainternational.com/t/how-to-plot-max-shear-stress/1024/5 "2023-05-10T13:00:41Z")

</div>

Hello Vijay,

i can see in your code that you did a loop through blocks and gps to set gp\_extra to zero and you closed that loop after that…  
Then you define some variable to store de stress differences but you never did the operation to give those variables a numeric value… also you are doing a loop throug a zone gridpoint, but you never define the zone pointer “Zi”, i suggest you to check those things.  
Regards
