Skip to content

Conversation

@jchkoch
Copy link

@jchkoch jchkoch commented Dec 4, 2025

To avoid a RuntimeError that a argument of type "float | None" cannot be assigned to parameter "phi" of type "float" in function fea.principal_coordinate" (line 318 in section.py)

To avoid a RuntimeError that a argument of type "float | None" cannot be assigned to parameter "phi" of type "float" in function fea.principal_coordinate" (line 318)
@robbievanleeuwen
Copy link
Owner

Happy to make this change, however curious as to how you got this error as phi should have been calculated earlier in the method calculate_centroidal_properties(). Do you have a file that can reproduce this runtime error?

@jchkoch
Copy link
Author

jchkoch commented Dec 4, 2025

I encountered this when retrieving stresses via the get_stress_at_points method on the following code snippet:

from sectionproperties.pre.library import primitive_sections
from sectionproperties.analysis.section import Section

geom = primitive_sections.rectangular_section(d=300, b=79)  # in mm

geom.create_mesh(mesh_sizes=[5])
sec = Section(geometry=geom)
sec.calculate_geometric_properties()
sec.calculate_warping_properties()
sec.display_results()

case1a = {'n': 2.860 * 1000, 'vx': 0.467, 'vy': -3.174, 'mzz': 1.362 * 1e6, 'mxx': -2.279 * 1e6, 'myy': -5.644 * 1e6, 'm11': 0, 'm22': 0}
case1b = {'n': -2.256 * 1000, 'vx': 0.076, 'vy': 7.002, 'mzz': -1.567 * 1e6, 'myy': 1.686 * 1e6, 'myy': 0.890 * 1e6, 'm11': 0, 'm22': 0}
case2 = {'n': -7.994 * 1000, 'vx': -1.431, 'vy': -0.187, 'mzz': 0.211 * 1e6, 'mxx': -10.747 * 1e6, 'myy': 2.018 * 1e6, 'm11': 0, 'm22': 0}

load_cases = [case1a, case1b, case2]

pt1 = (0., 0.); pt2 = (0., 300.); pt3 = (79., 300.); pt4 = (79., 0.)
points = [pt1, pt2, pt3, pt4]

for idx_lc, lc in enumerate(load_cases):
    print(f"Load case {lc}:")
    stress = sec.calculate_stress(**lc)

    results = sec.get_stress_at_points(pts=points, **lc)

@robbievanleeuwen
Copy link
Owner

Thanks @jchkoch, I'll have a look into this tomorrow, there shouldn't be a RuntimeError with this script, so maybe something else is going on.

@jchkoch
Copy link
Author

jchkoch commented Dec 6, 2025

yes, maybe there is something else going on here. My fix seemed to remove the error message I was getting from my script which was my immediate concern to get my stress results for my project I am working on.

It might be relevant to add that I needed also to add 'm11': 0, 'm22': 0 to my load cases in order for all of the error messages to disappear. Perhaps there is an issue with the input argument **lc in get_stress_at_points.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants