|
Boost : |
From: Oleg Abrosimov (beholder_at_[hidden])
Date: 2006-06-09 16:09:18
I believe that in current state PQS can not be accepted into boost.
Reasons:
1) It is almost useless for scientists. (of cause, it is very useful for
engineers, though). It lacks or makes it really hard to plug-in
different systems, such as C.G.S.E. (centimeter, gramme, second, and
intensity of electric field from one electron is given by formula: E =
e/r2. Note, no k coefficient, as in SI), standard model in theoretical
physics (velocity of light is 1, plank constant is 1, etc.),
relativistic model, where only velocity of light is 1 (it means that
dimensions of time and length are equal. length is time and time is
length). This list can be expanded dramatically (almost every physical
problem can benefit from some sort of special dimensions usage).
2) In PQS concept of dimensional analysis is tightly coupled with
concept of units. I believe that they _must_ be uncoupled and
implemented independently.
Dimensional analysis has its own value even without any units at all.
Below is a description of a Dimensional/Units library that would be good
enough for boost (and for users in the first place) IMO.
I envision the following workflow as a typical usage of
Dimensional/Units library:
1) define a dimensional space (some types of a basic dimensions. a
number of dimensions can vary from application to application
significantly: 7 in SI; 6 in relativistic theory; 2 in a simple
financial analysis (time and money); etc.). On this step one also can
establish some restrictions on dimensions usage, like: money can not be
in any power different from 1, if it makes sense in a particular
application.
As a result of this stage one would have a number of dimension types:
D1, D2,..., Dn. In SI it would be LengthDim, MassDim, etc.
2) define facets and manipulators for input/output of values of this
dimension space. It is the only place where units come to play. I
believe that there is really no need to have all these mm/mkm/nm stuff
in code. Simple Length should be used.
3) define all sensible conversions/relations to/with other dimensional
spaces. For example, if we already have SI and are going to define
relativistic model, we can state that Length and Time in relativistic
model can be treated as Length in SI model, and define a conversion
coefficient (if our relativistic model assumes parsecs as its native
Length unit, then this coefficient would map parsecs to meters). Note
that it is not required if we have no need to cooperate with SI.
4) define all value types desired as in the following example:
namespace relativistic {
typedef quantity<double, LengthDim> Length;
}
5) use it in your code:
int main()
{
using namespace relativistic;
Length l1, l2;
std::cin >> l1; // in parsecs
std::cin >> kilo >> l2; // in kilo parsecs
Length sum = l1 + l2;
//Length sum = l1 * l2; // error
std::cout << giga << sum; // output xxx GParsecs
}
Of cause, library would have many different dimensional spaces out of
the box. not only SI. Typically, user would be involved in the final (5)
step of this process, but library would provide primitives to make life
of those who can not escape 1-4 steps as easy as possible.
So far, dimensions were defined as a compile time entities, whose only
one influence on run-time were output. But run-time dimensional analysis
can be very useful too. It means that Boost.Dimensional library
should/can (note that this item is optional though) provide it. It can
be useful in validating formulas originated from user input at run-time
and in the real dimensional analysis. Below is a description of what I
mean by that:
Consider a simple experiment: drop a ball of mass M from a table whose
height is H with horizontal velocity V (the gravitational acceleration
is G). The question is how the horizontal distance L from the initial
ball position to the point where itll touch floor first time is
dependent on parameters {M, H, V, G}? In other words, we need to find a
function f such that L ~ f(M, H, V, G). Almost everyone knows how to
solve it using Newton mechanics, but we can do something even without
it, by using only dimensional analysis:
1) Is it possible to construct dimensionless value from given parameters?
M^m * H^h * V^v * G^g ~ Mass^m * Length^h * (Length/Time)^v *
(Length/Time2)^g == 1 <=> m == 0 && h + v + g == 0 && v + 2*g == 0 <=> m
== 0 && h == g && v == -2g. We can conclude that it is H * G / V2.
2) Let try to construct a Length:
M^m * H^h * V^v * G^g ~ Mass^m * Length^h * (Length/Time)^v *
(Length/Time2)^g == Length <=> m == 0 && h + v + g == 1 && v + 2*g == 0
<=> m == 0 && h == g + 1 && v == -2*g => H2 * G / V2
Now we can conclude, that L = (H^(g+1) * G^g / V^(2*g)) * f(H * G / V2),
where f is an arbitrarily function and g can be any rational number.
if g is set to be -1/2 it becomes:
L = (H * V2 / G)^(1/2) * f(H * G / V2)
Note that an exact answer is: L = (2 * H * V2 / G)^(1/2)
Also note that mass have disappeared from our equations completely, so
we can conclude that L is not affected by mass of our ball using only
dimensional analysis.
From this simple example it can be seen, that dimensional analysis can
be used to determine a functional relationship between experimentally
observable and unknown parameters that can be used to significantly
reduce problem complexity. Utility that can provide such functionality
would be very useful for many experimentalists and of cause a library
that can be used to implement such utility would be welcomed too.
I hope, that you Andy can transform your PQS library into something that
was described here. And I want to thank you that you made PQS and thank
you in advance if youd be the one wholl made Boost.Dimensional/Units
library.
Best regards,
Oleg Abrosimov.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk