Nächste: , Vorige:   [Inhalt][Index]

45 ezunits


Nächste: , Vorige: , Nach oben: ezunits   [Inhalt][Index]

45.1 Introduction to ezunits

ezunits is a package for working with dimensional quantities, including some functions for dimensional analysis. ezunits can carry out arithmetic operations on dimensional quantities and unit conversions. The built-in units include Systeme Internationale (SI) and US customary units, and other units can be declared. See also physical_constants, a collection of physical constants.

load("ezunits") loads this package. demo(ezunits) displays several examples. The convenience function known_units returns a list of the built-in and user-declared units, while display_known_unit_conversions displays the set of known conversions in an easy-to-read format.

An expression a ` b represents a dimensional quantity, with a indicating a nondimensional quantity and b indicating the dimensional units. A symbol can be used as a unit without declaring it as such; unit symbols need not have any special properties. The quantity and unit of an expression a ` b can be extracted by the qty and units functions, respectively.

A symbol may be declared to be a dimensional quantity, with specified quantity or specified units or both.

An expression a ` b `` c converts from unit b to unit c. ezunits has built-in conversions for SI base units, SI derived units, and some non-SI units. Unit conversions not already known to ezunits can be declared. The unit conversions known to ezunits are specified by the global variable known_unit_conversions, which comprises built-in and user-defined conversions. Conversions for products, quotients, and powers of units are derived from the set of known unit conversions.

As Maxima generally prefers exact numbers (integers or rationals) to inexact (float or bigfloat), so ezunits preserves exact numbers when they appear in dimensional quantities. All built-in unit conversions are expressed in terms of exact numbers; inexact numbers in declared conversions are coerced to exact.

There is no preferred system for display of units; input units are not converted to other units unless conversion is explicitly indicated. ezunits recognizes the prefixes m-, k-, M, and G- (for milli-, kilo-, mega-, and giga-) as applied to SI base units and SI derived units, but such prefixes are applied only when indicated by an explicit conversion.

Arithmetic operations on dimensional quantities are carried out by conventional rules for such operations.

ezunits does not require that units in a sum have the same dimensions; such terms are not added together, and no error is reported.

ezunits includes functions for elementary dimensional analysis, namely the fundamental dimensions and fundamental units of a dimensional quantity, and computation of dimensionless quantities and natural units. The functions for dimensional analysis were adapted from similar functions in another package, written by Barton Willis.

For the purpose of dimensional analysis, a list of fundamental dimensions and an associated list of fundamental units are maintained; by default the fundamental dimensions are length, mass, time, charge, temperature, and quantity, and the fundamental units are the associated SI units, but other fundamental dimensions and units can be declared.


45.2 Introduction to physical_constants

physical_constants is a collection of physical constants, copied from CODATA 2006 recommended values. [1] load("physical_constants") loads this package, and loads ezunits also, if it is not already loaded.

A physical constant is represented as a symbol which has a property which is the constant value. The constant value is a dimensional quantity, as represented by ezunits. The function constvalue fetches the constant value; the constant value is not the ordinary value of the symbol, so symbols of physical constants persist in evaluated expressions until their values are fetched by constvalue.

physical_constants includes some auxilliary information, namely, a description string for each constant, an estimate of the error of its numerical value, and a property for TeX display. To identify physical constants, each symbol has the physical_constant property; propvars(physical_constant) therefore shows the list of all such symbols.

physical_constants comprises the following constants.

%c

speed of light in vacuum

%mu_0

magnetic constant

%e_0

electric constant

%Z_0

characteristic impedance of vacuum

%G

Newtonian constant of gravitation

%h

Planck constant

%h_bar

Planck constant

%m_P

Planck mass

%T_P

Planck temperature

%l_P

Planck length

%t_P

Planck time

%%e

elementary charge

%Phi_0

magnetic flux quantum

%G_0

conductance quantum

%K_J

Josephson constant

%R_K

von Klitzing constant

%mu_B

Bohr magneton

%mu_N

nuclear magneton

%alpha

fine-structure constant

%R_inf

Rydberg constant

%a_0

Bohr radius

%E_h

Hartree energy

%ratio_h_me

quantum of circulation

%m_e

electron mass

%N_A

Avogadro constant

%m_u

atomic mass constant

%F

Faraday constant

%R

molar gas constant

%%k

Boltzmann constant

%V_m

molar volume of ideal gas

%n_0

Loschmidt constant

%ratio_S0_R

Sackur-Tetrode constant (absolute entropy constant)

%sigma

Stefan-Boltzmann constant

%c_1

first radiation constant

%c_1L

first radiation constant for spectral radiance

%c_2

second radiation constant

%b

Wien displacement law constant

%b_prime

Wien displacement law constant

References:

[1] http://physics.nist.gov/constants

Examples:

The list of all symbols which have the physical_constant property.

(%i1) load ("physical_constants")$
(%i2) propvars (physical_constant);
(%o2) [%c, %mu_0, %e_0, %Z_0, %G, %h, %h_bar, %m_P, %T_P, %l_P, 
%t_P, %%e, %Phi_0, %G_0, %K_J, %R_K, %mu_B, %mu_N, %alpha, 
%R_inf, %a_0, %E_h, %ratio_h_me, %m_e, %N_A, %m_u, %F, %R, %%k, 
%V_m, %n_0, %ratio_S0_R, %sigma, %c_1, %c_1L, %c_2, %b, %b_prime]

Properties of the physical constant %c.

(%i1) load ("physical_constants")$
(%i2) constantp (%c);
(%o2)                         true
(%i3) get (%c, description);
(%o3)               speed of light in vacuum
(%i4) constvalue (%c);
                                      m
(%o4)                     299792458 ` -
                                      s
