-
Notifications
You must be signed in to change notification settings - Fork 111
Add rectangular CLT section to (new) timber sections library #466
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
Merged
robbievanleeuwen
merged 14 commits into
robbievanleeuwen:master
from
jchkoch:feature-timber-sections
Mar 17, 2025
Merged
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
10bbcbf
add new timber section code
b94642e
create example for timber rectangular section
c765b69
add feature clt_rectangular_section
6cdb646
Merge branch 'master' into feature-timber-sections
5acd634
address comments from @connorferster
6254173
Merge branch 'master' into feature-timber-sections
1e07fc8
small fixes after running pre-commit
d822d96
update test for clt_rectangular_section
2bf69a9
update docs
b45a189
Merge branch 'master' into feature-timber-sections
robbievanleeuwen f3f3eea
small fixes as suggested by robbievanlewuwen
449314e
rm reference to concrete from section in example notebook
98073ca
corrected units on reinforced concrete example in example notebook
fef9d59
update docs geometry.rst
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| """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[int], | ||
| b: float, | ||
| timb_mat0: pre.Material = pre.DEFAULT_MATERIAL, | ||
| timb_mat90: pre.Material = pre.DEFAULT_MATERIAL, | ||
| ) -> 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: List of layer orientation | ||
robbievanleeuwen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| b: Timber section width | ||
| timb_mat0: Material object to assign to the timber area | ||
| parallel-to-grain | ||
| timb_mat90: Material object to assign to the timber area, | ||
| perpendicular-to-grain | ||
|
|
||
| Raises: | ||
| ValueError: Geometry generation failed | ||
|
|
||
| Returns: | ||
| Timber rectangular section geometry | ||
|
|
||
| Example: | ||
| The following example creates a 120mm CLT cross-section. | ||
| """ | ||
|
|
||
| layer_geom = list() | ||
| for idx in range(len(d)): | ||
| di = float(d[idx]) | ||
| layer = lay_orient[idx] | ||
|
|
||
| if layer is int(0): | ||
robbievanleeuwen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| timb_mat = timb_mat0 | ||
| else: | ||
| timb_mat = timb_mat90 | ||
|
|
||
| # 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) | ||
jchkoch marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if isinstance(geom, geometry.CompoundGeometry): | ||
| return geom | ||
| else: | ||
| raise ValueError("Timber section generation failed.") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| """Tests for the timber sections library.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import numpy as np | ||
| import pytest | ||
| import pytest_check as check | ||
|
|
||
| import sectionproperties.pre.library.timber_sections as ts | ||
| import sectionproperties.pre.library.primitive_sections as ps | ||
| 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=[0, 90, 0], | ||
| b=1000, | ||
| timb_mat0=timber0, | ||
| timb_mat90=timber90 | ||
| ) | ||
|
|
||
| # 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) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.