Mercurial > emacs
comparison lisp/calc/calc-units.el @ 108590:c84578d13e42
calc-aent.el (math-read-token, math-find-user-tokens):
calc-lang.el (math-read-big-rec, math-lang-read-symbol)
(math-compose-tex-func):
calccomp.el (math-compose-expr):
calc-ext.el (math-format-flat-expr-fancy):
calc-store.el (calc-read-var-name):
calc-units.el (calc-explain-units-rec): Allow Greek letters.
calc.el (var-¦Ð, var-¦Õ, var-¦Ã): New variables.
calc-aent.el (math-read-replacement-list): Add "micro" symbol.
calc-units.el (math-unit-prefixes): Add mu for micro.
(math-standard-units): Add units.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Fri, 14 May 2010 23:50:25 -0500 |
parents | 1d1d5d9bd884 |
children | d150a25a0eb9 |
comparison
equal
deleted
inserted
replaced
108589:b818f9578731 | 108590:c84578d13e42 |
---|---|
34 | 34 |
35 ;;; Units operations. | 35 ;;; Units operations. |
36 | 36 |
37 ;;; Units table last updated 9-Jan-91 by Ulrich Mueller (ulm@vsnhd1.cern.ch) | 37 ;;; Units table last updated 9-Jan-91 by Ulrich Mueller (ulm@vsnhd1.cern.ch) |
38 ;;; with some additions by Przemek Klosowski (przemek@rrdstrad.nist.gov) | 38 ;;; with some additions by Przemek Klosowski (przemek@rrdstrad.nist.gov) |
39 ;;; Updated April 2002 by Jochen Küpper | 39 ;;; Updated April 2002 by Jochen Küpper |
40 | 40 |
41 ;;; Updated August 2007, using | 41 ;;; Updated August 2007, using |
42 ;;; CODATA (http://physics.nist.gov/cuu/Constants/index.html) | 42 ;;; CODATA (http://physics.nist.gov/cuu/Constants/index.html) |
43 ;;; NIST (http://physics.nist.gov/Pubs/SP811/appenB9.html) | 43 ;;; NIST (http://physics.nist.gov/Pubs/SP811/appenB9.html) |
44 ;;; ESUWM (Encyclopaedia of Scientific Units, Weights and | 44 ;;; ESUWM (Encyclopaedia of Scientific Units, Weights and |
45 ;;; Measures, by François Cardarelli) | 45 ;;; Measures, by François Cardarelli) |
46 ;;; All conversions are exact unless otherwise noted. | 46 ;;; All conversions are exact unless otherwise noted. |
47 | 47 |
48 (defvar math-standard-units | 48 (defvar math-standard-units |
49 '( ;; Length | 49 '( ;; Length |
50 ( m nil "*Meter" ) | 50 ( m nil "*Meter" ) |
208 ( e "ech" "Elementary charge" ) | 208 ( e "ech" "Elementary charge" ) |
209 ( ech "1.602176487*10^(-19) C" "Elementary charge" nil | 209 ( ech "1.602176487*10^(-19) C" "Elementary charge" nil |
210 "1.602176487 10^-19 C (*)") ;;(approx) CODATA | 210 "1.602176487 10^-19 C (*)") ;;(approx) CODATA |
211 ( V "W/A" "Volt" ) | 211 ( V "W/A" "Volt" ) |
212 ( ohm "V/A" "Ohm" ) | 212 ( ohm "V/A" "Ohm" ) |
213 ( Ω "ohm" "Ohm" ) | |
213 ( mho "A/V" "Mho" ) | 214 ( mho "A/V" "Mho" ) |
214 ( S "A/V" "Siemens" ) | 215 ( S "A/V" "Siemens" ) |
215 ( F "C/V" "Farad" ) | 216 ( F "C/V" "Farad" ) |
216 ( H "Wb/A" "Henry" ) | 217 ( H "Wb/A" "Henry" ) |
217 ( T "Wb/m^2" "Tesla" ) | 218 ( T "Wb/m^2" "Tesla" ) |
257 ;; The values are from CODATA, and are approximate. | 258 ;; The values are from CODATA, and are approximate. |
258 ( h "6.62606896*10^(-34) J s" "*Planck's constant" nil | 259 ( h "6.62606896*10^(-34) J s" "*Planck's constant" nil |
259 "6.62606896 10^-34 J s (*)") | 260 "6.62606896 10^-34 J s (*)") |
260 ( hbar "h / (2 pi)" "Planck's constant" ) ;; Exact | 261 ( hbar "h / (2 pi)" "Planck's constant" ) ;; Exact |
261 ( mu0 "4 pi 10^(-7) H/m" "Permeability of vacuum") ;; Exact | 262 ( mu0 "4 pi 10^(-7) H/m" "Permeability of vacuum") ;; Exact |
263 ( μ0 "mu0" "Permeability of vacuum") ;; Exact | |
262 ( eps0 "1 / (mu0 c^2)" "Permittivity of vacuum" ) | 264 ( eps0 "1 / (mu0 c^2)" "Permittivity of vacuum" ) |
265 ( ε0 "eps0" "Permittivity of vacuum" ) | |
263 ( G "6.67428*10^(-11) m^3/(kg s^2)" "Gravitational constant" nil | 266 ( G "6.67428*10^(-11) m^3/(kg s^2)" "Gravitational constant" nil |
264 "6.67428 10^-11 m^3/(kg s^2) (*)") | 267 "6.67428 10^-11 m^3/(kg s^2) (*)") |
265 ( Nav "6.02214179*10^(23) / mol" "Avogadro's constant" nil | 268 ( Nav "6.02214179*10^(23) / mol" "Avogadro's constant" nil |
266 "6.02214179 10^23 / mol (*)") | 269 "6.02214179 10^23 / mol (*)") |
267 ( me "9.10938215*10^(-31) kg" "Electron rest mass" nil | 270 ( me "9.10938215*10^(-31) kg" "Electron rest mass" nil |
270 "1.672621637 10^-27 kg (*)") | 273 "1.672621637 10^-27 kg (*)") |
271 ( mn "1.674927211*10^(-27) kg" "Neutron rest mass" nil | 274 ( mn "1.674927211*10^(-27) kg" "Neutron rest mass" nil |
272 "1.674927211 10^-27 kg (*)") | 275 "1.674927211 10^-27 kg (*)") |
273 ( mmu "1.88353130*10^(-28) kg" "Muon rest mass" nil | 276 ( mmu "1.88353130*10^(-28) kg" "Muon rest mass" nil |
274 "1.88353130 10^-28 kg (*)") | 277 "1.88353130 10^-28 kg (*)") |
278 ( mμ "mmu" "Muon rest mass" nil | |
279 "1.88353130 10^-28 kg (*)") | |
275 ( Ryd "10973731.568527 /m" "Rydberg's constant" nil | 280 ( Ryd "10973731.568527 /m" "Rydberg's constant" nil |
276 "10973731.568527 /m (*)") | 281 "10973731.568527 /m (*)") |
277 ( k "1.3806504*10^(-23) J/K" "Boltzmann's constant" nil | 282 ( k "1.3806504*10^(-23) J/K" "Boltzmann's constant" nil |
278 "1.3806504 10^-23 J/K (*)") | 283 "1.3806504 10^-23 J/K (*)") |
279 ( alpha "7.2973525376*10^(-3)" "Fine structure constant" nil | 284 ( alpha "7.2973525376*10^(-3)" "Fine structure constant" nil |
285 "7.2973525376 10^-3 (*)") | |
286 ( α "alpha" "Fine structure constant" nil | |
280 "7.2973525376 10^-3 (*)") | 287 "7.2973525376 10^-3 (*)") |
281 ( muB "927.400915*10^(-26) J/T" "Bohr magneton" nil | 288 ( muB "927.400915*10^(-26) J/T" "Bohr magneton" nil |
282 "927.400915 10^-26 J/T (*)") | 289 "927.400915 10^-26 J/T (*)") |
283 ( muN "5.05078324*10^(-27) J/T" "Nuclear magneton" nil | 290 ( muN "5.05078324*10^(-27) J/T" "Nuclear magneton" nil |
284 "5.05078324 10^-27 J/T (*)") | 291 "5.05078324 10^-27 J/T (*)") |
314 ( 0 (^ 10 0) nil ) | 321 ( 0 (^ 10 0) nil ) |
315 ( ?d (^ 10 -1) "Deci" ) | 322 ( ?d (^ 10 -1) "Deci" ) |
316 ( ?c (^ 10 -2) "Centi" ) | 323 ( ?c (^ 10 -2) "Centi" ) |
317 ( ?m (^ 10 -3) "Milli" ) | 324 ( ?m (^ 10 -3) "Milli" ) |
318 ( ?u (^ 10 -6) "Micro" ) | 325 ( ?u (^ 10 -6) "Micro" ) |
326 ( ?μ (^ 10 -6) "Micro" ) | |
319 ( ?n (^ 10 -9) "Nano" ) | 327 ( ?n (^ 10 -9) "Nano" ) |
320 ( ?p (^ 10 -12) "Pico" ) | 328 ( ?p (^ 10 -12) "Pico" ) |
321 ( ?f (^ 10 -15) "Femto" ) | 329 ( ?f (^ 10 -15) "Femto" ) |
322 ( ?a (^ 10 -18) "Atto" ) | 330 ( ?a (^ 10 -18) "Atto" ) |
323 ( ?z (^ 10 -21) "zepto" ) | 331 ( ?z (^ 10 -21) "zepto" ) |
579 pos) | 587 pos) |
580 (if (and u (not (math-zerop pow))) | 588 (if (and u (not (math-zerop pow))) |
581 (let ((name (or (nth 2 u) (symbol-name (car u))))) | 589 (let ((name (or (nth 2 u) (symbol-name (car u))))) |
582 (if (eq (aref name 0) ?\*) | 590 (if (eq (aref name 0) ?\*) |
583 (setq name (substring name 1))) | 591 (setq name (substring name 1))) |
584 (if (string-match "[^a-zA-Z0-9']" name) | 592 (if (string-match "[^a-zA-Zα-ωΑ-Ω0-9']" name) |
585 (if (string-match "^[a-zA-Z0-9' ()]*$" name) | 593 (if (string-match "^[a-zA-Zα-ωΑ-Ω0-9' ()]*$" name) |
586 (while (setq pos (string-match "[ ()]" name)) | 594 (while (setq pos (string-match "[ ()]" name)) |
587 (setq name (concat (substring name 0 pos) | 595 (setq name (concat (substring name 0 pos) |
588 (if (eq (aref name pos) 32) "-" "") | 596 (if (eq (aref name pos) 32) "-" "") |
589 (substring name (1+ pos))))) | 597 (substring name (1+ pos))))) |
590 (setq name (concat "(" name ")")))) | 598 (setq name (concat "(" name ")")))) |
591 (or (eq (nth 1 expr) (car u)) | 599 (or (eq (nth 1 expr) (car u)) |
592 (setq name (concat (nth 2 (assq (aref (symbol-name | 600 (setq name (concat (nth 2 (assq (aref (symbol-name |
593 (nth 1 expr)) 0) | 601 (nth 1 expr)) 0) |
594 math-unit-prefixes)) | 602 math-unit-prefixes)) |
595 (if (and (string-match "[^a-zA-Z0-9']" name) | 603 (if (and (string-match "[^a-zA-Zα-ωΑ-Ω0-9']" name) |
596 (not (memq (car u) '(mHg gf)))) | 604 (not (memq (car u) '(mHg gf)))) |
597 (concat "-" name) | 605 (concat "-" name) |
598 (downcase name))))) | 606 (downcase name))))) |
599 (cond ((or (math-equal-int pow 1) | 607 (cond ((or (math-equal-int pow 1) |
600 (math-equal-int pow -1))) | 608 (math-equal-int pow -1))) |
1538 (pop-to-buffer (get-buffer "*Units Table*")) | 1546 (pop-to-buffer (get-buffer "*Units Table*")) |
1539 (display-buffer (get-buffer "*Units Table*"))))) | 1547 (display-buffer (get-buffer "*Units Table*"))))) |
1540 | 1548 |
1541 (provide 'calc-units) | 1549 (provide 'calc-units) |
1542 | 1550 |
1543 ;; Local Variables: | |
1544 ;; coding: iso-latin-1 | |
1545 ;; End: | |
1546 | |
1547 ;; arch-tag: e993314f-3adc-4191-be61-4ef8874881c4 | 1551 ;; arch-tag: e993314f-3adc-4191-be61-4ef8874881c4 |
1548 ;;; calc-units.el ends here | 1552 ;;; calc-units.el ends here |