0
$\begingroup$

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?!

$\endgroup$
  • $\begingroup$ There seems to be a problem with the parentheses - this doesn't run. $\endgroup$ – MelaGo Apr 24 '19 at 2:30
  • $\begingroup$ But Quantity inside Manipulate works, for example Manipulate[Pi Quantity[r, "Meters"]^2, {{r, 1., "radius"}, 1, 10}] $\endgroup$ – MelaGo Apr 24 '19 at 2:44
  • $\begingroup$ 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. $\endgroup$ – Bill Apr 25 '19 at 16:29
0
$\begingroup$

Here is the correct syntax for using Quantity in Manipulate.

\[Gamma] = ChemicalData["Water", "SurfaceTension"];
\[Mu] = ChemicalData["Water", "Viscosity"];
\[Rho] = ChemicalData["Water", "Density"];
g = Quantity["StandardAccelerationOfGravity"];

darcyEqn[d_, c_, \[Epsilon]_, Rb_, 
   L_, \[Theta]_, \[Phi]_] := ((Pi (d/
          2)^2 c \[Epsilon]^3 Rb^2)/((1 - \[Epsilon])^2 \[Mu])) (((3 \
(1 - \[Epsilon]) \[Gamma] Cos[\[Theta]])/(\[Epsilon] L Rb)) + 
     g \[Rho] Sin[\[Phi]]);

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

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.