Reruning a mathematica notebook

Skip to first unread message

Mikolaj Myszkowski

Feb 28, 2023, 5:44:39 PM2/28/23
to xAct Tensor Computer Algebra
Hi Everyone!

I have been learning XAct (XCoba in particular) recently and noticed that for many if not all of my scripts, rerunning them causes some issues. Usually, the errors don't stop the program from running properly, and indicate "Symbol ... is already used as a manifold" or ""Uncaught Throw[Null] returned to top level" (Examplary notebook is attached below).

Similarly, having more than one notebook opened at once causes some kind of interference between the notebooks when run (Especially if I use the same symbols in both notebooks). This seems to be quite a serious issue, as many programs crash/run forever even though they work just fine when run separately. I figure it has to do with how the global variables are stored during each session, but I was wondering whether there is an easy fix that would allow me to rerun my notebooks/work with multiple notebooks open at once?

Thank you for your help!
Evaluating Tensors with XCoba.nb


Feb 28, 2023, 8:16:38 PM2/28/23
to xAct Tensor Computer Algebra

This behavior is expected in all of xAct. Every symbol used must be defined with a unique type,  as a tensor, as an index, etc. A symbol cannot be defined twice, so there will be error messages if you evaluate DefTensor[T[a, b], M] twice, for example. I guess we could check whether we are trying to define an object exactly as it is defined already, and then not complain, but this seems difficult in general.

If this is important for your workflow, perhaps you can explore the WL function Once. I wrapped Once around the initial <<xAct`xCoba` and around the two Def commands and SetCMetric. Then I can rerun your example notebook multiple times without errors.

I don't understand what you mean by an interference between difference notebooks. Of course, if you evaluate two separate collections of DefTensor commands with the same symbols in the same session, you are going to get into trouble. I don't see any alternative. This is like assigning different values to the same variable from different functions that run simultaneously. Perhaps I'm misunderstanding the scenario you have in mind. But anyway, xAct is certainly not designed to be used in this way.


Reply all
Reply to author
0 new messages