Skip to content

refactor: use physical constants from Unitful#166

Merged
henry2004y merged 2 commits into
masterfrom
feat-constants
May 16, 2026
Merged

refactor: use physical constants from Unitful#166
henry2004y merged 2 commits into
masterfrom
feat-constants

Conversation

@henry2004y

Copy link
Copy Markdown
Owner

Use physical constants from Unitful instead of defining new ones locally.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the codebase to use Unitful.jl for physical constants and unit conversions, moving definitions to UnitfulBatsrus.jl and updating calculations in derived.jl. Feedback focuses on further centralizing scaling factors as constants within UnitfulBatsrus.jl to improve maintainability, ensure consistency, and avoid redundant calculations.

Comment thread src/unit/UnitfulBatsrus.jl Outdated
Comment thread src/unit/UnitfulBatsrus.jl
Comment thread src/derived.jl Outdated
Comment thread src/derived.jl Outdated
@github-actions

github-actions Bot commented May 16, 2026

Copy link
Copy Markdown

Benchmark Results (Julia v1)

Time benchmarks
master 6e84651... master / 6e84651...
amrex/load 26.1 ± 0.57 μs 25.3 ± 0.57 μs 1.03 ± 0.032
amrex/phase_space_3d 6.34 ± 1.8 ms 6.4 ± 0.91 ms 0.99 ± 0.31
amrex/select_region 0.246 ± 0.013 ms 0.25 ± 0.013 ms 0.983 ± 0.075
amrex/select_region_from_files 0.879 ± 0.17 ms 0.901 ± 0.17 ms 0.976 ± 0.26
read/ASCII 0.66 ± 0.014 ms 0.653 ± 0.015 ms 1.01 ± 0.032
read/Anisotropy 7.58 ± 0.12 μs 7.74 ± 1.6 μs 0.979 ± 0.2
read/Current density 9.8 ± 0.45 μs 9.66 ± 0.44 μs 1.01 ± 0.066
read/Current density 3D 10.6 ± 0.5 μs 10.5 ± 0.36 μs 1.01 ± 0.059
read/Current density 3D Jx 5.34 ± 0.12 μs 5.68 ± 0.11 μs 0.941 ± 0.028
read/Current density Jz 7.51 ± 0.09 μs 7.56 ± 0.11 μs 0.993 ± 0.019
read/Cutdir 2.26 ± 0.19 μs 2.28 ± 0.22 μs 0.991 ± 0.13
read/Cutdir subset 3.14 ± 0.27 μs 3.12 ± 0.27 μs 1.01 ± 0.12
read/Extract Bmag 0.561 ± 0.14 μs 0.501 ± 0.11 μs 1.12 ± 0.37
read/HDF5 0.11 ± 0.0053 ms 0.11 ± 0.0032 ms 0.994 ± 0.056
read/HDF5 extract 14 ± 0.35 μs 13.5 ± 0.35 μs 1.04 ± 0.038
read/Interp2d 1.1 ± 0.16 μs 1.09 ± 0.09 μs 1.01 ± 0.17
read/Load binary structured 0.0463 ± 0.0057 ms 0.0457 ± 0.005 ms 1.01 ± 0.17
time_to_load 1.25 ± 0.022 s 1.25 ± 0.0045 s 0.999 ± 0.018
Memory benchmarks
master 6e84651... master / 6e84651...
amrex/load 0.212 k allocs: 9.67 kB 0.212 k allocs: 9.67 kB 1
amrex/phase_space_3d 0.059 k allocs: 18.3 MB 0.059 k allocs: 18.3 MB 1
amrex/select_region 3 allocs: 1.07 MB 3 allocs: 1.07 MB 1
amrex/select_region_from_files 0.05 k allocs: 7.48 MB 0.05 k allocs: 7.48 MB 1
read/ASCII 0.395 k allocs: 0.109 MB 0.395 k allocs: 0.109 MB 1
read/Anisotropy 3 allocs: 4.84 kB 3 allocs: 4.84 kB 1
read/Current density 10 allocs: 12.5 kB 10 allocs: 12.5 kB 1
read/Current density 3D 10 allocs: 6.65 kB 10 allocs: 6.65 kB 1
read/Current density 3D Jx 4 allocs: 2.23 kB 4 allocs: 2.23 kB 1
read/Current density Jz 4 allocs: 4.18 kB 4 allocs: 4.18 kB 1
read/Cutdir 0.137 k allocs: 5.98 kB 0.137 k allocs: 5.98 kB 1
read/Cutdir subset 0.159 k allocs: 8.89 kB 0.159 k allocs: 8.89 kB 1
read/Extract Bmag 3 allocs: 4.09 kB 3 allocs: 4.09 kB 1
read/HDF5 0.1 k allocs: 3.67 kB 0.1 k allocs: 3.67 kB 1
read/HDF5 extract 17 allocs: 4.55 kB 17 allocs: 4.55 kB 1
read/Interp2d 12 allocs: 4.45 kB 12 allocs: 4.45 kB 1
read/Load binary structured 0.144 k allocs: 0.0743 MB 0.144 k allocs: 0.0743 MB 1
time_to_load 0.149 k allocs: 11.1 kB 0.149 k allocs: 11.1 kB 1

@codecov

codecov Bot commented May 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.05%. Comparing base (ab89902) to head (6e84651).

Files with missing lines Patch % Lines
src/derived.jl 20.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #166   +/-   ##
=======================================
  Coverage   83.05%   83.05%           
=======================================
  Files          21       21           
  Lines        4155     4155           
=======================================
  Hits         3451     3451           
  Misses        704      704           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@henry2004y henry2004y merged commit 1095c9d into master May 16, 2026
7 of 8 checks passed
@henry2004y henry2004y deleted the feat-constants branch May 16, 2026 03:46
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