ianhinder / Kranc

A Mathematica package for generating code for solving time dependent partial differential equations
http://kranccode.org
GNU General Public License v2.0
28 stars 10 forks source link

Support Mathematica 9 #92

Closed eschnett closed 11 years ago

barrywardell commented 11 years ago

The only problems appear to be from symbol clashes with TensorTools. In particular, the Symmetrize and TensorProduct symbols have been added to Mathematica 9. Simply renaming these as is done in the attached patch is sufficient to make Kranc work (in the sense that it successfully generates McLachlan, EinsetinExact and WeylScal4) with Mathematica 9.

I don't necessarily think this is the correct long-term (or possibly even short-term) solution. It would break any code which uses the Symmetrize or TensorProduct functions and it introduces ugly symbol names. One possibly better solution would be to adapt to using the new tensor support in version 9 if it is sufficient for Kranc's needs.

eschnett commented 11 years ago

I tried unprotecting these symbols, but this didn't work. For some reason, they automatically get protected again.

barrywardell commented 11 years ago

This is because they are AutoLoad symbols. A workaround is to use the symbol before unprotecting it, ie.

Symmetrize; Unprotect[Symmetrize];

do some stuff

Protect[Symmetrize];

Is it safe to override the definitions of Symmetrize and TensorProduct?

eschnett commented 11 years ago

If one doesn't use the packages where they are originally defined, then first undefining them (Symmetrize=.) and then redefining them should work, shouldn't it?

barrywardell commented 11 years ago

Unset (=.) is not sufficient. You would probably need something like:

Unprotect[Symmetrize];
Remove[Symmetrize];
Unprotect[TensorProduct];
Remove[TensorProduct];

This might work as a short-term solution, but I would imagine it's discouraged in the longer term.

ianhinder commented 11 years ago

The new tensor support in v9 is not sufficient; it does not do index calculations. If we are clashing with Mathematica's built-in symbols, we need to rename our symbols.