GRTensor: Metrics and Mac OS X

GRTensor is a very handy Maple package for doing calculations in General Relativity. Given a specific metric, it’s great at calculating the components of tensors. You can define your own tensors or use the predefined ones. You can even define your own metrics.

Unfortunately, getting it working on Mac OS X is a bit of a pain. This is due to a bug in GRTensor that has gone unfixed for quite a while. Fortunately, there is a straightforwarde solution.

The bug is triggered whenever you try to load a metric, which is usually the first thing you would do in a GRTensor session. When you do so, you are presented with the following error:

> qload(schw2);
Warning: grOptionMetricPath has not been assigned.
Error, (in qload) Could not find metric schw2

This error is telling us that GRTensor isn’t able to find the schw metric, even though we know it is present in the metrics directory. The problem seems to arise from the way GRTensor deals with path separators on the Mac. Historically, Mac OS used the colon as a path separator but, since OSX, it uses the more unix-like slash. GRTensor appears to be trying to use the old, pre-OSX colon system, so it mistakenly searches for metrics:schw, which it obviously can’t find.

The solution is fairly straightforward – since GRTensor is looking for the file metrics:schw.mpl, all we need to do is make sure our file is named as such and GRTensor will be able to find it (Note that the file must also reside in the directory GRTensor is installed in, not the metrics subdirectory). This rule is also valid for any other metric files you create – their names must all be prefixed with metrics:. Unfortunately, OSX is a bit awkward about naming things with colons in them, so it’s usually easiest to rename the files using the command line.

Now, quite a few metrics come bundled with GRTensor, so renaming them all manually is quite time consuming. It’s easiest to use a simple bash script such as this one to do it automatically. Just download this script and place it in the directory where GRTensor is installed (probably /usr/local/grii/). Make sure it’s executable and run it. On the command line, you could do so using the commands (assuming you downloaded the file to your desktop and GRTensor is in the default install location of /usr/local/grii/):

$ sudo cp ~/Desktop/fixmetrics.sh /usr/local/grii/
$ cd /usr/local/grii/
$ chmod +x fixmetrics.sh
$ ./fixmetrics.sh

You should now be able to load all your metrics in GRTensor without any problems:

> qload(schw2);
Calculated ds for schw (0.000000 sec.)
                         Default spacetime = schw
                         For the schw spacetime:
                               Coordinates
                                  x(up)
                           a
                         x   = [r, theta, phi, t]
                               Line element
          2
  2    d r       2         2     2           2       2    /     2 m\     2
ds  = ------- + r   d theta   + r  sin(theta)   d phi   + |-1 + ---|  d t
          2 m                                             \      r /
      1 - ---
           r
            The Schwarzschild metric in curvature coordinates