(%i5) get (%c, RSU);
(%o5)                           0
(%i6) tex (%c);
$$c$$
(%o6)                         false

The energy equivalent of 1 pound-mass. The symbol %c persists until its value is fetched by constvalue.

(%i1) load ("physical_constants")$
(%i2) m * %c^2;
                                2
(%o2)                         %c  m
(%i3) %, m = 1 ` lbm;
                              2
(%o3)                       %c  ` lbm
(%i4) constvalue (%);
                                            2
                                       lbm m
(%o4)              89875517873681764 ` ------
                                          2
                                         s
(%i5) E : % `` J;
Computing conversions to base units; may take a moment. 
                     366838848464007200
(%o5)                ------------------ ` J
                             9
(%i6) E `` GJ;
                      458548560580009
(%o6)                 --------------- ` GJ
                         11250000
(%i7) float (%);
(%o7)              4.0759872051556356e+7 ` GJ

45.3 Functions and Variables for ezunits

Operator: `

The dimensional quantity operator. An expression a ` b represents a dimensional quantity, with a indicating a nondimensional quantity and b indicating the dimensional units. A symbol can be used as a unit without declaring it as such; unit symbols need not have any special properties. The quantity and unit of an expression a ` b can be extracted by the qty and units functions, respectively.

Arithmetic operations on dimensional quantities are carried out by conventional rules for such operations.

  • (x ` a) * (y ` b) is equal to (x * y) ` (a * b).
  • (x ` a) + (y ` a) is equal to (x + y) ` a.
  • (x ` a)^y is equal to x^y ` a^y when y is nondimensional.

ezunits does not require that units in a sum have the same dimensions; such terms are not added together, and no error is reported.

load("ezunits") enables this operator.

Examples:

SI (Systeme Internationale) units.

(%i1) load ("ezunits")$
(%i2) foo : 10 ` m;
(%o2)                        10 ` m
(%i3) qty (foo);
(%o3)                          10
(%i4) units (foo);
(%o4)                           m
(%i5) dimensions (foo);
(%o5)                        length

"Customary" units.

(%i1) load ("ezunits")$
(%i2) bar : x ` acre;
(%o2)                       x ` acre
(%i3) dimensions (bar);
                                   2
(%o3)                        length
(%i4) fundamental_units (bar);
                                2
(%o4)                          m

Units ad hoc.

(%i1) load ("ezunits")$
(%i2) baz : 3 ` sheep + 8 ` goat + 1 ` horse;
(%o2)           8 ` goat + 3 ` sheep + 1 ` horse
(%i3) subst ([sheep = 3*goat, horse = 10*goat], baz);
(%o3)                       27 ` goat
(%i4) baz2 : 1000`gallon/fortnight;
                                gallon
(%o4)                   1000 ` ---------
                               fortnight
