Research Article
A model-driven approach to automatic conversion of physical units
Article first published online: 31 MAY 2007
DOI: 10.1002/spe.828
Copyright © 2007 John Wiley & Sons, Ltd.
Additional Information
How to Cite
Cooper, J. and McKeever, S. (2008), A model-driven approach to automatic conversion of physical units. Software: Practice and Experience, 38: 337–359. doi: 10.1002/spe.828
Publication History
- Issue published online: 22 FEB 2008
- Article first published online: 31 MAY 2007
- Manuscript Accepted: 11 MAR 2007
- Manuscript Revised: 9 MAR 2007
- Manuscript Received: 16 NOV 2006
- Abstract
- References
- Cited By
Keywords:
- physical dimensions;
- units of measurement;
- CellML;
- model driven
Abstract
When physical quantities are used in programs they are typically represented as raw numbers, with the units in which they were measured only being given in comments, if at all. This can lead to errors from the use of dimensionally inconsistent expressions, or the comparison of two quantities of the same dimension but measured in different units, which are not discovered until run time. Any program working with the physical world has this issue, with scientific modelling being a major application. Implementors of models have the time-consuming and error-prone task of adding in dynamic units checks and conversions manually. Most existing programming languages do not provide support for representing units explicitly (although extensions to some have been proposed). With the advent of domain-specific modelling languages, incorporating code generation techniques, we propose checking physical units at the level of the modelling language, removing the need for such a support in the underlying implementation language. We present our work in the context of one such modelling language: CellML, developed at the University of Auckland with a focus on modelling biological systems. We have developed an intuitive algorithm for performing automatic conversions between quantities measured in different units. It both requires fewer conversion operations than current approaches and makes more sensible choices about which quantities to convert. Uniquely, by using partial evaluation techniques it is also capable of dealing robustly with quantities raised to arbitrary powers, even where the exponent is given by an expression. We demonstrate our algorithm on various examples. Copyright © 2007 John Wiley & Sons, Ltd.

1097-024X/asset/olbannerleft.jpg?v=1&s=2d7d001211f2c40f177a231141601e9f52afc1f3)
1097-024X/asset/olbannerright.jpg?v=1&s=3aec7891a8ba78b361ead9743adfc0b6eae6369a)
1097-024X/asset/cover.gif?v=1&s=5a70ecca2928358eca4ff75b9921d0552ffb6539)