Skip to content

Constitutive models and ForwardDiff: Repalce Float64 by Real#158

Closed
miguelmaso wants to merge 10 commits into
mainfrom
real-params
Closed

Constitutive models and ForwardDiff: Repalce Float64 by Real#158
miguelmaso wants to merge 10 commits into
mainfrom
real-params

Conversation

@miguelmaso

@miguelmaso miguelmaso commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

This change allows to pass a constitutive model to ForwardDiff

Features:

  • Parametric {T<:Real} types allow the use of ForwardDiff
  • Property destructing in constitutive models
  • Enhanced mutability of αr in magnetic models

@miguelmaso miguelmaso requested a review from jmartfrut June 2, 2026 15:48
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

Benchmark Results (Julia v1)

Time benchmarks
main c1f1794... main / c1f1794...
Constitutive models/Visco-elastic Ψ 0.0488 ± 0.028 ms 0.0499 ± 0.029 ms 0.979 ± 0.81
Constitutive models/Visco-elastic ∂Ψu 0.0554 ± 0.002 ms 0.0552 ± 0.0019 ms 1 ± 0.05
Constitutive models/Visco-elastic ∂Ψuu 0.103 ± 0.02 ms 0.104 ± 0.019 ms 0.991 ± 0.26
Simulations/StaticMechanicalDirichlet 0.14 ± 0.0097 s 0.134 ± 0.0076 s 1.05 ± 0.094
Simulations/StaticMechanicalNeumann 0.132 ± 0.012 s 0.128 ± 0.012 s 1.03 ± 0.13
Simulations/ViscoElastic 18.4 s 18.3 s 1
Tensor algebra/Cofactor 0.06 ± 0.01 μs 0.06 ± 0.01 μs 1 ± 0.24
Tensor algebra/Det(A)Inv(A') 0.111 ± 0.01 μs 0.111 ± 0.01 μs 1 ± 0.13
Tensor algebra/δδ_λ_2d 30 ± 0 ns 30 ± 0 ns 1 ± 0
Tensor algebra/δδ_μ_2d 30 ± 0 ns 30 ± 0 ns 1 ± 0
time_to_load 2.77 ± 0.013 s 2.76 ± 0.02 s 1 ± 0.0089
Memory benchmarks
main c1f1794... main / c1f1794...
Constitutive models/Visco-elastic Ψ 1.24 k allocs: 0.0777 MB 1.28 k allocs: 0.079 MB 0.983
Constitutive models/Visco-elastic ∂Ψu 1.29 k allocs: 0.0826 MB 1.34 k allocs: 0.0846 MB 0.976
Constitutive models/Visco-elastic ∂Ψuu 2.25 k allocs: 0.149 MB 2.29 k allocs: 0.151 MB 0.988
Simulations/StaticMechanicalDirichlet 1.51 M allocs: 0.108 GB 1.51 M allocs: 0.108 GB 1
Simulations/StaticMechanicalNeumann 1.48 M allocs: 0.0927 GB 1.48 M allocs: 0.0927 GB 1
Simulations/ViscoElastic 0.327 G allocs: 20.6 GB 0.337 G allocs: 21 GB 0.979
Tensor algebra/Cofactor 1 allocs: 0.0781 kB 1 allocs: 0.0781 kB 1
Tensor algebra/Det(A)Inv(A') 4 allocs: 0.25 kB 4 allocs: 0.25 kB 1
Tensor algebra/δδ_λ_2d 0 allocs: 0 B 0 allocs: 0 B
Tensor algebra/δδ_μ_2d 0 allocs: 0 B 0 allocs: 0 B
time_to_load 0.149 k allocs: 11.1 kB 0.159 k allocs: 11.6 kB 0.964

@miguelmaso

Copy link
Copy Markdown
Collaborator Author

While fixing Ref{Real}, I've tried to enhance the accessor to the reference αr, an attempt to improve the user experience.

Should we extend all the αr to be mutable?

@miguelmaso

Copy link
Copy Markdown
Collaborator Author

⚠️ Note: All the field types in the struct must be parametric concrete types (T<:Real), rather than abstract types (Real)

@miguelmaso

Copy link
Copy Markdown
Collaborator Author

Conclusions after discussion:

  1. Keep Float64
  2. Go ahead with getproperty

@miguelmaso miguelmaso closed this Jun 5, 2026
@miguelmaso miguelmaso deleted the real-params branch June 5, 2026 11:28
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.

1 participant