|
|
last edited 6 years ago by Kurt Pagani |
1 2 3 | ||
Editor: Kurt Pagani
Time: 2018/07/28 20:21:36 GMT+0 |
||
Note: |
added: removed: - changed: -PhysQty(U): Exports == Implementation where PhysQty(U:PhysicalUnit): Exports == Implementation where changed: - U:PhysicalUnit - - added: _* : (Union(F,R,I,Q,PI),%) -> % _/ : (%,Union(F,R,I,Q,PI)) -> % changed: - unit : % -> U unit : % -> U magnitude : % -> F uncertainty : % -> F changed: - outputMode:PI:=1 - - x * y == [x.ival * y.ival, x.unit * y.unit]$Rep - x / y == outputMode:PI:=2 x:% * y:% == [x.ival * y.ival, x.unit * y.unit]$Rep x:% / y:% == added: r:Union(F,R,I,Q,PI) * x:% == r case I or r case PI => [r*x.ival, x.unit]$Rep mkrep(r) ==> [interval(r)$IVF * x.ival, x.unit]$Rep r case Q or r case F => mkrep r r case R => mkrep convert(r)$F x:% / r:Union(F,R,I,Q,PI) == s:%:=r*[interval(1.0)$IVF, one()]$Rep x/s added: magnitude x == (sup(x.ival)+inf(x.ival))/2.0 uncertainty x == (sup(x.ival)-inf(x.ival))/2.0 changed: -)abbrev package SI SIunits -SIunits : Exports == Implementation where - - USY ==> ['m,'kg,'s,'A,'K,'mol,'cd] - SIU ==> PhysicalUnitSystem(USY) - - Exports == with - - %m : Integer -> SIU - %kg : Integer -> SIU - %s : Integer -> SIU - %A : Integer -> SIU - %K : Integer -> SIU - %mol : Integer -> SIU - %cd : Integer -> SIU - - hertz : SIU - newton : SIU - pascal : SIU - joule : SIU - watt : SIU - coulomb : SIU - volt : SIU - farad : SIU - ohm : SIU - siemens : SIU - weber : SIU - tesla : SIU - henry : SIU - lumen : SIU - lux : SIU - becquerel : SIU - gray : SIU - sievert : SIU - katal : SIU - - Implementation == SIU add - - u:=baseUnits()$SIU )abbrev domain SI SIunit SIunit : Exports == Implementation where Exports == Join(SetCategory,PhysicalUnit) with unitSystem : () -> Type baseUnits : () -> List % %m : Integer -> % %kg : Integer -> % %s : Integer -> % %A : Integer -> % %K : Integer -> % %mol : Integer -> % %cd : Integer -> % metre : % kilogram : % second : % ampere : % kelvin : % mole : % candela : % hertz : % newton : % pascal : % joule : % watt : % coulomb : % volt : % farad : % ohm : % siemens : % weber : % tesla : % henry : % lumen : % lux : % becquerel : % gray : % sievert : % katal : % Implementation == PhysicalUnitSystem(['m,'kg,'s,'A,'K,'mol,'cd]) add USY:=['m,'kg,'s,'A,'K,'mol,'cd] Rep:=PhysicalUnitSystem(USY) unitSystem() == % u:=baseUnits()$Rep baseUnits() == u changed: - metre == %m(1) kilogram == %kg(1) second == %s(1) ampere == %A(1) kelvin == %K(1) mole == %mol(1) candela == %cd(1) changed: - )abbrev package DIMAN DimensionalAnalysis DimensionalAnalysis(P:PhysicalUnit) : Exports == Implementation where Exports == with buckingham : Table(Symbol,P) -> List(Expression(Integer)) Implementation == P add mkxpr(s:List Symbol,v:Vector Integer):Expression Integer == r:Expression Integer:=1 for j in 1..#s repeat r:=r*(s.j)::Expression(Integer)^(v.j) r buckingham(t) == --[1::Expression Integer] M:Matrix(Integer):=matrix [dim(t.x) for x in keys(t)] ns:List Vector Integer:=nullSpace transpose(M) r:List Expression Integer:=[] for j in 1..#ns repeat r:=append(r,[mkxpr(keys(t),ns.j)]) r changed: - -SIU:=PUSYS(['m,'kg,'s,'A,'K,'mol,'cd]) -u:=baseUnits()$SIU - -PSI==>PQTY(SIU) - -(interval(1.2)$Interval(Float)) (u.1*u.2^3) -a:=1.233 u.1 -b:=2 u.2 - -sin(ival a) (unit a) - -setOutputMode(2)$PSI -a -b -setOutputMode(3)$PSI -a -b -setOutputMode(1)$PSI - -F:=4.5555 newton()$SI -A:=300.45 %m(2)$SI -unit(F/A) /pascal()$SI - -dim unit(F) - -setOutputMode(2)$PSI - -c:=a*b -d:=a/b - -unit(c)/unit(d) - -)show PUNIT -)show PUSYS -)show PQTY - --- cannot show SI (reason? -> SIU) -)show SI -- -- Template jEdit: spad_unittest.vm -- Unittest .....: PQTY -- Author .......: Kurt Pagani -- Date .........: Sat Jul 28 16:56:04 CEST 2018 -- )set break resume )expose UnittestCount UnittestAux Unittest --)lib PUSYS PQTY SI DIMAN )expose PUSYS PQTY SI DIMAN --)co pdim2 )sh SI -- Usage m:=1400.3 %kg(1) v:=30.6 (%m(1)/%s(1)) E:=m*v^2/2 -- Test Suite testsuite "PUSYS" -- Cases testcase "cgs" CGS ==> PUSYS(['cm,'g,'s]) [cm,g,s]:=baseUnits()$CGS erg:=g*cm^2/s^2 dyne:=g*cm/s^2 testEquals("dim cm", "[1,0,0]") testEquals("dim g", "[0,1,0]") testEquals("dim s", "[0,0,1]") testEquals("dim(cm/s*g)","[1,1,-1]") testEquals("factors(cm/g).1.exp","1") testEquals("factors(cm/g).2.exp","-1") testEquals("factors(one()$CGS)","[]") testEquals("baseSymbols()$CGS","['cm,'g,'s]") testEquals("(cm^2/s^4*g=g*s^(-4)*cm^2)$CGS","true") testEquals("(dyne * cm = erg)$CGS","true") testcase "SI" [m,kg,s,A,K,mol,cd]:=baseUnits()$SI force1:=%kg(1) * %m(1) * %s(-2) force2:=kg * m / s^2 force3:=newton()$SI area1:=%m(2) area2:=m^2 area3:=metre()^2 pressure1:=force1/area1 pressure2:=pascal()$SI testEquals("(force1=force2)$SI","true") testEquals("(force2=force3)$SI","true") testEquals("(pressure1=pressure2)$SI","true") testEquals("dim force1","[1,1,- 2,0,0,0,0]") testEquals("dim pressure2","[- 1,1,- 2,0,0,0,0]") -- Test Suite testsuite "PQTY" testcase "PQTY(SI)" -- from codata.spad (package CODATA) CT(v,e,u) ==> (interval(v-e,v+e)$Interval(Float)) u -- speed of light in vacuum -- Value 299 792 458 m s-1 -- Standard uncertainty (exact) -- Relative standard uncertainty (exact) -- Concise form 299 792 458 m s-1 c := CT(299792458.0, 0.0, %m(1)*%s(-1)) -- Planck constant over 2 pi -- Value 1.054 571 800 x 10-34 J s -- Standard uncertainty 0.000 000 013 x 10-34 J s -- Relative standard uncertainty 1.2 x 10-8 -- Concise form 1.054 571 800(13) x 10-34 J s hbar := CT(1.054571800E-34, 0.000000013E-34,%m(2)*%kg(1)*%s(-1)) -- elementary charge -- $e$ -- Value 1.602 176 6208 x 10-19 C -- Standard uncertainty 0.000 000 0098 x 10-19 C -- Relative standard uncertainty 6.1 x 10-9 -- Concise form 1.602 176 6208(98) x 10-19 C e := CT(1.6021766208E-19, 0.0000000098E-19, %A(1)*%s(1)) -- electron mass -- $m_{\rm e}$ -- Value 9.109 383 56 x 10-31 kg -- Standard uncertainty 0.000 000 11 x 10-31 kg -- Relative standard uncertainty 1.2 x 10-8 -- Concise form 9.109 383 56(11) x 10-31 kg m_e := CT(9.10938356E-31, 0.00000011E-31, %kg(1)) -- fine-structure constant -- Value 7.297 352 5664 x 10-3 -- Standard uncertainty 0.000 000 0017 x 10-3 -- Relative standard uncertainty 2.3 x 10-10 -- Concise form 7.297 352 5664(17) x 10-3 alpha := CT(7.2973525664E-3, 0.0000000017E-3,%m(0)$SI) -- electric constant -- $\varepsilon_0$ -- Value 8.854 187 817... x 10-12 F m-1 -- Standard uncertainty (exact) -- Relative standard uncertainty (exact) -- Concise form 8.854 187 817... x 10-12 F m-1 eps_0 := CT(8.854187817E-12,0, %m(-3)*%kg(-1)*%s(4)*%A(2)) r1:=ival e r2:=unit e r3:=magnitude e r4:=uncertainty e testEquals("(unit e = %s(1)*%A(1))$SI","true") testEquals("(unit(m_e*c^2)/joule()$SI=one()$SI)$SI","true") -- fine structure myalpha:=(1/(4*%pi))::Float * eps_0^(-1)*e^2/hbar/c testEquals("abs(magnitude(myalpha-alpha))<1.0E-10","true") f:=2 newton()$SI l:=3.6 metre()$SI a:=l^2 p:=f/a testEquals("test(magnitude(7.2 joule()$SI / (f*l))=1$Float)","true") testEquals("uncertainty(m_e*c^2)<1.0E-20","true") setOutputMode(1)$PQTY(SI) hbar m_e c setOutputMode(3)$PQTY(SI) alpha eps_0 setOutputMode(2)$PQTY(SI) m_e hbar -- Test Suite testsuite "DIMAN" testcase "DIMAN(SI)" -- Dimensional analysis -- Buckingham Pi theorem D==> DIMAN(SI) t:Table(Symbol,SI):=table() t.L:=%m(1)$SI ; t.M:=%kg(1)$SI; t.T:=%s(1)$SI; t.g:=%m(1)$SI/%s(2)$SI bt:=buckingham(t) res1:=solve(bt.1=1,'T).1 s:Table(Symbol,SI):=table() s.v:=%m(1)$SI/%s(1)$SI; s.rho:=%kg(1)$SI/%m(3)$SI; s.p:=pascal()$SI bs:=buckingham(s) res2:=solve(bs.1=1,'v).1 -- https://en.wikipedia.org/w/index.php?title=Dimensional_analysis -- Example section 26 vb:Table(Symbol,SI):=table() vb.'l:=%m(1)$SI; vb.A:=%m(1)$SI; vb.rho:=%kg(1)$SI/%m(1)$SI; vb.'s:=%kg(1)$SI*%m(1)$SI/%s(2)$SI; vb.E:=%kg(1)$SI*%m(2)$SI/%s(2)$SI bvb:=buckingham vb testEquals("res1","T=sqrt(L/g)") testEquals("res2","v=sqrt(p/rho)") F:=operator 'F res3:=F(bvb.2,bvb.1)=0 testEquals("res3","F('l*'s/'E,'A*'s/'E)=0") -- Results/Statistics )set output algebra on )version )lisp (lisp-implementation-type) )lisp (lisp-implementation-version) statistics()
(1) -> <spad>
)abbrev category PUNIT PhysicalUnit PhysicalUnit() : Category == with "*" : (%,%) -> % "/" : (%, %) -> % "^" : (%, Integer) -> % "=" : (%, %) -> Boolean dim : % -> List Integer one : % coerce : % -> OutputForm
)abbrev domain PUSYS PhysicalUnitSystem PhysicalUnitSystem(u:List Symbol) : Exports == Implementation where BASU ==> OrderedVariableList(u) FAGB ==> FreeModule(Integer,BASU) Exports == Join(PhysicalUnit, CoercibleTo OutputForm) with baseSymbols : List Symbol baseUnits : List % factors : % -> List Record(gen: BASU, exp: Integer) Implementation == FreeGroup(BASU) add Rep:=FreeModule(Integer, BASU) x * y == x+y x / y == x-y x ^ n == n*x one() == 0$Rep baseSymbols() == [convert(x)@Symbol for x in enumerate$BASU] baseUnits() == [x::% for x in enumerate$BASU] dim(x) == [coefficient(x, b) for b in enumerate$BASU] x = y == test(dim x = dim y)
)abbrev domain PQTY PhysQty PhysQty(U:PhysicalUnit): Exports == Implementation where
Q ==> Fraction(Integer) F ==> Float R ==> DoubleFloat I ==> Integer OF ==> OutputForm PI ==> PositiveInteger IVF ==> Interval Float
Exports == Join(CoercibleTo OutputForm) with _* : (%,%) -> % _/ : (%, %) -> % _+ : (%, %) -> % _- : (%, %) -> % _^ : (%, Integer) -> % _- : % -> %
_* : (Union(F,R, I, Q, PI), %) -> % _/ : (%, Union(F, R, I, Q, PI)) -> %
ival : % -> IVF unit : % -> U
magnitude : % -> F uncertainty : % -> F
elt : (IVF,U) -> % elt : (F, U) -> %
setOutputMode : PI -> PI coerce : % -> OutputForm
Implementation == add
Rep := Record(ival:IVF,unit:U)
outputMode:PI:=2
x:% * y:% == [x.ival * y.ival,x.unit * y.unit]$Rep x:% / y:% == r:Union(IVF, "failed"):=recip(y.ival) r case IVF => [x.ival * r, x.unit / y.unit]$Rep error "failed" x + y == x.unit=y.unit => [x.ival + y.ival, x.unit]$Rep error "failed" x - y == x.unit=y.unit => [x.ival - y.ival, x.unit]$Rep error "failed" x ^ n == n > 0 => [x.ival^n::PI, x.unit^n::PI]$Rep n = 0 => [interval(1.0, 1.0)$IVF, one()]$Rep r:Union(IVF, "failed"):=recip(x.ival) m:PI:=(-n)::PI r case IVF => [r^m, x.unit^n]$Rep error "failed"
- x == [-x.ival,x.unit]$Rep
r:Union(F,R, I, Q, PI) * x:% == r case I or r case PI => [r*x.ival, x.unit]$Rep mkrep(r) ==> [interval(r)$IVF * x.ival, x.unit]$Rep r case Q or r case F => mkrep r r case R => mkrep convert(r)$F
x:% / r:Union(F,R, I, Q, PI) == s:%:=r*[interval(1.0)$IVF, one()]$Rep x/s
ival x == x.ival unit x == x.unit
magnitude x == (sup(x.ival)+inf(x.ival))/2.0 uncertainty x == (sup(x.ival)-inf(x.ival))/2.0
elt(v:IVF,u:U):% == [v, u]$Rep elt(v:F, u:U):% == [interval(v)$IVF, u]$Rep
setOutputMode(s:PI):PI == modes:List PI:= [1,2, 3] if member?(s, modes) then outputMode := s return s error "1: plusMinus, 2: single, 3: interval"
coerce(x) == pm:Character:=char(177) pmof:=pm::String::Symbol::OF val:Float:=(sup(x.ival)+inf(x.ival))/2 err:Float:=sup(x.ival)-val outputMode=1 => blankSeparate [val::OF,pmof, err::OF, x.unit::OF] outputMode=2 => blankSeparate [val::OF, x.unit::OF] outputMode=3 => blankSeparate [x.ival::OF, x.unit::OF]
)abbrev domain SI SIunit SIunit : Exports == Implementation where
Exports == Join(SetCategory,PhysicalUnit) with
unitSystem : () -> Type baseUnits : () -> List %
%m : Integer -> % %kg : Integer -> % %s : Integer -> % %A : Integer -> % %K : Integer -> % %mol : Integer -> % %cd : Integer -> %
metre : % kilogram : % second : % ampere : % kelvin : % mole : % candela : %
hertz : % newton : % pascal : % joule : % watt : % coulomb : % volt : % farad : % ohm : % siemens : % weber : % tesla : % henry : % lumen : % lux : % becquerel : % gray : % sievert : % katal : %
Implementation == PhysicalUnitSystem(['m,'kg, 's, 'A, 'K, 'mol, 'cd]) add
USY:=['m,'kg, 's, 'A, 'K, 'mol, 'cd] Rep:=PhysicalUnitSystem(USY)
unitSystem() == %
u:=baseUnits()$Rep baseUnits() == u
%m(n) == u.1^n %kg(n) == u.2^n %s(n) == u.3^n %A(n) == u.4^n %K(n) == u.5^n %mol(n) == u.6^n %cd(n) == u.7^n
metre == %m(1) kilogram == %kg(1) second == %s(1) ampere == %A(1) kelvin == %K(1) mole == %mol(1) candela == %cd(1)
hertz == %s(-1) newton == %kg(1)*%m(1)*%s(-2) pascal == %kg(1)*%m(-1)*%s(-2) joule == %kg(1)*%m(2)*%s(-2) watt == %kg(1)*%m(2)*%s(-3) coulomb == %s(1)*%A(1) volt == %kg(1)*%m(2)*%s(-3)*%A(-1) farad == %kg(-1)*%m(-2)*%s(4)*%A(2) ohm == %kg(1)*%m(2)*%s(-3)*%A(2) siemens == %kg(-1)*%m(-2)*%s(3)*%A(2) weber == %kg(1)*%m(2)*%s(-2)*%A(-1) tesla == %kg(1)*%s(-2)*%A(-1) henry == %kg(1)*%m(2)*%s(-2)*%A(-2) lumen == %cd(1) lux == %m(-2)*%cd(1) becquerel == %s(-1) gray == %m(2)*%s(-2) sievert == %m(2)*%s(-2) katal == %s(-1)*%mol(1)
)abbrev package DIMAN DimensionalAnalysis DimensionalAnalysis(P:PhysicalUnit) : Exports == Implementation where
Exports == with
buckingham : Table(Symbol,P) -> List(Expression(Integer))
Implementation == P add
mkxpr(s:List Symbol,v:Vector Integer):Expression Integer == r:Expression Integer:=1 for j in 1..#s repeat r:=r*(s.j)::Expression(Integer)^(v.j) r
buckingham(t) == --[1::Expression Integer] M:Matrix(Integer):=matrix [dim(t.x) for x in keys(t)] ns:List Vector Integer:=nullSpace transpose(M) r:List Expression Integer:=[] for j in 1..#ns repeat r:=append(r,[mkxpr(keys(t), ns.j)]) r</spad>
Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/4318783589297783802-25px001.spad using old system compiler. PUNIT abbreviates category PhysicalUnit ------------------------------------------------------------------------ initializing NRLIB PUNIT for PhysicalUnit compiling into NRLIB PUNIT
;;; *** |PhysicalUnit| REDEFINED Time: 0 SEC.
finalizing NRLIB PUNIT Processing PhysicalUnit for Browser database: --->-->PhysicalUnit(constructor): Not documented!!!! --->-->PhysicalUnit((* (% % %))): Not documented!!!! --->-->PhysicalUnit((/ (% % %))): Not documented!!!! --->-->PhysicalUnit((^ (% % (Integer)))): Not documented!!!! --->-->PhysicalUnit((= ((Boolean) % %))): Not documented!!!! --->-->PhysicalUnit((dim ((List (Integer)) %))): Not documented!!!! --->-->PhysicalUnit((one (%) constant)): Not documented!!!! --->-->PhysicalUnit((coerce ((OutputForm) %))): Not documented!!!! --->-->PhysicalUnit(): Missing Description ; compiling file "/var/aw/var/LatexWiki/PUNIT.NRLIB/PUNIT.lsp" (written 02 NOV 2024 02:51:10 AM):
; wrote /var/aw/var/LatexWiki/PUNIT.NRLIB/PUNIT.fasl ; compilation finished in 0:00:00.000 ------------------------------------------------------------------------ PhysicalUnit is now explicitly exposed in frame initial PhysicalUnit will be automatically loaded when needed from /var/aw/var/LatexWiki/PUNIT.NRLIB/PUNIT
PUSYS abbreviates domain PhysicalUnitSystem ------------------------------------------------------------------------ initializing NRLIB PUSYS for PhysicalUnitSystem compiling into NRLIB PUSYS compiling exported * : (%,%) -> % Time: 0 SEC.
compiling exported / : (%,%) -> % Time: 0 SEC.
compiling exported ^ : (%,Integer) -> % Time: 0 SEC.
compiling exported one : () -> % Time: 0 SEC.
compiling exported baseSymbols : () -> List Symbol Time: 0 SEC.
compiling exported baseUnits : () -> List % Time: 0 SEC.
compiling exported dim : % -> List Integer Time: 0 SEC.
compiling exported = : (%,%) -> Boolean Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |PhysicalUnitSystem| REDEFINED
;;; *** |PhysicalUnitSystem| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor PhysicalUnitSystem Time: 0.02 seconds
--------------non extending category---------------------- .. PhysicalUnitSystem(#1) of cat (|Join| (|PhysicalUnit|) (|CoercibleTo| (|OutputForm|)) (CATEGORY |domain| (SIGNATURE |baseSymbols| ((|List| (|Symbol|))) |constant|) (SIGNATURE |baseUnits| ((|List| %)) |constant|) (SIGNATURE |factors| ((|List| (|Record| (|:| |gen| (|OrderedVariableList| |#1|)) (|:| |exp| (|Integer|)))) %)))) has no (|Group|) finalizing NRLIB PUSYS Processing PhysicalUnitSystem for Browser database: --->-->PhysicalUnitSystem(constructor): Not documented!!!! --->-->PhysicalUnitSystem((baseSymbols ((List (Symbol))) constant)): Not documented!!!! --->-->PhysicalUnitSystem((baseUnits ((List %)) constant)): Not documented!!!! --->-->PhysicalUnitSystem((factors ((List (Record (: gen (OrderedVariableList u)) (: exp (Integer)))) %))): Not documented!!!! --->-->PhysicalUnitSystem(): Missing Description ; compiling file "/var/aw/var/LatexWiki/PUSYS.NRLIB/PUSYS.lsp" (written 02 NOV 2024 02:51:10 AM):
; wrote /var/aw/var/LatexWiki/PUSYS.NRLIB/PUSYS.fasl ; compilation finished in 0:00:00.016 ------------------------------------------------------------------------ PhysicalUnitSystem is now explicitly exposed in frame initial PhysicalUnitSystem will be automatically loaded when needed from /var/aw/var/LatexWiki/PUSYS.NRLIB/PUSYS
PQTY abbreviates domain PhysQty ------------------------------------------------------------------------ initializing NRLIB PQTY for PhysQty compiling into NRLIB PQTY Local variable Rep type redefined: (Join (SetCategory) (CATEGORY domain (SIGNATURE construct ((Record (: ival (Interval (Float))) (: unit U)) (Interval (Float)) U)) (SIGNATURE ~= ((Boolean) (Record (: ival (Interval (Float))) (: unit U)) (Record (: ival (Interval (Float))) (: unit U)))) (SIGNATURE coerce ((OutputForm) (Record (: ival (Interval (Float))) (: unit U)))) (SIGNATURE elt ((Interval (Float)) (Record (: ival (Interval (Float))) (: unit U)) ival)) (SIGNATURE elt (U (Record (: ival (Interval (Float))) (: unit U)) unit)) (SIGNATURE setelt! ((Interval (Float)) (Record (: ival (Interval (Float))) (: unit U)) ival (Interval (Float)))) (SIGNATURE setelt! (U (Record (: ival (Interval (Float))) (: unit U)) unit U)) (SIGNATURE copy ((Record (: ival (Interval (Float))) (: unit U)) (Record (: ival (Interval (Float))) (: unit U)))))) to (Join (BiModule (Integer) (Integer)) (FreeModuleCategory (Integer) (OrderedVariableList u)) (CATEGORY domain (IF (has (Integer) (CommutativeRing)) (ATTRIBUTE (Module (Integer))) noBranch) (IF (has (Integer) (SemiRing)) (ATTRIBUTE (RetractableTo (OrderedVariableList u))) noBranch) (IF (has (Integer) (Hashable)) (IF (has (OrderedVariableList u) (Hashable)) (ATTRIBUTE (Hashable)) noBranch) noBranch) (IF (has (OrderedVariableList u) (OrderedSet)) (PROGN (IF (has (Integer) (OrderedAbelianMonoid)) (ATTRIBUTE (OrderedAbelianMonoid)) noBranch) (IF (has (Integer) (OrderedAbelianMonoidSup)) (ATTRIBUTE (OrderedAbelianMonoidSup)) noBranch)) noBranch) (SIGNATURE * (% (Integer) (OrderedVariableList u))) (SIGNATURE * (% (OrderedVariableList u) (Integer))))) compiling exported * : (%,%) -> % Time: 0 SEC.
compiling exported / : (%,%) -> % Time: 0 SEC.
compiling exported + : (%,%) -> % Time: 0 SEC.
compiling exported - : (%,%) -> % Time: 0 SEC.
compiling exported ^ : (%,Integer) -> % Time: 0 SEC.
compiling exported - : % -> % Time: 0 SEC.
compiling exported * : (Union(Float,DoubleFloat, Integer, Fraction Integer, PositiveInteger), %) -> % processing macro definition mkrep r ==> (Sel Rep construct)(*((Sel (Interval (Float)) interval) r, x ival), x unit) Time: 0 SEC.
compiling exported / : (%,Union(Float, DoubleFloat, Integer, Fraction Integer, PositiveInteger)) -> % Time: 0 SEC.
compiling exported ival : % -> Interval Float PQTY;ival;%I;9 is replaced by QCAR Time: 0 SEC.
compiling exported unit : % -> U PQTY;unit;%U;10 is replaced by QCDR Time: 0 SEC.
compiling exported magnitude : % -> Float Time: 0 SEC.
compiling exported uncertainty : % -> Float Time: 0 SEC.
compiling exported elt : (Interval Float,U) -> % PQTY;elt;IU%;13 is replaced by CONS Time: 0 SEC.
compiling exported elt : (Float,U) -> % Time: 0 SEC.
compiling exported setOutputMode : PositiveInteger -> PositiveInteger Time: 0 SEC.
compiling exported coerce : % -> OutputForm Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |PhysQty| REDEFINED
;;; *** |PhysQty| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor PhysQty Time: 0.04 seconds
finalizing NRLIB PQTY Processing PhysQty for Browser database: --->-->PhysQty(constructor): Not documented!!!! --->-->PhysQty((* (% % %))): Not documented!!!! --->-->PhysQty((/ (% % %))): Not documented!!!! --->-->PhysQty((+ (% % %))): Not documented!!!! --->-->PhysQty((- (% % %))): Not documented!!!! --->-->PhysQty((^ (% % (Integer)))): Not documented!!!! --->-->PhysQty((- (% %))): Not documented!!!! --->-->PhysQty((* (% (Union (Float) (DoubleFloat) (Integer) (Fraction (Integer)) (PositiveInteger)) %))): Not documented!!!! --->-->PhysQty((/ (% % (Union (Float) (DoubleFloat) (Integer) (Fraction (Integer)) (PositiveInteger))))): Not documented!!!! --->-->PhysQty((ival ((Interval (Float)) %))): Not documented!!!! --->-->PhysQty((unit (U %))): Not documented!!!! --->-->PhysQty((magnitude ((Float) %))): Not documented!!!! --->-->PhysQty((uncertainty ((Float) %))): Not documented!!!! --->-->PhysQty((elt (% (Interval (Float)) U))): Not documented!!!! --->-->PhysQty((elt (% (Float) U))): Not documented!!!! --->-->PhysQty((setOutputMode ((PositiveInteger) (PositiveInteger)))): Not documented!!!! --->-->PhysQty((coerce ((OutputForm) %))): Not documented!!!! --->-->PhysQty(): Missing Description ; compiling file "/var/aw/var/LatexWiki/PQTY.NRLIB/PQTY.lsp" (written 02 NOV 2024 02:51:10 AM):
; wrote /var/aw/var/LatexWiki/PQTY.NRLIB/PQTY.fasl ; compilation finished in 0:00:00.032 ------------------------------------------------------------------------ PhysQty is now explicitly exposed in frame initial PhysQty will be automatically loaded when needed from /var/aw/var/LatexWiki/PQTY.NRLIB/PQTY
SI abbreviates domain SIunit ------------------------------------------------------------------------ initializing NRLIB SI for SIunit compiling into NRLIB SI Local variable Rep type redefined: (Join (PhysicalUnit) (CoercibleTo (OutputForm)) (CATEGORY domain (SIGNATURE baseSymbols ((List (Symbol))) constant) (SIGNATURE baseUnits ((List %)) constant) (SIGNATURE factors ((List (Record (: gen (OrderedVariableList USY)) (: exp (Integer)))) %)))) to (Join (SetCategory) (CATEGORY domain (SIGNATURE construct ((Record (: ival (Interval (Float))) (: unit U)) (Interval (Float)) U)) (SIGNATURE ~= ((Boolean) (Record (: ival (Interval (Float))) (: unit U)) (Record (: ival (Interval (Float))) (: unit U)))) (SIGNATURE coerce ((OutputForm) (Record (: ival (Interval (Float))) (: unit U)))) (SIGNATURE elt ((Interval (Float)) (Record (: ival (Interval (Float))) (: unit U)) ival)) (SIGNATURE elt (U (Record (: ival (Interval (Float))) (: unit U)) unit)) (SIGNATURE setelt! ((Interval (Float)) (Record (: ival (Interval (Float))) (: unit U)) ival (Interval (Float)))) (SIGNATURE setelt! (U (Record (: ival (Interval (Float))) (: unit U)) unit U)) (SIGNATURE copy ((Record (: ival (Interval (Float))) (: unit U)) (Record (: ival (Interval (Float))) (: unit U)))))) compiling exported unitSystem : () -> Type Time: 0 SEC.
compiling exported baseUnits : () -> List % Time: 0 SEC.
compiling exported %m : Integer -> % Time: 0 SEC.
compiling exported %kg : Integer -> % Time: 0 SEC.
compiling exported %s : Integer -> % Time: 0 SEC.
compiling exported %A : Integer -> % Time: 0 SEC.
compiling exported %K : Integer -> % Time: 0 SEC.
compiling exported %mol : Integer -> % Time: 0 SEC.
compiling exported %cd : Integer -> % Time: 0 SEC.
compiling exported metre : () -> % Time: 0 SEC.
compiling exported kilogram : () -> % Time: 0 SEC.
compiling exported second : () -> % Time: 0 SEC.
compiling exported ampere : () -> % Time: 0 SEC.
compiling exported kelvin : () -> % Time: 0 SEC.
compiling exported mole : () -> % Time: 0 SEC.
compiling exported candela : () -> % Time: 0 SEC.
compiling exported hertz : () -> % Time: 0 SEC.
compiling exported newton : () -> % Time: 0 SEC.
compiling exported pascal : () -> % Time: 0 SEC.
compiling exported joule : () -> % Time: 0 SEC.
compiling exported watt : () -> % Time: 0 SEC.
compiling exported coulomb : () -> % Time: 0 SEC.
compiling exported volt : () -> % Time: 0 SEC.
compiling exported farad : () -> % Time: 0 SEC.
compiling exported ohm : () -> % Time: 0 SEC.
compiling exported siemens : () -> % Time: 0 SEC.
compiling exported weber : () -> % Time: 0 SEC.
compiling exported tesla : () -> % Time: 0 SEC.
compiling exported henry : () -> % Time: 0 SEC.
compiling exported lumen : () -> % Time: 0 SEC.
compiling exported lux : () -> % Time: 0 SEC.
compiling exported becquerel : () -> % Time: 0 SEC.
compiling exported gray : () -> % Time: 0 SEC.
compiling exported sievert : () -> % Time: 0 SEC.
compiling exported katal : () -> % Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |SIunit| REDEFINED
;;; *** |SIunit| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor SIunit Time: 0.03 seconds
--------------non extending category---------------------- .. SIunit of cat (|Join| (|SetCategory|) (|PhysicalUnit|) (CATEGORY |domain| (SIGNATURE |unitSystem| ((|Type|))) (SIGNATURE |baseUnits| ((|List| %))) (SIGNATURE |%m| (% (|Integer|))) (SIGNATURE |%kg| (% (|Integer|))) (SIGNATURE |%s| (% (|Integer|))) (SIGNATURE %A (% (|Integer|))) (SIGNATURE %K (% (|Integer|))) (SIGNATURE |%mol| (% (|Integer|))) (SIGNATURE |%cd| (% (|Integer|))) (SIGNATURE |metre| (%) |constant|) (SIGNATURE |kilogram| (%) |constant|) (SIGNATURE |second| (%) |constant|) (SIGNATURE |ampere| (%) |constant|) (SIGNATURE |kelvin| (%) |constant|) (SIGNATURE |mole| (%) |constant|) (SIGNATURE |candela| (%) |constant|) (SIGNATURE |hertz| (%) |constant|) (SIGNATURE |newton| (%) |constant|) (SIGNATURE |pascal| (%) |constant|) (SIGNATURE |joule| (%) |constant|) (SIGNATURE |watt| (%) |constant|) (SIGNATURE |coulomb| (%) |constant|) (SIGNATURE |volt| (%) |constant|) (SIGNATURE |farad| (%) |constant|) (SIGNATURE |ohm| (%) |constant|) (SIGNATURE |siemens| (%) |constant|) (SIGNATURE |weber| (%) |constant|) (SIGNATURE |tesla| (%) |constant|) (SIGNATURE |henry| (%) |constant|) (SIGNATURE |lumen| (%) |constant|) (SIGNATURE |lux| (%) |constant|) (SIGNATURE |becquerel| (%) |constant|) (SIGNATURE |gray| (%) |constant|) (SIGNATURE |sievert| (%) |constant|) (SIGNATURE |katal| (%) |constant|))) has no (SIGNATURE |baseSymbols| ((|List| (|Symbol|))) |constant|) finalizing NRLIB SI Processing SIunit for Browser database: --->-->SIunit(constructor): Not documented!!!! --->-->SIunit((unitSystem ((Type)))): Not documented!!!! --->-->SIunit((baseUnits ((List %)))): Not documented!!!! --->-->SIunit( %(Integer())()
): Not documented!!!! --->-->SIunit((%kg (% (Integer)))): Not documented!!!! --->-->SIunit(((% (|Integer|)))): Not documented!!!! --->-->SIunit((%A (% (Integer)))): Not documented!!!! --->-->SIunit((%K (% (Integer)))): Not documented!!!! --->-->SIunit((%mol (% (Integer)))): Not documented!!!! --->-->SIunit((%cd (% (Integer)))): Not documented!!!! --->-->SIunit((metre (%) constant)): Not documented!!!! --->-->SIunit((kilogram (%) constant)): Not documented!!!! --->-->SIunit((second (%) constant)): Not documented!!!! --->-->SIunit((ampere (%) constant)): Not documented!!!! --->-->SIunit((kelvin (%) constant)): Not documented!!!! --->-->SIunit((mole (%) constant)): Not documented!!!! --->-->SIunit((candela (%) constant)): Not documented!!!! --->-->SIunit((hertz (%) constant)): Not documented!!!! --->-->SIunit((newton (%) constant)): Not documented!!!! --->-->SIunit((pascal (%) constant)): Not documented!!!! --->-->SIunit((joule (%) constant)): Not documented!!!! --->-->SIunit((watt (%) constant)): Not documented!!!! --->-->SIunit((coulomb (%) constant)): Not documented!!!! --->-->SIunit((volt (%) constant)): Not documented!!!! --->-->SIunit((farad (%) constant)): Not documented!!!! --->-->SIunit((ohm (%) constant)): Not documented!!!! --->-->SIunit((siemens (%) constant)): Not documented!!!! --->-->SIunit((weber (%) constant)): Not documented!!!! --->-->SIunit((tesla (%) constant)): Not documented!!!! --->-->SIunit((henry (%) constant)): Not documented!!!! --->-->SIunit((lumen (%) constant)): Not documented!!!! --->-->SIunit((lux (%) constant)): Not documented!!!! --->-->SIunit((becquerel (%) constant)): Not documented!!!! --->-->SIunit((gray (%) constant)): Not documented!!!! --->-->SIunit((sievert (%) constant)): Not documented!!!! --->-->SIunit((katal (%) constant)): Not documented!!!! --->-->SIunit(): Missing Description ; compiling file "/var/aw/var/LatexWiki/SI.NRLIB/SI.lsp" (written 02 NOV 2024 02:51:11 AM):
; wrote /var/aw/var/LatexWiki/SI.NRLIB/SI.fasl ; compilation finished in 0:00:00.036 ------------------------------------------------------------------------ SIunit is now explicitly exposed in frame initial SIunit will be automatically loaded when needed from /var/aw/var/LatexWiki/SI.NRLIB/SI
DIMAN abbreviates package DimensionalAnalysis ------------------------------------------------------------------------ initializing NRLIB DIMAN for DimensionalAnalysis compiling into NRLIB DIMAN compiling local mkxpr : (List Symbol,Vector Integer) -> Expression Integer Time: 0.02 SEC.
compiling exported buckingham : Table(Symbol,P) -> List Expression Integer Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |DimensionalAnalysis| REDEFINED
;;; *** |DimensionalAnalysis| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor DimensionalAnalysis Time: 0.03 seconds
finalizing NRLIB DIMAN Processing DimensionalAnalysis for Browser database: --->-->DimensionalAnalysis(constructor): Not documented!!!! --->-->DimensionalAnalysis((buckingham ((List (Expression (Integer))) (Table (Symbol) P)))): Not documented!!!! --->-->DimensionalAnalysis(): Missing Description ; compiling file "/var/aw/var/LatexWiki/DIMAN.NRLIB/DIMAN.lsp" (written 02 NOV 2024 02:51:11 AM):
; wrote /var/aw/var/LatexWiki/DIMAN.NRLIB/DIMAN.fasl ; compilation finished in 0:00:00.008 ------------------------------------------------------------------------ DimensionalAnalysis is now explicitly exposed in frame initial DimensionalAnalysis will be automatically loaded when needed from /var/aw/var/LatexWiki/DIMAN.NRLIB/DIMAN
--
)set break resume
)expose UnittestCount UnittestAux Unittest
UnittestCount is now explicitly exposed in frame initial UnittestAux is now explicitly exposed in frame initial Unittest is now explicitly exposed in frame initial
--)lib PUSYS PQTY SI DIMAN
)expose PUSYS PQTY SI DIMAN
PhysicalUnitSystem is already explicitly exposed in frame initial PhysQty is already explicitly exposed in frame initial SIunit is already explicitly exposed in frame initial DimensionalAnalysis is already explicitly exposed in frame initial --)co pdim2
)sh SI
SIunit is a domain constructor. Abbreviation for SIunit is SI This constructor is exposed in this frame. 44 Names for 44 Operations in this Domain. ------------------------------- Operations --------------------------------
%A : Integer -> % %K : Integer -> % %cd : Integer -> % %kg : Integer -> % %m : Integer -> % %mol : Integer -> % %s : Integer -> % ?*? : (%,%) -> % ?/? : (%, %) -> % ?=? : (%, %) -> Boolean ?^? : (%, Integer) -> % ampere : () -> % baseUnits : () -> List(%) becquerel : () -> % candela : () -> % coerce : % -> OutputForm coulomb : () -> % dim : % -> List(Integer) farad : () -> % gray : () -> % henry : () -> % hertz : () -> % joule : () -> % katal : () -> % kelvin : () -> % kilogram : () -> % latex : % -> String lumen : () -> % lux : () -> % metre : () -> % mole : () -> % newton : () -> % ohm : () -> % one : () -> % pascal : () -> % second : () -> % siemens : () -> % sievert : () -> % tesla : () -> % unitSystem : () -> Type volt : () -> % watt : () -> % weber : () -> % ?~=? : (%, %) -> Boolean
-- Usage
m:=1400.3 %kg(1)
(1) |
v:=30.6 (%m(1)/%s(1))
(2) |
E:=m*v^2/2
(3) |
-- Test Suite testsuite "PUSYS"
All user variables and function definitions have been cleared.
-- Cases testcase "cgs"
All user variables and function definitions have been cleared.
CGS ==> PUSYS(['cm,'g, 's])
[cm,g, s]:=baseUnits()$CGS
(4) |
erg:=g*cm^2/s^2
(5) |
dyne:=g*cm/s^2
(6) |
testEquals("dim cm","[1, 0, 0]")
testEquals("dim g","[0, 1, 0]")
testEquals("dim s","[0, 0, 1]")
testEquals("dim(cm/s*g)","[1, 1, -1]")
testEquals("factors(cm/g).1.exp","1")
testEquals("factors(cm/g).2.exp","-1")
testEquals("factors(one()$CGS)","[]")
testEquals("baseSymbols()$CGS","['cm, 'g, 's]")
testEquals("(cm^2/s^4*g=g*s^(-4)*cm^2)$CGS","true")
testEquals("(dyne * cm = erg)$CGS","true")
testcase "SI"
All user variables and function definitions have been cleared.
[m,kg, s, A, K, mol, cd]:=baseUnits()$SI
(7) |
force1:=%kg(1) * %m(1) * %s(-2)
(8) |
force2:=kg * m / s^2
(9) |
force3:=newton()$SI
(10) |
area1:=%m(2)
(11) |
area2:=m^2
(12) |
area3:=metre()^2
(13) |
pressure1:=force1/area1
(14) |
pressure2:=pascal()$SI
(15) |
testEquals("(force1=force2)$SI","true")
testEquals("(force2=force3)$SI","true")
testEquals("(pressure1=pressure2)$SI","true")
testEquals("dim force1","[1, 1, - 2, 0, 0, 0, 0]")
testEquals("dim pressure2","[- 1, 1, - 2, 0, 0, 0, 0]")
-- Test Suite testsuite "PQTY"
All user variables and function definitions have been cleared.
testcase "PQTY(SI)"
All user variables and function definitions have been cleared.
-- from codata.spad (package CODATA) CT(v,e, u) ==> (interval(v-e, v+e)$Interval(Float)) u
-- speed of light in vacuum -- Value 299 792 458 m s-1 -- Standard uncertainty (exact) -- Relative standard uncertainty (exact) -- Concise form 299 792 458 m s-1 c := CT(299792458.0,0.0, %m(1)*%s(-1))
(16) |
-- Planck constant over 2 pi -- Value 1.054 571 800 x 10-34 J s -- Standard uncertainty 0.000 000 013 x 10-34 J s -- Relative standard uncertainty 1.2 x 10-8 -- Concise form 1.054 571 800(13) x 10-34 J s hbar := CT(1.054571800E-34,0.000000013E-34, %m(2)*%kg(1)*%s(-1))
(17) |
-- elementary charge -- $e$ -- Value 1.602 176 6208 x 10-19 C -- Standard uncertainty 0.000 000 0098 x 10-19 C -- Relative standard uncertainty 6.1 x 10-9 -- Concise form 1.602 176 6208(98) x 10-19 C e := CT(1.6021766208E-19,0.0000000098E-19, %A(1)*%s(1))
(18) |
-- electron mass -- $m_{\rm e}$ -- Value 9.109 383 56 x 10-31 kg -- Standard uncertainty 0.000 000 11 x 10-31 kg -- Relative standard uncertainty 1.2 x 10-8 -- Concise form 9.109 383 56(11) x 10-31 kg m_e := CT(9.10938356E-31,0.00000011E-31, %kg(1))
(19) |
-- fine-structure constant -- Value 7.297 352 5664 x 10-3 -- Standard uncertainty 0.000 000 0017 x 10-3 -- Relative standard uncertainty 2.3 x 10-10 -- Concise form 7.297 352 5664(17) x 10-3 alpha := CT(7.2973525664E-3,0.0000000017E-3, %m(0)$SI)
(20) |
-- electric constant -- $\varepsilon_0$ -- Value 8.854 187 817... x 10-12 F m-1 -- Standard uncertainty (exact) -- Relative standard uncertainty (exact) -- Concise form 8.854 187 817... x 10-12 F m-1 eps_0 := CT(8.854187817E-12,0, %m(-3)*%kg(-1)*%s(4)*%A(2))
(21) |
r1:=ival e
(22) |
r2:=unit e
(23) |
r3:=magnitude e
(24) |
r4:=uncertainty e
(25) |
testEquals("(unit e = %s(1)*%A(1))$SI","true")
testEquals("(unit(m_e*c^2)/joule()$SI=one()$SI)$SI","true")
-- fine structure myalpha:=(1/(4*%pi))::Float * eps_0^(-1)*e^2/hbar/c
(26) |
testEquals("abs(magnitude(myalpha-alpha))<1.0E-10","true")
f:=2 newton()$SI
(27) |
l:=3.6 metre()$SI
(28) |
a:=l^2
(29) |
p:=f/a
(30) |
testEquals("test(magnitude(7.2 joule()$SI / (f*l))=1$Float)","true")
testEquals("uncertainty(m_e*c^2)<1.0E-20","true")
setOutputMode(1)$PQTY(SI)
(31) |
hbar
(32) |
m_e
(33) |
c
(34) |
setOutputMode(3)$PQTY(SI)
(35) |
alpha
(36) |
eps_0
(37) |
setOutputMode(2)$PQTY(SI)
(38) |
m_e
(39) |
hbar
(40) |
-- Test Suite testsuite "DIMAN"
All user variables and function definitions have been cleared.
testcase "DIMAN(SI)"
All user variables and function definitions have been cleared.
-- Dimensional analysis -- Buckingham Pi theorem
D==> DIMAN(SI)
t:Table(Symbol,SI):=table()
(41) |
t.L:=%m(1)$SI ; t.M:=%kg(1)$SI; t.T:=%s(1)$SI; t.g:=%m(1)$SI/%s(2)$SI
(42) |
bt:=buckingham(t)
(43) |
res1:=solve(bt.1=1,'T).1
(44) |
s:Table(Symbol,SI):=table()
(45) |
s.v:=%m(1)$SI/%s(1)$SI; s.rho:=%kg(1)$SI/%m(3)$SI; s.p:=pascal()$SI
(46) |
bs:=buckingham(s)
(47) |
res2:=solve(bs.1=1,'v).1
(48) |
-- https://en.wikipedia.org/w/index.php?title=Dimensional_analysis -- Example section 26 vb:Table(Symbol,SI):=table()
(49) |
vb.'l:=%m(1)$SI; vb.A:=%m(1)$SI; vb.rho:=%kg(1)$SI/%m(1)$SI;
vb.'s:=%kg(1)$SI*%m(1)$SI/%s(2)$SI; vb.E:=%kg(1)$SI*%m(2)$SI/%s(2)$SI
(50) |
bvb:=buckingham vb
(51) |
testEquals("res1","T=sqrt(L/g)")
testEquals("res2","v=sqrt(p/rho)")
F:=operator 'F
(52) |
res3:=F(bvb.2,bvb.1)=0
(53) |
testEquals("res3","F('l*'s/'E, 'A*'s/'E)=0")
-- Results/Statistics
)set output algebra on
)version
"FriCAS 1.3.10 compiled at Wed 10 Jan 02:19:45 CET 2024"
)lisp (lisp-implementation-type)
Your user access level is compiler and this command is therefore not available. See the )set userlevel command for more information.
)lisp (lisp-implementation-version)
Your user access level is compiler and this command is therefore not available. See the )set userlevel command for more information.
statistics()
============================================================================= General WARNINGS: * do not use ')clear completely' before having used 'statistics()' It clears the statistics without warning! * do not forget to pass the arguments of the testXxxx functions as Strings! Otherwise,the test will fail and statistics() will not notice! ============================================================================= WARNINGS: Testsuite: PUSYS Testcase: cgs test: 7 testing in a domain without InputForm!
============================================================================= Testsuite: PUSYS failed (total): 0 (2) ============================================================================= Testsuite: PQTY failed (total): 0 (1) ============================================================================= Testsuite: DIMAN failed (total): 0 (1)
============================================================================= testsuite | testcases: failed (total) | tests: failed (total) PUSYS 0 (2) 0 (15) PQTY 0 (1) 0 (5) DIMAN 0 (1) 0 (3) ============================================================================= File summary. unexpected failures: 0 expected failures: 0 unexpected passes: 0 total tests: 23