Skip to content

Fix product of inertia (Ixy) weighting in cutwp.prop2 (part of #128)#299

Merged
brookshsmith merged 1 commit into
brookshsmith:masterfrom
gaoflow:fix/128-prop2-product-of-inertia
Jun 2, 2026
Merged

Fix product of inertia (Ixy) weighting in cutwp.prop2 (part of #128)#299
brookshsmith merged 1 commit into
brookshsmith:masterfrom
gaoflow:fix/128-prop2-product-of-inertia

Conversation

@gaoflow
Copy link
Copy Markdown
Contributor

@gaoflow gaoflow commented Jun 1, 2026

Problem

In cutwp.prop2, the product of inertia Ixy is computed with a misplaced closing parenthesis:

I_xy = np.sum((x_diffs * y_diffs / 12 + (x_means - x_centroid) * (y_means - y_centroid) * lengths * thicknesses))

Compare with how Ixx and Iyy are formed just above:

I_xx = np.sum((y_diffs**2 / 12 + (y_means - y_centroid) ** 2) * lengths * thicknesses)
I_yy = np.sum((x_diffs**2 / 12 + (x_means - x_centroid) ** 2) * lengths * thicknesses)

For Ixx/Iyy the * lengths * thicknesses factor multiplies the whole bracket (the element's own second moment d²/12 plus the parallel-axis term). For Ixy the parenthesis closes too late, so * lengths * thicknesses only multiplies the parallel-axis term and the element's own contribution x_diffs * y_diffs / 12 is left unweighted by the element area.

The result is an incorrect Ixy (and therefore an incorrect principal angle phi and principal moments I11/I22) for any section containing inclined elements. Sections whose elements are all axis-aligned are unaffected, because then x_diffs * y_diffs is zero for every element — which is likely why this went unnoticed.

This is one of the two issues reported in #128.

Fix

Move the closing parenthesis so the full bracket is weighted by lengths * thicknesses, consistent with Ixx/Iyy:

I_xy = np.sum((x_diffs * y_diffs / 12 + (x_means - x_centroid) * (y_means - y_centroid)) * lengths * thicknesses)

Verification

For a small section with an inclined element (so the x_diffs * y_diffs / 12 term is non-zero):

coord = np.array([[0.0, 0.0], [4.0, 0.0], [6.0, 3.0]])
ends  = np.array([[0, 1, 0.1], [1, 2, 0.1]], dtype=float)
cutwp.prop2(coord, ends)["Ixy"]
# before: 1.3533230611135743
# after : 1.0336006248867737

The fixed value matches both an independent thin-walled product-of-inertia formula and direct numerical integration of (x - xc)(y - yc) along the elements (agreement to ~1e-9). The rotation invariant Ixx + Iyy == I11 + I22 continues to hold, and a section symmetric about an axis still yields Ixy == 0.

Added tests/test_cutwp.py with these checks; the inclined-element test fails on master and passes with this change. The rest of the suite is unchanged (the one pre-existing it_results_in_correct_signature_curve failure fails identically before and after this change).

Note

#128 mentions two problems in prop2. This PR addresses the product-of-inertia one, which is self-contained and straightforward to verify. The other appears to be in the shear-center/unit-warping loop (the warping constant path) and needs separate, carefully validated treatment, so I've kept it out of this change rather than ship a partial fix there.

The element's own contribution to the product of inertia, x_diff*y_diff/12,
was left outside the '* lengths * thicknesses' factor due to a misplaced
parenthesis, so only the parallel-axis term was weighted by the element
area. This gave an incorrect Ixy (and hence principal angle / I11 / I22)
for sections with inclined elements; axis-aligned elements were unaffected
because their x_diff*y_diff term is zero.

Move the closing parenthesis so the whole bracket is weighted by
lengths * thicknesses, matching how Ixx and Iyy are formed. Verified against
an independent thin-walled formula and direct numerical integration; the
fixed Ixy matches both. Part of brookshsmith#128.
@brookshsmith brookshsmith self-requested a review June 2, 2026 10:01
Copy link
Copy Markdown
Owner

@brookshsmith brookshsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much, @gaoflow ! And thank you for adding the test file for cutwp as well. Simple fix, but you've added a lot value in your PR - merged.

@brookshsmith brookshsmith merged commit 9e9f9ed into brookshsmith:master Jun 2, 2026
4 checks passed
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