Skip to content

Commit 124fbd6

Browse files
Add example for mesh refinement
1 parent c8a8c66 commit 124fbd6

File tree

18 files changed

+380
-70
lines changed

18 files changed

+380
-70
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ about: Create a report to help us improve
88
A clear and concise description of what the bug is.
99

1010
**To Reproduce**
11-
Steps to reproduce the behavior:
11+
Steps to reproduce the behaviour:
1212
1. Go to '...'
1313
2. Click on '....'
1414
3. Scroll down to '....'
1515
4. See error
1616

17-
**Expected behavior**
17+
**Expected behaviour**
1818
A clear and concise description of what you expected to happen.
1919

2020
**Screenshots**
1.14 KB
Binary file not shown.

docs/build/doctrees/index.doctree

0 Bytes
Binary file not shown.
7.5 KB
Binary file not shown.
File renamed without changes.
31.4 KB
Loading

docs/build/html/_sources/index.rst.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
Documentation
1212
=============
1313

14-
*sectionproperties* is a python package for the analysis of arbitrary cross-sections
15-
using the finite element method written by Robbie van Leeuwen. *sectionproperties*
16-
can be used to determine section properties to be used in structural design and
17-
visualise cross-sectional stresses resulting from combinations of applied forces and
18-
bending moments.
14+
*sectionproperties* is a python package for the analysis of arbitrary cross-sections using the
15+
finite element method written by Robbie van Leeuwen. *sectionproperties* can be used to determine
16+
section properties to be used in structural design and visualise cross-sectional stresses resulting
17+
from combinations of applied forces and bending moments.
1918

2019
A list of the `current features of the package and implementation goals for future releases
2120
<https://github.com/robbievanleeuwen/section-properties/tree/master/README.md>`_

docs/build/html/_sources/rst/examples.rst.txt

Lines changed: 90 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -829,14 +829,17 @@ accuracy of the result compared with the time taken to obtain the solution::
829829

830830
Plot of the torsion constant as a function of the solution time.
831831

832-
Advanced Example
833-
----------------
832+
Advanced Examples
833+
-----------------
834834

835-
The following example demonstrates an example in which *sectionproperties* can
836-
be used for more academic purposes. In this example, the aspect ratio of a
837-
rectangular section is varied whilst keeping a constant cross-sectional area
838-
and the torsion constant calculated. The variation of the torsion constant with
839-
the aspect ratio is then plotted::
835+
The following examples demonstrates how *sectionproperties* can be used for more academic purposes.
836+
837+
Torsion Constant of a Rectangle
838+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
839+
840+
In this example, the aspect ratio of a rectangular section is varied whilst keeping a constant
841+
cross-sectional area and the torsion constant calculated. The variation of the torsion constant
842+
with the aspect ratio is then plotted::
840843

841844
import numpy as np
842845
import matplotlib.pyplot as plt
@@ -880,8 +883,87 @@ the aspect ratio is then plotted::
880883
ax.set_title("Rectangular Section Torsion Constant")
881884
plt.show()
882885

883-
.. figure:: ../images/examples/advanced.png
886+
.. figure:: ../images/examples/advanced1.png
884887
:align: center
885888
:scale: 75 %
886889

