From ed0445555b00d2f79b522c497ff399f2af8aa05b Mon Sep 17 00:00:00 2001 From: Eitan Weinstein Date: Wed, 31 Jul 2024 12:13:32 -0500 Subject: [PATCH 1/4] First commit for NJOY file cleanup. --- src/DataLib/fendl32B_retrofit/groupr_tools.py | 20 ++++++++++++++++++- .../fendl32B_retrofit/process_fendl3.2.py | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/DataLib/fendl32B_retrofit/groupr_tools.py b/src/DataLib/fendl32B_retrofit/groupr_tools.py index 0a90c3e..9dfa535 100644 --- a/src/DataLib/fendl32B_retrofit/groupr_tools.py +++ b/src/DataLib/fendl32B_retrofit/groupr_tools.py @@ -199,4 +199,22 @@ def run_njoy(element, A, matb): subprocess.run(['cp', 'tape31', gendf_path]) ensure_gendf_markers(gendf_path, matb) - return gendf_path \ No newline at end of file + return gendf_path + +def cleanup_njoy_files(output_path = 'njoy_ouput'): + """ + Clean up repository from unnecessary intermediate files from NJOY run. + + Arguments: + output_path (str, optional): The save path for the NJOY output. + Defaults to 'njoy_output', which will save the file in the + same directory as all other saved files from the script run. + + Returns: + None + """ + + njoy_files = [f'groupr.inp', 'tape20', 'tape21', 'tape31'] + for file in njoy_files: + subprocess.run(['rm', file]) + subprocess.run(['mv', 'output', output_path]) \ No newline at end of file diff --git a/src/DataLib/fendl32B_retrofit/process_fendl3.2.py b/src/DataLib/fendl32B_retrofit/process_fendl3.2.py index 43f218b..d7b985e 100644 --- a/src/DataLib/fendl32B_retrofit/process_fendl3.2.py +++ b/src/DataLib/fendl32B_retrofit/process_fendl3.2.py @@ -17,6 +17,7 @@ def main(): njoy_input = groupr_tools.fill_input_template(material_id, MTs, 'Fe', 56, mt_dict) groupr_tools.write_njoy_input_file(njoy_input) groupr_tools.run_njoy('Fe', 56, material_id) + groupr_tools.cleanup_njoy_files() if __name__ == '__main__': main() \ No newline at end of file From d829ac3ef7b0e79ae830af0c525163a68314e8ea Mon Sep 17 00:00:00 2001 From: Eitan Weinstein Date: Wed, 31 Jul 2024 12:43:19 -0500 Subject: [PATCH 2/4] First commit for extracting pKZA values. --- .../files_for_tests/gendf_test1.gendf | 279 ++++++++++++++++++ .../fendl32B_retrofit/process_fendl3.2.py | 8 +- .../fendl32B_retrofit/tendl_preprocessing.py | 24 -- .../fendl32B_retrofit/tendl_processing.py | 52 ++++ .../fendl32B_retrofit/test_groupr_tools.py | 3 +- ...processing.py => test_tendl_processing.py} | 16 +- 6 files changed, 350 insertions(+), 32 deletions(-) create mode 100644 src/DataLib/fendl32B_retrofit/files_for_tests/gendf_test1.gendf delete mode 100644 src/DataLib/fendl32B_retrofit/tendl_preprocessing.py create mode 100644 src/DataLib/fendl32B_retrofit/tendl_processing.py rename src/DataLib/fendl32B_retrofit/{test_tendl_preprocessing.py => test_tendl_processing.py} (63%) diff --git a/src/DataLib/fendl32B_retrofit/files_for_tests/gendf_test1.gendf b/src/DataLib/fendl32B_retrofit/files_for_tests/gendf_test1.gendf new file mode 100644 index 0000000..a101245 --- /dev/null +++ b/src/DataLib/fendl32B_retrofit/files_for_tests/gendf_test1.gendf @@ -0,0 +1,279 @@ +26-Fe-56 for TENDL 2017 0 0 0 0 + 2.605600+4 5.545443+1 0 1 -1 12631 1451 1 + 2.931600+2 0.000000+0 175 0 179 02631 1451 2 + 0.000000+0 1.00000+10 1.000000-5 1.000000-1 4.139900-1 5.315800-12631 1451 3 + 6.825600-1 8.764200-1 1.125400+0 1.445000+0 1.855400+0 2.382400+02631 1451 4 + 3.059000+0 3.927900+0 5.043500+0 6.476000+0 8.315300+0 1.067700+12631 1451 5 + 1.371000+1 1.760300+1 2.260300+1 2.902300+1 3.726700+1 4.785100+12631 1451 6 + 6.144200+1 7.889300+1 1.013000+2 1.300700+2 1.670200+2 2.144500+22631 1451 7 + 2.753600+2 3.535800+2 4.540000+2 5.829500+2 7.485200+2 9.611200+22631 1451 8 + 1.234100+3 1.584600+3 2.034700+3 2.248700+3 2.485200+3 2.612600+32631 1451 9 + 2.746500+3 3.035400+3 3.354600+3 3.707400+3 4.307400+3 5.530800+32631 1451 10 + 7.101700+3 9.118800+3 1.059500+4 1.170900+4 1.503400+4 1.930500+42631 1451 11 + 2.187500+4 2.357900+4 2.417600+4 2.478800+4 2.605800+4 2.700000+42631 1451 12 + 2.850000+4 3.182800+4 3.430700+4 4.086800+4 4.630900+4 5.247500+42631 1451 13 + 5.656200+4 6.737900+4 7.200000+4 7.950000+4 8.250000+4 8.651700+42631 1451 14 + 9.803700+4 1.110900+5 1.167900+5 1.227700+5 1.290700+5 1.356900+52631 1451 15 + 1.426400+5 1.499600+5 1.576400+5 1.657300+5 1.742200+5 1.831600+52631 1451 16 + 1.925500+5 2.024200+5 2.128000+5 2.237100+5 2.351800+5 2.472400+52631 1451 17 + 2.732400+5 2.872500+5 2.945200+5 2.972000+5 2.985000+5 3.019700+52631 1451 18 + 3.337300+5 3.688300+5 3.877400+5 4.076200+5 4.504900+5 4.978700+52631 1451 19 + 5.234000+5 5.502300+5 5.784400+5 6.081000+5 6.392800+5 6.720600+52631 1451 20 + 7.065100+5 7.427400+5 7.808200+5 8.208500+5 8.629400+5 9.071800+52631 1451 21 + 9.616400+5 1.002600+6 1.108000+6 1.164800+6 1.224600+6 1.287300+62631 1451 22 + 1.353400+6 1.422700+6 1.495700+6 1.572400+6 1.653000+6 1.737700+62631 1451 23 + 1.826800+6 1.920500+6 2.019000+6 2.122500+6 2.231300+6 2.306900+62631 1451 24 + 2.345700+6 2.365300+6 2.385200+6 2.466000+6 2.592400+6 2.725300+62631 1451 25 + 2.865000+6 3.011900+6 3.166400+6 3.328700+6 3.678800+6 4.065700+62631 1451 26 + 4.493300+6 4.723700+6 4.965900+6 5.220500+6 5.488100+6 5.769500+62631 1451 27 + 6.065300+6 6.376300+6 6.592400+6 6.703200+6 7.046900+6 7.408200+62631 1451 28 + 7.788000+6 8.187300+6 8.607100+6 9.048400+6 9.512300+6 1.000000+72631 1451 29 + 1.051300+7 1.105200+7 1.161800+7 1.221400+7 1.252300+7 1.284000+72631 1451 30 + 1.349900+7 1.384000+7 1.419100+7 1.455000+7 1.491800+7 1.568300+72631 1451 31 + 1.648700+7 1.690500+7 1.733300+7 1.964000+7 0.000000+0 2631 1451 32 + 2631 0 0 0 + 2.605600+4 0.000000+0 1 1 0 1752631 3 1 1 + 2.931600+2 0.000000+0 2 1 2 12631 3 1 2 + 4.319881+4 1.459683+1 2631 3 1 3 + 2.931600+2 0.000000+0 2 1 2 22631 3 1 4 + 4.541348+3 1.324482+1 2631 3 1 5 + 2.931600+2 0.000000+0 2 1 2 32631 3 1 6 + 2.500159-1 1.267039+1 2631 3 1 7 + 2.931600+2 0.000000+0 2 1 2 42631 3 1 8 + 2.500007-1 1.259765+1 2631 3 1 9 + 2.931600+2 0.000000+0 2 1 2 52631 3 1 10 + 2.499990-1 1.253365+1 2631 3 1 11 + 2.931600+2 0.000000+0 2 1 2 62631 3 1 12 + 2.500524-1 1.247673+1 2631 3 1 13 + 2.931600+2 0.000000+0 2 1 2 72631 3 1 14 + 2.499749-1 1.242875+1 2631 3 1 15 + 2.931600+2 0.000000+0 2 1 2 82631 3 1 16 + 2.499950-1 1.238581+1 2631 3 1 17 + 2.931600+2 0.000000+0 2 1 2 92631 3 1 18 + 2.500122-1 1.235217+1 2631 3 1 19 + 2.931600+2 0.000000+0 2 1 2 102631 3 1 20 + 2.499838-1 1.230984+1 2631 3 1 21 + 2.931600+2 0.000000+0 2 1 2 112631 3 1 22 + 2.500210-1 1.227876+1 2631 3 1 23 + 2.931600+2 0.000000+0 2 1 2 122631 3 1 24 + 2.499995-1 1.225294+1 2631 3 1 25 + 2.931600+2 0.000000+0 2 1 2 132631 3 1 26 + 2.500069-1 1.221980+1 2631 3 1 27 + 2.931600+2 0.000000+0 2 1 2 142631 3 1 28 + 2.499982-1 1.219018+1 2631 3 1 29 + 2.931600+2 0.000000+0 2 1 2 152631 3 1 30 + 2.499988-1 1.217005+1 2631 3 1 31 + 2.931600+2 0.000000+0 2 1 2 162631 3 1 32 + 2.500377-1 1.214428+1 2631 3 1 33 + 2.931600+2 0.000000+0 2 1 2 172631 3 1 34 + 2.499480-1 1.211118+1 2631 3 1 35 + 2.931600+2 0.000000+0 2 1 2 182631 3 1 36 + 2.500173-1 1.207806+1 2631 3 1 37 + 2.931600+2 0.000000+0 2 1 2 192631 3 1 38 + 2.500101-1 1.205026+1 2631 3 1 39 + 2.931600+2 0.000000+0 2 1 2 202631 3 1 40 + 2.500237-1 1.201470+1 2631 3 1 41 + 2.931600+2 0.000000+0 2 1 2 212631 3 1 42 + 2.499879-1 1.196904+1 2631 3 1 43 + 2.931600+2 0.000000+0 2 1 2 222631 3 1 44 + 2.500057-1 1.191042+1 2631 3 1 45 + 2.931600+2 0.000000+0 2 1 2 232631 3 1 46 + 2.500029-1 1.184061+1 2631 3 1 47 + 2.931600+2 0.000000+0 2 1 2 242631 3 1 48 + 2.499980-1 1.176568+1 2631 3 1 49 + 2.931600+2 0.000000+0 2 1 2 252631 3 1 50 + 2.499905-1 1.167023+1 2631 3 1 51 + 2.931600+2 0.000000+0 2 1 2 262631 3 1 52 + 2.500449-1 1.154765+1 2631 3 1 53 + 2.931600+2 0.000000+0 2 1 2 272631 3 1 54 + 2.499671-1 1.139148+1 2631 3 1 55 + 2.931600+2 0.000000+0 2 1 2 282631 3 1 56 + 2.500068-1 1.121308+1 2631 3 1 57 + 2.931600+2 0.000000+0 2 1 2 292631 3 1 58 + 2.500345-1 1.099251+1 2631 3 1 59 + 2.931600+2 0.000000+0 2 1 2 302631 3 1 60 + 2.499915-1 1.072248+1 2631 3 1 61 + 2.931600+2 0.000000+0 2 1 2 312631 3 1 62 + 2.500082-1 1.040994+1 2631 3 1 63 + 2.931600+2 0.000000+0 2 1 2 322631 3 1 64 + 2.500006-1 1.004436+1 2631 3 1 65 + 2.931600+2 0.000000+0 2 1 2 332631 3 1 66 + 2.500054-1 9.625461+0 2631 3 1 67 + 2.931600+2 0.000000+0 2 1 2 342631 3 1 68 + 2.500013-1 9.946609+0 2631 3 1 69 + 2.931600+2 0.000000+0 2 1 2 352631 3 1 70 + 2.499941-1 8.652168+0 2631 3 1 71 + 2.931600+2 0.000000+0 2 1 2 362631 3 1 72 + 2.500204-1 8.110573+0 2631 3 1 73 + 2.931600+2 0.000000+0 2 1 2 372631 3 1 74 + 1.000055-1 7.722111+0 2631 3 1 75 + 2.931600+2 0.000000+0 2 1 2 382631 3 1 76 + 1.000023-1 7.495014+0 2631 3 1 77 + 2.931600+2 0.000000+0 2 1 2 392631 3 1 78 + 4.999357-2 7.325398+0 2631 3 1 79 + 2.931600+2 0.000000+0 2 1 2 402631 3 1 80 + 4.998229-2 7.209525+0 2631 3 1 81 + 2.931600+2 0.000000+0 2 1 2 412631 3 1 82 + 1.000174-1 7.037444+0 2631 3 1 83 + 2.931600+2 0.000000+0 2 1 2 422631 3 1 84 + 9.999087-2 6.808570+0 2631 3 1 85 + 2.931600+2 0.000000+0 2 1 2 432631 3 1 86 + 9.999992-2 6.582544+0 2631 3 1 87 + 2.931600+2 0.000000+0 2 1 2 442631 3 1 88 + 1.500061-1 6.297940+0 2631 3 1 89 + 2.931600+2 0.000000+0 2 1 2 452631 3 1 90 + 2.500021-1 5.847841+0 2631 3 1 91 + 2.931600+2 0.000000+0 2 1 2 462631 3 1 92 + 2.500057-1 5.287524+0 2631 3 1 93 + 2.931600+2 0.000000+0 2 1 2 472631 3 1 94 + 2.500081-1 4.722131+0 2631 3 1 95 + 2.931600+2 0.000000+0 2 1 2 482631 3 1 96 + 1.500464-1 4.252011+0 2631 3 1 97 + 2.931600+2 0.000000+0 2 1 2 492631 3 1 98 + 9.997713-2 3.939177+0 2631 3 1 99 + 2.931600+2 0.000000+0 2 1 2 502631 3 1 100 + 2.499605-1 3.443242+0 2631 3 1 101 + 2.931600+2 0.000000+0 2 1 2 512631 3 1 102 + 2.500537-1 2.530690+0 2631 3 1 103 + 2.931600+2 0.000000+0 2 1 2 522631 3 1 104 + 1.249821-1 1.469728+0 2631 3 1 105 + 2.931600+2 0.000000+0 2 1 2 532631 3 1 106 + 7.501286-2 6.284884-1 2631 3 1 107 + 2.931600+2 0.000000+0 2 1 2 542631 3 1 108 + 2.500395-2 1.364669-1 2631 3 1 109 + 2.931600+2 0.000000+0 2 1 2 552631 3 1 110 + 2.499926-2 1.757607-2 2631 3 1 111 + 2.931600+2 0.000000+0 2 1 2 562631 3 1 112 + 4.996517-2 8.876288-1 2631 3 1 113 + 2.931600+2 0.000000+0 2 1 2 572631 3 1 114 + 3.551205-2 1.030514+1 2631 3 1 115 + 2.931600+2 0.000000+0 2 1 2 582631 3 1 116 + 5.406733-2 7.096015+1 2631 3 1 117 + 2.931600+2 0.000000+0 2 1 2 592631 3 1 118 + 1.104427-1 2.715288+1 2631 3 1 119 + 2.931600+2 0.000000+0 2 1 2 602631 3 1 120 + 7.500387-2 1.062752+1 2631 3 1 121 + 2.931600+2 0.000000+0 2 1 2 612631 3 1 122 + 1.750002-1 6.978020+0 2631 3 1 123 + 2.931600+2 0.000000+0 2 1 2 622631 3 1 124 + 1.249907-1 5.325431+0 2631 3 1 125 + 2.931600+2 0.000000+0 2 1 2 632631 3 1 126 + 1.250021-1 4.747641+0 2631 3 1 127 + 2.931600+2 0.000000+0 2 1 2 642631 3 1 128 + 7.500147-2 3.796694+0 2631 3 1 129 + 2.931600+2 0.000000+0 2 1 2 652631 3 1 130 + 1.749981-1 3.246844+0 2631 3 1 131 + 2.931600+2 0.000000+0 2 1 2 662631 3 1 132 + 6.633306-2 1.600618+0 2631 3 1 133 + 2.931600+2 0.000000+0 2 1 2 672631 3 1 134 + 9.909115-2 6.441929+0 2631 3 1 135 + 2.931600+2 0.000000+0 2 1 2 682631 3 1 136 + 3.704131-2 1.392070+0 2631 3 1 137 + 2.931600+2 0.000000+0 2 1 2 692631 3 1 138 + 4.754265-2 1.545420+1 2631 3 1 139 + 2.931600+2 0.000000+0 2 1 2 702631 3 1 140 + 1.250048-1 5.462993+0 2631 3 1 141 + 2.931600+2 0.000000+0 2 1 2 712631 3 1 142 + 1.249972-1 3.435093+0 2631 3 1 143 + 2.931600+2 0.000000+0 2 1 2 722631 3 1 144 + 5.003736-2 2.587324+0 2631 3 1 145 + 2.931600+2 0.000000+0 2 1 2 732631 3 1 146 + 4.993576-2 2.129654+0 2631 3 1 147 + 2.931600+2 0.000000+0 2 1 2 742631 3 1 148 + 5.004222-2 1.752068+0 2631 3 1 149 + 2.931600+2 0.000000+0 2 1 2 752631 3 1 150 + 5.001800-2 3.831837+0 2631 3 1 151 + 2.931600+2 0.000000+0 2 1 2 762631 3 1 152 + 4.995112-2 6.977907+0 2631 3 1 153 + 2.931600+2 0.000000+0 2 1 2 772631 3 1 154 + 5.004469-2 7.014942+0 2631 3 1 155 + 2.931600+2 0.000000+0 2 1 2 782631 3 1 156 + 4.994581-2 3.626420+0 2631 3 1 157 + 2.931600+2 0.000000+0 2 1 2 792631 3 1 158 + 5.004634-2 2.266350+0 2631 3 1 159 + 2.931600+2 0.000000+0 2 1 2 802631 3 1 160 + 4.995892-2 4.528772+0 2631 3 1 161 + 2.931600+2 0.000000+0 2 1 2 812631 3 1 162 + 5.004141-2 1.902920+0 2631 3 1 163 + 2.931600+2 0.000000+0 2 1 2 822631 3 1 164 + 4.999578-2 7.002319+0 2631 3 1 165 + 2.931600+2 0.000000+0 2 1 2 832631 3 1 166 + 4.998895-2 5.645749+0 2631 3 1 167 + 2.931600+2 0.000000+0 2 1 2 842631 3 1 168 + 5.000826-2 3.256655+0 2631 3 1 169 + 2.931600+2 0.000000+0 2 1 2 852631 3 1 170 + 4.999783-2 3.512216+0 2631 3 1 171 + 2.931600+2 0.000000+0 2 1 2 862631 3 1 172 + 5.000067-2 3.673773+0 2631 3 1 173 + 2.931600+2 0.000000+0 2 1 2 872631 3 1 174 + 5.000854-2 2.631777+0 2631 3 1 175 + 2.931600+2 0.000000+0 2 1 2 882631 3 1 176 + 9.999131-2 1.937891+0 2631 3 1 177 + 2.931600+2 0.000000+0 2 1 2 892631 3 1 178 + 5.000240-2 4.989688+0 2631 3 1 179 + 2.931600+2 0.000000+0 2 1 2 902631 3 1 180 + 2.499400-2 2.862222+0 2631 3 1 181 + 2.931600+2 0.000000+0 2 1 2 912631 3 1 182 + 9.058409-3 1.703590+0 2631 3 1 183 + 2.931600+2 0.000000+0 2 1 2 922631 3 1 184 + 4.364625-3 1.458408+0 2631 3 1 185 + 2.931600+2 0.000000+0 2 1 2 932631 3 1 186 + 1.155775-2 1.433735+0 2631 3 1 187 + 2.931600+2 0.000000+0 2 1 2 942631 3 1 188 + 1.000046-1 3.134425+0 2631 3 1 189 + 2.931600+2 0.000000+0 2 1 2 952631 3 1 190 + 1.000036-1 2.868020+0 2631 3 1 191 + 2.931600+2 0.000000+0 2 1 2 962631 3 1 192 + 4.999919-2 3.272407+0 2631 3 1 193 + 2.931600+2 0.000000+0 2 1 2 972631 3 1 194 + 5.000046-2 5.767080+0 2631 3 1 195 + 2.931600+2 0.000000+0 2 1 2 982631 3 1 196 + 1.000006-1 4.744402+0 2631 3 1 197 + 2.931600+2 0.000000+0 2 1 2 992631 3 1 198 + 1.000032-1 3.391752+0 2631 3 1 199 + 2.931600+2 0.000000+0 2 1 2 1002631 3 1 200 + 5.000701-2 3.674403+0 2631 3 1 201 + 2.931600+2 0.000000+0 2 1 2 1012631 3 1 202 + 4.999039-2 2.955011+0 2631 3 1 203 + 2.931600+2 0.000000+0 2 1 2 1022631 3 1 204 + 4.999846-2 3.162487+0 2631 3 1 205 + 2.931600+2 0.000000+0 2 1 2 1032631 3 1 206 + 5.000453-2 2.133893+0 2631 3 1 207 + 2.931600+2 0.000000+0 2 1 2 1042631 3 1 208 + 5.000320-2 1.769510+0 2631 3 1 209 + 2.931600+2 0.000000+0 2 1 2 1052631 3 1 210 + 5.000508-2 2.154769+0 2631 3 1 211 + 2.931600+2 0.000000+0 2 1 2 1062631 3 1 212 + 4.998974-2 3.132541+0 2631 3 1 213 + 2.931600+2 0.000000+0 2 1 2 1072631 3 1 214 + 5.000870-2 3.658481+0 2631 3 1 215 + 2.931600+2 0.000000+0 2 1 2 1082631 3 1 216 + 4.999860-2 4.399239+0 2631 3 1 217 + 2.931600+2 0.000000+0 2 1 2 1092631 3 1 218 + 4.999574-2 4.249472+0 2631 3 1 219 + 2.931600+2 0.000000+0 2 1 2 1102631 3 1 220 + 5.000478-2 3.008509+0 2631 3 1 221 + 2.931600+2 0.000000+0 2 1 2 1112631 3 1 222 + 4.999573-2 2.841384+0 2631 3 1 223 + 2.931600+2 0.000000+0 2 1 2 1122631 3 1 224 + 5.829927-2 1.830204+0 2631 3 1 225 + 2.931600+2 0.000000+0 2 1 2 1132631 3 1 226 + 4.171175-2 3.003806+0 2631 3 1 227 + 2.931600+2 0.000000+0 2 1 2 1142631 3 1 228 + 9.995997-2 2.691565+0 2631 3 1 229 + 2.931600+2 0.000000+0 2 1 2 1152631 3 1 230 + 4.999281-2 2.471290+0 2631 3 1 231 + 2.931600+2 0.000000+0 2 1 2 1162631 3 1 232 + 5.006486-2 2.342512+0 2631 3 1 233 + 2.931600+2 0.000000+0 2 1 2 1172631 3 1 234 + 4.993274-2 3.360408+0 2631 3 1 235 + 2.931600+2 0.000000+0 2 1 2 1182631 3 1 236 + 5.007295-2 2.994287+0 2631 3 1 237 + 2.931600+2 0.000000+0 2 1 2 1192631 3 1 238 + 4.993654-2 2.616855+0 2631 3 1 239 + 2.931600+2 0.000000+0 2 1 2 1202631 3 1 240 + 5.003786-2 3.151124+0 2631 3 1 241 + 2.931600+2 0.000000+0 2 1 2 1212631 3 1 242 + 5.000881-2 3.303890+0 2631 3 1 243 + 2.931600+2 0.000000+0 2 1 2 1222631 3 1 244 + 4.998871-2 2.844546+0 2631 3 1 245 diff --git a/src/DataLib/fendl32B_retrofit/process_fendl3.2.py b/src/DataLib/fendl32B_retrofit/process_fendl3.2.py index d7b985e..bfe314b 100644 --- a/src/DataLib/fendl32B_retrofit/process_fendl3.2.py +++ b/src/DataLib/fendl32B_retrofit/process_fendl3.2.py @@ -1,6 +1,6 @@ # Import packages import reaction_data as rxd -import tendl_preprocessing as tpp +import tendl_processing as tp import groupr_tools def main(): @@ -13,11 +13,13 @@ def main(): endf_path = 'tape20' pendf_path = 'tape21' - material_id, MTs = tpp.extract_endf_specs(endf_path) + material_id, MTs = tp.extract_endf_specs(endf_path) njoy_input = groupr_tools.fill_input_template(material_id, MTs, 'Fe', 56, mt_dict) groupr_tools.write_njoy_input_file(njoy_input) - groupr_tools.run_njoy('Fe', 56, material_id) + gendf_path = groupr_tools.run_njoy('Fe', 56, material_id) groupr_tools.cleanup_njoy_files() + pKZA = tp.extract_gendf_pkza(gendf_path) + if __name__ == '__main__': main() \ No newline at end of file diff --git a/src/DataLib/fendl32B_retrofit/tendl_preprocessing.py b/src/DataLib/fendl32B_retrofit/tendl_preprocessing.py deleted file mode 100644 index 23aadfc..0000000 --- a/src/DataLib/fendl32B_retrofit/tendl_preprocessing.py +++ /dev/null @@ -1,24 +0,0 @@ -# Import packages -import ENDFtk - -def extract_endf_specs(path): - """ - Extract the material ID and MT numbers from an ENDF file. - - Arguments: - path (str): File path to the selected ENDF file. - - Returns: - matb (int): Unique material ID extracted from the file. - MTs (list): List of reaction types (MT's) present in the file. - """ - - tape = ENDFtk.tree.Tape.from_file(path) - matb = tape.material_numbers[0] - # Set MF for cross sections - xs_MF = 3 - file = tape.material(matb).file(xs_MF) - # Extract the MT numbers that are present in the file - MTs = [MT.MT for MT in file.sections.to_list()] - - return matb, MTs \ No newline at end of file diff --git a/src/DataLib/fendl32B_retrofit/tendl_processing.py b/src/DataLib/fendl32B_retrofit/tendl_processing.py new file mode 100644 index 0000000..708927a --- /dev/null +++ b/src/DataLib/fendl32B_retrofit/tendl_processing.py @@ -0,0 +1,52 @@ +# Import packages +import ENDFtk + +def extract_endf_specs(path): + """ + Extract the material ID and MT numbers from an ENDF file. + + Arguments: + path (str): File path to the selected ENDF file. + + Returns: + matb (int): Unique material ID extracted from the file. + MTs (list): List of reaction types (MT's) present in the file. + """ + + tape = ENDFtk.tree.Tape.from_file(path) + matb = tape.material_numbers[0] + # Set MF for cross sections + xs_MF = 3 + file = tape.material(matb).file(xs_MF) + # Extract the MT numbers that are present in the file + MTs = [MT.MT for MT in file.sections.to_list()] + + return matb, MTs + +def extract_gendf_pkza(gendf_path): + """ + Read in and parse the contents of a GENDF file to construct the parent + KZA. KZA values are defined as ZZAAAM, where ZZ is the isotope's + atomic number, AAA is the mass number, and M is the isomeric state + (0 if non-isomeric). + + Arguments: + gendf_path (str): File path to the GENDF file being analyzed. + M (str, optional): Identifier of isomer, signified by the letter "M" + at the end of the mass number string. + + Defaults to None and will be otherwise defined internally. + + Returns: + pKZA (int): Parent KZA identifier. + """ + + with open(gendf_path, 'r') as f: + first_line = f.readline() + Z, element, A = first_line.split('-')[:3] + + Z = int(Z) + M = 1 if 'm' in A.lower() else 0 + A = int(A.lower().split(' ')[0].split('m')[0]) + pKZA = (Z * 1000 + A) * 10 + M + return pKZA diff --git a/src/DataLib/fendl32B_retrofit/test_groupr_tools.py b/src/DataLib/fendl32B_retrofit/test_groupr_tools.py index c667297..edebfcd 100644 --- a/src/DataLib/fendl32B_retrofit/test_groupr_tools.py +++ b/src/DataLib/fendl32B_retrofit/test_groupr_tools.py @@ -17,8 +17,7 @@ 'Fe', 56, mt_dict, - ''' -groupr/ + '''groupr/ 20 21 0 31/ 2631 17 0 11 0 1 1 1/ "26-Fe-56 for TENDL 2017"/ diff --git a/src/DataLib/fendl32B_retrofit/test_tendl_preprocessing.py b/src/DataLib/fendl32B_retrofit/test_tendl_processing.py similarity index 63% rename from src/DataLib/fendl32B_retrofit/test_tendl_preprocessing.py rename to src/DataLib/fendl32B_retrofit/test_tendl_processing.py index 99c1123..56c49de 100644 --- a/src/DataLib/fendl32B_retrofit/test_tendl_preprocessing.py +++ b/src/DataLib/fendl32B_retrofit/test_tendl_processing.py @@ -1,6 +1,6 @@ # Import packages import pytest -import tendl_preprocessing as tpp +import tendl_processing as tp dir = './files_for_tests' @@ -16,9 +16,19 @@ ] ) def test_extract_endf_specs(endf_file, exp): - obs = tpp.extract_endf_specs(f'{dir}/{endf_file}') + obs = tp.extract_endf_specs(f'{dir}/{endf_file}') assert obs == exp def test_extract_endf_specs_empty_endf(): with pytest.raises(Exception, match='std::exception'): - tpp.extract_endf_specs(f'{dir}/endf_test2.tendl') \ No newline at end of file + tp.extract_endf_specs(f'{dir}/endf_test2.tendl') + +@pytest.mark.parametrize( + "gendf_file, exp", + [ + ('gendf_test1.gendf', 260560) + ] +) +def test_extract_gendf_pkza(gendf_file, exp): + obs = tp.extract_gendf_pkza(f'{dir}/{gendf_file}') + assert obs == exp \ No newline at end of file From 005a71d9d4c2eb8b234ff370f74f8775352b8cba Mon Sep 17 00:00:00 2001 From: Eitan Weinstein Date: Fri, 2 Aug 2024 16:00:59 -0500 Subject: [PATCH 3/4] Finish rebase. --- .../fendl32B_retrofit/tendl_processing.py | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/DataLib/fendl32B_retrofit/tendl_processing.py b/src/DataLib/fendl32B_retrofit/tendl_processing.py index 23aadfc..909f9b4 100644 --- a/src/DataLib/fendl32B_retrofit/tendl_processing.py +++ b/src/DataLib/fendl32B_retrofit/tendl_processing.py @@ -21,4 +21,32 @@ def extract_endf_specs(path): # Extract the MT numbers that are present in the file MTs = [MT.MT for MT in file.sections.to_list()] - return matb, MTs \ No newline at end of file + return matb, MTs + +def extract_gendf_pkza(gendf_path): + """ + Read in and parse the contents of a GENDF file to construct the parent + KZA. KZA values are defined as ZZAAAM, where ZZ is the isotope's + atomic number, AAA is the mass number, and M is the isomeric state + (0 if non-isomeric). + + Arguments: + gendf_path (str): File path to the GENDF file being analyzed. + M (str, optional): Identifier of isomer, signified by the letter "M" + at the end of the mass number string. + + Defaults to None and will be otherwise defined internally. + + Returns: + pKZA (int): Parent KZA identifier. + """ + + with open(gendf_path, 'r') as f: + first_line = f.readline() + Z, element, A = first_line.split('-')[:3] + + Z = int(Z) + M = 1 if 'm' in A.lower() else 0 + A = int(A.lower().split(' ')[0].split('m')[0]) + pKZA = (Z * 1000 + A) * 10 + M + return pKZA \ No newline at end of file From 1fac9f166ab78543afa0a114e808dfdd7bf7acef Mon Sep 17 00:00:00 2001 From: Eitan Weinstein Date: Fri, 2 Aug 2024 16:04:55 -0500 Subject: [PATCH 4/4] Including pKZA extraction in example usage. --- src/DataLib/fendl32B_retrofit/process_fendl3.2.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/DataLib/fendl32B_retrofit/process_fendl3.2.py b/src/DataLib/fendl32B_retrofit/process_fendl3.2.py index 3be5603..bfe314b 100644 --- a/src/DataLib/fendl32B_retrofit/process_fendl3.2.py +++ b/src/DataLib/fendl32B_retrofit/process_fendl3.2.py @@ -16,8 +16,10 @@ def main(): material_id, MTs = tp.extract_endf_specs(endf_path) njoy_input = groupr_tools.fill_input_template(material_id, MTs, 'Fe', 56, mt_dict) groupr_tools.write_njoy_input_file(njoy_input) - groupr_tools.run_njoy('Fe', 56, material_id) + gendf_path = groupr_tools.run_njoy('Fe', 56, material_id) groupr_tools.cleanup_njoy_files() + pKZA = tp.extract_gendf_pkza(gendf_path) + if __name__ == '__main__': main() \ No newline at end of file