m
PbFc           @   s  d  Z  d k l Z l Z l Z l Z l Z l Z l Z l	 Z	 l
 Z
 l Z l Z l Z l Z l Z l Z l Z l Z l Z l Z l Z d k l Z l Z l Z l Z l Z l Z l Z d e f d     YZ d e e f d     YZ d e e f d     YZ  d	   Z! d
 e f d     YZ" d e e" f d     YZ# d e e" f d     YZ$ d   Z% d e f d     YZ& d e f d     YZ' d e f d     YZ( d e& f d     YZ) h  Z* e) e* d  Z) e* i+ Z, d   Z- [* d g d  Z. d e& f d     YZ/ [. ddd  Z1 e% d  d! d" d# d$ d% e e	 d& d'  e e  d( e e% d  d  d) d* d+ d( e! d  d  d, d- d. d% d/ e d0 d1 e e e% d  d d2 d3 d4  e% d d d5 d6 d7 d( e! d d d8 d- d9 e1 d" d# d  d: d; e h  d  d< <d d= <d> d<d?  Z2 e1 d5 d6 d d@ h  d> dA <dB dC <dD  Z3 e1 dE dF d> dG h  dH dI <dJ dK <dL  Z4 e1 dM dN dB dO h  dP d  <dQ  Z5 e1 dR dS dT dU dV e h  dW dX <dY dZ <d[  Z6 e1 d\ d] dH d^ d_ e h  d` da <db dc <dd d<de df e dg  Z7 e1 dh di dJ dj h  dd dk <dl dm <dn  Z8 e1 do dp dq dr ds e h  dt du <dv dw <dx dy <dz d{ e( d| d} e  Z9 e1 d~ d dP d h  d d  <d  Z: e1 d d dW d dV e h  d d <d d <d d <d  Z; e1 d d dY d h  d d  <d d d Z< e1 d d d` d h  d d <d d <d d <d  Z= e1 d d db d h  d d  <d d dZ> e d e e
 d d e> d _? e1 d d dd d d e h  d d <d d <d d <dC  Z@ e1 d d dl d h  d d  <d  ZA e1 d d dt d dV e h  d d <d d <d d <d d <d d dZB e1 d d dv d d e h  d d <d d <de  ZC e1 d d dx d h  d d <d d <d d <d d dZD e1 d d d d h  d d <d d <d d <d d d ZE e1 d d d d h  d d <d d <d d <d d <d dV <d d <dt  ZF e1 d d d d h  d d  <d  ZG e1 d d d d h  d d <d d <d d <d d <d d <d  ZH e1 d d d d h  d d <dd<d ZI e1 ddd dd e h  d d<dd	<d
