How does one specify a QuantityVariable within a DimensionalCombinations invocation such that a resulting expression can be used in a substitution thence evaluation of a numeric Quantity? At the end of the attached notebook, notice that I had to strip off the expression that contained the QuantityVariable from the desired solution to DimensionalCombinations and do a manual substitution of the original Quantity so it could be numerically evaluated and converted into the desired units.
I will suggest naming intermediate computations and avoiding use of the percent operator %.
As for what went wrong, it involves use of QuantityVariable and I do not know if it is a bug or a misuse. The gist is that at least in some cases you will need to explicitly evaluate the second argument. The minor variation of your code below seems to give a plausible result.
mm = mUmaximum /. Solve[Sqrt[
c^5/((4 Pi)^2*G blackbodyEmissivity BoltzmannConstant *
CBRTemp^4)] == (2 G mUmaximum)/
c^2 + (4 G \[Pi] mUmaximum)/c^2 - (
4 G \[Pi] Cos[(c^3 t)/(G mUmaximum)] mUmaximum)/c^2 /.
t -> 0,
mUmaximum] /. {t -> 0,
BoltzmannConstant -> Quantity[1, "StefanBoltzmannConstant"],
blackbodyEmissivity ->
Quantity[1, "Joules"/("Meters"*"Meters"*"Seconds")],
G -> Quantity[1, "GravitationalConstant"],
c -> Quantity[1, "SpeedOfLight"],
CBRTemp -> Quantity[2.73, "Kelvins"]};
qu = QuantityUnit[First[mm]];
ud = UnitDimensions[qu]
(* Out[531]= {{"MassUnit", 1/2}, {"TimeUnit", 3/2}} *)
dc = DimensionalCombinations[
{QuantityVariable["mUmx", Evaluate@ud]},
QuantityVariable["mss", "Mass"],
IncludeQuantities -> "PhysicalConstants",
GeneratedParameters -> None
];
ne = First[Rest[dc]]
(* Out[534]= (Quantity[1, ("SpeedOfLight")^(9/4)/(
"GravitationalConstant")^(3/4)]) Sqrt[QuantityVariable[
"mUmx",{{"MassUnit", 1/2}, {"TimeUnit", 3/2}}]] *)
QuantityVariable has the Attribute HoldRest (primarily to handle custom physical quantities like "Mass"/"Mass"). That interferes with the substitution with %.
SetAttributes[test,HoldRest]
1+1
test[1, %]
(*Out[2]= 2
Out[3]= test[1, %]*)
It may be that QuantityVariable could handle this better. But that is the reason your original code failed.
It should probably evaluate its argument at some point. I had to use Evaluate[] to get my version to work and that seems a bit excessive. Granted, I am not versed in use of QuantityVariable. Then again, it might be good to plan for users not being versed in such.