Skip to content

feat: Draft Add sections framework#27

Merged
mortenengen merged 90 commits intodevfrom
add-sections-framework
May 20, 2024
Merged

feat: Draft Add sections framework#27
mortenengen merged 90 commits intodevfrom
add-sections-framework

Conversation

@talledodiego
Copy link
Collaborator

@talledodiego talledodiego commented Aug 29, 2023

This PR contains a first draft on sections level.
The structure given considers the section (for now only the generic section has been implemented) object that contains a combination of geometries (e.g. surfaces, points) and materials (constitutive relation). The section calculator is the object implementing the different computation algorithms. The integrator object is the one necessary for doing the integration of stresses in the section: two integrators have been implemented, Marin (default) and Fibre integration. The results are stored as proper dataclasses.
The implementation relys on shapely package.

Some limited usecase examples are reported.

  1. Importing the necessary functions
from structuralcodes.materials.constitutive_laws import ElasticPlastic
from structuralcodes.materials.concrete import ConcreteMC2010
from structuralcodes.materials.reinforcement import ReinforcementMC2010
from structuralcodes.sections._generic import GenericSection
from structuralcodes.sections._geometry import add_reinforcement, add_reinforcement_line, SurfaceGeometry
from shapely import Polygon
  1. Creating material objects (note: the section framework supports both constitutive laws or material classes from where the constitutive law is available)
concrete = ConcreteMC2010(30)
reinforcement = ReinforcementMC2010(410, 200000, 410, 0.0675)
  1. Create a rectangular section with some reinforcement
rect = Polygon(((-100,-250),(100,-250),(100,250),(-100,250)))
geo = SurfaceGeometry(rect, concrete)
geo = add_reinforcement(geo, (-60, 210), 16, reinforcement)
geo = add_reinforcement(geo, (60, 210), 16, reinforcement)

The output is the following:
image

  1. Different ways of adding reinforcement:
    Specifying a line and a number of reinforcements (spacing is automatically computed):
add_reinforcement_line(geo, (-60,-210), (60,-210), 16, reinforcement, n = 4)

image
Specifying a line and the spacing of bars (number is automatically computed):

add_reinforcement_line(geo, (-60,-210), (60,-210), 16, reinforcement, s = 30)

image
The function can be also nested

geo = add_reinforcement_line(
    add_reinforcement_line(geo, (-60, -210), (60, -210), 16, reinforcement, n = 2),
    (-60,-210),
    (60,-210),
    8,
    reinforcement,
    s = 20,
    first = False,
    last = False
)

image
Also, both spacing and number can be given:

add_reinforcement_line(
    add_reinforcement_line(geo, (60, -210), (60, 210), 12, reinforcement, n = 2, s = 100), 
    (-60, -210), 
    (-60, 210), 
    12, 
    reinforcement, 
    n = 2, 
    s = 100
)

image
5. Translate and other editing are included

geo = geo.translate(-100,-100)
  1. Create the section (if integrator is not specified, Marin integration is used)
sec = GenericSection(geo, 'mySection', integrator = 'Fiber')
  1. Compute gross properties (e.g. Area)
print(sec.gross_properties.area)
  1. Compute bending strength
res = sec.section_analyzer.calculate_bending_strength(theta = 0, n = 0)
print(res.m_x)
  1. Compute moment Curvature
res = sec.section_analyzer.calculate_moment_curvature(theta=0, n=0)
import matplotlib.pyplot as plt
plt.plot(res.chi, -res.my)
  1. Analyze a steel section (like I-shaped)
fyk = 355
Es = 206000
Eh = 0.0
eps_su = 10.0e-2 #plastic strength
eps_su = fyk / Es #elastic strength

# H section
h = 300
b = 150
tf = 10.7
tw = 7.1
steel = ElasticPlastic(E=Es, fy=fyk, Eh=Eh, eps_su=eps_su)
# Geometry
sec_geom = Polygon(
    (
        (-b/2, -h/2),
        (b/2, -h/2),
        (b/2, -h/2+tf),
        (tw/2, -h/2+tf),
        (tw/2, h/2 - tf),
        (b/2, h/2-tf),
        (b/2, h/2),
        (-b/2, h/2),
        (-b/2, h/2 - tf),
        (-tw/2, h/2 - tf),
        (-tw/2, -h/2 + tf),
        (-b/2, -h/2 + tf),
    )
)
# Trick: create a CompundGeometry with just one SurfaceGeometry to make algorithms work
geo = CompoundGeometry([SurfaceGeometry(sec_geom, steel)])
# Section
sec = GenericSection(geo)

res_fiber = sec.section_analyzer.calculate_bending_strength(theta=0, n=0)
print(f'Mx = {res_fiber.m_x * 1e-6:.2f} kNm')
# Expected bending strength
J = 2/12 * (b * tf**3) + 2 * (tf*b) * (h/2-tf/2)**2 + 1/12 * (tw * (h-2*tf)**3)
W = J/(h/2)
print(f'Expected Mx,el = {fyk * W * 1e-6:.2f} kNm')
Wpl = 2 * (tf * b * (h/2 - tf/2) + (h/2-tf) * tw * (h/2-tf)/2)
print(f'Expected Mx,pl = {fyk * Wpl * 1e-6:.2f} kNm')

talledodiego and others added 11 commits March 21, 2023 11:23
- add base abstract class of constitutive law objected
- add some class implementation for some common constitutive laws (elastic, elastic-plastic, parabola rectangle)
TODO in next commits:
- add hardening part in elastic-plastic
- vectorize the getStress and getTangent functions?
Added some constitutive laws for sectional analysis of RC sections.
For now added:
- Elastic
- Elastic-Perfectly-Plastic
- Elastic-Plastic with hardening
- Parabola Rectangle
- User defined by points (possible to give the positive and/or negative envelope)
1. Changed typing to ArrayLike in functions get_stress
2. Started adding tests
Fix format on first test for passing black
@talledodiego talledodiego added the enhancement New feature or request label Aug 29, 2023
- Included tangents for ParabolaRectangle
- Implemented get_secant in base class
- NotImplementError when asking tangent to UserDefined. We could implement here a numerical tangent if we need it...
@mortenengen mortenengen added this to the Framework milestone Sep 22, 2023
@mortenengen mortenengen changed the title Draft Add sections framework feat: Draft Add sections framework Sep 26, 2023
The draft is still in progress and not working.
- worked on base and generic structure
- Still to update to that structure the rectangular section (next commit)
@mortenengen mortenengen linked an issue Sep 27, 2023 that may be closed by this pull request
2 tasks
@mortenengen mortenengen removed this from the Framework milestone Sep 27, 2023
included a first proposal for generic section definition
1. Included a base Geometry with naming useful for filtering later on (name by default incremental with global counter)
2. Included a PointGeometry
3. Added split between two lines to the SurfaceGeometry

TODO:
a. implement split method for compuund
b. implement __add__ for geometry for creating a compound
c. implementing add_reinforcement methods to add a single rebar (for now) to the section

Created some example usecase on test_generic.ipynb (to be removed later on)
An exception was raised when low values of eps_su was set for reinforcement. This was due to function _prefind_range_curvature_equilibrium that had unexpected behavior when material failure (due to strains higher than eps_su) occured during iterations.
Solved this problem.
- included marin coefficients for elastic-plastic law
- bug fixes: in normal CRS the values of Mx or Kx that stretches bottom fibers are *negative*. This solves some problems observed during testing.
- feature: if no eps_su is specified for elastic plastic material, by default 2*fy/Es is adopted
when using steel cross section moment curvature was not working because equilibrium was found even before the first iteration. Added a proper check.
Optimized slightly computation of moment-curvature avoiding to add 100s of points when eps_su was set to eps_sy.
@talledodiego
Copy link
Collaborator Author

@mortenengen with 9a9d2c7 I included several tests on steel structures with I section. I have a problem: with parametrize if I un-comment more than 2-3 lines for possible testing the make test freezes.. I don't know if this a memory limit for my PC. Any suggestion?

@mortenengen
Copy link
Member

@mortenengen with 9a9d2c7 I included several tests on steel structures with I section. I have a problem: with parametrize if I un-comment more than 2-3 lines for possible testing the make test freezes.. I don't know if this a memory limit for my PC. Any suggestion?

This was a strange one. There were tests that were either failing or freezing, and it was due to polygons that were joined through unions, but were still disconnected. Taking the union of disconnected geometries produces MultiPolygon and not Polygon, and therefore, the constructor of SurfaceGeometry raised a TypeError. I used the set_precision function from shapely to set the precision of the geometries to a very low number, and this made the tests pass 😃

@mortenengen
Copy link
Member

In 1d64e13 I added constitutive laws to the Reinforcement class and swapped the ElasticPlastic objects with ReinforcementMC2010 in relevant tests.

talledodiego and others added 14 commits May 15, 2024 15:04
- added functions __marin__ to elastic and user defined materials
- added for elastic and user defined materials the possibility for setting ultimate strain, useful for when computing bending strength of cross section.
- updated docstrings for generic section and reinforcement
- addd more tests to cover the new marin coefficients for elastic and userdefined constitutive laws
- Included __add__ method for adding a CompoundGeometry with a Geometry
- included related tests.
- added __sub__ method for SurfaceGeometry and CompoundGeometry;
- included related tests;
- solved problems with signs in moments evaluation.
- solved bug evidenced by @mortenengen in failure of moment curvature with values of N.
@mortenengen mortenengen merged commit 820c346 into dev May 20, 2024
@mortenengen mortenengen deleted the add-sections-framework branch May 20, 2024 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done 🚀

Development

Successfully merging this pull request may close these issues.

Add section classes for rectangular and generic reinforced concrete

4 participants