Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature timber sections #466

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

185 changes: 184 additions & 1 deletion docs/examples/geometry/section_library.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,189 @@
"print(f\"I_eff = {ei[0]:.3e} mm6\")\n",
"print(f\"I_rec = {(300 * 600**3 / 12):.3e} mm6\")"
]
},
{
"cell_type": "markdown",
"id": "37",
"metadata": {},
"source": [
"## Rectangular Concrete Section\n",
"\n",
"The following example calculates the geometric properties of a rectangular reinforced concrete section."
]
},
{
"cell_type": "markdown",
"id": "38",
"metadata": {},
"source": [
"### Import Modules\n",
"\n",
"We start by importing the [concrete_rectangular_section()](../../gen/sectionproperties.pre.library.concrete_sections.concrete_rectangular_section.rst#sectionproperties.pre.library.concrete_sections.concrete_rectangular_section) function from the section library, and the [Material()](../../gen/sectionproperties.pre.pre.Material.rst#sectionproperties.pre.pre.Material) object to define our timber material."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "39",
"metadata": {},
"outputs": [],
"source": [
"from sectionproperties.pre import Material"
]
},
{
"cell_type": "markdown",
"id": "40",
"metadata": {},
"source": [
"## Rectangular Timber CLT Section\n",
"\n",
"The following example calculates the geometric properties of a rectangular timber crosslaminated section."
]
},
{
"cell_type": "markdown",
"id": "41",
"metadata": {},
"source": [
"### Import Modules\n",
"\n",
"We start by importing the [timber_rectangular_section()](../../gen/sectionproperties.pre.library.timber_sections.timber_rectangular_section.rst#sectionproperties.pre.library.timber_sections.timber_rectangular_section) function from the section library, and the [Material()](../../gen/sectionproperties.pre.pre.Material.rst#sectionproperties.pre.pre.Material) object to define our timber material."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "42",
"metadata": {},
"outputs": [],
"source": [
"from sectionproperties.analysis import Section\n",
"from sectionproperties.pre import Material\n",
"from sectionproperties.pre.library import clt_rectangular_section"
]
},
{
"cell_type": "markdown",
"id": "43",
"metadata": {},
"source": [
"### Create Geometry\n",
"\n",
"Create a 120 deep by 1000 wide crosslaminated timber slab.\n",
"\n",
"The following material properties are used:\n",
"\n",
"**SPF-Timber - Parallel-to-grain**\n",
" \n",
"- Elastic modulus = 9500 MPa\n",
"- Poisson's ratio = 0.35\n",
"- Density = 4400 kg/m$^3$\n",
"- Yield Strengh = 5.5 MPa\n",
"\n",
"**SPF-Timber - Perpendicular-to-grain**\n",
" \n",
"- Elastic modulus = 317 MPa\n",
"- Poisson's ratio = 0.35\n",
"- Density = 4400 kg/m$^3$\n",
"- Yield Strengh = 5.5 MPa"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "44",
"metadata": {},
"outputs": [],
"source": [
"timber0 = Material(\n",
" name=\"Timber0\",\n",
" elastic_modulus=9.5e3,\n",
" poissons_ratio=0.35,\n",
" density=4.4e-7,\n",
" yield_strength=5.5,\n",
" color=\"burlywood\",\n",
")\n",
"\n",
"timber90 = Material(\n",
" name=\"Timber90\",\n",
" elastic_modulus=317,\n",
" poissons_ratio=0.35,\n",
" density=4.4e-7,\n",
" yield_strength=5.5,\n",
" color=\"orange\",\n",
")\n",
"\n",
"# create the geometry\n",
"geom = clt_rectangular_section(\n",
" d=[40, 40, 40], lay_orient=[timber0, timber90, timber0], b=1000\n",
")"
]
},
{
"cell_type": "markdown",
"id": "45",
"metadata": {},
"source": [
"### Create Mesh and ``Section`` object\n",
"\n",
"Create a mesh with a mesh size of 200 mm$^2$ and plot the mesh."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "46",
"metadata": {},
"outputs": [],
"source": [
"geom.create_mesh(mesh_sizes=[200])\n",
"sec = Section(geometry=geom)\n",
"sec.plot_mesh()"
]
},
{
"cell_type": "markdown",
"id": "47",
"metadata": {},
"source": [
"### Perform an Analysis\n",
"\n",
"We perform only a geometric analysis on the reinforced concrete section."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "48",
"metadata": {},
"outputs": [],
"source": [
"sec.calculate_geometric_properties()"
]
},
{
"cell_type": "markdown",
"id": "49",
"metadata": {},
"source": [
"### Calculate Gross Effective Moment of Inertia\n",
"\n",
"We can calculate the gross effective moment of inertia by obtaining the flexural rigidity ($\\sum E.I$) of the section and dividing it by the elastic modulus of the concrete. We compare this to the moment of inertia of a rectangular section of the same dimensions."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "50",
"metadata": {},
"outputs": [],
"source": [
"ei = sec.get_eic(e_ref=timber0)\n",
"print(f\"I_eff,x = {ei[0]:.3e} mm6\")\n",
"print(f\"I_eff,y = {ei[1]:.3e} mm6\")"
]
}
],
"metadata": {
Expand All @@ -471,7 +654,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.17"
"version": "3.12.8"
}
},
"nbformat": 4,
Expand Down
8 changes: 8 additions & 0 deletions docs/user_guide/geometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ Concrete Sections

.. _label-bridge-library:

Timber Section
""""""""""""""

.. autosummary::
:nosignatures:

~sectionproperties.pre.library.timber_sections.clt_rectangular_section

Bridge Sections
"""""""""""""""

Expand Down
1 change: 1 addition & 0 deletions src/sectionproperties/pre/library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@
tee_section,
zed_section,
)
from sectionproperties.pre.library.timber_sections import clt_rectangular_section
54 changes: 54 additions & 0 deletions src/sectionproperties/pre/library/timber_sections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""Timber sections library."""

from __future__ import annotations

import sectionproperties.pre.geometry as geometry
import sectionproperties.pre.library.primitive_sections as primitive_sections
import sectionproperties.pre.pre as pre


def clt_rectangular_section(
d: list[float], lay_orient: list[pre.Material], b: float
) -> geometry.CompoundGeometry:
"""Constructs a timber rectangular section.

Constructs a timber rectangular section of depth ``d`` and width ``b``.

.. note::

Args:
d: Timber layer section thickness
lay_orient: A list of materials for each layer defined by the user.
b: Timber section width

Raises:
ValueError: Geometry generation failed

Returns:
Timber rectangular section geometry

Example:
The following example creates a 120mm CLT cross-section.
"""
layer_geom = []
for idx in range(len(d)):
di = float(d[idx])
layer = lay_orient[idx]

timb_mat = layer

# create rectangular timber geometry
layer = primitive_sections.rectangular_section(d=di, b=b, material=timb_mat)
offset = -d[idx] * (idx + 1)
layer = layer.shift_section(y_offset=offset)

layer_geom.append(layer)

# create compound geometry
geom = geometry.CompoundGeometry(geoms=layer_geom)

if isinstance(geom, geometry.CompoundGeometry):
return geom
else:
msg = "Timber section generation failed."
raise ValueError(msg)
66 changes: 66 additions & 0 deletions tests/section_library/test_timber_sections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""Tests for the timber sections library."""

from __future__ import annotations

import pytest
import pytest_check as check

import sectionproperties.pre.library.timber_sections as ts
import sectionproperties.pre.pre as pre

r_tol = 1e-6


# material setup
@pytest.fixture
def get_materials() -> tuple[pre.Material, pre.Material]:
"""Creates a timber material parallel and perpendicular-to-grain.

Returns:
Material objects
"""
timb_mat0 = pre.Material(
name="Timber E0",
elastic_modulus=9.5e3,
poissons_ratio=0.35,
density=4.4e-7,
yield_strength=5.5,
color="burlywood",
)

timb_mat90 = pre.Material(
name="Timber90",
elastic_modulus=317,
poissons_ratio=0.35,
density=4.4e-7,
yield_strength=5.5,
color="orange",
)

return timb_mat0, timb_mat90


def test_timber_clt_rectangular_section(get_materials):
"""Tests the timber clt_rectangular_section() method."""
timber0, timber90 = get_materials

rect = ts.clt_rectangular_section(
d=[40, 40, 40], lay_orient=[timber0, timber90, timber0], b=1000
)

# check geometry is created correctly
timb0_area = 0
timb90_area = 0

for geom in rect.geoms:
if geom.material == timber0:
timb0_area += geom.calculate_area()
elif geom.material == timber90:
timb90_area += geom.calculate_area()

actual_timb0_area = 2 * 40 * 1000
actual_timb90_area = 40 * 1000

# check areas
check.almost_equal(timb0_area, actual_timb0_area)
check.almost_equal(timb90_area, actual_timb90_area)