As I was running in to issues converting units for handling various bits of data I wrote some classes to help. I have one class for MKS units and one for the KCal/Mol/Angstrom sorts of units that MD expects. And methods to handle conversions between the two. Using them you can write things like PicoJoules(1)/Meter(2) and get something with the right units out and then call convert_to_kcal to convert it to the MD units. Perhaps the latter unit should be called MDUnit or something.
It is written as C++ template classes but specific units can probably be exposed to python. However I think Scientific Python already includes this sort of thing, so it is probably not very useful. However, that means there is no easy way to test any of it with our current test framework.
Since it is written using templates, there is no easy way to integrate it into the attribute table. So don't get any ideas about that, as nice as it would be. On the plus side, there is no runtime penalty.
It is used in the soon-to-be-submitted brownian dynamics code among other things.
Daniel Russel wrote: > As I was running in to issues converting units for handling various bits > of data I wrote some classes to help. I have one class for MKS units and > one for the KCal/Mol/Angstrom sorts of units that MD expects. And > methods to handle conversions between the two. Using them you can write > things like PicoJoules(1)/Meter(2) and get something with the right > units out and then call convert_to_kcal to convert it to the MD units. > Perhaps the latter unit should be called MDUnit or something.
I have no particular problem with any of this, except that the comments (not sure about the code though) seem rather confused about many of the units. I don't know what KCal and Mol are, for example - these should be kcal and mol, of course. And there are far better sources for fundamental constants than Wikipedia!
> It is written as C++ template classes but specific units can probably be > exposed to python. However I think Scientific Python already includes > this sort of thing, so it is probably not very useful.
Indeed. Certainly MMTK does.
Assuming a cleaned-up version of this patch is available, and nobody has further comments/suggestions, I can commit it later tomorrow.
Ben
participants (2)
-
Ben Webb
-
Daniel Russel