Maple Units package



--- Eike Welk  wrote:
> On Friday 01 April 2005 01:04, C Y wrote:
> 
> > I guess what I could do is assign a unit prefix which can be
> > appended to the unit definition arrays.  E.g. the program could go
> > through and stick unit_ on all current unit names.  Something like
> > :
> >
> > setunitprefix("unit_");
> 
> I find this simple and flexible. It makes me think about a simple 
> solution for inclusion of substances in unit names: Copy the whole 
> definitions and also add a suffix. Something like:
> 
> copyunitdefs("_H2O");
> 
> And then you could use:
> unit_mol_H2O
> You'd also have unit_N_H2O, unit_m_H2O ... but you don't have to use 
> them; unit_l_H2O may be usefull. 
> OK it is unelegant.

I think a much better course is to somehow make Maxima "aware" of the
chemical nature of these things, but that's for down the road.  When
that time comes feedback from you and other people interested in
blending chemistry calculations with CASs will be invaluable.

> > I think this would make more sense as part of a chemistry package
> > which makes use of the units package.  I could add all interesting
> > periodic table information while I'm at it :-).
> 
> How do you want to provide the information? Many constants?

Sort of.  I was thinking perhaps using the symbol for each element
(e.g. %elem_Au or something similar) and using qput to associate all
relevant periodic table and other interesting information with each
element.  physconst uses this for the RSU for units - it might scale up
well to this type of application.

> Very nice would be computing with chemical formulas. I could imagine 
> this:
> 
> (%i10) chem_defsymbol(X, H*i1+O*i2);
> (%o10)
> (%i11) chem_solve( 2*H2+X->H2O, X );
> (%o11)                       [ X=O2, i1=0, i2=2 ]
> 
> There should be a means to include a (partial) chemical analysis
> which is given in weight %, and to give product ratios in g/g. I
> have  currently no vision of an elegant syntax for this.

That could be rather difficult to figure out.  Another "down the road"
issue, but an interesting one.
 
> I have already written a small program (for Maxima and Maple) that 
> solves problems like this for a specific biochemical reaction.
 
Cool.
 
> > In essence, yes.  I will think about how to handle that.  It is not
> > clear to me whether diff needs to know about this, although I
> > suppose it might.  I get a cold chill or two when I think about
> 
> Thinking about it, with your approach there seems no change to diff()
> 
> and int() necessary:
> 
> diff(10/2*u_m/u_s^2*t^2, t) = 10*u_m/u_s^2*t  
> (like with pen and paper)
> 
> The need for changing int() and diff() seems to come from Maple's 
> approach to insure correctness of the units.

Hmm.  That might be the case.  That would make life much simpler.

> What would happen if I had typed:
> (%i3) N;
> (%o3)         kg/m/s^2       /* ? */

Unless you have told it otherwise, it would return N in this case.  It
should also be possible to select the above behavior, but I have yet to
add that flag IIRC.
 
> If yes, I would prefer a separate conversion function, and not do
> much conversions automaticly. But who codes decides, offcourse.

This should be easily doable.  The intent of the package is to be
flexible, after all.  You might have to change from the defaults in
some cases, but that's what maxima-init.mac is all about ;-).

> I guess that will be fairly soon. Does conversion to arbitrary units 
> work already?

Sort of.  I don't know if you've been watching the list, but we have
had some problems creating the post-eval mechanism necessary to do
automatic conversion.  I expect we will get it licked, it's just a
question of what parts of Maxima need to be informed of something new
needing to happen, or how our mechanism needs to be defined to work
correctly within the context of things like kill(all)

So yes, the structure for arbitrary unit conversion is mostly in place,
and being debugged.  It's the most fundamental part of the system, so I
need to be as sure as my rudimentry abilities allow that I did it
correctly.  Then enough unit defs can be added to make it really
useful.
 
> I've also written a unit conversion package for Maxima, you can have 
> it if you want. (Although you won't be much impressed.) 

That would be great, if you don't mind releasing it under the GPL
(Maxima's license).  What are its capabilities?

CY


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Personals - Better first dates. More second dates. 
http://personals.yahoo.com