d<dd<d ZJ e1 ddd dh  dd  <d ZK e1 ddd ddV e h  dd<dd<dd<dd<d d dZL e1 dd d d!h  d"d  <d  ZM e1 d#d$d d%h  dd&<d'd(<d)d*<d+d,<d-d.<d/ ZN e1 d0d1d d2d e h  d3d4<d5d6<d7d d8ZO e1 d9d:d d;h  d-d<<d=d><d?d@<dAdB<dCdD<dE ZP e1 dFdGd dHh  dIdJ<dKdL<dM ZQ e1 dNdOd dPh  dCdQ<dRdS<dTdU<dVdW<dXdU<dY ZR e1 dZd[d d\h  d]d  <d  ZS e1 d^d_d d`h  dVda<dXdb<dcdd<dedf<dgdh<didj<dk ZT e1 dldmd dndoe h  dpdq<drds<dt ZU e1 dudvd dwh  dedx<dgdy<didz<d{d|<d}d~<dd<d ZV e1 ddd dh  dd<dd<de  ZW e1 ddd dh  d}d<dd<dd<dd<d ZX e1 ddd dh  dd  <d ZY e1 ddd dh  d} d<dd<dd<dd<dd<d ZZ e1 ddd dh  dd  <dd dZ[ e1 ddd dh  dd<dd<d d<dd<dd<dd<dC d<dM Z\ e1 ddd ddg  Z] e1 ddd dh  dd <dd<dd<dC d<dd<dd<dd<d Z^ e1 ddd dh  dd  <d Z_ e1 ddd dh  dd  <ddY <dd<dd<dd<dd<d Z` e1 ddd ddV e h  dd<dd<dd dZa e1 ddd dh  dd<dd<dd<dd<dd<dd<dd<ddd<d Zb e1 ddd dh  dd<dd<d Zc e1 ddd dh  dd<dd<dd <dd<dd<dd <dd<dd<dd <dd<dd d	Zd e1 d
dddh  dd<dd<dd dZe e1 ddddh  ddn <dd<dd<dd<dd<dd<dd<dd <d! Zf e1 d"d#d
d$h  d%d  <dA  Zg e1 d&d'dd(h  dd)<ddn <dd*<d+d,<dd-<d.d/<d0d1<d2d3<d4d5<d6 Zh e1 d7d8dd9h  d:d  <dYd dZi e1 d<d=dd>h  dd?<d0d<d2d@<dAdB<d4dC<dDdE<dFdG<d?  Zj e1 dHdIddJh  dFdn <dKdL<dM Zk e1 dNdOddPh  d4dQ<dFd <dRdS<dTdU<dV Zl e1 dWdXd"dYh  dZd  <d[ Zm e1 d\d]d'd^h  dTd_<d`da<dbdc<ddde<dfdg<dhdi<djdk<d Zn e1 dldmd)ddddg  Zo e1 dndod+dph  dbdq<drds<dhdt<dudv<djdw<dxdy<dzd{<d| Zp e1 d}d~d3dh  dd<dd<d Zq e1 ddd-dh  dxd<dzd<dd<dd<dd<dd<dd<d Zr e1 ddd5dh  dd  <d Zs e1 ddd=dh  dd<ddn <dd<dd<dd<dd<dd<do Zt e1 ddd?dh  dd  <d Zu e1 dddAdh  dde <dd<dd<dd<dd<dd<d Zv e1 dddIdh  dd  <d Zw e1 dddCdh  dde <dd<dd<dd<dd<dd<dd<d Zx e1 dddKdh  dd<dd<d Zy e1 dddRdh  dd<dd<ddB<dd<dd<dd<do Zz e1 dddTdh  dd <dd<d Z{ e1 dddVdh  dde <dd<dd<dd<dd<dd dZ| e1 ddd]dh  dd<dd<d Z} e1 dddXdh  dd<d d<dd<dd <ddde e de d Z~ e1 d	d
dcdh  dd<dd<ddde e Z e1 dddedh  dd <dd<dd<dd<dd<dd<ddde e Z e1 dddpd h  d!d  <dd d"Z e1 d#d$dgd%h  dd <dd&<d'd(<d)d*<d+d,<d-d.<d/d0<d1d d2d dd{ e( d5e d6 d| e d7  d8e' de de d e e e  d| e d9e d e e e  d:e d;e d e e e d<e d   de d=e d>e e d> d? d@dAZ e i i e e e i e  e1 dBdCdrdDh  dEdF<dGdH<d[  Z e1 dIdJdidKh  d-dL<d/d <dMdN<dOdP<dQdR<dSd dTZ e1 dUdVd{dWh  dXd  <d Z e1 dYdZd}d[h  d[d  <d Z e1 d\d]dd[dMd^g  Z e1 d_d`ddadadbg d dZ e1 dedfddgdgg  Z e1 dhdiddjdkdldmdgg dn Z e1 dodpddqdqdlg dr Z e1 dsdtd} duh  dvd! <dwd  <dx Z e1 dydzdd{h  d{d  <d| Z e1 d}d~ddh  dd<dd<dd<d Z e1 ddddddg  Z e1 dddddddg  Z e1 ddd ddg  Z e1 dddddg  Z e1 dddddg  Z e1 dddddg  Z e1 dddddg  Z e1 dddC ddg  Z e1 dddddg  Z e1 dddddg  Z e1 dddddg  Z e1 dddddg d dZ e1 dddddg  Z e1 ddddddg  Z e1 dddddddg  Z e1 dddddg  Z e1 dddddg  Z e1 ddddddg  Z e1 dddddg  Z e2 d  i dd Z e2 d i d) d*  Z e2 d> i d2 d3  Z e dvi dd Z e dbi dd Z e i% i! Z e i% i! Z e3 dB i% i! Z [ [ [ [ [ [ [ [ [ [ [ [ [ [ [
 [ [ [ [ [ [ [ [ [1 dS(  s  Repository of data about the chemical elements and their isotopes.

The problem: we have two paths for isotopic mixing.  That is: an element's
composition describes it as a mix of atoms of various isotopes, each of which
has a composition comprising a definite number of neutrons, along with the
appropriate number of protons and electrons; but equally, e.g. from the point of
view of a chemical species (via its molecule), the element's atom has a definite
arrangement of electrons around a nucleus which is a mixture of possible
variants.  I chose to take the former description seriously and fake the latter.

For data, see (inter alia): http://www.webelements.com/

$Id: element.py,v 1.11 2007/06/03 16:41:52 eddy Exp $
(   s   Objects   Samples   Quantitys   megas   kilos   harpos   tophats   samples   years   Joules   Teslas   Kelvins
   Centigrades   grams   kgs   tonnes   metres   mols   torrs   cc(   s   AMUs   Particles   Bosons   Fermions   protons   neutrons   electront   Nucleusc           B   s   t  Z d Z RS(   Ns   Nucleus.item(   t   __name__t
   __module__t
   _namespace(    (    (    t)   /home/eddy/.sys/py/study/chemy/element.pyR       s    t   bNucleusc           B   s   t  Z d  Z RS(   s   Bosonic nucleus(   R   R   t   __doc__(    (    (    R   R      s    t   fNucleusc           B   s   t  Z d  Z RS(   s   Fermionic nucleus(   R   R   R   (    (    (    R   R      s    c         K   s{   | i h  d | <d h  t |  <t | << y t t g |  | d } Wn t
 j
 o } t } n Xt | f  |  S(   Nt   namet   constituentsi   (   t   whatt   updateR   t   protont   Qt   neutront   NR   R   t   klazt
   IndexErrort	   TypeErrorR    t   apply(   R   R   R   R
   R   R   (    (    R   t   nucleus   s    1  t   Atomc           B   s   t  Z d Z RS(   Ns	   Atom.item(   R   R   R   (    (    (    R   R       s   t   bAtomc           B   s   t  Z d  Z RS(   s   Bosonic atom(   R   R   R   (    (    (    R   R   "   s    t   fAtomc           B   s   t  Z d  Z RS(   s   Fermionic atom(   R   R   R   (    (    (    R   R   #   s    c   	      K   s   d | |  | f } y | d } Wn- t j
 o! t |  | |  } | d <n= Xy | i d p
 t  n Wn t j
 o | | _	 n X| i
 h  d | <d | <d | <d h  | d <t |  << y$ h  d t <d t <| d	 } Wn t j
 o t } n Xt | f  |  S(
   Ns   %s %d's nucleusR   R   R   t   symbolR	   i   i    i   (   R   R   R   t   ndocR
   t   nt   KeyErrorR   t   __dict__R   R   R   t   doct   electronR   R   R   R   R   (	   R   R   R   R   R   R
   R   R   R   (    (    R   t   atom$   s        C $ t	   Substancec           B   s   t  Z RS(   N(   R   R   (    (    (    R   R    4   s    t   Heatsc           B   s5   t  Z d   Z d   Z d   Z d   Z d   Z RS(   Nc         C   s   |  i S(   N(   t   selft   melt(   R"   t   ig(    (    R   t   _lazy_get_fusion_=   s    c         C   s   |  i S(   N(   R"   R#   (   R"   R$   (    (    R   t   _lazy_get_freeze_>   s    c         C   s   |  i S(   N(   R"   t   boil(   R"   R$   (    (    R   t   _lazy_get_vaporization_?   s    c         C   s   |  i S(   N(   R"   R'   (   R"   R$   (    (    R   t   _lazy_get_vaporisation_@   s    c         C   s   |  i S(   N(   R"   R'   (   R"   R$   (    (    R   t   _lazy_get_condense_A   s    (   R   R   R%   R&   R(   R)   R*   (    (    (    R   R!   ;   s
   				t   Temperaturesc           B   s5   t  Z d   Z d   Z d   Z d   Z d   Z RS(   Nc         C   s   |  i S(   N(   R"   R#   (   R"   R$   (    (    R   R%   D   s    c         C   s   |  i S(   N(   R"   R#   (   R"   R$   (    (    R   R&   E   s    c         C   s   |  i S(   N(   R"   R'   (   R"   R$   (    (    R   R(   F   s    c         C   s   |  i S(   N(   R"   R'   (   R"   R$   (    (    R   R)   G   s    c         C   s   |  i S(   N(   R"   R'   (   R"   R$   (    (    R   R*   H   s    (   R   R   R%   R&   R(   R)   R*   (    (    (    R   R+   C   s
   				t   Isotopec           B   s   t  Z d  Z e i Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z RS(   s   Single actual isotope.

    Well, OK, if constructor's N is a distribution, you get a distribution.
    But my intent is that we don't do that; though we might do the equivalent for
    a Nucleus, for the sake of an Element's atom.
c         C   s   f  |  _ t |  t d  j o t |  j n p t  |  i d | d |  y t i |  i	 } Wn t j
 o n! X| d  j	 o |  | | | <n d  S(   Ni   t   protonst   neutrons(   R"   t   _Isotope__namest   typeR   R   t   AssertionErrort   _Isotope__upinitt   Elementt   byNumberR-   t   elR   t   None(   R"   R   R   R5   (    (    R   t   __init__R   s    	7  c         C   s   |  t i | <t i | <|  i o |  i i |  i  n |  i |  i g |  _ |  i i	 d |  i  y
 |  ` Wn t
 j
 o n X| | |  _ |  _ |  S(   Ni    (   R"   R3   t   bySymbolR   t   byNameR   R/   t   appendt   _Isotope__namet   insertt   AttributeError(   R"   R   R   (    (    R   t   nominate]   s    
  
 c         C   sB   |  i o! d |  i d i |  i  f Sn d |  i i |  i f S(   Ns   %s (a.k.a. %s)s   , s   %s[%s](   R"   R/   R;   t   joint   elementR   t
   massnumber(   R"   t   ignored(    (    R   t   _lazy_get_name_k   s    
 !c         C   s   d |  i i |  i f S(   Ns   %s[%s](   R"   R@   R   RA   (   R"   RB   (    (    R   t   _lazy_get_symbol_o   s    c         C   s   d |  i |  i |  i f S(   Ns   <sup>%d</sup><sub>%d</sub>%s(   R"   RA   R-   R   (   R"   RB   (    (    R   t   _lazy_get_fullsymbol_r   s    c         C   s'   t  |  i  t  |  i  At  |  i  AS(   N(   t   hashR"   t	   __class__R-   R.   (   R"   RB   (    (    R   t   _lazy_get__lazy_hash_u   s    c         C   s)   t  |  i |  i |  i |  i d |  i  S(   Ns   Atom of isotope %s(   R   R"   R-   R.   R   R   t
   fullsymbol(   R"   RB   (    (    R   t   _lazy_get_atom_x   s    c         C   s   |  i S(   N(   R"   R-   (   R"   RB   (    (    R   t   _lazy_get_electrons_|   s    c         C   s   |  i |  i S(   N(   R"   R-   R.   (   R"   RB   (    (    R   t   _lazy_get_massnumber_}   s    c         C   s=   t  i |  i } | d  j o t  d  d  |  i d   } n | S(   N(   R3   R4   R"   R-   R5   R6   (   R"   RB   R5   (    (    R   t   _lazy_get_element_~   s    c         C   s   |  i S(   N(   R"   R   (   R"   (    (    R   t   __repr__   s    c         C   s   |  i S(   N(   R"   R   (   R"   (    (    R   t   __str__   s    (   R   R   R   R    R7   R2   R>   RC   RD   RE   RH   RJ   RK   RL   RM   RN   RO   (    (    (    R   R,   J   s    												c         C   sK   y | |  | f } Wn0 t j
 o$ | |  |  } | |  | f <n X| S(   N(   t   rackR   R   t   ansR   R   (   R   R   R   RP   RQ   (    (    R   R,      s
      "c           C   s   t  d   t    S(   Nc         C   s   t  |  d d   S(   Nt	   abundance(   t   getattrt   xR6   (   RT   (    (    R   t   <lambda>   s    (   t   filtert   Isotopes(    (    (    R   RU      s    i   c         C   so   |  d j  o
 t  n xM |  t |  j o9 t |  d d } | i | d d | d d  q W| |  S(   s  Element number for noble gas number n (counting with He as 0).

    If we take each noble gas as the last element in its cycle, the successive
    cycles of the periodic table have lengths (breaking after each group VIII
    element) 2, 8, 8, 18, 18, 32, 32, 50, 50, 72, 72, ...; let L be the list
    whose entries these are; then L[2*i] == L[2*i-1] == 2*(i+1)**2.  Summing
    according to Noble(i) = Noble(i-1) + L[i] then suffices to determine the
    element numbers of the noble gasses.
i    i   i   iN(   R   R   t   lent   cachet   iR:   (   R   RY   RZ   (    (    R   t   Noble   s      
 &R3   c        
   B   s	  t  Z d  Z e i Z d   Z h  h  Z Z e g d Z	 d  d  Z
 d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e e d  Z e d  Z d k l Z d e f d     YZ [ e e g d d  Z e e d  Z [ RS(!   s   Mixture of isotopes. c         K   s  h  |  _ | d j	 o | | d <n | d j	 o | | d <n | | d <| d j	 o | | d <n t |  i	 f  |  | |  _ | d j	 o | |  _ n x+ t
 t i  | j o t i i d  q W|  t i |  i <t i |  i <t i | <y | d } Wn t j
 o n Xx | D] } t
 |  d j  pI t
 d j oh | | i   j oU | d d j oD t d	   | d
  o, t i i |  p t  |  t i | <qt i i |  p t  |  t i | <qWy | d } Wn t j
 o n* Xt i i |  p t  |  t i | <| d j o^ | d j	 o  |  i d  } |  t i | <n | d j	 o  |  i d  } |  t i | <qn d S(   s   Initialise an Element. R   R   s   atomic numbers   relative atomic masst   aliasi   i    t	   UBTQPHSOEc         C   s
   |  d j S(   Nt
   nubtqphsoe(   RT   (   RT   (    (    R   RU      s    i   t   arcanumid   N(   R"   t   _Element__isotopesR   R6   R
   R   t   Zt   AR   t   _Element__upinitRX   R3   R4   R:   R8   R9   R\   R   t   symt
   capitaliseRV   t   has_keyR1   RC   RD   (   R"   R   R   Ra   Rb   R
   R\   Rd   (    (    R   R7      sR     	  
 	   )   \  ih   t   nilt   unt   bit   trit   quadt   pentt   hext   septt   octt   ennc         C   sM   f  |  i } } x6 | o. t | d  \ } } | | | d !| } q W| S(   Ni
   i   (   R"   Ra   t   rowt   divmodt   dt   latin(   R"   R$   Rt   Rs   Ra   Rq   (    (    R   t   _lazy_get__nom_   s     c         C   s7   d i  |  i  } | d d j o | d Sn | d S(   Nt    iRZ   t   umt   ium(   R?   R"   t   _nomR   (   R"   R$   R   (    (    R   RC      s     c         C   s"   d i  t d   |  i   i   S(   NRv   c         C   s   |  d S(   Ni    (   RT   (   RT   (    (    R   RU      s    (   R?   t   mapR"   Ry   t
   capitalize(   R"   R$   (    (    R   RD      s    c         C   sd   y |  i | } WnL t j
 o@ | t |  j p t  t |  i t |  |  i  } n X| S(   N(	   R"   R`   t   keyRQ   R   t   intR1   R,   Ra   (   R"   R|   RQ   (    (    R   t   __getitem__   s     $c         C   sr   | t |  j p t  y |  i | } Wn  t j
 o | |  i | <n" X| | j	 o t | d   n d  S(   Ns#   setting the same isotope repeatedly(	   R|   R}   R1   R"   R`   t   oldR   t   valuet
   ValueError(   R"   R|   R   R   (    (    R   t   __setitem__   s      c         C   s   t  |  i  S(   N(   RX   R"   R`   (   R"   (    (    R   t   __len__   s    c         C   s   |  i i   S(   N(   R"   R`   t   copy(   R"   (    (    R   t   isotopes   s    c         C   sb   h  } xU |  i i   D]D } y | i } | p
 t  n Wn t j
 o q X| | | <q W| S(   N(   t   bokR"   R`   t   valuest   isoRR   t   bunR=   (   R"   RB   R   R   R   (    (    R   t   _lazy_get_composition_   s     	  c         C   sc   d } } xC |  i i   D]2 \ } } | | i | | i | i	 | } } q W|  i
 | | d S(   Ni    i   (   t   sumt   countR"   t   compositiont   itemst   kt   vt   bestR-   R.   Rb   (   R"   RB   R   R   R   R   (    (    R   t   _lazy_get_margin_  s
    
 *c         C   s   |  i S(   N(   R"   R   (   R"   (    (    R   RN   
  s    c         C   s   |  i S(   N(   R"   R   (   R"   (    (    R   RO     s    c         C   s  t  |   d j o |  i i   d i Sn h  h  f  } } }	 y |  i } Wn t	 j
 o n2 Xt
 | |  o | i } n | f }	 | | d <x |  i i   D] } | i } t | i d |  |  | d <t | i d |  |  | d <y | i }
 |
 p
 t	  n Wn t	 j
 o q X|
 | | <q W| o | f |	 }	 n y t | |	 |  Wn" t j
 o t	 d |    n Xt |  i | |  i |  i d |  i  S(   Ni   i    R   t   hight   lows4   I don't know enough about myself to describe my atoms   %s atom(   RX   R"   R`   R   R   R   R
   t   baseRb   R=   t
   isinstanceR   t   _scalarR   R.   R   t   maxt   gett   minRR   R   R   t   SR   Ra   R   R   (   R"   RB   R   R   Rb   R
   R   R   R   R   R   (    (    R   RJ     s<        	
 		    c         C   s6   d } x% | |  |  i j  o | d 7} q	 W| d S(   s|   Conventional Period number of the element.

        This places H and He in period 1, Li through Ne in period 2, and so on.
i    i   N(   RZ   R   R"   Ra   (   R"   R$   R   RZ   (    (    R   t   _lazy_get_period_+  s       (   s   Lazyt   Groupc        	   B   sV   t  Z d  Z d   Z d   Z e Z e d d  Z e d  Z e d  Z	 d   Z
 RS(   s   A column of the periodic table of the elements.

        For my purposes, columns are numbered leftwards from 0 at group VIII,
        except that Groups I and II get negative values -1 and -2, respectively.
        See http://www.chaos.org.uk/~eddy/bits/elements.html for why.

        Groups I through VIII are named classically; each other column of the
        table reuses the name of its first element.  Each group has a .leader
        element, which is the first in the group (except that H is ignored).
c         C   s   | g  |  _ |  _ d  S(   N(   t   numberR"   t   _Group__numt   _Group__seq(   R"   R   (    (    R   R7   @  s    c         C   s   |  i S(   N(   R"   R   (   R"   (    (    R   RN   C  s    t   VIIIt   VIIt   VIt   Vt   IVt   IIIt   IIt   Ic         C   s4   |  i } | d j  o d | | Sn |  i i d S(   s5   Classical name, else symbol of first element in groupi   s   Group s   -GroupN(   R"   R   RZ   Rt   t   leaderR   (   R"   R$   R   Rt   RZ   (    (    R   RC   F  s
     	 c         C   s  |  i } | d j o t i d | Sn | d j  o t i d | Sn d } x( d | d | d j  o | d 7} qR W| d j p t  | d | d  | d | d  | d j p t  | d | d  | d | d  | d j p t  t i | d | d  | S(
   s'   First element in this group, ignoring Hi    i   i   i
   i   i   i   i   N(   R"   R   t   gR3   R4   RZ   R1   R   (   R"   R$   R   R   RZ   (    (    R   t   _lazy_get_leader_M  s     	    88c         C   s   | d j  o t |  n |  i pR |  i d j p |  i d j o |  i i t i d  n |  i i |  i  n |  i d i	 } |  i d j  o | d 8} n xI t |  i  | j o2 |  i i t i | |  |  i  | d 7} q W|  i | S(   Ni    i   i(   R|   R   R"   R   R   R:   R3   R4   R   t   periodt   PRX   R   (   R"   R|   R   R   (    (    R   R~   `  s     
   $c         C   sN   y4 t  |  i  } x t o |  | | d 7} q WWn t j
 o n X| S(   Ni   (   RX   R"   R   RZ   t   TrueR   (   R"   RZ   (    (    R   R   t  s      (   R   R   R   R   R   R   R   R   (   R   R   R   R7   RN   RO   R[   RC   R   R~   R   (    (    (    R   R   5  s   	 		i   c         C   s{   |  d j p t  x) t |  |  d j o | i d   q W| |  d } | d  j o | |   } | |  d <n | S(   Nii   (   R   R1   RX   RY   R:   R6   RQ   t   G(   R   R   RY   RQ   (    (    R   R   ~  s      c         C   s|   |  i } | d j oK |  i | | d  } | d j  o# | d j p t  | |  Sqa n | | | d  |  i  S(   Ni   i   i   i    (   R"   R   R   Ra   R   t   tailR1   R   (   R"   R$   R   R   R   R   (    (    R   t   _lazy_get_group_  s    	(
   Rg   Rh   Ri   Rj   Rk   Rl   s   hexRn   s   octRp   (   R   R   R   R    R7   Rc   R8   R9   R6   R4   Ru   RC   RD   R~   R   R   R   R   R   RN   RO   t   Quantityt   SampleRJ   R[   R   t   study.snake.lazyt   LazyR   R   (    (    (    R   R3      s0    		,								
				H

c         K   s  | d j o d | d <ng y | i WnJ t j
 o> d }	 x |	 | j o |	 d }	 q@ W| t |	 d } n X| d | d <y | i Wng t j
 o[ y	 | Wn! t	 j
 o | t d } q X| t t
 d t
 |  t |   } n Xt t |  | | | f |  } y	 | Wn{t	 j
 ooy | i Wn t j
 o qXt d | i    } t |  } | d j o d \ } }
 nN d }
 | d j o
 d } n1 d d | t d d	 t t d
   |   } x | i   D] \ } } t | | |  } | o d }	 | d j  o- x |	 | j o |	 d }	 q#W|	 d }	 n | o | d j o | | } n | |	 t d } | |
 | _  qqWn$ Xx | D] } t | | |  qW| S(   s  Create an Element based on my Nuffield Advanced Data book's data.

    Required arguments:
      name -- string giving the full name of the element.
      symbol -- string giving the (one or two letter) symbol of the element.
      Z -- atomic number.

    Optional arguments:
      A -- molar mass * mol / g; a.k.a. atomic mass / AMU (default, None, means
           unknown).
      isos -- description of isotopes (see below); default is None.
      abundance -- relative terrestrial abundance, scaled to make Si score 100;
      default is None, indicating an artificial element.

    plus any further keyword arguments, to taste.  See Element's constructor for
    further details; it receives a suitably scaled abundance.

    The description of isotopes, if given, should either be a list of atomic
    mass numbers for which an isotope is known (for artificial elements and
    those natural radioactives whose isotopic composition varies wildly) or a
    mapping from known atomic mass numbers to relative abundances (or to None
    for those radioactive isotopes which normally have negligible abundance).
    If the sum of these relative abundances isn't 1, they'll be (fudged to make
    it 100 - because the NAS book is a bit off on some elements - and then)
    scaled down to make it 1.

    Both the element's terrestrial abundance and the relative abundance of its
    isotopes will be given an error bar, if they don't already have one, to
    accord with the limited precision indicated in the NAS table. RR   i   f0.10000000000000001f0.2772f0.0001f0.01id   f0.5i   c         C   s
   |  d j S(   Ni   (   RT   (   RT   (    (    R   RU     s    N(   Ni   (   RR   R6   R
   t   widthR=   t   unitt   tophatRb   t   isosR   R   R   R   R3   R   R   Ra   RQ   R   RV   R   t   weightsR   t   totalt   fixt   scaleR   R   R   R,   R   (   R   R   Ra   Rb   R   RR   R
   RQ   R   R   R   R   R   R   R   R   (    (    R   t
   NASelement  sl           	 , 	    
0     i   i    t   Hydrogent   Hs3   The simplest atom; the most abundant form of mattert   massf1673.4300000000001f0.080000000000000002R   t	   Deuteriumt   Ds   (Ordinary) Heavy Hydrogent   deuteronR   s   Deuterium's nucleusf2.0135532127100002t   magneticmomentf4.3307345699999999e-27t   Tritiumt   Ts   Radioactive Heavy Hydrogent   Heliumt   Hes#   Second most abundant form of mattert   alphas   Helium's nucleusf1.0079f1.0000000000000001e-05f99.984999999999999f0.014999999999999999i   f0.56999999999999995f4.0026000000000002f0.00012999999999999999i   id   f1.3e-06t   Lithiumt   Lif6.9390000000000001i   f7.4199999999999999i   f92.579999999999998f0.029000000000000001t	   Berylliumt   Bef9.0122i	   f0.0025999999999999999t   Boront   Bi   f10.811f0.0030000000000000001i
   f19.699999999999999i   f80.299999999999997f0.0012999999999999999t   Carbont   Cf12.011100000000001f5.0000000000000002e-05i   f98.890000000000001i   f1.1100000000000001i   f0.14000000000000001t   sublimeit  t   NitrogenR   f14.0067f99.629999999999995i   f0.37f0.089999999999999997t   Oxygent   Oi   f15.994f0.0001i   f99.759i   f0.036999999999999998i   f0.20399999999999999f0.021000000000000001t   temperatureR'   iZ   t   Fluorinet   Ff18.9984i   f0.40000000000000002t   Neont   Nef20.183i   f90.920000000000002i   f0.26000000000000001i   f8.8200000000000003f3.1e-08t   Sodiumt   Naf22.989799999999999i   f12.5R_   t   Natriumt	   Magnesiumt   Mgf24.312000000000001i   f78.599999999999994i   f10.109999999999999i   f11.289999999999999f9.1999999999999993t	   Aluminiumt   Alf26.918500000000002i   f35.799999999999997R\   t   Aluminumf0.69999999999999996t   citese   http://space.newscientist.com/article/dn11366-saturn-moons-mysterious-heat-traced-to-early-fever.htmlt   Silicont   Sif28.085999999999999f0.001i   f92.180000000000007i   f4.71i   f3.1200000000000001t
   PhosphorusR   f30.973800000000001i   f5.2000000000000002t   SulphurR   f32.064i    i_   i!   f0.76000000000000001i"   f4.2199999999999998i$   f0.01f0.23000000000000001t   Sulfurt   Chlorinet   Clf35.453000000000003i#   f75.530000000000001i%   f24.469999999999999t   Argont   Arf39.948f0.34000000000000002i&   f0.063i(   f99.599999999999994f1.8e-05Rb   t	   Potassiumt   Kf39.101999999999997i'   f93.219999999999999f0.12i)   f6.7699999999999996f11.4t   Kaliumt   Calciumt   Caf40.079999999999998f96.969999999999999i*   f0.64000000000000001i+   f0.14999999999999999i,   f2.0600000000000001i.   i0   f0.19t   Scandiumt   Scf44.956000000000003i-   f0.0022000000000000001t   Titaniumt   Tif47.899999999999999f7.9900000000000002i/   f7.3200000000000003f73.989999999999995i1   f5.46i2   f5.25f1.3999999999999999t   VanadiumR   f50.942f0.25i3   f99.75f0.066000000000000003t   Chromiumt   Crf51.996000000000002f4.3099999999999996i4   f83.760000000000005i5   f9.5500000000000007i6   f2.3799999999999999f0.043999999999999997t	   Manganeset   Mnf54.938000000000002i7   f0.44t   Iront   Fef55.847000000000001f5.8399999999999999i8   f91.680000000000007i9   f2.1699999999999999i:   f0.31t   Ferrumt   Cobaltt   Cof58.933199999999999i;   t   Nickelt   Nif58.710000000000001f67.760000000000005i<   f26.16i=   f1.25i>   f3.6600000000000001i@   f1.1599999999999999f0.035000000000000003t   Coppert   Cuf63.539999999999999i?   f69.099999999999994iA   f30.899999999999999f0.031t   Cuprumt   Zinct   Znf65.370000000000005f48.890000000000001iB   f27.809999999999999iC   f4.1100000000000003iD   f18.559999999999999iF   f0.62f0.058000000000000003t   Galliumt   Gaf69.719999999999999iE   f60.200000000000003iG   f39.799999999999997f0.0066t	   Germaniumt   Gef72.590000000000003f20.550000000000001iH   f27.370000000000001iI   f7.6699999999999999iJ   f36.740000000000002iL   f0.0030999999999999999t   Arsenict   Asf74.921599999999998iK   t   Seleniumt   Sef78.959999999999994f0.89000000000000001f9.0199999999999996iM   f7.5800000000000001iN   f23.52iP   f49.82iR   f9.1899999999999995f4.0000000000000003e-05t   Brominet   Brf79.909000000000006f0.002iO   f50.520000000000003iQ   f49.479999999999997f0.00071000000000000002t   Kryptont   Krf83.799999999999997f0.34999999999999998f2.27f11.56iS   f11.550000000000001iT   f56.899999999999999iV   f17.370000000000001f4.3000000000000001e-08t   Rubidiumt   Rbf85.469999999999999iU   f72.150000000000006iW   f27.850000000000001t	   Strontiumt   Srf87.620000000000005f0.56000000000000005f9.8599999999999994f7.0199999999999996iX   f82.560000000000002f0.13t   Yttriumt   Yf88.905000000000001iY   f0.012t	   Zirconiumt   Zrf91.219999999999999f51.460000000000001i[   f11.23i\   f17.109999999999999i^   f17.399999999999999i`   f2.7999999999999998f0.097000000000000003t   Niobiumt   Nbf92.906000000000006i]   f0.010999999999999999t	   Columbiumt   Cbt
   Molybdenumt   Mof95.939999999999998f15.859999999999999f9.1199999999999992f15.699999999999999f16.5ia   f9.4499999999999993ib   f23.75f9.6199999999999992t
   Technetiumt   Tcic   t	   Rutheniumt   Ruf101.06999999999999f1.8700000000000001f12.630000000000001f12.529999999999999ie   f17.02if   f31.600000000000001ih   f18.870000000000001f1.7999999999999999e-06t   Rhodiumt   Rhf102.905ig   f4.4000000000000002e-07t	   Palladiumt   Pdf106.40000000000001ii   f22.199999999999999ij   f27.300000000000001il   f26.699999999999999in   f11.800000000000001f4.4000000000000002e-06t   Silvert   Agf107.87ik   f51.350000000000001im   f48.649999999999999f4.3999999999999999e-05t   Argentumt   Cadmiumt   Cdf112.40000000000001f1.22f0.88f12.390000000000001io   f12.75ip   f24.07iq   f12.26ir   f28.859999999999999it   f6.6000000000000005e-05t   Indiumt   Inf114.81999999999999f4.2300000000000004is   f95.769999999999996t   Tint   Snf118.69f0.94999999999999996f0.65000000000000002f14.24iu   f7.5700000000000003iv   f24.010000000000002iw   f8.5800000000000001ix   f32.969999999999999iz   i|   f5.9800000000000004f0.017999999999999999t   Stannumt   Antimonyt   Sbf121.755iy   f57.25i{   f42.75f0.00044000000000000002t   Stibiumt	   Telluriumt   Tef127.59999999999999f2.46f0.87f4.6100000000000003i}   f6.9900000000000002i~   f18.710000000000001i   f31.789999999999999i   f34.490000000000002f8.8000000000000004e-07t   IodineR   f126.9044i   t   Xenont   Xef131.30000000000001f0.012999999999999999f1.9199999999999999i   f26.440000000000001f4.0800000000000001i   f21.18i   f26.890000000000001i   f10.4i   f8.8699999999999992f5.3000000000000003e-10t   Caesiumt   Csf132.905i   t   Cesiumt   Bariumt   Baf137.34f0.10100000000000001f2.4199999999999999i   f6.5899999999999999f7.8099999999999996i   f11.32i   f71.659999999999997t	   Lanthanumt   Laf138.91i   f99.909999999999997f0.0080999999999999996t   Ceriumt   Cef140.12f0.193i   f88.480000000000004i   f11.07f0.02t   Praseodymiumt   Prf140.90700000000001i   f0.0023999999999999998t	   Neodymiumt   Ndf144.24000000000001f27.129999999999999i   f12.199999999999999i   f23.870000000000001i   f8.2899999999999991i   f17.18i   f5.7199999999999998i   f5.5999999999999996t
   Promethiumt   Pmt   Samariumt   Smf150.34999999999999f3.1600000000000001i   f15.07f11.27i   f13.82f7.4699999999999998i   f26.629999999999999i   f22.530000000000001f0.0028t   Europiumt   Euf151.96000000000001i   f47.770000000000003i   f52.229999999999997f0.00046999999999999999t
   Gadoliniumt   Gdf157.25f0.20000000000000001f2.1499999999999999i   f14.699999999999999i   f20.469999999999999i   f15.68i   f24.899999999999999i   f21.899999999999999f2.1000000000000001t   Terbiumt   Tbf158.92400000000001i   f0.00040000000000000002t
   Dysprosiumt   Dyf162.5f0.050000000000000003f2.29i   f18.879999999999999i   f25.530000000000001i   f24.969999999999999i   f28.18t   Holmiumt   Hof164.93000000000001i   f0.00051000000000000004t   Erbiumt   Erf167.25999999999999f1.5600000000000001i   f33.409999999999997i   f22.940000000000001i   f27.07i   f14.880000000000001f0.0011000000000000001t   Thuliumt   Tmf168.934i   f8.7999999999999998e-05t	   Ytterbiumt   Ybf173.03999999999999f3.0299999999999998i   f14.31i   f21.82i   f16.129999999999999i   f31.84i   f12.73f0.0011999999999999999t   Lutetiumt   Luf174.97i   f97.400000000000006f2.6000000000000001f0.00033t   Hafniumt   Hff178.49000000000001f0.16f5.21i   i   f27.100000000000001i   f13.75i   f35.219999999999999t   Tantalumt   Taf180.94800000000001i   f99.989999999999995f0.00092000000000000003t   Tungstent   Wf183.84999999999999i   f26.399999999999999i   f14.4i   f30.600000000000001i   f28.399999999999999f0.029999999999999999t   Wolframt   Rheniumt   Ref186.19999999999999i   f37.07i   f62.93f4.3999999999999997e-08t   Osmiumt   Osf190.19999999999999i   f13.300000000000001i   f16.100000000000001i   i   f2.2000000000000001e-06t   densityf22.5R#   i
  t   Iridiumt   Irf192.19999999999999i   f38.5i   f61.5f22.420000000000002t   Platinumt   Ptf195.09f0.78000000000000003i   f32.899999999999999i   f33.799999999999997i   f25.199999999999999i   f7.2000000000000002f21.370000000000001t   Goldt   Auf196.96700000000001i   t   Aurumt   Mercuryt   Hgf200.59200000000001f10.02i   f16.84i   f23.129999999999999i   f13.220000000000001i   f29.800000000000001i   f6.8499999999999996f0.00022000000000000001t   Hydrargyrums   Quick-silvert   Quicksilvert   freezef-38.899999999999999f356.57999999999998t   heatf59.109999999999999t   capacityf27.952999999999999t   atf13595.1f0.10000000000000001sv  Density of merucry.

This is equivalently Atmosphere / .76 / metre / Earth.surface.g, since a 76 cm
column of mercury balances one atmosphere's pressure.  (Note that Eart.surface.g
is equivalently m/m.weight for any mass m.)

I have also seen its value given (using the British gallon) as 136.26 lb /
gallon, which conflicts with the value given here (135.9 pound / gallon).R   s/  Mercury

http://www.du.edu/~jcalvert/phys/mercury.htm
says:

  The name hydrargyrum, 'water silver', was given by Pliny from Greek roots for
  the common name, and is the source of its chemical symbol, Hg. In German, it
  is called Quecksilber, from its usual ancient name, and in French it is
  mercure, from which the English 'mercury' is derived. This, no doubt, comes
  from the fancies of late medieval alchemy, where it was represented by the
  symbol for the god Mercury, ...

and provides lots of further (but, in places, inconsistent) physical data.
t   Thalliumt   Tlf204.37i   f29.5i   f70.5t   Leadt   Pbf207.19f0.5i   f25.100000000000001i   f21.699999999999999i   f52.299999999999997f0.0070000000000000001t   Plumbumt   Bismutht   Bif208.97999999999999i   t   Poloniumt   Poi   t   Astatinet   Ati   t   Radont   Rni   i   t	   Emanationt   Emt   Franciumt   Fri   t   Radiumt   Raf226.05000000000001i   i   i   f5.6999999999999998e-09t   Actiniumt   Aci   f1.3e-15t   Thoriumt   Thf232.03800000000001i   i   f0.0051000000000000004t   Protactiniumt   Pai   f3.4999999999999998e-10t   Uraniumt   Uf238.03i   f0.0057000000000000002i   f0.71960000000000002i   f99.275999999999996f0.0018t	   Neptuniumt   Npi   i   t	   Plutoniumt   Pui   t	   Americiumt   Ami   t   Curiumt   Cmi   t	   Berkeliumt   Bki   t   Californiumt   Cfi   t   Einsteiniumt   Esi   t   Fermiumt   Fmi   t   Mendeleviumt   Mdi   t   Nobeliumt   Not
   Lawrenciumt   Lri  t   Rutherfordiumt   Rfi  i  t   Kurchatoviumt   Kut   Dubniumt   Dbi  t
   Seaborgiumt   Sgi
  i  t   Bohriumt   Bhi  i  t   Hassiumt   Hsi  i	  t
   Meitneriumt   Mti  t   Darmstadtiumt   Dsi  i  t   Roentgeniumt   Rgi  t   protiumt   pt   Ioniumt   Iot   Thoront   TnN(   R   (   R   (   Rb   (   R  R  (   R>  (   s   Quick-silverRu  (   R  R  (   R  R  (   R   t   study.value.unitst   ObjectR   R   t   megat   kilot   harpoR   t   samplet   yeart   Joulet   Teslat   Kelvint
   Centigradet   gramt   kgt   tonnet   metret   molt   torrt   cct   particlet   AMUt   Particlet   Bosont   FermionR   R   R   R    R   R   R   R   R   R   R   R    R!   R+   R,   t   allR   RW   t   naturalIsotopesR[   R3   R6   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   halflifeR   R   R   R   R   R   R   R   R   R   R   R   R   R   R  R  R  R  R
  R  R  R  R  R  R  R  R  R  R   R"  R$  R&  R(  R*  R-  R/  R1  R4  R7  R9  R:  R<  R?  RA  RC  RE  RG  RI  RK  RM  RO  RQ  RS  RU  RW  RY  R[  R]  R_  Ra  Rc  Rf  Rh  Rk  Rm  Ro  Rr  Rj  t   observet   weightRz  R|  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R>   R  R   R   R  R  R   t   tritonR   (   RW  Rr  R  RS  R|  Rz  R]  R  R  R   R  RK  R7  R  R  R  R   R(  R   R   RQ  R   R  R   R   R  R  R  R  R   Rf  R   R  RY  R  R   Rm  R  R   R  R  R&  R  R  R   R?  R  R  R    R  R  R  R  RO  R  R    R  R  R   R   R   R+   R/  R  R  R  R  R  R  R
  R   R!   R  R  R   RG  R  R   R  R4  RM  R  R  R   R  RC  Rh  R   R   R  R$  R  R   R  R   R  R   R   RW   R<  R   R  R  R   R   Rk  R   R9  R  R   R  Ro  R  R   RE  R  R  R   R   R  R   R  R_  R  R"  R  R  R1  R  R  RU  R  R  R   R[   RA  R  R,   R  R  R-  R   Rc  R*  R   RI  R[  R   R  R3   R   R   R:  R   R  R  R   R   R   Ra  R   R  R  R   (    (    R   t   ?   sf  1		>		T

>--$55-!$>*6*>$M5<-Q$H-G$M$H;H-H$Q5Q-?$H*ZZ$Q;c-{3c$c	*Z-?$ZZ-Z$Z$Q$Z-Q-N-'#'9*B%-?$$$'!-$6!!