mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-08-06 04:21:33 +00:00
6a8f8adc1f
RESEARCH QUESTION: Should JuliaFEM use hand-calculated derivatives or AD? Created comprehensive benchmark comparing: - Manual: Hand-calculated derivatives (traditional FEM) - AD: Tensors.jl gradient() (automatic differentiation) RESULTS (AMD Ryzen 9, Julia 1.12.1): - Manual: 8.7 ns, 0 allocations - AD: 268.1 ns, 0 allocations - AD is 30× SLOWER than manual KEY FINDINGS: ✅ Both achieve zero allocations (Tensors.jl is well-optimized) ❌ AD has 30× compute overhead from dual number arithmetic ⚠️ In assembly loops: millions of calls = 10+ seconds extra per solve RECOMMENDATION: - Keep manual derivatives for common elements (Tet10, Hex8, Quad4, etc.) - Use AD for prototyping and rare elements - Unit test manual vs AD to catch errors - Future: Generate derivatives symbolically (Symbolics.jl) WHY NOT AD EVERYWHERE? Assembly is hottest path in FEM. 30× overhead = unacceptable for production code. Users will notice the performance difference. WHY NOT ABANDON AD? - Excellent for prototyping - Required for exotic bases (NURBS) - Perfect for unit testing manual derivatives - Zero allocations impressive Files: - benchmarks/tet10_derivatives_benchmark.jl (runnable benchmark) - docs/benchmarks/shape_function_derivatives_ad_vs_manual.md (analysis) Dependencies added: BenchmarkTools This answers the research question definitively with data.