-
Notifications
You must be signed in to change notification settings - Fork 66
Description
Bug Description
There's a missing closing parenthesis in src/dkt.jl line 180 that causes incorrect computation of the DKT element stiffness matrix.
Location
src/dkt.jl, line 180, in the dHxdeta function within basis_factory:
# CURRENT (INCORRECT):
d9 = -2.0 + 6.0*eta + r5*(1.0-2.0*eta+xi*(r4-r5))
↑ missing closing paren
# SHOULD BE:
d9 = -2.0 + 6.0*eta + r5*(1.0-2.0*eta) + xi*(r4-r5)
↑ paren should close hereImpact
This bug causes:
- Incorrect values for 13 out of 81 entries in the element stiffness matrix
- All errors are in row 8 and column 8 (θy rotation at node 3)
- The incorrect formula multiplies
r5by the entire expression instead of just(1.0-2.0*eta)
How to Reproduce
Run the existing test in test/test_dkt.jl:
@test isapprox(K, K_expected)With the current code, this test passes because K_expected contains the incorrect values. After fixing the bug, K_expected needs to be
updated.
Expected Behavior
According to the Batoz & Bathe 1980 paper (the original DKT formulation), the shape function derivative should be:
dHxdeta[9] = -2 + 6η + r5(1-2η) + ξ(r4-r5)
Not:
dHxdeta[9] = -2 + 6η + r5(1-2η + ξ(r4-r5))
Proposed Fix
1. Fix src/dkt.jl line 180:
d9 = -2.0 + 6.0*eta + r5*(1.0-2.0*eta) + xi*(r4-r5)2. Update test/test_dkt.jl lines 25-33:
The corrected K_expected should have these values for column 8 (changes marked):
K_expected = [
4880 0 0 -2440 1220 -1220 -2440 1220 -1220 # was: 0
0 915 -305 610 305 610 -610 -610 305 # no change
0 -305 915 610 305 -610 -610 610 305 # no change
-2440 610 610 2440 0 610 0 -610 1220 # was: 610
1220 305 305 0 610 -305 -1220 305 0 # was: 305
-1220 610 -610 610 -305 915 610 -915 305 # was: 0
-2440 -610 -610 0 -1220 610 2440 -610 0 # was: -610
1220 -610 610 -610 305 -915 -610 915 -305 # was: 0
-1220 305 305 1220 0 305 0 -305 610] # entire row was wrongHow This Was Discovered
While implementing an independent DKT element in Rust and cross-validating against FEMPlates.jl, we found systematic differences in row/column 8
of the stiffness matrix (84% match, 13/81 entries differing). After exhaustive debugging and line-by-line comparison with the Batoz & Bathe
paper, we traced the issue to this parenthesis error.
Validation
The corrected formula has been validated by:
- Comparing against Batoz & Bathe 1980 paper equations
- Independent implementation in Rust matching the corrected values
- Hand calculation for the unit right triangle test case
- Verifying stiffness matrix remains symmetric
- All 81 entries match expected analytical values
References
- Batoz, Jean-Louis, Klaus-Jürgen Bathe, and Lee-Wing Ho. "A study of three-node triangular plate bending elements." International Journal for
Numerical Methods in Engineering 15.12 (1980): 1771-1812.