(%i5) subst (fortnight = 14*day, baz2);
                          500   gallon
(%o5)                     --- ` ------
                           7     day

Arithmetic operations on dimensional quantities.

(%i1) load ("ezunits")$
(%i2) 100 ` kg + 200 ` kg;
(%o2)                       300 ` kg
(%i3) 100 ` m^3 - 100 ` m^3;
                                  3
(%o3)                        0 ` m
(%i4) (10 ` kg) * (17 ` m/s^2);
                                 kg m
(%o4)                      170 ` ----
                                   2
                                  s
(%i5) (x ` m) / (y ` s);
                              x   m
(%o5)                         - ` -
                              y   s
(%i6) (a ` m)^2;
                              2    2
(%o6)                        a  ` m
Operator: ``

The unit conversion operator. An expression a ` b `` c converts from unit b to unit c. ezunits has built-in conversions for SI base units, SI derived units, and some non-SI units. Unit conversions not already known to ezunits can be declared. The unit conversions known to ezunits are specified by the global variable known_unit_conversions, which comprises built-in and user-defined conversions. Conversions for products, quotients, and powers of units are derived from the set of known unit conversions.

There is no preferred system for display of units; input units are not converted to other units unless conversion is explicitly indicated. ezunits does not attempt to simplify units by prefixes (milli-, centi-, deci-, etc) unless such conversion is explicitly indicated.

load("ezunits") enables this operator.

Examples:

The set of known unit conversions.

(%i1) load ("ezunits")$
(%i2) display2d : false$
(%i3) known_unit_conversions;
(%o3) {acre = 4840*yard^2,Btu = 1055*J,cfm = feet^3/minute,
       cm = m/100,day = 86400*s,feet = 381*m/1250,ft = feet,
       g = kg/1000,gallon = 757*l/200,GHz = 1000000000*Hz,
       GOhm = 1000000000*Ohm,GPa = 1000000000*Pa,
       GWb = 1000000000*Wb,Gg = 1000000*kg,Gm = 1000000000*m,
       Gmol = 1000000*mol,Gs = 1000000000*s,ha = hectare,
       hectare = 100*m^2,hour = 3600*s,Hz = 1/s,inch = feet/12,
       km = 1000*m,kmol = 1000*mol,ks = 1000*s,l = liter,
       lbf = pound_force,lbm = pound_mass,liter = m^3/1000,
       metric_ton = Mg,mg = kg/1000000,MHz = 1000000*Hz,
       microgram = kg/1000000000,micrometer = m/1000000,
       micron = micrometer,microsecond = s/1000000,
       mile = 5280*feet,minute = 60*s,mm = m/1000,
       mmol = mol/1000,month = 2629800*s,MOhm = 1000000*Ohm,
       MPa = 1000000*Pa,ms = s/1000,MWb = 1000000*Wb,
       Mg = 1000*kg,Mm = 1000000*m,Mmol = 1000000000*mol,
       Ms = 1000000*s,ns = s/1000000000,ounce = pound_mass/16,
       oz = ounce,Ohm = s*J/C^2,
       pound_force = 32*ft*pound_mass/s^2,
       pound_mass = 200*kg/441,psi = pound_force/inch^2,
       Pa = N/m^2,week = 604800*s,Wb = J/A,yard = 3*feet,
       year = 31557600*s,C = s*A,F = C^2/J,GA = 1000000000*A,
       GC = 1000000000*C,GF = 1000000000*F,GH = 1000000000*H,
       GJ = 1000000000*J,GK = 1000000000*K,GN = 1000000000*N,
       GS = 1000000000*S,GT = 1000000000*T,GV = 1000000000*V,
       GW = 1000000000*W,H = J/A^2,J = m*N,kA = 1000*A,
       kC = 1000*C,kF = 1000*F,kH = 1000*H,kHz = 1000*Hz,
       kJ = 1000*J,kK = 1000*K,kN = 1000*N,kOhm = 1000*Ohm,
       kPa = 1000*Pa,kS = 1000*S,kT = 1000*T,kV = 1000*V,
       kW = 1000*W,kWb = 1000*Wb,mA = A/1000,mC = C/1000,
       mF = F/1000,mH = H/1000,mHz = Hz/1000,mJ = J/1000,
       mK = K/1000,mN = N/1000,mOhm = Ohm/1000,mPa = Pa/1000,
       mS = S/1000,mT = T/1000,mV = V/1000,mW = W/1000,
       mWb = Wb/1000,MA = 1000000*A,MC = 1000000*C,
       MF = 1000000*F,MH = 1000000*H,MJ = 1000000*J,
       MK = 1000000*K,MN = 1000000*N,MS = 1000000*S,
       MT = 1000000*T,MV = 1000000*V,MW = 1000000*W,
       N = kg*m/s^2,R = 5*K/9,S = 1/Ohm,T = J/(m^2*A),V = J/C,
       W = J/s}

