parsing sensitivity output

Discussion on the serpentTools python package

Moderator: drewejohnson

Post Reply
nico
Posts: 21
Joined: Wed Feb 28, 2018 1:57 pm
Security question 1: No
Security question 2: 93

parsing sensitivity output

Post by nico » Thu Nov 28, 2019 3:34 pm

Dear Andrew,
I am trying to use serpentTools to post-process the output of a sensitivity calculation.
Your code is really awesome!
I have a couple of questions.
1) Why does the code only print the results of the second last generation? Assuming 10 generations, if I type in the notebook the command

Code: Select all

print(sens.sensitivities['keff'][0,0,0,:,:])
the data ADJ_PERT_KEFF_SENS_9_GEN are printed in output, but I would expect the ones stored in ADJ_PERT_KEFF_SENS, which should contain the results related to the "real" last generation.

2) Is it possible to access also to the data of previous latent generations? This would be nice to check the convergence on the latent generations employed in the calculation...

Thank you so much for your great work and for your attention

Nicolo'

drewejohnson
Posts: 57
Joined: Thu Oct 20, 2016 4:25 pm
Security question 1: No
Security question 2: 84

Re: parsing sensitivity output

Post by drewejohnson » Fri Nov 29, 2019 6:21 pm

Hi Nicolo,

Thank you for those nice words!

As for the sensitivity calculations, I think the output format have changed slightly from when it was first implemented. Can you provide the following information:
  1. Serpent version
  2. serpentTools version ( from serpentTools.__version__)
  3. The output of the following command

    Code: Select all

    grep -n ADJ_PERT_KEFF_SENS <file_sens0.m>
    
For your second point, are you interested in storing data from ADJ_PERT_KEFF_SENS_1_GEN, ... ADJ_PERT_KEFF_SENS_N_GEN, where here N is the second to last generation in the simulation?

Regards,

Andrew

nico
Posts: 21
Joined: Wed Feb 28, 2018 1:57 pm
Security question 1: No
Security question 2: 93

Re: parsing sensitivity output

Post by nico » Sat Nov 30, 2019 12:02 pm

Hi Andrew,

the Serpent version is the last one, the 2.1.31, while the serpentTools version is the 0.9.0!
The output of grep is the following,

Code: Select all

