ncrystal icon indicating copy to clipboard operation
ncrystal copied to clipboard

SAB table format description

Open dddijulio opened this issue 1 year ago • 1 comments

It would be useful to have the format of the SAB tables written in the description of the ncmat files on this page: https://github.com/mctools/ncrystal/wiki/NCMAT-format#dynamic-model-scattering-kernel

dddijulio avatar Apr 09 '24 06:04 dddijulio

Thanks @dddijulio - just to clarify from your own message: " i.e. is it first all the betas for each alpha or other way around".

That looks like on oversight, I will fix this soonish (for the next release most likely).

tkittel avatar Apr 09 '24 06:04 tkittel

Proposed text ( a bit cumbersome, but mathematically clear I hope):

Of course, the number of entries in the sab field must be equal to the product of the number of entries in the alphagrid and betagrid fields. Furthermore, the ordering of the sab values must be so that if ai is the i'th alphagrid value, bj is the j'th betagrid value, and Na is the number of alphagrid values, then S(ai,bj) is given by the k'th sab value, where k=j*Na+i.

Ok @dddijulio ?

tkittel avatar Jun 18 '24 11:06 tkittel

Maybe indicating the loop in someway might help? Or showing a simple list? Did I understand it correctly?

for(int j=0; j<Nb; j++) {
    for(int i=0;i<Na, i++){
         S(ai,bj)
    }
}

S(a_1,b_0),S(a_1,b_0),S(a_2,b_0), ... ,S(a_1,b_1),S(a_1,b_1),S(a_2,b_1), ... ,S(a_1,b_2),S(a_1,b_2),S(a_2,b_2), ...   
```

dddijulio avatar Jun 18 '24 16:06 dddijulio

Yeah, so that makes sense... except that it is then tied to a specific programming language and how numbers are indexed. I am not 100% sure that your example would hold true in Fortran.

tkittel avatar Jun 18 '24 16:06 tkittel

maybe the list then? I was thinking some kind of indication of the structure of the loop, or maybe a statement saying that the order runs first over all i values for a given j ?

dddijulio avatar Jun 18 '24 18:06 dddijulio

Ok, here is another attempt, making the order more clear, but still focused on the data itself rather than a programming language (also, in my last comment I was committing the sin of using C/C++ style zero-based offsets, so I corrected that as well):

new text:

Of course, the number of entries in the sab field must be equal to the product of the number of entries in the alphagrid and betagrid fields. Furthermore, the ordering of the sab values must be so that if ai is the i'th alphagrid value, bj is the j'th betagrid value, and A is the number of alphagrid values, then S(ai,bj) is given by the k'th sab value, where k=(j-1)*A+i. Thus, if B is the number of entries in the betagrid field, the entries in the sab field are ordered as indicated here:

  sab    S(a1,b1) S(a2,b1) S(a3,b1) ... S(aA,b1)
         S(a1,b2) S(a2,b2) S(a3,b2) ... S(aA,b2)
         ...
         S(a1,bB) S(a2,bB) S(a3,bB) ... S(aA,bB)

All ok now @dddijulio ?

tkittel avatar Jun 19 '24 07:06 tkittel

@tkittel Looks good!

dddijulio avatar Jun 19 '24 07:06 dddijulio

Btw., I realise that part of why you are asking for a coding loop example is because you are not really asking for to format NCMAT data, you are asking how to use the NCrystal API to access the data after being loaded? It is two different things in principle - if we for instance would one day add the ability to load data directly from ENDF files, there would be no NCMAT data involved at all, and you would then be forced to actually go and look the (very very inlined currently) API documentation :-)

tkittel avatar Jun 19 '24 07:06 tkittel

So this is added for the next NCrystal release, but since it is merely a documentation fix I also went ahead and updated the wiki already now. Thus, I am closing this issue already.

tkittel avatar Jun 19 '24 07:06 tkittel