Skip to content

Commit e5e6744

Browse files
Merge pull request #78 from ccaprani/master
Added principal major and minor stress outputs & docs
2 parents 4166d18 + 77f534d commit e5e6744

File tree

4 files changed

+155
-26
lines changed

4 files changed

+155
-26
lines changed
84.9 KB
Loading
85.6 KB
Loading

docs/source/rst/post.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,16 @@ Shear Stress (:math:`\sigma_{zxy}`)
332332

333333
.. automethod:: sectionproperties.analysis.cross_section.StressPost.plot_vector_zxy
334334
:noindex:
335+
336+
Major Principal Stress (:math:`\sigma_{1}`)
337+
""""""""""""""""""""""""""""""""""""
338+
.. automethod:: sectionproperties.analysis.cross_section.StressPost.plot_stress_1
339+
:noindex:
340+
341+
Minor Principal Stress (:math:`\sigma_{2}`)
342+
""""""""""""""""""""""""""""""""""""
343+
.. automethod:: sectionproperties.analysis.cross_section.StressPost.plot_stress_2
344+
:noindex:
335345

336346
von Mises Stress (:math:`\sigma_{vM}`)
337347
"""""""""""""""""""""""""""""""""""""""

sectionproperties/analysis/cross_section.py

100755100644
Lines changed: 145 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,6 +2615,8 @@ def get_stress(self):
26152615
* *'sig_zy'*: *y*-component of the shear stress :math:`\sigma_{zy}` resulting from all
26162616
actions
26172617
* *'sig_zxy'*: Resultant shear stress :math:`\sigma_{zxy}` resulting from all actions
2618+
* *'sig_1'*: Major principal stress :math:`\sigma_{1}` resulting from all actions
2619+
* *'sig_2'*: Minor principal stress :math:`\sigma_{2}` resulting from all actions
26182620
* *'sig_vm'*: von Mises stress :math:`\sigma_{vM}` resulting from all actions
26192621
26202622
The following example returns the normal stress within a 150x90x12 UA section resulting
@@ -2642,32 +2644,36 @@ def get_stress(self):
26422644
stress = []
26432645

26442646
for group in self.material_groups:
2645-
stress.append({
2646-
'Material': group.material.name,
2647-
'sig_zz_n': group.stress_result.sig_zz_n,
2648-
'sig_zz_mxx': group.stress_result.sig_zz_mxx,
2649-
'sig_zz_myy': group.stress_result.sig_zz_myy,
2650-
'sig_zz_m11': group.stress_result.sig_zz_m11,
2651-
'sig_zz_m22': group.stress_result.sig_zz_m22,
2652-
'sig_zz_m': group.stress_result.sig_zz_m,
2653-
'sig_zx_mzz': group.stress_result.sig_zx_mzz,
2654-
'sig_zy_mzz': group.stress_result.sig_zy_mzz,
2655-
'sig_zxy_mzz': group.stress_result.sig_zxy_mzz,
2656-
'sig_zx_vx': group.stress_result.sig_zx_vx,
2657-
'sig_zy_vx': group.stress_result.sig_zy_vx,
2658-
'sig_zxy_vx': group.stress_result.sig_zxy_vx,
2659-
'sig_zx_vy': group.stress_result.sig_zx_vy,
2660-
'sig_zy_vy': group.stress_result.sig_zy_vy,
2661-
'sig_zxy_vy': group.stress_result.sig_zxy_vy,
2662-
'sig_zx_v': group.stress_result.sig_zx_v,
2663-
'sig_zy_v': group.stress_result.sig_zy_v,
2664-
'sig_zxy_v': group.stress_result.sig_zxy_v,
2665-
'sig_zz': group.stress_result.sig_zz,
2666-
'sig_zx': group.stress_result.sig_zx,
2667-
'sig_zy': group.stress_result.sig_zy,
2668-
'sig_zxy': group.stress_result.sig_zxy,
2669-
'sig_vm': group.stress_result.sig_vm
2670-
})
2647+
stress.append(
2648+
{
2649+
"Material": group.material.name,
2650+
"sig_zz_n": group.stress_result.sig_zz_n,
2651+
"sig_zz_mxx": group.stress_result.sig_zz_mxx,
2652+
"sig_zz_myy": group.stress_result.sig_zz_myy,
2653+
"sig_zz_m11": group.stress_result.sig_zz_m11,
2654+
"sig_zz_m22": group.stress_result.sig_zz_m22,
2655+
"sig_zz_m": group.stress_result.sig_zz_m,
2656+
"sig_zx_mzz": group.stress_result.sig_zx_mzz,
2657+
"sig_zy_mzz": group.stress_result.sig_zy_mzz,
2658+
"sig_zxy_mzz": group.stress_result.sig_zxy_mzz,
2659+
"sig_zx_vx": group.stress_result.sig_zx_vx,
2660+
"sig_zy_vx": group.stress_result.sig_zy_vx,
2661+
"sig_zxy_vx": group.stress_result.sig_zxy_vx,
2662+
"sig_zx_vy": group.stress_result.sig_zx_vy,
2663+
"sig_zy_vy": group.stress_result.sig_zy_vy,
2664+
"sig_zxy_vy": group.stress_result.sig_zxy_vy,
2665+
"sig_zx_v": group.stress_result.sig_zx_v,
2666+
"sig_zy_v": group.stress_result.sig_zy_v,
2667+
"sig_zxy_v": group.stress_result.sig_zxy_v,
2668+
"sig_zz": group.stress_result.sig_zz,
2669+
"sig_zx": group.stress_result.sig_zx,
2670+
"sig_zy": group.stress_result.sig_zy,
2671+
"sig_zxy": group.stress_result.sig_zxy,
2672+
"sig_1": group.stress_result.sig_1,
2673+
"sig_2": group.stress_result.sig_2,
2674+
"sig_vm": group.stress_result.sig_vm,
2675+
}
2676+
)
26712677

26722678
return stress
26732679

@@ -3802,6 +3808,111 @@ def plot_vector_zxy(self, pause=True):
38023808

38033809
return self.plot_stress_vector(sigxs, sigys, title, pause)
38043810

3811+
def plot_stress_1(self, pause=True):
3812+
"""Produces a contour plot of the Major principal stress :math:`\sigma_{1}` resulting from all
3813+
actions.
3814+
3815+
:param bool pause: If set to true, the figure pauses the script until the window is closed.
3816+
If set to false, the script continues immediately after the window is rendered.
3817+
3818+
:return: Matplotlib figure and axes objects (fig, ax)
3819+
:rtype: (:class:`matplotlib.figure.Figure`, :class:`matplotlib.axes`)
3820+
3821+
The following example plots a contour of the Major principal stress within a 150x90x12 UA section
3822+
resulting from the following actions:
3823+
3824+
* :math:`N = 50` kN
3825+
* :math:`M_{xx} = -5` kN.m
3826+
* :math:`M_{22} = 2.5` kN.m
3827+
* :math:`M_{zz} = 1.5` kN.m
3828+
* :math:`V_{x} = 10` kN
3829+
* :math:`V_{y} = 5` kN
3830+
3831+
::
3832+
3833+
import sectionproperties.pre.sections as sections
3834+
from sectionproperties.analysis.cross_section import CrossSection
3835+
3836+
geometry = sections.AngleSection(d=150, b=90, t=12, r_r=10, r_t=5, n_r=8)
3837+
mesh = geometry.create_mesh(mesh_sizes=[2.5])
3838+
section = CrossSection(geometry, mesh)
3839+
3840+
section.calculate_geometric_properties()
3841+
section.calculate_warping_properties()
3842+
stress_post = section.calculate_stress(
3843+
N=50e3, Mxx=-5e6, M22=2.5e6, Mzz=0.5e6, Vx=10e3, Vy=5e3
3844+
)
3845+
3846+
stress_post.plot_stress_1()
3847+
3848+
.. figure:: ../images/stress/stress_1.png
3849+
:align: center
3850+
:scale: 75 %
3851+
3852+
Contour plot of the Major Principal stress.
3853+
"""
3854+
3855+
title = 'Stress Contour Plot - $\sigma_{1}$'
3856+
sigs = []
3857+
3858+
for group in self.material_groups:
3859+
sigs.append(group.stress_result.sig_1)
3860+
3861+
return self.plot_stress_contour(sigs, title, pause)
3862+
3863+
def plot_stress_2(self, pause=True):
3864+
"""Produces a contour plot of the Minor principal stress :math:`\sigma_{2}` resulting from all
3865+
actions.
3866+
3867+
:param bool pause: If set to true, the figure pauses the script until the window is closed.
3868+
If set to false, the script continues immediately after the window is rendered.
3869+
3870+
:return: Matplotlib figure and axes objects (fig, ax)
3871+
:rtype: (:class:`matplotlib.figure.Figure`, :class:`matplotlib.axes`)
3872+
3873+
The following example plots a contour of the Minor principal stress within a 150x90x12 UA section
3874+
resulting from the following actions:
3875+
3876+
* :math:`N = 50` kN
3877+
* :math:`M_{xx} = -5` kN.m
3878+
* :math:`M_{22} = 2.5` kN.m
3879+
* :math:`M_{zz} = 1.5` kN.m
3880+
* :math:`V_{x} = 10` kN
3881+
* :math:`V_{y} = 5` kN
3882+
3883+
::
3884+
3885+
import sectionproperties.pre.sections as sections
3886+
from sectionproperties.analysis.cross_section import CrossSection
3887+
3888+
geometry = sections.AngleSection(d=150, b=90, t=12, r_r=10, r_t=5, n_r=8)
3889+
mesh = geometry.create_mesh(mesh_sizes=[2.5])
3890+
section = CrossSection(geometry, mesh)
3891+
3892+
section.calculate_geometric_properties()
3893+
section.calculate_warping_properties()
3894+
stress_post = section.calculate_stress(
3895+
N=50e3, Mxx=-5e6, M22=2.5e6, Mzz=0.5e6, Vx=10e3, Vy=5e3
3896+
)
3897+
3898+
stress_post.plot_stress_2()
3899+
3900+
.. figure:: ../images/stress/stress_2.png
3901+
:align: center
3902+
:scale: 75 %
3903+
3904+
Contour plot of the Minor Principal stress.
3905+
"""
3906+
3907+
title = 'Stress Contour Plot - $\sigma_{2}$'
3908+
sigs = []
3909+
3910+
for group in self.material_groups:
3911+
sigs.append(group.stress_result.sig_2)
3912+
3913+
return self.plot_stress_contour(sigs, title, pause)
3914+
3915+
38053916
def plot_stress_vm(self, pause=True):
38063917
"""Produces a contour plot of the von Mises stress :math:`\sigma_{vM}` resulting from all
38073918
actions.
@@ -3962,6 +4073,10 @@ class StressResult:
39624073
:cvar sig_zxy: Combined resultant shear stress (:math:`\sigma_{zxy}`) resulting from all
39634074
actions
39644075
:vartype sig_zxy: :class:`numpy.ndarray`
4076+
:cvar sig_1: Major principal stress (:math:`\sigma_{1}`) resulting from all actions
4077+
:vartype sig_1: :class:`numpy.ndarray`
4078+
:cvar sig_2: Minor principal stress (:math:`\sigma_{2}`) resulting from all actions
4079+
:vartype sig_2: :class:`numpy.ndarray`
39654080
:cvar sig_vm: von Mises stress (:math:`\sigma_{VM}`) resulting from all actions
39664081
:vartype sig_vm: :class:`numpy.ndarray`
39674082
"""
@@ -3994,6 +4109,8 @@ def __init__(self, num_nodes):
39944109
self.sig_zx = np.zeros(num_nodes)
39954110
self.sig_zy = np.zeros(num_nodes)
39964111
self.sig_zxy = np.zeros(num_nodes)
4112+
self.sig_1 = np.zeros(num_nodes)
4113+
self.sig_2 = np.zeros(num_nodes)
39974114
self.sig_vm = np.zeros(num_nodes)
39984115

39994116
def calculate_combined_stresses(self):
@@ -4010,6 +4127,8 @@ def calculate_combined_stresses(self):
40104127
self.sig_zx = self.sig_zx_mzz + self.sig_zx_v
40114128
self.sig_zy = self.sig_zy_mzz + self.sig_zy_v
40124129
self.sig_zxy = (self.sig_zx ** 2 + self.sig_zy ** 2) ** 0.5
4130+
self.sig_1 = self.sig_zz / 2 + np.sqrt( (self.sig_zz / 2) ** 2 + self.sig_zxy ** 2)
4131+
self.sig_2 = self.sig_zz / 2 - np.sqrt( (self.sig_zz / 2) ** 2 + self.sig_zxy ** 2)
40134132
self.sig_vm = (self.sig_zz ** 2 + 3 * self.sig_zxy ** 2) ** 0.5
40144133

40154134

0 commit comments

Comments
 (0)