Re: Units, simplification
- To: mathgroup at smc.vnet.net
- Subject: [mg59818] Re: Units, simplification
- From: "John Jowett" <John.Jowett at cern.ch>
- Date: Tue, 23 Aug 2005 04:51:13 -0400 (EDT)
- Organization: CERN - European Laboratory for Particle Physics
- References: <ddh9a8$cde$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Yes, I should probably mention that the ToFundamentalSI function in our Accelerator`ConstantsUnits` package was also inspired by inspecting the standard package and finding the $ToFundamental rules. Rather than modifying the standard package, we made a new package since we added a lot of other things too. However in the context of this discussion, it's worth mentioning that you can easily make your own version of a standard package that will still be there when you upgrade to the next version of Mathematica. I do this, e.g., for Graphics`Colors` to avoid clashes with the ChemicalElements package and define all colours as instances of RGBColor. To do this, just create a directory Graphics in one of the directories that comes earlier in $Path than the standard packages and put the modified package file (Colors.m in this case) there. A sensible choice is ToFileName[{$BaseDirectory, "Applications"}] or, perhaps, ToFileName[{$UserBaseDirectory, "Applications"}] Then this version will override the standard version and there is no need to touch anything inside the installation directories. John Jowett "Bill Rowe" <readnewsciv at earthlink.net> wrote in message news:ddh9a8$cde$1 at smc.vnet.net... > On 8/11/05 at 4:54 AM, not_valid at w.pl (KaeL) wrote: > >>I admit I am not too experienced mit M. (v. 5.1). My problems >>regards simplification of unit equations. Consider such a simple >>entry: > >>Simplify[Ampere Meter Meter/Joule Tesla] > >>Explanation for non-physicist: this is equal to 1 Usage of >>"<<Miscellaneous`Units`" does not help here, as this package is >>rather _conversion_ (SI into cgs, .i.e Tesla into Gauss) oriented. >>Running "<<Miscellaneous`PhysicalConstants`" does not help either, >>as this package rather _introduces/defines_ the units. And you >>would need here sort of relation between units-am I right? > >>Any idea how to solve my problem? > > Yes. The way I have solved this issue for myself is to edit the Units.m > package by adding the following two lines: > > FundamentalSI::usage = "FundamentalSI[expr] converts expr to fundamental > SI units (International System)." > > and > > FundamentalSI[expr_]:=SI[expr]//.$ToFundamental > > These two lines define a new function that does what you want. The first > line should be added to the section of the file that defines usage > messages. I've put it just ahead of the usage message for SI. > > The second line defines the function and needs to go somewhere in the > Private context. Like the other line, I added it just ahead of the > definintion for SI[expr_] > > Once these two lines are added the following works > > In[1]:= > << "Miscellaneous`Units`"; > FundamentalSI[Ampere Meter Meter/Joule Tesla] > > Out[2]= > 1 > > Note if you always want these set of fundamental units simply adding > //.$Fundamental on the end of the definition for SI[expr_] will make SI > behave in this manner. > > There are a couple of consequences of solving the issue in this manner. > > I have modified one of the standard distribution packages. So, every > upgrade to Mathematica will overwrite these changes and you will lose this > behaviour until you edit the new Units.m file. > > Since I have not modified the stub that gets called when doing > <<Miscellaneous` this new function will not be loaded. That is, to get > this new functionality as I have modified things you must explictly load > the Miscellaneous`Units` package using Needs, Get or <<. > > Of course this last issue would disapper if you also edit the stub or > modify the definition for SI[expr_] > > There is undoubtedly a way to do this without modifying the Units.m > package. But since this functionality already exists in the package this > seemed the most elegant solution to me. > -- > To reply via email subtract one hundred and four >