123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- #| -*-Scheme-*-
- Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Massachusetts
- Institute of Technology
- This file is part of MIT/GNU Scheme.
- MIT/GNU Scheme is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at
- your option) any later version.
- MIT/GNU Scheme is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with MIT/GNU Scheme; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
- USA.
- |#
- ;;;; SI units
- (define-unit-system 'SI
- (list '&meter "m" "length")
- (list '&kilogram "kg" "mass")
- (list '&second "s" "time")
- (list '&ere "A" "electric current")
- (list '&kelvin "K" "temperature")
- (list '&mole "mol" "amount of substance")
- (list '&candela "cd" "luminous intensity")
- #|
- (list '&radian "rad" "plane angle")
- (list '&steradian "sr" "solid angle")
- |#
- )
- (define &angular &unitless)
- (define-derived-unit SI '&radian
- "rad" "plane angle" &angular)
- (define-derived-unit SI '&steradian
- "rad" "solid angle" &angular)
- ;;; Derived SI units
- (define-derived-unit SI '&newton
- "N" "force" (g:/ (g:* &kilogram &meter) (g:square &second)))
- (define-derived-unit SI '&joule
- "J" "energy" (g:* &newton &meter))
- (define-derived-unit SI '&coulomb
- "C" "electric charge" (g:* &ere &second))
- (define-derived-unit SI '&watt
- "W" "power" (g:/ &joule &second))
- (define-derived-unit SI '&volt
- "V" "electric potential" (g:/ &watt &ere))
- ;;; FBE need to escape backslash: \Omega -> \\Omega
- (define-derived-unit SI '&ohm
- ;; "\Omega" "electric resistance" (/ &volt &ere))
- "\\Omega" "electric resistance" (g:/ &volt &ere))
- (define-derived-unit SI '&siemens
- "S" "electric conductance" (g:/ &unitless &ohm))
- (define-derived-unit SI '&farad
- "F" "capacitance" (g:/ &coulomb &volt))
- (define-derived-unit SI '&weber
- "Wb" "magnetic flux" (g:* &volt &second))
- (define-derived-unit SI '&henry
- "H" "inductance" (g:/ &weber &ere))
- (define-derived-unit SI '&hertz
- "Hz" "frequency" (g:/ &unitless &second) :2pi)
- (define-derived-unit SI '&tesla
- "T" "magnetic flux density" (g:/ &weber (g:square &meter)))
- (define-derived-unit SI '&pascal
- "Pa" "pressure" (g:/ &newton (g:square &meter)))
- ;;;; SI multipliers
- (define-multiplier '&exa "E" 18)
- (define-multiplier '&peta "P" 15)
- (define-multiplier '&tera "T" 12)
- (define-multiplier '&giga "G" 9)
- (define-multiplier '&mega "M" 6)
- (define-multiplier '&kilo "k" 3)
- (define-multiplier '&hecto "h" 2)
- (define-multiplier '&deka "da" 1)
- (define-multiplier '&deci "d" -1)
- (define-multiplier '¢i "c" -2)
- (define-multiplier '&milli "m" -3)
- ;;; FBE escape backslash
- ;;(define-multiplier 'µ "\mu" -6)
- (define-multiplier 'µ "\\mu" -6)
- (define-multiplier '&nano "n" -9)
- (define-multiplier '&pico "p" -12)
- (define-multiplier '&femto "f" -15)
- (define-multiplier '&atto "a" -18)
- ;;; abbreviations
- (define-multiplier '&E "E" 18)
- (define-multiplier '&P "P" 15)
- (define-multiplier '&T "T" 12)
- (define-multiplier '&G "G" 9)
- (define-multiplier '&M "M" 6)
- (define-multiplier '&k "k" 3)
- (define-multiplier '&h "h" 2)
- (define-multiplier '&da "da" 1)
- (define-multiplier '&d "d" -1)
- (define-multiplier '&c "c" -2)
- (define-multiplier '&m "m" -3)
- ;;; FBE escape backslash
- ;;(define-multiplier '&u "\mu" -6)
- (define-multiplier '&u "\\mu" -6)
- (define-multiplier '&n "n" -9)
- (define-multiplier '&p "p" -12)
- (define-multiplier '&f "f" -15)
- (define-multiplier '&a "a" -18)
- ;;; Other units in terms of SI system
- (define-additional-unit SI '&lumen
- "lm" "luminous flux" (g:* &candela &steradian))
- (define-additional-unit SI '&lux
- "lx" "illuminance" (g:/ &lumen (g:square &meter)))
- (define-additional-unit SI '&katal
- "kat" "catalytic activity" (g:/ &mole &second))
- (define-additional-unit SI '&becquerel
- "Bq" "activity" (g:/ &unitless &second))
- (define-additional-unit SI '&gray
- "Gy" "absorbed dose" (g:/ &joule &kilogram))
- (define-additional-unit SI '&sievert
- "Sv" "dose equivalent" (g:/ &joule &kilogram))
- (define-additional-unit SI '°ree
- "$^\\circ$" "1/360 circle" &angular (g:/ :2pi 360))
- (define-additional-unit SI '&gram
- "gm" "CGS mass" &kilogram 1/1000)
- (define-additional-unit SI '&inch
- "in" "English length" &meter (* 2.54 ¢i))
- (define-additional-unit SI '¢imeter
- "cm" "CGS length" &meter 1/100)
- (define-additional-unit SI '£
- "lb" "English force" &newton 4.4482)
- (define-additional-unit SI '&slug
- "slug" "English mass" &kilogram 14.594)
- (define-additional-unit SI '&foot
- "ft" "English length" &inch 12)
- (define-additional-unit SI '&mile
- "mi" "English length" &foot 5280)
- (define-additional-unit SI '&dyne
- "dyne" "Force" &newton 1.0e-5)
- (define-additional-unit SI '&calorie ;at 20 C
- "cal" "Heat energy" &joule 4.1819)
- (define-additional-unit SI '&minute
- "day" "Time" &second 60)
- (define-additional-unit SI '&hour
- "day" "Time" &second 3600)
- (define-additional-unit SI '&day
- "day" "Time" &second 86400)
- (define-additional-unit SI '&year
- "yr" "Tropical year 1900" &second 31556925.9747)
- (define-additional-unit SI '&sidereal-year
- "syr" "Sidereal year 1900" &second 3.1558149984e7)
- (define-additional-unit SI '&AU
- "AU" "Astronomical Unit" &meter 1.4959787066e11)
- (define-additional-unit SI '&arcsec
- "arcsec" "arc second" &radian (g:/ (g:* 2 :pi) (g:* 60 60 360)))
- (define parsec
- (g:/ (& 1 &AU) (tan (& 1 &arcsec))))
- (define-additional-unit SI '&pc
- "pc" "Parsec" &meter (u:value parsec))
- (define speed-of-light (& 2.99792458e8 (g:/ &meter &second)))
- (define-additional-unit SI '&ly
- "ly" "Light Year"
- &meter
- (u:value (g:* speed-of-light &year)))
- (define-additional-unit SI '&esu
- "esu" "Electrostatic Unit"
- &coulomb
- (u:value (g:/ 1 (g:* 10 speed-of-light))))
- (define-additional-unit SI '&ev
- "ev" "Electron Volt"
- &joule 1.602e-19)
|