SymbolicML / DynamicQuantities.jl

Efficient and type-stable physical quantities in Julia
https://symbolicml.org/DynamicQuantities.jl/dev/
Apache License 2.0
132 stars 17 forks source link

DifferentialEquations.jl extensions #74

Open MilesCranmer opened 11 months ago

MilesCranmer commented 11 months ago

@gaurav-arya this is an attempt to get DifferentialEquations.jl working. @ChrisRackauckas got part of the way on this issue: https://github.com/SciML/DifferentialEquations.jl/issues/993#issuecomment-1785034821

github-actions[bot] commented 11 months ago

Benchmark Results

main 8e03c10916438e... t[main]/t[8e03c10916438e...]
Quantity/creation/Quantity(x) 2.79 ± 0.01 ns 2.79 ± 0.01 ns 1
Quantity/creation/Quantity(x, length=y) 4.02 ± 0.01 ns 3.11 ± 0.01 ns 1.29
Quantity/with_numbers/*real 3.1 ± 0.01 ns 3.1 ± 0.01 ns 1
Quantity/with_numbers/^int 7.74 ± 1.8 ns 7.74 ± 1.8 ns 1
Quantity/with_numbers/^int * real 7.75 ± 1.9 ns 7.75 ± 1.9 ns 1
Quantity/with_quantity/+y 5.27 ± 0.01 ns 5.27 ± 0.01 ns 1
Quantity/with_quantity//y 3.41 ± 0.01 ns 3.41 ± 0.01 ns 1
Quantity/with_self/dimension 1.55 ± 0.01 ns 1.55 ± 0.01 ns 1
Quantity/with_self/inv 3.11 ± 0.01 ns 3.11 ± 0.01 ns 1
Quantity/with_self/ustrip 1.55 ± 0.01 ns 1.55 ± 0.01 ns 1
QuantityArray/broadcasting/multi_array_of_quantities 0.149 ± 0.14 ms 0.149 ± 0.14 ms 0.998
QuantityArray/broadcasting/multi_normal_array 0.05 ± 0.00034 ms 0.05 ± 0.00025 ms 1
QuantityArray/broadcasting/multi_quantity_array 0.159 ± 0.0017 ms 0.159 ± 0.0019 ms 1
QuantityArray/broadcasting/x^2_array_of_quantities 27.8 ± 2.1 μs 27.6 ± 2.1 μs 1.01
QuantityArray/broadcasting/x^2_normal_array 5.88 ± 0.76 μs 5.9 ± 0.82 μs 0.997
QuantityArray/broadcasting/x^2_quantity_array 6.25 ± 0.4 μs 6.27 ± 0.39 μs 0.997
QuantityArray/broadcasting/x^4_array_of_quantities 0.0789 ± 0.00066 ms 0.0788 ± 0.00058 ms 1
QuantityArray/broadcasting/x^4_normal_array 0.0469 ± 0.00021 ms 0.0469 ± 0.00021 ms 1
QuantityArray/broadcasting/x^4_quantity_array 0.0563 ± 0.00025 ms 0.0563 ± 0.00023 ms 0.999
time_to_load 0.168 ± 0.00067 s 0.168 ± 0.0081 s 0.999

Benchmark Plots

A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).

ChrisRackauckas commented 10 months ago

I think you'll need a few changes to OrdinaryDiffEq.jl itself. Also, we'll need to think about how some things like scalar tolerances are handled if there's multiple different units, that needs some representation like a fillvector just for the units

MilesCranmer commented 10 months ago

By multiple different units do you mean if the user were to use SymbolicDimensions, which let's you choose cm or m for storing length? The default Dimensions type enforces SI units (i.e., no prefixes) everywhere; will that be an issue?