22 thoughts on “GRTensor: Metrics and Mac OS X”

  1. Thanks for your useful hints. The first one about installing GRTensorII worked in my Mac but I have the following error after running the third line of your commands in this page for initializing the metric sources, i.e. chmod +x fixmetrics.sh.
    error:
    chmod: Unable to change file mode on fixmetrics.sh: Operation not permitted

    Any comment or suggestion is more than welcome.
    S.

    1. You may have already discovered the answer, but in this case, you probably also need to use sudo for the third and fourth commands, e.g.


      $ sudo chmod +x fixmetrics.sh
      $ sudo ./fixmetrics.sh

      1. Hi!! when I write $ ./fixmetrics.sh It says:
        EL.mpl -> ../metrics:EL.mpl
        cp: ../metrics:EL.mpl: Permission denied

        and more and more permissions denied!!

        What can I do???

  2. Just what I needed, thanks very much!

    NB: I’m using version 1.79 of GRTensor2 and Maple 15, and the bug is still there.

    Now if only I had found this page earlier…

  3. Hi Barry,

    That’s a nice comment, but I’ve run into a different problem and I was wondering if you had any suggestions. I’ve recently installed OS Lion, and of course, I had to install Maple 15, as Maple 12 (the version I used to be running) is not supported in Lion anymore (PowerPC support is gone!). In any case, grtensor doesn’t seem to be working anymore on Maple 15. I had been using Maple 12 + grtensor for the longest time (with the : trick that you mentioned above), but this is not the problem now.

    The first problem seems to be that when I load grtensor, it doesn’t seem to load properly. I type: grtw(); and the output is not centered on the screen as it used to be. The real problem, however, is when I try to load a metric qload(metric); and I get the error message:

    Error, (in grF_core) unrecognized conversion

    Has anybody run into this ? Thanks for your help.

    1. For reference, Nico worked around this problem as follows:

      So we’ve figured out a temporary solution to this problem.
      Install a virtual machine on your Mac OS. VirtualBox is free.
      Install ubuntu or some other linux distro on the virtual machine.
      Install maple 12 or lower in the virtual machine, activate it and
      re-install grtensor. After that, you can use maple 12 and grtensor
      just like before but on the virtual machine. It’s a bit annoying to
      have to do it this way, but it works. Perhaps this will help other
      people in the future that make the same mistake of updating their
      Mac OS, like me!

    1. I’m not sure why this would happen. I’ve just followed the instructions myself with Lion and the ~/.mapleinit file seems to be created OK. I have heard that there are problems getting GRTensor working with Lion (see the above post from Nico), but have not tried using it myself as I don’t have a Maple license any more.

      1. I have now tried GRTensorII with Mountain Lion and Maple 15 and everything seems to work perfectly. I never got around to trying it with Lion, so I’m not sure if there’s still a problem or not.

  4. I’m completely new to both Maple and GRTensor. This article, as well as your article on installing GRTensor on OS X, have been immensely helpful in making my day about getting research done rather than fighting with Maple. So thanks!!

  5. Hi barry,
    i am using maple 13 on window 8 64 bit system of 4Gb RAM.
    i am having problem with working grtensor in maple 13.
    for e.g.
    >grtw();
    >qload(schw);
    >qload(npschw);
    >grcalc(WeylSc)
    it shows
    Warning: grOptionMetricPath has not been assigned.
    Error, (in grload) unable to read `grOptionMetricPath/npschw.mpl`

    i am not getting how to resolve this. please help me to resolve this problem.
    regards
    suresh

    1. I have not tried recently, and have not tried at all with Windows, but the error suggests that the metrics directory cannot be found. I suggest you look in maple.ini (it is installed in the locations listed here) and check that the appropriate paths as described in the Readme file are correctly set there.

      1. Thanks for your reply. i have figure it out by adding the command
        > grlib(basislib);

        now its working for the metrics already given in the grtensor package. However, when i am trying to find the same for my concern metric,
        first of all, its not giving me the nulltetrad for concern metric, even if i run the program for 4-5 hours. then i manually calculated the nulltetrad. however, now when i am using these tetrad and try to find the WeylScalar
        >grcalc(WeylSc);
        >grdisplay(WeylSc);
        its giving,

        Weyl Scalar, NP Psi0
        Psi0 = 0
        Weyl Scalar, NP Psi1
        Psi1 = 9231 words. Exceeds grOptionDisplayLimit
        Weyl Scalar, NP Psi2
        Psi2 = 108069 words. Exceeds grOptionDisplayLimit
        Weyl Scalar, NP Psi3
        Psi3 = 22083 words. Exceeds grOptionDisplayLimit
        Weyl Scalar, NP Psi4
        Psi4 = 16940 words. Exceeds grOptionDisplayLimit
        could you please give some hint, how to resolve this.
        Regards,
        Suresh

  6. Hi Barry,

    When I’m trying to save a new metric I’m getting the error:

    Error, cannot open file “/Library/Frameworks/Maple.framework/Versions/2015/bin.APPLE_UNIVERSAL_OSX/:usr:local:grii:metrics:MyersPerry5D.mpl” to write to

    I’ve fixed the problem where i cannot read the pre-existing metrics in but I cannot save a new metric.

    1. I’m not sure if saving a metric works from inside Maple. You are better off directly editing the file in a text editor.

Leave a Reply

Your email address will not be published. Required fields are marked *