
I'm using Boost.Units in a program for school to make certain that my
equations are consistent (and that I didn't screw them up entering
them). In the next Velocity equation, first get assigned with no
problems, second causes a compiler error that I believe is saying that
the constructor for quantity<velocity> is explicit.
Why does first work without a conversion and second doesn't? Also,
how do I get second to work? I assume this will require some type of
explicit conversion, but wrapping the right-hand side with
quantity<velocity>(...) doesn't work.
const quantity<dimensionless> pi =
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798;
const quantity<time> deltaTime = .1 * second;
const quantity<length> particleDiameter = .001 * meter;
const quantity<dimensionless> dragCoefficient = 0.5;
const quantity<dimensionless> specificGravityGold = 19.32;
const quantity<acceleration> gravity = 9.80665 * meters_per_second_squared;
const quantity<length> initialHeight = 0 * meters;
const quantity<time> initialTime = 0 * seconds;
const quantity<velocity> initialVelocity = root<2>(4.0/3 *
specificGravityGold * gravity * particleDiameter / dragCoefficient);
const quantity

Why does first work without a conversion and second doesn't? Also, how do I get second to work? I assume this will require some type of explicit conversion, but wrapping the right-hand side with quantity<velocity>(...) doesn't work.
quantity<velocity> nextVelocity(quantity<velocity> old) { quantity<velocity> first = (pi / 6.0 * pow<3>(particleDiameter) * gravity * (densityWater - densityGold)) * deltaTime / particleMass; quantity<velocity> second = (pi / 8.0 * densityWater * dragCoefficient * old * root<2>(pow<2>(old))) * deltaTime / particleMass; ... }
The second equation is dimensionally incorrect; i.e. the library is doing what it should be doing : telling you that you've made a mistake in your equation. In particular, the first equation gives m^3 (m s^-2) (kg m^-3) s kg^-1 -> m s^-1 while the second gives (kg m^-3) (m s^-1)^2 s kg^-1 -> m^-1 s^-1 Matthias
participants (2)
-
Daniel Dilts
-
Matthias Schabel