# Integrate with Units

Calculate the diameter needed to empty a conical tank with a known coefficient of discharge.

#### Find the area of the tank as the diameter changes with respect to height h.

 In:= Xarea = Integrate[ Boole[x^2 + y^2 <= ((d0/2) + ((d1 - d0)/(2*h0))*h)^2], {x, -Infinity, Infinity}, {y, -Infinity, Infinity}, Assumptions -> {d0 > 0, d1 > d0, h > 0, h0 > 0}];

#### Assuming the tank has a diameter of 2.44 meters at the top and 1.22 meters at the bottom and has a coefficient of discharge of 0.6, find the diameter of an orifice that would empty the tank in six minutes if the full depth is 3.05 meters.

 In:= Xrules = Rationalize[{cd -> 0.6, g -> UnitConvert[Quantity["earth gravity"]], d0 -> Quantity[ 1.22, "Meters"], d1 -> Quantity[ 2.44, "Meters"], h0 -> Quantity[3.05, "Meters"]}, 0];
 In:= Xlhs = Integrate[(area/Sqrt[2*g*h]) /. rules, {Quantity[h, "Meters"], Quantity[0, "Meters"], Quantity[3.05, "Meters"]}] ; rhs = Integrate[(cd*(Pi*d^2)/4), {t, 0, Quantity[360, "Seconds"]}] /. rules;
 In:= Xradius = QuantityMagnitude[d /. First[Solve[{lhs == rhs, d > 0}, d]]]
 Out= In:= XRegionPlot3D[ x^2 + y^2 <= (1.22/2) + (2.44/(2*3.05))*z && (x^2 + y^2 >= radius/2 || z > 1), {x, -2, 2}, {y, -2, 2}, {z, 0, 3.05}, PlotPoints -> 25, ViewPoint -> {1.3, -2.4, 2.}, PlotLabel -> Style[Row[{TraditionalForm[d], Quantity[radius, "Meters"]}, "="], FontFamily -> "Verdana"], ViewPoint -> {-2.2, -0.9, -2.3}, ViewVertical -> {-.87, -.39, -0.29}, PlotStyle -> Directive[Specularity[White, 40], Orange], Mesh -> None]
 Out= 