Elementary unit conversions.

(%i1) load ("ezunits")$
(%i2) 1 ` ft `` m;
Computing conversions to base units; may take a moment. 
                            381
(%o2)                       ---- ` m
                            1250
(%i3) %, numer;
(%o3)                      0.3048 ` m
(%i4) 1 ` kg `` lbm;
                            441
(%o4)                       --- ` lbm
                            200
(%i5) %, numer;
(%o5)                      2.205 ` lbm
(%i6) 1 ` W `` Btu/hour;
                           720   Btu
(%o6)                      --- ` ----
                           211   hour
(%i7) %, numer;
                                        Btu
(%o7)               3.412322274881517 ` ----
                                        hour
(%i8) 100 ` degC `` degF;
(%o8)                      212 ` degF
(%i9) -40 ` degF `` degC;
(%o9)                     (- 40) ` degC
(%i10) 1 ` acre*ft `` m^3;
                        60228605349    3
(%o10)                  ----------- ` m
                         48828125
(%i11) %, numer;
                                          3
(%o11)                1233.48183754752 ` m

Coercing quantities in feet and meters to one or the other.

(%i1) load ("ezunits")$
(%i2) 100 ` m + 100 ` ft;
(%o2)                  100 ` m + 100 ` ft
(%i3) (100 ` m + 100 ` ft) `` ft;
Computing conversions to base units; may take a moment. 
                           163100
(%o3)                      ------ ` ft
                            381
(%i4) %, numer;
(%o4)                428.0839895013123 ` ft
(%i5) (100 ` m + 100 ` ft) `` m;
                            3262
(%o5)                       ---- ` m
                             25
(%i6) %, numer;
(%o6)                      130.48 ` m

Dimensional analysis to find fundamental dimensions and fundamental units.

(%i1) load ("ezunits")$
(%i2) foo : 1 ` acre * ft;
(%o2)                      1 ` acre ft
(%i3) dimensions (foo);
                                   3
(%o3)                        length
(%i4) fundamental_units (foo);
                                3
(%o4)                          m
(%i5) foo `` m^3;
Computing conversions to base units; may take a moment. 
                        60228605349    3
(%o5)                   ----------- ` m
                         48828125
(%i6) %, numer;
                                          3
(%o6)                 1233.48183754752 ` m

Declared unit conversions.

(%i1) load ("ezunits")$
(%i2) declare_unit_conversion (MMBtu = 10^6*Btu, kW = 1000*W);
(%o2)                         done
(%i3) declare_unit_conversion (kWh = kW*hour, 
                               MWh = 1000*kWh, bell = 1800*s);
(%o3)                         done
(%i4) 1 ` kW*s `` MWh;
Computing conversions to base units; may take a moment. 
                             1
(%o4)                     ------- ` MWh
                          3600000
(%i5) 1 ` kW/m^2 `` MMBtu/bell/ft^2;
                       1306449      MMBtu
(%o5)                 ---------- ` --------
                      8242187500          2
                                   bell ft
Function: constvalue (x)
Function: declare_constvalue (a, x)

Returns the declared constant value of a symbol, or value of an expression with declared constant values substituted for symbols.

