I have been playing with Maple's units package a little.
I want to use the units package to write differential equations where
the variables are in convenient units and leave the tedious unit
conversions to Maple. I haven't really done this yet because my
current simulation program is already written entirely in SI base
units. ( m^3 even if I simulate in the range of liters)
My impression of Maxima's units package:
----------------------------------------------
Good:
- Units have an own namespace without too much typing.
This refers to the "standard" units environment. I find the "natural"
environment where units appear in the global namespace impractical.
>3*Unit(cm/h);
1/120000*Unit([m/s])
- Easy creation of more specialized units. (Alternative description:
supports the usual notation of chemists.)
>m_mol_O2 = 2*16 * Unit(g(O2)/mol(O2));
m_mol_O2 = 4/125*Unit([kg(O2)/mol(O2)])
- Systems of base units can be created and manipulated. You can tell
the system to always convert volumes to liters. (I think)
- (Partial) integration into the rest of Maple. Many functions, most
notably int() and diff(), know of units.
---------------------------------------------------------------------
Bad:
- Only partial integration into the rest of Maple. The plot() function
for example does unfortunately not know of units.
- Instead much energy was spent on many exotic units eg.: US dry
barrels (there are hundreds of them). This is surely an anglo-saxon
speciality.
- The program gets easylie confused with expressions where only some
terms contain units eg.:
e_2 := s = 1/2*a*t^2+1/12*Unit([m/s])*t+20*Unit([cm])
It is impossible to simplify such an expression. It would be nice if
there were a way to tell the program that "t" is a time, "a" is an
acceleration, and "s" is a distance. (And a sensible way to display
this.)
- You can however substitute the symbols by a purely numeric symbol
multiplied by the correct units. e.g.:
>e_3:=subs([t=t_min*Unit(min), s=s_cm*Unit(cm),
>a=a_cmmin*Unit(cm/min^2)], e_2);
e_3 := s_cm*Unit([cm]) =
1/720000*a_cmmin*Unit([m/s^2]) * t_min^2*Unit([min])^2
+ 1/12*Unit([m/s])*t_min*Unit([min])
+ 20*Unit([cm])
I find this rather unelegant but it works. After a simplification all
desired conversion factors are there, but the units are gone.
>e_4:=simplify( solve(e_3,s_cm));
e_4 := 1/2*a_cmMin2*t_min^2+500*t_min+20
-------------------------------------------------------------------
I hope this is at least kind of helpfull for you. I find the work on
Maxima very valuable since Maple and Mathematica are insanely
expensive. If the RWTH would not have a site license for Maple I'd
use Maxima too.
Yours,
Eike.