The following notebook performs a relatively simple physical calculation interacting position, velocity and acceleration of two charged point particles according to Weber electrodynamics.It is simple enough that the correctness of the physical dimensions is apparent by inspection. However, Mathematica, when it differentiates a constant "Meters" function with respect to time, drops the meters dimension, resulting in a failure to calculate the desired force.
e.g. 100m+0.833924
I understand, from the sole response to a related question at the Mathematica community, that the imperial "we" considers this appropriate behavior for Mathematica. It manifestly is not appropriate behavior, of course. So I don't expect this bug to be fixed. Therefore I need a workaround for those of us who need to ensure that our models are dimensionally correct.
QuantityVector[name_String, components_List, unit_, vars_List : {}] := Module[{syms}, If[Length[vars] > 0, syms = Quantity[Symbol[name <> #][Sequence @@ vars], unit] & /@ components, syms = Quantity[Symbol[name <> #], unit] & /@ components]; syms]Q = Quantity[QM, "Coulombs"];q = Quantity[qM, "Coulombs"];Txhertz = Quantity[TxhertzM, "Seconds^-1"];Rxhertz = Quantity[RxhertzM, "Seconds^-1"];rVec = QuantityVector["Txr", {"x", "y", "z"}, "Meters", {t}] - QuantityVector["Rxr", {"x", "y", "z"}, "Meters", {t}]vVec = D[rVec, t]aVec = D[vVec, t]rUnitVec = rVec/Norm[rVec]c = Quantity["SpeedOfLight"];(*Speed of light in m/s*)epsilon0 = Quantity["ElectricConstant"];weberForce[ t_] = (Q q rUnitVec)/(4 Pi epsilon0 Norm[rVec]^2)*(1 + (1/ c^2) (vVec . vVec - 3/2 ((rUnitVec) . vVec)^2 + Norm[rVec] rUnitVec . aVec));(weberForce[t] /. { Txrx -> Function[0 #], Txry -> Function[0 #], Txrz -> Function[Quantity[100, "Meters"] + Sin[# Txhertz]] } /. { Rxrx -> Function[0 #], Rxry -> Function[0 #], Rxrz -> Function[Sin[# Rxhertz]] } /. {t -> Quantity[1/10^9, "Second"], TxhertzM -> 1.3*10^9, RxhertzM -> 1.3*10^8, qM -> 1, QM -> 1})[[3]]
Result:$$\frac{(100\text{m}+0.833924) \left(\frac{1}{4 \pi | 100\text{m}+0.833924| ^2}\text{C}^2\;\text{/(}\text{m}^2\varepsilon _0)\right) \left(\left(1/\text{c}^2\right) \left(4.78933\times 10^{16}\text{m}^2 \; /\text{s}^2+\frac{1}{2} (-3) \left(\frac{(100\text{m}+0.833924) \left(2.18845\times 10^8\text{m}/\text{s}\right)}{| 100\text{m}+0.833924| }+0\text{m}\right)^2+(| 100\text{m}+0.833924| \text{m}) \left(\frac{(100\text{m}+0.833924) \left(-1.62622\times 10^{18}\text{m}/\text{s}^2\right)}{| 100\text{m}+0.833924| }+0\text{m}\right)\right)+1\right)}{| 100\text{m}+0.833924| }$$