# How can I add units to variables inside Manipulate?

I've created a Manipulate expression with many variables. I would like each of these variables to have associated units as in the standard Quantity[Value,"Unit"] so that I can easily enter the values I want and get the answer in correct units. Unfortunately, Manipulate doesn't seem to tolerate this regardless of where I try to insert this feature. I'd also like to add UnitConvert to the answer so that I can see it in "mL/min".

Manipulate[
(Pi*(d/2)^2*c*e^3*Rb^2)*((3*(1 - e)*0.0728*Cos[t])/(e*L*Rb)+9800*Sin[p]))/((1 - e)^2*0.00089),
{{L, 0.07, "wick length"}, 0.01, 0.1},
{{d, 0.0068, "wick diameter"},0.001, 0.008},
{c, 1/60, 1/30},
{{e, 0.5, "porosity"}, 0.3, 0.9},
{{Rb, 0.0001, "fiber radius"}, 0.00001, 0.0002},
{{t, 70*(Pi/180), "contact angle"},0, Pi/2},
{{p, Pi/2, "wick orientation"}, 0, Pi/2}]


I've already tried replacing the bounds on each variable with quantities. And I've tried defining the symbols as quantities before entering the manipulate expression. I've also tried adding Quantity[] to each variable within the math expression. None of these works. Please help, there must be a way to do this, right?!

• There seems to be a problem with the parentheses - this doesn't run. Apr 24, 2019 at 2:30
• But Quantity inside Manipulate works, for example Manipulate[Pi Quantity[r, "Meters"]^2, {{r, 1., "radius"}, 1, 10}] Apr 24, 2019 at 2:44
• Thanks, I modified my original code, so I may have misplaced a parentheses. I've since gotten a good explanation of where I went wrong in my Quantity syntax via the Mathematica community.
– Bill
Apr 25, 2019 at 16:29

Here is the correct syntax for using Quantity in Manipulate.

γ = ChemicalData["Water", "SurfaceTension"];
μ = ChemicalData["Water", "Viscosity"];
ρ = ChemicalData["Water", "Density"];
g = Quantity["StandardAccelerationOfGravity"];

darcyEqn[d_, c_, ϵ_, Rb_,
L_, θ_, ϕ_] := ((Pi (d/
2)^2 c ϵ^3 Rb^2)/((1 - ϵ)^2 μ)) (((3 \
(1 - ϵ) γ Cos[θ])/(ϵ L Rb)) +
g ρ Sin[ϕ]);

Manipulate[
UnitConvert[
darcyEqn[d Quantity[1, "Millimeters"], c, ϵ,
Rb Quantity[1, "Microns"],
L Quantity[70,
"Millimeters"], θ °, ϕ °],
"mL/min"], {{L, 70, "wick length"}, 1,
100}, {{d, 6.8, "wick diameter"}, 1, 8}, {c, 1/60,
1/30}, {{ϵ, 0.5, "porosity"}, 0.3,
0.9}, {{Rb, 100, "fiber radius"}, 10,
200}, {{θ, 70, "contact angle"}, 0,
90}, {{ϕ, 90, "wick orientation"}, 0, 90}]


Note that the parameters at the beginning could also have been defined within Manipulate.