59:ADJ_PERT_KEFF_SENS = [
63:ADJ_PERT_KEFF_SENS = reshape(ADJ_PERT_KEFF_SENS, [2, SENS_N_ENE, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
64:ADJ_PERT_KEFF_SENS = permute(ADJ_PERT_KEFF_SENS, [5, 4, 3, 2, 1]);
66:ADJ_PERT_KEFF_SENS_E_INT = [
70:ADJ_PERT_KEFF_SENS_E_INT = reshape(ADJ_PERT_KEFF_SENS_E_INT, [2, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
71:ADJ_PERT_KEFF_SENS_E_INT = permute(ADJ_PERT_KEFF_SENS_E_INT, [4, 3, 2, 1]);
282:ADJ_PERT_KEFF_SENS_0_GEN = [
286:ADJ_PERT_KEFF_SENS_0_GEN = reshape(ADJ_PERT_KEFF_SENS_0_GEN, [2, SENS_N_ENE, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
287:ADJ_PERT_KEFF_SENS_0_GEN = permute(ADJ_PERT_KEFF_SENS_0_GEN, [5, 4, 3, 2, 1]);
289:ADJ_PERT_KEFF_SENS_0_GEN_E_INT = [
293:ADJ_PERT_KEFF_SENS_0_GEN_E_INT = reshape(ADJ_PERT_KEFF_SENS_0_GEN_E_INT, [2, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
294:ADJ_PERT_KEFF_SENS_0_GEN_E_INT = permute(ADJ_PERT_KEFF_SENS_0_GEN_E_INT, [4, 3, 2, 1]);
493:ADJ_PERT_KEFF_SENS_1_GEN = [
497:ADJ_PERT_KEFF_SENS_1_GEN = reshape(ADJ_PERT_KEFF_SENS_1_GEN, [2, SENS_N_ENE, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
498:ADJ_PERT_KEFF_SENS_1_GEN = permute(ADJ_PERT_KEFF_SENS_1_GEN, [5, 4, 3, 2, 1]);
500:ADJ_PERT_KEFF_SENS_1_GEN_E_INT = [
504:ADJ_PERT_KEFF_SENS_1_GEN_E_INT = reshape(ADJ_PERT_KEFF_SENS_1_GEN_E_INT, [2, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
505:ADJ_PERT_KEFF_SENS_1_GEN_E_INT = permute(ADJ_PERT_KEFF_SENS_1_GEN_E_INT, [4, 3, 2, 1]);
704:ADJ_PERT_KEFF_SENS_2_GEN = [
708:ADJ_PERT_KEFF_SENS_2_GEN = reshape(ADJ_PERT_KEFF_SENS_2_GEN, [2, SENS_N_ENE, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
709:ADJ_PERT_KEFF_SENS_2_GEN = permute(ADJ_PERT_KEFF_SENS_2_GEN, [5, 4, 3, 2, 1]);
711:ADJ_PERT_KEFF_SENS_2_GEN_E_INT = [
715:ADJ_PERT_KEFF_SENS_2_GEN_E_INT = reshape(ADJ_PERT_KEFF_SENS_2_GEN_E_INT, [2, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
716:ADJ_PERT_KEFF_SENS_2_GEN_E_INT = permute(ADJ_PERT_KEFF_SENS_2_GEN_E_INT, [4, 3, 2, 1]);
915:ADJ_PERT_KEFF_SENS_3_GEN = [
919:ADJ_PERT_KEFF_SENS_3_GEN = reshape(ADJ_PERT_KEFF_SENS_3_GEN, [2, SENS_N_ENE, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
920:ADJ_PERT_KEFF_SENS_3_GEN = permute(ADJ_PERT_KEFF_SENS_3_GEN, [5, 4, 3, 2, 1]);
922:ADJ_PERT_KEFF_SENS_3_GEN_E_INT = [
926:ADJ_PERT_KEFF_SENS_3_GEN_E_INT = reshape(ADJ_PERT_KEFF_SENS_3_GEN_E_INT, [2, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
927:ADJ_PERT_KEFF_SENS_3_GEN_E_INT = permute(ADJ_PERT_KEFF_SENS_3_GEN_E_INT, [4, 3, 2, 1]);
1126:ADJ_PERT_KEFF_SENS_4_GEN = [
1130:ADJ_PERT_KEFF_SENS_4_GEN = reshape(ADJ_PERT_KEFF_SENS_4_GEN, [2, SENS_N_ENE, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
1131:ADJ_PERT_KEFF_SENS_4_GEN = permute(ADJ_PERT_KEFF_SENS_4_GEN, [5, 4, 3, 2, 1]);
1133:ADJ_PERT_KEFF_SENS_4_GEN_E_INT = [
1137:ADJ_PERT_KEFF_SENS_4_GEN_E_INT = reshape(ADJ_PERT_KEFF_SENS_4_GEN_E_INT, [2, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
1138:ADJ_PERT_KEFF_SENS_4_GEN_E_INT = permute(ADJ_PERT_KEFF_SENS_4_GEN_E_INT, [4, 3, 2, 1]);
1337:ADJ_PERT_KEFF_SENS_5_GEN = [
1341:ADJ_PERT_KEFF_SENS_5_GEN = reshape(ADJ_PERT_KEFF_SENS_5_GEN, [2, SENS_N_ENE, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
1342:ADJ_PERT_KEFF_SENS_5_GEN = permute(ADJ_PERT_KEFF_SENS_5_GEN, [5, 4, 3, 2, 1]);
1344:ADJ_PERT_KEFF_SENS_5_GEN_E_INT = [
1348:ADJ_PERT_KEFF_SENS_5_GEN_E_INT = reshape(ADJ_PERT_KEFF_SENS_5_GEN_E_INT, [2, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
1349:ADJ_PERT_KEFF_SENS_5_GEN_E_INT = permute(ADJ_PERT_KEFF_SENS_5_GEN_E_INT, [4, 3, 2, 1]);
1548:ADJ_PERT_KEFF_SENS_6_GEN = [
1552:ADJ_PERT_KEFF_SENS_6_GEN = reshape(ADJ_PERT_KEFF_SENS_6_GEN, [2, SENS_N_ENE, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
1553:ADJ_PERT_KEFF_SENS_6_GEN = permute(ADJ_PERT_KEFF_SENS_6_GEN, [5, 4, 3, 2, 1]);
1555:ADJ_PERT_KEFF_SENS_6_GEN_E_INT = [
1559:ADJ_PERT_KEFF_SENS_6_GEN_E_INT = reshape(ADJ_PERT_KEFF_SENS_6_GEN_E_INT, [2, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
1560:ADJ_PERT_KEFF_SENS_6_GEN_E_INT = permute(ADJ_PERT_KEFF_SENS_6_GEN_E_INT, [4, 3, 2, 1]);
1759:ADJ_PERT_KEFF_SENS_7_GEN = [
1763:ADJ_PERT_KEFF_SENS_7_GEN = reshape(ADJ_PERT_KEFF_SENS_7_GEN, [2, SENS_N_ENE, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
1764:ADJ_PERT_KEFF_SENS_7_GEN = permute(ADJ_PERT_KEFF_SENS_7_GEN, [5, 4, 3, 2, 1]);
1766:ADJ_PERT_KEFF_SENS_7_GEN_E_INT = [
1770:ADJ_PERT_KEFF_SENS_7_GEN_E_INT = reshape(ADJ_PERT_KEFF_SENS_7_GEN_E_INT, [2, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
1771:ADJ_PERT_KEFF_SENS_7_GEN_E_INT = permute(ADJ_PERT_KEFF_SENS_7_GEN_E_INT, [4, 3, 2, 1]);
1970:ADJ_PERT_KEFF_SENS_8_GEN = [
1974:ADJ_PERT_KEFF_SENS_8_GEN = reshape(ADJ_PERT_KEFF_SENS_8_GEN, [2, SENS_N_ENE, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
1975:ADJ_PERT_KEFF_SENS_8_GEN = permute(ADJ_PERT_KEFF_SENS_8_GEN, [5, 4, 3, 2, 1]);
1977:ADJ_PERT_KEFF_SENS_8_GEN_E_INT = [
1981:ADJ_PERT_KEFF_SENS_8_GEN_E_INT = reshape(ADJ_PERT_KEFF_SENS_8_GEN_E_INT, [2, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
1982:ADJ_PERT_KEFF_SENS_8_GEN_E_INT = permute(ADJ_PERT_KEFF_SENS_8_GEN_E_INT, [4, 3, 2, 1]);
2181:ADJ_PERT_KEFF_SENS_9_GEN = [
2185:ADJ_PERT_KEFF_SENS_9_GEN = reshape(ADJ_PERT_KEFF_SENS_9_GEN, [2, SENS_N_ENE, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
2186:ADJ_PERT_KEFF_SENS_9_GEN = permute(ADJ_PERT_KEFF_SENS_9_GEN, [5, 4, 3, 2, 1]);
2188:ADJ_PERT_KEFF_SENS_9_GEN_E_INT = [
2192:ADJ_PERT_KEFF_SENS_9_GEN_E_INT = reshape(ADJ_PERT_KEFF_SENS_9_GEN_E_INT, [2, SENS_N_PERT, SENS_N_ZAI, SENS_N_MAT]);
2193:ADJ_PERT_KEFF_SENS_9_GEN_E_INT = permute(ADJ_PERT_KEFF_SENS_9_GEN_E_INT, [4, 3, 2, 1]);
Yeah, the idea would be to store the data from ADJ_PERT_KEFF_SENS_0_GEN to ADJ_PERT_KEFF_SENS_N_GEN in order to control the latent generations convergence behaviour...

Thank you so much
Nicolo'

drewejohnson
Posts: 57
Joined: Thu Oct 20, 2016 4:25 pm
Security question 1: No
Security question 2: 84

Re: parsing sensitivity output

Post by drewejohnson » Tue Dec 03, 2019 10:29 pm

Okay, I see the issue. We use a pattern to determine where the KEFF_SENS array is located in the file. It also matches the values from additional latent generations, which in turn overwrite the "actual" KEFF_SENS value. On the plus side, it could be really easy for us to store all the latent generation data by modifying the regular expression.

I will raise an issue on our GitHub and put out a fix in the coming days. As for storing the information from previous latent generations, I'm not sure how we want to store those so that might come a bit later.

For some follow up questions:
  1. Did you have to add new settings to obtain the data across the latent generations, or are they provided by default with the latest version
  2. Are similar data provided for other responses? E.g. reaction rate ratios?

drewejohnson
Posts: 57
Joined: Thu Oct 20, 2016 4:25 pm
Security question 1: No
Security question 2: 84

Re: parsing sensitivity output

Post by drewejohnson » Sun Dec 08, 2019 4:46 am

Nicolo,

I have written up a change and it is currently up for review - https://github.com/CORE-GATECH-GROUP/se ... s/pull/366

If you are able to test these changes with your current setup, please let me know here or on this issue directly. If you wish to apply this patch, follow the below instructions

Code: Select all

git clone https://github.com/CORE-GATECH-GROUP/serpent-tools.git
cd serpent-tools
git checkout -b drewejohnson-bug-sens-ngen master
git pull https://github.com/drewejohnson/serpent-tools.git bug-sens-ngen
And then install following https://serpent-tools.readthedocs.io/en ... stall.html
The first two items can be replaced if you have already cloned the repository. I expect this fix to be a part of a new release 0.9.1 soon-ish, but the storage of the _N_GEN variables will come later.

Thank you,
Drew

Post Reply