As a physical scientists I am definitely excited about this.  I think
the basic plans are sound.

I presently do units as symbolic variable defined in terms of a list
of standard SI units.  I also define a list of physical constants with
units.  This works quite well, but as mentioned by others this means
everything ends up expressed in terms of the fundamental units.  I
then either have to recognize what derived unit the fundamental
expression is or divide it by derived units to see what I have.

So here are the key things beyond the already existing functionality
that would be ideal:
1) Automatic look up of physical units and their uncertainties at the
NIST web site.  I think the package should maintain a table and then
have a check_physical_constants() function.

2) Checking that units are compatible for addition. (already
mentioned)

3) The convert function that has been mentioned.  I would use this
they way I use recognizing derived units or division to check units on
final results.  I actually think it isn't a bad idea to always reduce
the expression to the fundamental units.  It might be most useful to
have multiple sets of fundamental units with the ability to define
your own set.  The common ones I would start with are SI, cgs, English
and computer units like bytes.  The way this would work is that you
would define which set of fundamental units you want to use at the
beginning of a calculation.

>
> >   sage: N = units.newton

4) The above ability is key.  My students get very confused if the
notation is not the standard used in chemistry/physics (ie. what's in
their textbooks).

To give people an idea how a working physical scientist uses this, I
include a section of the function I use to set up my calculations with
units.  One problem with this implementation is that it does not
account the limited number of significant figures in most of the
physical constants.  I don't usually worry about this because my
measurements usually have larger errors, which I account for using
standard error propagation techniques (another simple package I've
written for myself).

This is essentially what I did when using Maple and Mathematica as
well.  The unit package for Mathematic didn't exist at the time I was
using it and, as mentioned, Maple's is hard to use.

Jonathan
--------
def SI_units():
    var('m kg s N J Pa K C V A mol mm cm km g kJ mmol')
    global m, kg, s, N, J, Pa, K, C, V, A, mol, mm, cm, km, g, kJ,
mmol
    N = kg*m/s^2
    J = N*m
    Pa = N/m^2
    mm = 10^-3*m
    cm = 10^-2*m
    km = 10^3*m
    g = 10^-3*kg
    kJ = 10^3*J
    mmol =  10^-3*mol
    A = C/s
    V = J/C
    print "Have defined the following metric units: m, kg, s, N, J,
Pa, K, C, V, A,"
    print "mol,mm, cm, km, g, kJ, mmol. Expressions using any of these
units will "
    print "be converted to expressions in terms of kg, m , s , K, C
and mol."
    print "Do not use any of these symbolic combinations as
variables.  "
    print "The results will not be what you expect."

def p_chem_constants():
    SI_units()  #requires
    var('c e F k R h hbar N_A u m_e m_p m_n a_o G')
    global c, e, F, k, R, h, hbar, N_A, u, m_e, m_p, m_n, a_o, G
    c = 2.99792558e8*m*s^-1
    e = 1.602176e-19*C
    N_A = 6.02214e23*mol^-1
  [snip...]
    print "Have assigned the following physical constant values to the
following"
    print "symbols:"
    print "speed of light c ="+str(c)
    print "elementary charge e="+str(e)
    print "Avogadro's number N_A="+str(N_A)
    print "Faraday's constant F = "+str(F)
[snip...]
    print "Note that some of these have too many significant figures.
You can"
    print "also assign your preferred values to any of the variables
simply by"
    print "typing 'variablename = newvalue' on the command line."
    print "A specific example might be a more approximate speed of
light by"
    print "typing 'c = 3.00e8*m/s'."
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to