You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to determine if an expression, with arbitrary constants, is dimensionally correct. The constants essentially have "wildcard" units which one would solve for to make an expression consistent. How can I do this with Unitful.jl?
For example,
$a_1 x - a_2 y$ , is dimensionally correct, for any dimensions in $x$ and $y$, because $a_1$ and $a_2$ are free parameters.
$\cos(a_1*x)$ is dimensionally correct, as the $a_1$ can cancel out the dimensions of $x$.
But, $\cos(a_1*x - y)$ is not dimensionally correct if $y$ has units which cannot be cancelled out.
$\cos(a_1*x) * a_2 - y$ is dimensionally correct, as the $a_2$ can give the result of the $\cos$ the same units as $y$ has.
I am wondering what the best way to approach this with Unitful.jl is?
The text was updated successfully, but these errors were encountered:
""" WildcardDimensionWrapper{T}A wrapper for `Quantity{T}` that allows for a "wildcard" unit, indicatingthere is a free constant whose dimensions are not yet determined.Also stores a flag indicating whether an expression is dimensionally consistent."""
Base.@kwdefstruct WildcardDimensionWrapper{T}
val::Quantity{T}=one(Quantity{T})
wildcard::Bool=false
violates::Bool=falseend
and propagate wildcard through a depth-first tree traversal evaluation.
However, it is slow. I think this is due to the type instability in val, as the units are variable at each node in an expression. Is there any way I can get around this? Or maybe a type-stable version of Unitful.jl I could use?
I want to determine if an expression, with arbitrary constants, is dimensionally correct. The constants essentially have "wildcard" units which one would solve for to make an expression consistent. How can I do this with Unitful.jl?
For example,
I am wondering what the best way to approach this with Unitful.jl is?
The text was updated successfully, but these errors were encountered: