Skip to content

Get stress at point yz#300

Closed
MestreCarlos wants to merge 36 commits intofib-international:devfrom
MestreCarlos:get_stress_at_point_YZ
Closed

Get stress at point yz#300
MestreCarlos wants to merge 36 commits intofib-international:devfrom
MestreCarlos:get_stress_at_point_YZ

Conversation

@MestreCarlos
Copy link
Collaborator

I’m adding a new feature to obtain the stress at any coordinates of the section.

Feel free to comment on any other changes regarding the functionality of the method or how I’ve integrated it into the repository.

Here’s an example:

from shapely import Polygon

from structuralcodes import set_design_code
from structuralcodes.geometry import SurfaceGeometry, add_reinforcement
from structuralcodes.materials.concrete import create_concrete
from structuralcodes.materials.reinforcement import create_reinforcement
from structuralcodes.sections import GenericSection

# Set the active design code
set_design_code('ec2_2004')
# Create a concrete and a reinforcement
fck = 45
fyk = 500
ftk = 550
Es = 200000
epsuk = 0.07

# These factory functions create concrete and reinforcement materials according
# to the globally set design code
concrete = create_concrete(fck=fck)
reinforcement = create_reinforcement(fyk=fyk, Es=Es, ftk=ftk, epsuk=epsuk)


# Create a rectangular geometry
width = 250
height = 500
polygon = Polygon(
    [
        (-width / 2, -height / 2),
        (width / 2, -height / 2),
        (width / 2, height / 2),
        (-width / 2, height / 2),
    ]
)  # We leverage shapely to create geometries
geometry = SurfaceGeometry(
    poly=polygon, material=concrete, group_label='concrete'
)  # A SurfaceGeometry is a shapely Polygon with an assigned material


# Add reinforcement
diameter_reinf = 25
cover = 50

geometry = add_reinforcement(
    geometry,
    (
        -width / 2 + cover + diameter_reinf / 2,
        -height / 2 + cover + diameter_reinf / 2,
    ),
    diameter_reinf,
    reinforcement,
    group_label='bar 1',
)  # The add_reinforcement function returns a CompoundGeometry
geometry = add_reinforcement(
    geometry,
    (
        width / 2 - cover - diameter_reinf / 2,
        -height / 2 + cover + diameter_reinf / 2,
    ),
    diameter_reinf,
    reinforcement,
    group_label='bar 2',
)

# Create section
section = GenericSection(geometry)
section.geometry

Now, the calculation of the stress at certain coordinates for a bending moment of 200 kN·m and an axial compression of 200 kN.

strain = section.section_calculator.calculate_strain_profile(
    n=-200.0 * 1e3,
    my=-200.0 * 1e6,
    mz=0.0 * 1e6,
)

results = section.section_calculator.get_stress_point(
    y=width / 2 - cover - diameter_reinf / 2,
    z=-height / 2 + cover + diameter_reinf / 2,
    eps_a=strain[0],
    chi_y=strain[1],
    chi_z=strain[2],
    where=0,
)

if results:
    for result in results:
        print(f'Stres in ({result.y}, {result.z}): {result.stress}')
        print(f'Strain: {result.strain}')
        print(f'Geometry: {result.geometry_group_label}')
        print('---')
else:
    print('Point outside any geometry')

mortenengen and others added 30 commits December 13, 2022 21:01
Co-authored-by: talledodiego <38036285+talledodiego@users.noreply.github.com>
@MestreCarlos MestreCarlos changed the base branch from main to dev November 4, 2025 17:01
@talledodiego
Copy link
Collaborator

Thanks @MestreCarlos for this contribution.
I've looked at while I was developing the results classes in #289
I think a method for getting stress or strain on a point $\left(y, z\right)$ of a section should be conceptually inside a result object, not in the section calculator.
We have implemented such features inside #289, #325 and #326. We also have included a filtering system to filter on geometry names and group_labels in #321.
A usage_guide example (included in #289) in the docs is showing the use of this feature.

You could take a look to it: if you think this may meet the required function, and if also @mortenengen agrees, we can close this PR.

@mortenengen
Copy link
Member

Thanks for the clarification, @talledodiego. I agree with your analysis, but will await the feedback from @MestreCarlos before proceeding.

@MestreCarlos
Copy link
Collaborator Author

@talledodiego , your proposal seems appropriate to me. On my side, we can close this PR and use your implementation to get stresses in points. Thanks.

@github-project-automation github-project-automation bot moved this to Under review 👀 in PR tracker Mar 17, 2026
@mortenengen mortenengen moved this from Under review 👀 to Closed 😑 in PR tracker Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed 😑

Development

Successfully merging this pull request may close these issues.

4 participants