Skip to content

Trying to use Measurements to differentiate respect to a unitful quantity. #151

@martinmestre

Description

@martinmestre

Hi,
I have tried with the following:

x = (98.1 ± 12.7)u"km"
y = (105.4 ± 25.6)*u"km"
Measurements.derivative.(x^2*y^2+2*x^3*y, [x, y])
ERROR: MethodError: no method matching derivative(::Quantity{Measurement{Float64}, 𝐋^4, Unitful.FreeUnits{(km^4,), 𝐋^4, nothing}}, ::Quantity{Measurement{Float64}, 𝐋, Unitful.FreeUnits{(km,), 𝐋, nothing}})
Stacktrace:
 [1] _broadcast_getindex_evalf
   @ ./broadcast.jl:683 [inlined]
 [2] _broadcast_getindex
   @ ./broadcast.jl:656 [inlined]
 [3] getindex
   @ ./broadcast.jl:610 [inlined]
 [4] copy
   @ ./broadcast.jl:912 [inlined]
 [5] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(Measurements.derivative), Tuple{Quantity{Measurement{Float64}, 𝐋^4, Unitful.FreeUnits{(km^4,), 𝐋^4, nothing}}, Vector{Quantity{Measurement{Float64}, 𝐋, Unitful.FreeUnits{(km,), 𝐋, nothing}}}}})
   @ Base.Broadcast ./broadcast.jl:873
 [6] top-level scope
   @ REPL[28]:1

I would like to know how could I modify the code.
Besides I would like to know if giving gradients with units to DifferentialEquations is possible and if it has time penalty.
Thank you very much

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions