[Users] debugging kranc .m

Ian Hinder ian.hinder at aei.mpg.de
Tue Aug 18 05:15:38 CDT 2015


On 17 Aug 2015, at 22:23, Eloisa Bentivegna <eloisa.bentivegna at ct.infn.it> wrote:

> On 17/08/15 21:09, Comer Duncan wrote:
>> Hi,
>> 
>> I am trying to make a Kranc file to build a thorn to make a Brill wave
>> using CT_Cosmology.  I am bogged down with errors in the script and
>> would appreciate some help in getting the thing to work.  I am attaching
>> the script and the output err file.  Basically what I am trying to do is
>> to build a single kranc file to handle the specification of the initial
>> metric and extrinsic curvature and have the Hamiltonian constraint
>> solved using the CT_Cosmology thorn CT_Multilevel.  I have been trying
>> to copy existing thorns but have not been able to iron out the problems.  
> 
> Hi Comer!
> 
> I notice that you use an underscore in one of your calculation names.
> This will almost certainly interfere with the way Mathematica uses
> underscores and should be avoided. You can, for instance, simply call
> the calculation "BrillAnalyticCalc".


Yes, that seems to be the problem.  When you define a calculation, you usually assign it to a Mathematica variable so that it can be referred to later in the arguments to CreateThornTT.  In Comer's example, this Mathematica variable has an underscore, i.e.

CT_BrillAnalyticCalc  =
{
  Name -> ThornName ,
...
}

where ThornName has been previously defined.  This is "bad" because the underscore is used by Mathematica to indicate patterns, so CT_BrillAnalyticCalc is interpreted as Pattern[CT,Blank[BrillAnalyticCalc]].  i.e.

In[560]:= FullForm[CT_BrillAnalyticCalc]
Out[560]//FullForm= Pattern[CT,Blank[BrillAnalyticCalc]]

By using an underscore on the left hand side of an assignment, you are actually telling Mathematica to create a rule for replacing expressions with head BrillAnalyticCalc.  I don't think there's any way that Kranc can detect this sort of error, as it might be something you are legitimately using in the Kranc script (which is just a Mathematica program calling CreateThorn from Kranc, which could be thought of as a library).  Probably the error message could be more explicit if the value passed is a pattern, and warn the user not to use underscores in variable names.  I have created an issue (https://github.com/ianhinder/Kranc/issues/130) for this.  This was part of the motivation for the "script language" (pre-production, do not use yet!) where we define an entirely new syntax, which is very restrictive.  i.e. it can only express Kranc calculations; you cannot write generic programs which produce your thorn. Ideally, users could start with this, which would have much more stringent error checking available, and only if they wanted to apply more "programmatic" code generation, would they use Kranc from the Mathematica API.

-- 
Ian Hinder
http://members.aei.mpg.de/ianhin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.einsteintoolkit.org/pipermail/users/attachments/20150818/a9f946d0/attachment.html 


More information about the Users mailing list