Constant values are declared by declare_constvalue. Note that constant values as recognized by constvalue are separate from values declared by numerval and recognized by constantp.

The physical_units package declares constant values for a number of physical constants.

load("ezunits") loads these functions.

Examples:

Constant value of a physical constant.

(%i1) load ("physical_constants")$
(%i2) constvalue (%G);
                                     3
                                    m
(%o2)                    6.67428 ` -----
                                       2
                                   kg s
(%i3) get ('%G, 'description);
(%o3)           Newtonian constant of gravitation

Declaring a new constant.

(%i1) load ("ezunits")$
(%i2) declare_constvalue (FOO, 100 ` lbm / acre);
                                 lbm
(%o2)                      100 ` ----
                                 acre
(%i3) FOO * (50 ` acre);
(%o3)                     50 FOO ` acre
(%i4) constvalue (%);
(%o4)                      5000 ` lbm
Function: units (x)
Function: declare_units (a, u)

Returns the units of a dimensional quantity x, or returns 1 if x is nondimensional.

x may be a literal dimensional expression a ` b, a symbol with declared units via declare_units, or an expression containing either or both of those.

declare_units declares that units(a) should return u, where u is an expression.

load("ezunits") loads these functions.

Examples:

units applied to literal dimensional expressions.

(%i1) load ("ezunits")$
(%i2) foo : 100 ` kg;
(%o2)                       100 ` kg
(%i3) bar : x ` m/s;
                                  m
(%o3)                         x ` -
                                  s
(%i4) units (foo);
(%o4)                          kg
(%i5) units (bar);
                                m
(%o5)                           -
                                s
(%i6) units (foo * bar);
                              kg m
(%o6)                         ----
                               s
(%i7) units (foo / bar);
                              kg s
(%o7)                         ----
                               m
(%i8) units (foo^2);
                                 2
(%o8)                          kg

units applied to symbols with declared units.

(%i1) load ("ezunits")$
(%i2) units (aa);
(%o2)                           1
(%i3) declare_units (aa, J);
(%o3)                           J
(%i4) units (aa);
(%o4)                           J
(%i5) units (aa^2);
                                2
(%o5)                          J
(%i6) foo : 100 ` kg;
(%o6)                       100 ` kg
(%i7) units (aa * foo);
(%o7)                         kg J
Function: qty (x)
Function: declare_qty (a, x)

qty returns the nondimensional part of a dimensional quantity x, or returns x if x is nondimensional. x may be a literal dimensional expression a ` b, a symbol with declared quantity, or an expression containing either or both of those.

declare_qty declares that qty(a) should return x, where x is a nondimensional quantity.

load("ezunits") loads these functions.

Examples:

qty applied to literal dimensional expressions.

(%i1) load ("ezunits")$
(%i2) foo : 100 ` kg;
(%o2)                       100 ` kg
(%i3) qty (foo);
(%o3)                          100
(%i4) bar : v ` m/s;
                                  m
(%o4)                         v ` -
                                  s
(%i5) foo * bar;
                                  kg m
(%o5)                     100 v ` ----
                                   s
(%i6) qty (foo * bar);
(%o6)                         100 v

qty applied to symbols with declared quantity.

(%i1) load ("ezunits")$
(%i2) declare_qty (aa, xx);
(%o2)                          xx
(%i3) qty (aa);
(%o3)                          xx
(%i4) qty (aa^2);
                                 2
(%o4)                          xx
(%i5) foo : 100 ` kg;
(%o5)                       100 ` kg
(%i6) qty (aa * foo);
(%o6)                        100 xx
Function: unitp (x)

Returns true if x is a literal dimensional expression, a symbol declared dimensional, or an expression in which the main operator is declared dimensional. unitp returns false otherwise.

load("ezunits") loads this function.

Examples:

unitp applied to a literal dimensional expression.

(%i1) load ("ezunits")$
(%i2) unitp (100 ` kg);
(%o2)                         true

unitp applied to a symbol declared dimensional.

(%i1) load ("ezunits")$
(%i2) unitp (foo);
(%o2)                         false
(%i3) declare (foo, dimensional);
(%o3)                         done
(%i4) unitp (foo);
(%o4)                         true

