[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [h5md-user] Units Module Question

From: Felix Höfling
Subject: Re: [h5md-user] Units Module Question
Date: Mon, 12 May 2014 10:32:45 +0200
User-agent: Opera Mail/12.16 (Linux)

Am 10.05.2014, 19:10 Uhr, schrieb Pierre de Buyl <address@hidden>:

On Sat, May 10, 2014 at 02:46:04PM +0200, Konrad Hinsen wrote:
Hart, David Blaine writes:

> I want to convert “Kcal mol-1 Å-1” into “J mol-1 m-1”, which leads me to want to > use the unit string “4.184 10+10 J mol-1 m-1”. But I’m not sure that’s valid. But > is seems weird that it would be invalid since there are so many numeric conversion > factors that are multiplied by a factor of ten, like “1.602e-19 C” written as
 > “1.602 10-19 C”.
> This isn’t a big deal, since the SI prefixes can usually make it so that the > decimal only has to be shifted one or two places in the numeric factor, but I
 > thought I’d mention it.

How about “4.184e10 J mol-1 m-1” ?

I did think of that but this possibility is only implicit in the specification
(both Mosaic and H5MD). It seems however logical to accept the scientific
notation for the numeric factor.

An explicit syntax grammar would be very helpful here. I had one interpretation of how a unit string should look like and I thought that there is no doubt about it. But now I realise that many other interperations are possible:

The first (optional) part is a number in non-scientific notation (integer or decimal fraction—what is the decimal sign? "." in English, "," in German). Thus "4.184e10" is excluded although it seems very natural.

It is unclear from the wording of the spec whether the number can be followed by an exponent, e.g., whether 4.184-10 would be allowed (evaluating to pow(4.184, -10)).

It is probably intended that the string "1.602 10-19 C" is valid. On first reading, however, I thought it has 2 numeric factors and is not covered. It seems that the second part is a "numeric (unit) factor", to be distinguished from the leading "number".

If "1.602 10-19 C" would be valid, then the reading of the spec would also allow for "10-19 C 1.602" (because nothing is said about the position of the "number").

To avoid this kind of confusion I suggest to either include "10" as the only possible numeric unit symbol. (What about 2, positive integers?) Or we call "1.602 10-19" the (leading) number and make its format explicit.

@David: in the course of the development of the units module, there was also support for non-SI units which were dropped later on. I believe because there was no concensus of what should be included. Your use case involving "kcal" would probably be covered more naturally by such an extension of the units module, see the udunits2 library: http://nongnu.org/h5md/implementation.html#using-udunits2-for-units-interpretation



reply via email to

[Prev in Thread] Current Thread [Next in Thread]