(*********************************************************************** This file was generated automatically by the Mathematica front end. It contains Initialization cells from a Notebook file, which typically will have the same name as this file except ending in ".nb" instead of ".m". This file is intended to be loaded into the Mathematica kernel using the package loading commands Get or Needs. Doing so is equivalent to using the Evaluate Initialiation Cells menu command in the front end. DO NOT EDIT THIS FILE. This entire file is regenerated automatically each time the parent Notebook file is saved in the Mathematica front end. Any changes you make to this file will be overwritten. ***********************************************************************) (* :Title: V3ReducedUnits *) (* :Context: Miscellaneous`V3ReducedUnits` *) (* :Author: David J. M. Park Jr. djmp@earthlink.net *) (* :Summary: This is an auxiliary package to Miscellaneous`ExtendUnits`. It provides for unit conversions when certain physical constants are unitized. *) (* :Copyright: \[Copyright] 1999 by David J. M. Park Jr. *) (* :Package Version: 1.0 *) (* :Mathematica Version: 3.0 *) (* :Keywords: Units *) (* :Requirements: Miscellaneous`V3ExtendUnits` *) BeginPackage["Miscellaneous`V3ReducedUnits`",{"Miscellaneous`V3ExtendUnits`"}] Miscellaneous`V3ReducedUnits::usage= "This is an auxiliary package to Miscellaneous`ExtendUnits` which provides \ for unit conversions when certain physical constants are unitized." ReducedEquivalent::nosol= "There is not a proper solution to the conversion equations."; ReducedEquivalent::usage= "ReducedEquivalent[expr, oldunit, newunit] will attempt to convert oldunit \ in expr to the newunit by multiplying by the right combination of the unit \ quantities in the reduced unit system. If there are no retained units, use 1. \ For this particular function only, ReducedEquivalent[a, 1, b] = a/b if a and \ b are both numbers. SetupReducedUnits must have been previously evaluated."; ReducedUnitRules::usage= "ReducedUnitRules is the generated list of rules which transform the base \ SI units under the reduced unit system."; ReducedUnits::usage= "ReducedUnits[expr] will convert the units in expr to the retained base SI \ units. SetupReducedUnits must have previously been evaluated to establish the \ transformation rules."; SetupReducedUnits::nosol= "The equations for SetUpUnits do not have a proper solution."; SetupReducedUnits::usage= "SetupReducedUnits[unitquantities, retainedunits] establishes a set of \ rules which will convert nonretained base SI quantities to retained base SI \ quantities. The rules are calculated by solving the equations which result \ from setting each of the unitquantities to 1. The retained units must be \ picked from the list {Meter, Kilogram, Second, Ampere, Kelvin}. The number of \ unitquantities plus the number of retainedunits should sum to 5."; Begin["`Private`"] baseunits={Miscellaneous`SIUnits`Meter,Miscellaneous`SIUnits`Kilogram, System`Second,Miscellaneous`SIUnits`Ampere,Miscellaneous`SIUnits`Kelvin}; numunits=0; ReducedUnitRules={}; ReducedEquivalent[a_?NumberQ,1,b_?NumberQ]:=a/b \!\(ReducedEquivalent[expr_, oldunit_, newunit_] := \n\t Module[{eqns, e1, k, baseratio, sol, dsol, d}, \n\t\t baseratio = BaseSI[newunit/oldunit]; \n\t\t e1 = Sum[k[i] Log[pc[i]] // PowerExpand, {i, 1, numunits}] - Log[baseratio] // PowerExpand; \n\t\t eqns = \(\((Coefficient[e1, Log[#]] == 0)\)&\)/@baseunits; \n\t\t sol = Solve[eqns]; \n\t\t If[Length[sol] \[NotEqual] 1 \[Or] Length[sol\[LeftDoubleBracket]1\[RightDoubleBracket]] \[NotEqual] numunits, Message[ReducedEquivalent::nosol]; Return[$Failed]]; \n \t\teqns = Product[pc[i]\^k[i], {i, 1, numunits}] == d\ baseratio /. sol\[LeftDoubleBracket]1\[RightDoubleBracket]; \n\t\t dsol = \(Solve[eqns, d]\)\[LeftDoubleBracket]1, 1 \[RightDoubleBracket] // PowerExpand; \n\t\t If[oldunit === 1, \n\t\t\t \(expr /. a_?NumberQ \[Rule] a\ \ d\ newunit\) /. dsol, \n\t\t\t \(expr /. oldunit \[Rule] d\ \ newunit\) /. dsol]\n\t\t]\) ReducedUnits[expr_]:=BaseSI[expr]/.ReducedUnitRules SetupReducedUnits[unitquantities_List,retainedunits_List]:= Module[{eqns,solvedunits,sols}, numunits=Length[unitquantities]; Clear[pc]; Do[pc[i]=PowerExpand[ BaseSI[unitquantities\[LeftDoubleBracket]i\[RightDoubleBracket]]],{ i,1,numunits}]; solvedunits=Complement[baseunits, retainedunits ]; eqns=(PowerExpand[BaseSI[#]]==1)&/@unitquantities; sols=Solve[eqns,solvedunits]; If[Length[sols]\[NotEqual]1 \[Or]Length[sols\[LeftDoubleBracket]1\[RightDoubleBracket]] \[NotEqual]numunits,Message[SetupReducedUnits::nosol]; Return[$Failed]]; ReducedUnitRules=sols\[LeftDoubleBracket]1\[RightDoubleBracket] ] End[] Protect[ReducedEquivalent,ReducedUnits,SetupReducedUnits] EndPackage[]