From c06b47ce336068ca6997a3fbec796557e66084f9 Mon Sep 17 00:00:00 2001 From: talledodiego <38036285+talledodiego@users.noreply.github.com> Date: Wed, 7 Aug 2024 19:12:58 +0200 Subject: [PATCH 1/3] Fix area computation on Generic Section This fix an issue mentioned in PR #113: the area should be the sum of surface + reinforcement area. --- structuralcodes/sections/_generic.py | 3 + tests/test_core/test_generic_section.py | 76 +++++++++++++++++++------ 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/structuralcodes/sections/_generic.py b/structuralcodes/sections/_generic.py index 0d4ace47..8dadf8ae 100644 --- a/structuralcodes/sections/_generic.py +++ b/structuralcodes/sections/_generic.py @@ -142,6 +142,9 @@ def _calculate_gross_section_properties(self) -> s_res.GrossProperties: # this assumes area in mm2 and density in kg/m3 gp.mass += geo.area * geo.density * 1e-9 + # Add area of reinforcement to total area + gp.area += gp.area_reinforcement + # Computation of area moments # # Implementation idea: diff --git a/tests/test_core/test_generic_section.py b/tests/test_core/test_generic_section.py index 6ef52134..49020cac 100644 --- a/tests/test_core/test_generic_section.py +++ b/tests/test_core/test_generic_section.py @@ -27,8 +27,16 @@ def test_rectangular_section(): # The section poly = Polygon(((0, 0), (200, 0), (200, 400), (0, 400))) geo = SurfaceGeometry(poly, concrete) - geo = add_reinforcement_line(geo, (40, 40), (160, 40), 16, steel, n=4) - geo = add_reinforcement_line(geo, (40, 360), (160, 360), 16, steel, n=4) + diam_reinf = 16 + area_reinf = diam_reinf**2 * math.pi / 4.0 + n_reinf = 4 + expected_area = 200 * 400 + 2 * area_reinf * n_reinf + geo = add_reinforcement_line( + geo, (40, 40), (160, 40), diam_reinf, steel, n=n_reinf + ) + geo = add_reinforcement_line( + geo, (40, 360), (160, 360), diam_reinf, steel, n=n_reinf + ) geo = geo.translate(-100, -200) assert geo.geometries[0].centroid[0] == 0 assert geo.geometries[0].centroid[1] == 0 @@ -37,7 +45,7 @@ def test_rectangular_section(): sec = GenericSection(geo) assert sec.name == 'GenericSection' - assert math.isclose(sec.gross_properties.area, 200 * 400) + assert math.isclose(sec.gross_properties.area, expected_area) # Compute bending strength res_marin = sec.section_calculator.calculate_bending_strength(theta=0, n=0) @@ -52,7 +60,7 @@ def test_rectangular_section(): # Use fiber integration sec = GenericSection(geo, integrator='Fiber', mesh_size=0.0001) - assert math.isclose(sec.gross_properties.area, 200 * 400) + assert math.isclose(sec.gross_properties.area, expected_area) # Compute bending strength res_fiber = sec.section_calculator.calculate_bending_strength(theta=0, n=0) @@ -243,10 +251,18 @@ def test_rectangular_section_Sargin(): ) # The section + diam_reinf = 16 + area_reinf = diam_reinf**2 * math.pi / 4.0 + n_reinf = 4 + expected_area = 200 * 400 + 2 * area_reinf * n_reinf poly = Polygon(((0, 0), (200, 0), (200, 400), (0, 400))) geo = SurfaceGeometry(poly, concrete) - geo = add_reinforcement_line(geo, (40, 40), (160, 40), 16, steel, n=4) - geo = add_reinforcement_line(geo, (40, 360), (160, 360), 16, steel, n=4) + geo = add_reinforcement_line( + geo, (40, 40), (160, 40), diam_reinf, steel, n=n_reinf + ) + geo = add_reinforcement_line( + geo, (40, 360), (160, 360), diam_reinf, steel, n=n_reinf + ) geo = geo.translate(-100, -200) assert geo.geometries[0].centroid[0] == 0 assert geo.geometries[0].centroid[1] == 0 @@ -254,14 +270,22 @@ def test_rectangular_section_Sargin(): # Create the section (default Marin integrator) sec = GenericSection(geo) - assert math.isclose(sec.gross_properties.area, 200 * 400) + assert math.isclose(sec.gross_properties.area, expected_area) + assert math.isclose(sec.gross_properties.area_surface, 200 * 400) + assert math.isclose( + sec.gross_properties.area_reinforcement, area_reinf * n_reinf * 2 + ) # Compute bending strength res_marin = sec.section_calculator.calculate_bending_strength(theta=0, n=0) # Use fiber integration sec = GenericSection(geo, integrator='Fiber', mesh_size=0.0001) - assert math.isclose(sec.gross_properties.area, 200 * 400) + assert math.isclose(sec.gross_properties.area, expected_area) + assert math.isclose(sec.gross_properties.area_surface, 200 * 400) + assert math.isclose( + sec.gross_properties.area_reinforcement, area_reinf * n_reinf * 2 + ) # Compute bending strength res_fiber = sec.section_calculator.calculate_bending_strength(theta=0, n=0) @@ -284,8 +308,16 @@ def test_holed_section(): geo = SurfaceGeometry(poly, concrete) # Add reinforcement - geo = add_reinforcement_line(geo, (50, 50), (450, 50), 28, steel, n=4) - geo = add_reinforcement_line(geo, (50, 950), (450, 950), 28, steel, n=4) + diam_reinf = 28 + area_reinf = diam_reinf**2 * math.pi / 4.0 + n_reinf = 4 + expected_area = 260000 + 2 * area_reinf * n_reinf + geo = add_reinforcement_line( + geo, (50, 50), (450, 50), diam_reinf, steel, n=n_reinf + ) + geo = add_reinforcement_line( + geo, (50, 950), (450, 950), diam_reinf, steel, n=n_reinf + ) # Translate the section geo = geo.translate(-250, -500) assert geo.geometries[0].centroid[0] == 0 @@ -295,14 +327,16 @@ def test_holed_section(): sec = GenericSection(geo) assert sec.name == 'GenericSection' - assert math.isclose(sec.gross_properties.area, 260000) + assert math.isclose(sec.gross_properties.area, expected_area) + assert math.isclose(sec.gross_properties.area_surface, 260000) # Compute bending strength with Marin res_marin = sec.section_calculator.calculate_bending_strength(theta=0, n=0) # Use fiber integration sec = GenericSection(geo, integrator='Fiber', mesh_size=0.0001) - assert math.isclose(sec.gross_properties.area, 260000) + assert math.isclose(sec.gross_properties.area, expected_area) + assert math.isclose(sec.gross_properties.area_surface, 260000) # Compute bending strength res_fiber = sec.section_calculator.calculate_bending_strength(theta=0, n=0) @@ -329,9 +363,15 @@ def test_u_section(): geo = SurfaceGeometry(poly, concrete) # Add reinforcement - geo = add_reinforcement_line(geo, (50, 50), (450, 50), 28, steel, n=4) - geo = add_reinforcement(geo, (50, 950), 28, steel) - geo = add_reinforcement(geo, (450, 950), 28, steel) + diam_reinf = 28 + area_reinf = diam_reinf**2 * math.pi / 4.0 + n_reinf = 4 + expected_area = 230000 + area_reinf * (n_reinf + 2) + geo = add_reinforcement_line( + geo, (50, 50), (450, 50), diam_reinf, steel, n=n_reinf + ) + geo = add_reinforcement(geo, (50, 950), diam_reinf, steel) + geo = add_reinforcement(geo, (450, 950), diam_reinf, steel) # Translate the section geo = geo.translate(-250, -441.30434782608694) assert geo.geometries[0].centroid[0] == 0 @@ -341,14 +381,16 @@ def test_u_section(): sec = GenericSection(geo) assert sec.name == 'GenericSection' - assert math.isclose(sec.gross_properties.area, 230000) + assert math.isclose(sec.gross_properties.area, expected_area) + assert math.isclose(sec.gross_properties.area_surface, 230000) # Compute bending strength res_marin = sec.section_calculator.calculate_bending_strength(theta=0, n=0) # Use fiber integration sec = GenericSection(geo, integrator='Fiber', mesh_size=0.0001) - assert math.isclose(sec.gross_properties.area, 230000) + assert math.isclose(sec.gross_properties.area, expected_area) + assert math.isclose(sec.gross_properties.area_surface, 230000) # Compute bending strength res_fiber = sec.section_calculator.calculate_bending_strength(theta=0, n=0) From 10c53bf5ed7399b04b442a06613cecd2c4131b0f Mon Sep 17 00:00:00 2001 From: talledodiego <38036285+talledodiego@users.noreply.github.com> Date: Thu, 8 Aug 2024 14:32:20 +0200 Subject: [PATCH 2/3] Revert "Fix area computation on Generic Section" This reverts commit c06b47ce336068ca6997a3fbec796557e66084f9. --- structuralcodes/sections/_generic.py | 3 - tests/test_core/test_generic_section.py | 76 ++++++------------------- 2 files changed, 17 insertions(+), 62 deletions(-) diff --git a/structuralcodes/sections/_generic.py b/structuralcodes/sections/_generic.py index 8dadf8ae..0d4ace47 100644 --- a/structuralcodes/sections/_generic.py +++ b/structuralcodes/sections/_generic.py @@ -142,9 +142,6 @@ def _calculate_gross_section_properties(self) -> s_res.GrossProperties: # this assumes area in mm2 and density in kg/m3 gp.mass += geo.area * geo.density * 1e-9 - # Add area of reinforcement to total area - gp.area += gp.area_reinforcement - # Computation of area moments # # Implementation idea: diff --git a/tests/test_core/test_generic_section.py b/tests/test_core/test_generic_section.py index 49020cac..6ef52134 100644 --- a/tests/test_core/test_generic_section.py +++ b/tests/test_core/test_generic_section.py @@ -27,16 +27,8 @@ def test_rectangular_section(): # The section poly = Polygon(((0, 0), (200, 0), (200, 400), (0, 400))) geo = SurfaceGeometry(poly, concrete) - diam_reinf = 16 - area_reinf = diam_reinf**2 * math.pi / 4.0 - n_reinf = 4 - expected_area = 200 * 400 + 2 * area_reinf * n_reinf - geo = add_reinforcement_line( - geo, (40, 40), (160, 40), diam_reinf, steel, n=n_reinf - ) - geo = add_reinforcement_line( - geo, (40, 360), (160, 360), diam_reinf, steel, n=n_reinf - ) + geo = add_reinforcement_line(geo, (40, 40), (160, 40), 16, steel, n=4) + geo = add_reinforcement_line(geo, (40, 360), (160, 360), 16, steel, n=4) geo = geo.translate(-100, -200) assert geo.geometries[0].centroid[0] == 0 assert geo.geometries[0].centroid[1] == 0 @@ -45,7 +37,7 @@ def test_rectangular_section(): sec = GenericSection(geo) assert sec.name == 'GenericSection' - assert math.isclose(sec.gross_properties.area, expected_area) + assert math.isclose(sec.gross_properties.area, 200 * 400) # Compute bending strength res_marin = sec.section_calculator.calculate_bending_strength(theta=0, n=0) @@ -60,7 +52,7 @@ def test_rectangular_section(): # Use fiber integration sec = GenericSection(geo, integrator='Fiber', mesh_size=0.0001) - assert math.isclose(sec.gross_properties.area, expected_area) + assert math.isclose(sec.gross_properties.area, 200 * 400) # Compute bending strength res_fiber = sec.section_calculator.calculate_bending_strength(theta=0, n=0) @@ -251,18 +243,10 @@ def test_rectangular_section_Sargin(): ) # The section - diam_reinf = 16 - area_reinf = diam_reinf**2 * math.pi / 4.0 - n_reinf = 4 - expected_area = 200 * 400 + 2 * area_reinf * n_reinf poly = Polygon(((0, 0), (200, 0), (200, 400), (0, 400))) geo = SurfaceGeometry(poly, concrete) - geo = add_reinforcement_line( - geo, (40, 40), (160, 40), diam_reinf, steel, n=n_reinf - ) - geo = add_reinforcement_line( - geo, (40, 360), (160, 360), diam_reinf, steel, n=n_reinf - ) + geo = add_reinforcement_line(geo, (40, 40), (160, 40), 16, steel, n=4) + geo = add_reinforcement_line(geo, (40, 360), (160, 360), 16, steel, n=4) geo = geo.translate(-100, -200) assert geo.geometries[0].centroid[0] == 0 assert geo.geometries[0].centroid[1] == 0 @@ -270,22 +254,14 @@ def test_rectangular_section_Sargin(): # Create the section (default Marin integrator) sec = GenericSection(geo) - assert math.isclose(sec.gross_properties.area, expected_area) - assert math.isclose(sec.gross_properties.area_surface, 200 * 400) - assert math.isclose( - sec.gross_properties.area_reinforcement, area_reinf * n_reinf * 2 - ) + assert math.isclose(sec.gross_properties.area, 200 * 400) # Compute bending strength res_marin = sec.section_calculator.calculate_bending_strength(theta=0, n=0) # Use fiber integration sec = GenericSection(geo, integrator='Fiber', mesh_size=0.0001) - assert math.isclose(sec.gross_properties.area, expected_area) - assert math.isclose(sec.gross_properties.area_surface, 200 * 400) - assert math.isclose( - sec.gross_properties.area_reinforcement, area_reinf * n_reinf * 2 - ) + assert math.isclose(sec.gross_properties.area, 200 * 400) # Compute bending strength res_fiber = sec.section_calculator.calculate_bending_strength(theta=0, n=0) @@ -308,16 +284,8 @@ def test_holed_section(): geo = SurfaceGeometry(poly, concrete) # Add reinforcement - diam_reinf = 28 - area_reinf = diam_reinf**2 * math.pi / 4.0 - n_reinf = 4 - expected_area = 260000 + 2 * area_reinf * n_reinf - geo = add_reinforcement_line( - geo, (50, 50), (450, 50), diam_reinf, steel, n=n_reinf - ) - geo = add_reinforcement_line( - geo, (50, 950), (450, 950), diam_reinf, steel, n=n_reinf - ) + geo = add_reinforcement_line(geo, (50, 50), (450, 50), 28, steel, n=4) + geo = add_reinforcement_line(geo, (50, 950), (450, 950), 28, steel, n=4) # Translate the section geo = geo.translate(-250, -500) assert geo.geometries[0].centroid[0] == 0 @@ -327,16 +295,14 @@ def test_holed_section(): sec = GenericSection(geo) assert sec.name == 'GenericSection' - assert math.isclose(sec.gross_properties.area, expected_area) - assert math.isclose(sec.gross_properties.area_surface, 260000) + assert math.isclose(sec.gross_properties.area, 260000) # Compute bending strength with Marin res_marin = sec.section_calculator.calculate_bending_strength(theta=0, n=0) # Use fiber integration sec = GenericSection(geo, integrator='Fiber', mesh_size=0.0001) - assert math.isclose(sec.gross_properties.area, expected_area) - assert math.isclose(sec.gross_properties.area_surface, 260000) + assert math.isclose(sec.gross_properties.area, 260000) # Compute bending strength res_fiber = sec.section_calculator.calculate_bending_strength(theta=0, n=0) @@ -363,15 +329,9 @@ def test_u_section(): geo = SurfaceGeometry(poly, concrete) # Add reinforcement - diam_reinf = 28 - area_reinf = diam_reinf**2 * math.pi / 4.0 - n_reinf = 4 - expected_area = 230000 + area_reinf * (n_reinf + 2) - geo = add_reinforcement_line( - geo, (50, 50), (450, 50), diam_reinf, steel, n=n_reinf - ) - geo = add_reinforcement(geo, (50, 950), diam_reinf, steel) - geo = add_reinforcement(geo, (450, 950), diam_reinf, steel) + geo = add_reinforcement_line(geo, (50, 50), (450, 50), 28, steel, n=4) + geo = add_reinforcement(geo, (50, 950), 28, steel) + geo = add_reinforcement(geo, (450, 950), 28, steel) # Translate the section geo = geo.translate(-250, -441.30434782608694) assert geo.geometries[0].centroid[0] == 0 @@ -381,16 +341,14 @@ def test_u_section(): sec = GenericSection(geo) assert sec.name == 'GenericSection' - assert math.isclose(sec.gross_properties.area, expected_area) - assert math.isclose(sec.gross_properties.area_surface, 230000) + assert math.isclose(sec.gross_properties.area, 230000) # Compute bending strength res_marin = sec.section_calculator.calculate_bending_strength(theta=0, n=0) # Use fiber integration sec = GenericSection(geo, integrator='Fiber', mesh_size=0.0001) - assert math.isclose(sec.gross_properties.area, expected_area) - assert math.isclose(sec.gross_properties.area_surface, 230000) + assert math.isclose(sec.gross_properties.area, 230000) # Compute bending strength res_fiber = sec.section_calculator.calculate_bending_strength(theta=0, n=0) From d768f91b6e80d02c06f3c153d282810ba438184d Mon Sep 17 00:00:00 2001 From: talledodiego <38036285+talledodiego@users.noreply.github.com> Date: Thu, 8 Aug 2024 22:09:13 +0200 Subject: [PATCH 3/3] Removed unecessary area_surface --- structuralcodes/core/_section_results.py | 3 --- structuralcodes/sections/_generic.py | 1 - 2 files changed, 4 deletions(-) diff --git a/structuralcodes/core/_section_results.py b/structuralcodes/core/_section_results.py index f0cc3e5f..aaa1b6d9 100644 --- a/structuralcodes/core/_section_results.py +++ b/structuralcodes/core/_section_results.py @@ -12,9 +12,6 @@ class GrossProperties: # section areas area: float = field(default=0, metadata={'description': 'Total area'}) - area_surface: float = field( - default=0, metadata={'description': 'Surface area'} - ) area_reinforcement: float = field( default=0, metadata={'description': 'Reinforcement area'} ) diff --git a/structuralcodes/sections/_generic.py b/structuralcodes/sections/_generic.py index e6a1e6a3..60d72f29 100644 --- a/structuralcodes/sections/_generic.py +++ b/structuralcodes/sections/_generic.py @@ -136,7 +136,6 @@ def _calculate_gross_section_properties(self) -> s_res.GrossProperties: # and mass: Morten -> problem with units! how do we deal with it? for geo in self.section.geometry.geometries: gp.ea += geo.area * geo.material.get_tangent(eps=0)[0] - gp.area_surface += geo.area if geo.density is not None: # this assumes area in mm2 and density in kg/m3 gp.mass += geo.area * geo.density * 1e-9