Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve non dimensionalization of AbstractMaterialParams #242

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

albert-de-montserrat
Copy link
Member

@albert-de-montserrat albert-de-montserrat commented Jan 17, 2025

This PR Improves and simplifies the non dimensionalization of AbstractMaterialParams, so that it does not rely on Setfields.jl anymore. This solves the problems reported by @Iddingsite in #241. It also slighlty improves the performance

using GeoParams
# This tests the MaterialParameters structure
CharUnits_GEO = GEO_units(; viscosity=1Pa * s, length=1m)
x = DiffusionCreep()

This PR:

julia> @benchmark nondimensionalize($x, $CharUnits_GEO)
BenchmarkTools.Trial: 10000 samples with 10 evaluations.
 Range (min … max):  1.470 μs …  18.470 μs  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     1.620 μs               ┊ GC (median):    0.00%    
 Time  (mean ± σ):   1.621 μs ± 307.944 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

       ▁ ▅█▇ ▃           ▁ ▄▄ ▁
  ▂▃▄▁██▁███▁█▇▁▄▃▃▁▃▄▁▅▆█▁██▁█▆▅▁▅▄▁▅▅▅▁▅▄▁▃▃▃▁▃▂▁▂▂▂▁▂▂▁▂▂▂ ▃
  1.47 μs         Histogram: frequency by time        1.89 μs <        

 Memory estimate: 688 bytes, allocs estimate: 33.

#main:

julia> @benchmark nondimensionalize($x, $CharUnits_GEO)
BenchmarkTools.Trial: 10000 samples with 10 evaluations.
 Range (min … max):  1.740 μs …   5.230 μs  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     1.810 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   1.831 μs ± 142.881 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

    █▇▄
  ▂▄███▆▆▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▂▁▂▁▂▂▂▂▂▂▂▂▂▂▁▂▂▂▂▂▂▂▂▂▁▁▂▂▂▁▁▂▂▂▂ ▃
  1.74 μs         Histogram: frequency by time        2.81 μs <

 Memory estimate: 688 bytes, allocs estimate: 33.

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Units.jl 66.66% 4 Missing ⚠️
Additional details and impacted files

📢 Thoughts on this report? Let us know!

@albert-de-montserrat albert-de-montserrat merged commit 6d36651 into main Jan 17, 2025
22 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.

1 participant