unitp applied to an expression in which the main operator is declared dimensional.

(%i1) load ("ezunits")$
(%i2) unitp (bar (x, y, z));
(%o2)                         false
(%i3) declare (bar, dimensional);
(%o3)                         done
(%i4) unitp (bar (x, y, z));
(%o4)                         true
Function: declare_unit_conversion (u = v, ...)

Appends equations u = v, ... to the list of unit conversions known to the unit conversion operator ``. u and v are both multiplicative terms, in which any variables are units, or both literal dimensional expressions.

At present, it is necessary to express conversions such that the left-hand side of each equation is a simple unit (not a multiplicative expression) or a literal dimensional expression with the quantity equal to 1 and the unit being a simple unit. This limitation might be relaxed in future versions.

known_unit_conversions is the list of known unit conversions.

load("ezunits") loads this function.

Examples:

Unit conversions expressed by equations of multiplicative terms.

(%i1) load ("ezunits")$
(%i2) declare_unit_conversion (nautical_mile = 1852 * m, 
                               fortnight = 14 * day);
(%o2)                         done
(%i3) 100 ` nautical_mile / fortnight `` m/s;
Computing conversions to base units; may take a moment. 
                            463    m
(%o3)                       ---- ` -
                            3024   s

Unit conversions expressed by equations of literal dimensional expressions.

(%i1) load ("ezunits")$
(%i2) declare_unit_conversion (1 ` fluid_ounce = 2 ` tablespoon);
(%o2)                         done
(%i3) declare_unit_conversion (1 ` tablespoon = 3 ` teaspoon);
(%o3)                         done
(%i4) 15 ` fluid_ounce `` teaspoon;
Computing conversions to base units; may take a moment. 
(%o4)                     90 ` teaspoon
Function: declare_dimensions (a_1, d_1, ..., a_n, d_n)
Function: remove_dimensions (a_1, ..., a_n)

declare_dimensions declares a_1, ..., a_n to have dimensions d_1, ..., d_n, respectively.

Each a_k is a symbol or a list of symbols. If it is a list, then every symbol in a_k is declared to have dimension d_k.

remove_dimensions reverts the effect of declare_dimensions.

load("ezunits") loads these functions.

Examples:

(%i1) load ("ezunits") $
(%i2) declare_dimensions ([x, y, z], length, [t, u], time);
(%o2)                         done
(%i3) dimensions (y^2/u);
                                   2
                             length
(%o3)                        -------
                              time
(%i4) fundamental_units (y^2/u);
0 errors, 0 warnings
                                2
                               m
(%o4)                          --
                               s
Function: declare_fundamental_dimensions (d_1, d_2, d_3, ...)
Function: remove_fundamental_dimensions (d_1, d_2, d_3, ...)
Global variable: fundamental_dimensions

declare_fundamental_dimensions declares fundamental dimensions. Symbols d_1, d_2, d_3, ... are appended to the list of fundamental dimensions, if they are not already on the list.

remove_fundamental_dimensions reverts the effect of declare_fundamental_dimensions.

fundamental_dimensions is the list of fundamental dimensions. By default, the list comprises several physical dimensions.

load("ezunits") loads these functions.

Examples:

(%i1) load ("ezunits") $
(%i2) fundamental_dimensions;
(%o2) [length, mass, time, current, temperature, quantity]
(%i3) declare_fundamental_dimensions (money, cattle, happiness);
(%o3)                         done
(%i4) fundamental_dimensions;
(%o4) [length, mass, time, current, temperature, quantity, 
                                        money, cattle, happiness]
(%i5) remove_fundamental_dimensions (cattle, happiness);
(%o5)                         done
(%i6) fundamental_dimensions;
(%o6) [length, mass, time, current, temperature, quantity, money]
Function: declare_fundamental_units (u_1, d_1, ..., u_n, d_n)
Function: remove_fundamental_units (u_1, ..., u_n)

declare_fundamental_units declares u_1, ..., u_n to have dimensions d_1, ..., d_n, respectively. All arguments must be symbols.

After calling declare_fundamental_units, dimensions(u_k) returns d_k for each argument u_1, ..., u_n, and fundamental_units(d_k) returns u_k for each argument d_1, ..., d_n.

remove_fundamental_units reverts the effect of declare_fundamental_units.

load("ezunits") loads these functions.

Examples:

(%i1) load ("ezunits") $
(%i2) declare_fundamental_dimensions (money, cattle, happiness);
(%o2)                         done
(%i3) declare_fundamental_units (dollar, money, goat, 
                                 cattle, smile, happiness);
(%o3)                 [dollar, goat, smile]
(%i4) dimensions (100 ` dollar/goat/km^2);
                             money
(%o4)                    --------------
                                      2
                         cattle length
(%i5) dimensions (x ` smile/kg);
                            happiness
(%o5)                       ---------
                              mass
(%i6) fundamental_units (money*cattle/happiness);
0 errors, 0 warnings
                           dollar goat
(%o6)                      -----------
                              smile
Function: dimensions (x)
Function: dimensions_as_list (x)

dimensions returns the dimensions of the dimensional quantity x as an expression comprising products and powers of base dimensions.

dimensions_as_list returns the dimensions of the dimensional quantity x as a list, in which each element is an integer which indicates the power of the corresponding base dimension in the dimensions of x.

load("ezunits") loads these functions.

Examples:

(%i1) load ("ezunits")$
(%i2) dimensions (1000 ` kg*m^2/s^3);
                                2
                          length  mass
(%o2)                     ------------
                                 3
                             time
(%i3) declare_units (foo, acre*ft/hour);
                             acre ft
(%o3)                        -------
                              hour
(%i4) dimensions (foo);
                                   3
                             length
(%o4)                        -------
                              time
(%i1) load ("ezunits")$
(%i2) fundamental_dimensions;
(%o2)  [length, mass, time, charge, temperature, quantity]
(%i3) dimensions_as_list (1000 ` kg*m^2/s^3);
(%o3)                 [2, 1, - 3, 0, 0, 0]
(%i4) declare_units (foo, acre*ft/hour);
                             acre ft
(%o4)                        -------
                              hour
(%i5) dimensions_as_list (foo);
(%o5)                 [3, 0, - 1, 0, 0, 0]
Function: fundamental_units (x)
Function: fundamental_units ()

fundamental_units(x) returns the units associated with the fundamental dimensions of x. as determined by dimensions(x).

x may be a literal dimensional expression a ` b, a symbol with declared units via declare_units, or an expression containing either or both of those.

fundamental_units() returns the list of all known fundamental units, as declared by declare_fundamental_units.

load("ezunits") loads this function.

Examples:

(%i1) load ("ezunits")$
(%i2) fundamental_units ();
(%o2)                 [m, kg, s, A, K, mol]
(%i3) fundamental_units (100 ` mile/hour);
                                m
(%o3)                           -
                                s
(%i4) declare_units (aa, g/foot^2);
                                g
(%o4)                         -----
                                  2
                              foot
(%i5) fundamental_units (aa);
                               kg
(%o5)                          --
                                2
                               m
Function: dimensionless (L)

Returns a basis for the dimensionless quantities which can be formed from a list L of dimensional quantities.

load("ezunits") loads this function.

Examples:

(%i1) load ("ezunits") $
(%i2) dimensionless ([x ` m, y ` m/s, z ` s]);
0 errors, 0 warnings
0 errors, 0 warnings
                               y z
(%o2)                         [---]
                                x

Dimensionless quantities derived from fundamental physical quantities. Note that the first element on the list is proportional to the fine-structure constant.

(%i1) load ("ezunits") $
(%i2) load ("physical_constants") $
(%i3) dimensionless([%h_bar, %m_e, %m_P, %%e, %c, %e_0]);
0 errors, 0 warnings
0 errors, 0 warnings
                              2
                           %%e        %m_e
(%o3)                [--------------, ----]
                      %c %e_0 %h_bar  %m_P
Function: natural_unit (expr, [v_1, ..., v_n])

Finds exponents e_1, ..., e_n such that dimension(expr) = dimension(v_1^e_1 ... v_n^e_n).

load("ezunits") loads this function.

Examples:


Nächste: , Vorige:   [Inhalt][Index]