Kai Ludwig wrote:
-------- Original Message -------- Subject: Re: Physical Units From: "Kai Ludwig" <kai.ludwig@uni-tuebingen.de> Date: Fri, January 23, 2004 9:10 am To: <ginac-list@zino.physik.uni-mainz.de>
I've created a few programs for optimizing things, doing simple FEA (finite element analysis) and other sorts of calculations. Invariably, I end up restricting the domain to a consistent set of physical units (e.g. metric meter, kg, sec) or writing a lot of code to compensate for varying units across the input. For general-purpose tools, it can be a real pain in the shorts to get right.
Indeed, omitting units (and, for that matter, dimensions!) can lead to a lot of problems. By the way: in my opinion, sin(pi) is a number without dimension and unit (dimensionless number). However, it is interesting what unit the argument of the sin function, i.e. the pi, should have. Of course, this must be dimensionless. It could be a pure number, but it could equally well have a unit. It could result from some calculation with dimensioned quantities, which result in a dimensionless one. The Quantity library mentioned below does solve this problem by (a) checking the fact that the argument to a sin (and of course other such functions) to be dimensionless, (b) providing a type PureNumber, which can be used if a dimensionless quantity does not have any unit, and (c) if you want to work with an angle a type PlaneAngle (the name is according to IUPAC standards, the so-call Green Book), which can have units of Radian, Degree (not to be mixed up with temperature!!), Minute, Second, and Grade (all according to the Green Book). The Radian is the SI unit. Some general comment on Quantity follows below.
Have a look at,
http://sourceforge.net/projects/quantity
this is a C++ template library designed for unit conversions and unit type checking (already at compile time). As far as I know, there will be a new (redesigned) release in due course.
The current version 0.6 of Quantity is still somehow preliminary. In particular, a lot of checking is still done at run time, resulting in considerable overhead. I am currently working on a thorough re-design where most of the functionality is shifted to compile time, and the type design is much more secure. I am not really finished, since I learned about static template metaprogramming (which is used for this re-design in many instances) only recently. This is not simple. I used some ideas of W. Brown (http://www.oonumerics.org/tmpw01/brown.pdf), and the possibilities of A. Alexandrescu's Typelist concept (A. Alexandrescu, Modern C++ Design. Generic Programming and Design Patterns Applied, Addison-Wesley, Boston, 2001). Unfortunately, the re-design also necessitates a slight re-design of the interface, so version 0.6 will not be fully compatible with the upcoming, more recent versions. If anyone is interested in the library, please let me know and/or check the announcements and news on the sourceforge page of the project. regards Bernd -- =================================================================== Bernd Speiser Institut f"ur Organische Chemie Auf der Morgenstelle 18 D-72076 T"ubingen Germany phone: +49-7071-2976205 (office) +49-7071-2976242 (laboratory) fax: +49-7071-295518 (new!) e-mail: bernd.speiser@uni-tuebingen.de Internet: http://www.uni-tuebingen.de/speiser ===================================================================
participants (1)
-
Bernd Speiser