887890
Plot of the torsion constant as a function of the aspect ratio.
891+
892+
Mesh Refinement
893+
^^^^^^^^^^^^^^^
894+
895+
In this example the convergence of the torsion constant is investigated through an analysis of an
896+
I-section. The mesh is refined both by modifying the mesh size and by specifying the number of
897+
points making up the root radius. The figure below the example code shows that mesh refinement
898+
adjacent to the root radius is a far more efficient method in obtaining fast convergence when
899+
compared to reducing the mesh area size for the entire section::
900+
901+
import numpy as np
902+
import matplotlib.pyplot as plt
903+
import sectionproperties.pre.sections as sections
904+
from sectionproperties.analysis.cross_section import CrossSection
905+
906+
# define mesh sizes
907+
mesh_size_list = [50, 20, 10, 5, 3, 2, 1]
908+
nr_list = [4, 8, 12, 16, 20, 24, 32, 64]
909+
910+
# initialise result lists
911+
mesh_results = []
912+
mesh_elements = []
913+
nr_results = []
914+
nr_elements = []
915+
916+
# calculate reference solution
917+
geometry = sections.ISection(d=203, b=133, t_f=7.8, t_w=5.8, r=8.9, n_r=64)
918+
mesh = geometry.create_mesh(mesh_sizes=[0.5]) # create mesh
919+
section = CrossSection(geometry, mesh) # create a CrossSection object
920+
section.calculate_geometric_properties()
921+
section.calculate_warping_properties()
922+
j_reference = section.get_j() # get the torsion constant
923+
924+
# run through mesh_sizes with n_r = 16
925+
for mesh_size in mesh_size_list:
926+
geometry = sections.ISection(d=203, b=133, t_f=7.8, t_w=5.8, r=8.9, n_r=16)
927+
mesh = geometry.create_mesh(mesh_sizes=[mesh_size]) # create mesh
928+
section = CrossSection(geometry, mesh) # create a CrossSection object
929+
section.calculate_geometric_properties()
930+
section.calculate_warping_properties()
931+
932+
mesh_elements.append(len(section.elements))
933+
mesh_results.append(section.get_j())
934+
935+
# run through n_r with mesh_size = 3
936+
for n_r in nr_list:
937+
geometry = sections.ISection(d=203, b=133, t_f=7.8, t_w=5.8, r=8.9, n_r=n_r)
938+
mesh = geometry.create_mesh(mesh_sizes=[3]) # create mesh
939+
section = CrossSection(geometry, mesh) # create a CrossSection object
940+
section.calculate_geometric_properties()
941+
section.calculate_warping_properties()
942+
943+
nr_elements.append(len(section.elements))
944+
nr_results.append(section.get_j())
945+
946+
# convert results to a numpy array
947+
mesh_results = np.array(mesh_results)
948+
nr_results = np.array(nr_results)
949+
950+
# compute the error
951+
mesh_error_vals = (mesh_results - j_reference) / mesh_results * 100
952+
nr_error_vals = (nr_results - j_reference) / nr_results * 100
953+
954+
# plot the results
955+
(fig, ax) = plt.subplots()
956+
ax.loglog(mesh_elements, mesh_error_vals, 'kx-', label='Mesh Size Refinement')
957+
ax.loglog(nr_elements, nr_error_vals, 'rx-', label='Root Radius Refinement')
958+
plt.xlabel("Number of Elements")
959+
plt.ylabel("Torsion Constant Error [%]")
960+
plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))
961+
plt.tight_layout()
962+
plt.show()
963+
964+
.. figure:: ../images/examples/advanced2.png
965+
:align: center
966+
:scale: 75 %
967+
968+
Plot of the torsion constant error as a function of number of elements used in the analysis for
969+
both general mesh refinement and root radius refinement.

docs/build/html/index.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,10 @@
161161
<a class="reference internal image-reference" href="_images/logo.png"><img alt="sectionproperties" class="align-left" src="_images/logo.png" style="width: 100%;" /></a>
162162
<div class="section" id="documentation">
163163
<h1>Documentation<a class="headerlink" href="#documentation" title="Permalink to this headline"></a></h1>
164-
<p><em>sectionproperties</em> is a python package for the analysis of arbitrary cross-sections
165-
using the finite element method written by Robbie van Leeuwen. <em>sectionproperties</em>
166-
can be used to determine section properties to be used in structural design and
167-
visualise cross-sectional stresses resulting from combinations of applied forces and
168-
bending moments.</p>
164+
<p><em>sectionproperties</em> is a python package for the analysis of arbitrary cross-sections using the
165+
finite element method written by Robbie van Leeuwen. <em>sectionproperties</em> can be used to determine
166+
section properties to be used in structural design and visualise cross-sectional stresses resulting
167+
from combinations of applied forces and bending moments.</p>
169168
<p>A list of the <a class="reference external" href="https://github.com/robbievanleeuwen/section-properties/tree/master/README.md">current features of the package and implementation goals for future releases</a>
170169
can be found in the README file on github.</p>
171170
<div class="toctree-wrapper compound">

0 commit comments

Comments
 (0)