This repository was archived by the owner on Mar 14, 2023. It is now read-only.
forked from openmc-dev/openmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathace.F90
1738 lines (1444 loc) · 62.3 KB
/
ace.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
module ace
use angleenergy_header, only: AngleEnergy
use constants
use distribution_univariate, only: Uniform, Equiprobable, Tabular
use endf, only: is_fission, is_disappearance
use endf_header, only: Constant1D, Tabulated1D, Polynomial
use energy_distribution, only: TabularEquiprobable, LevelInelastic, &
ContinuousTabular, MaxwellEnergy, Evaporation, WattEnergy
use error, only: fatal_error, warning
use global
use list_header, only: ListInt
use material_header, only: Material
use multipole, only: multipole_read
use nuclide_header
use output, only: write_message
use product_header, only: ReactionProduct
use sab_header
use set_header, only: SetChar
use secondary_correlated, only: CorrelatedAngleEnergy
use secondary_kalbach, only: KalbachMann
use secondary_nbody, only: NBodyPhaseSpace
use secondary_uncorrelated, only: UncorrelatedAngleEnergy
use string, only: to_str, to_lower
implicit none
integer :: JXS(32) ! Pointers into ACE XSS tables
integer :: NXS(16) ! Descriptors for ACE XSS tables
real(8), allocatable :: XSS(:) ! Cross section data
integer :: XSS_index ! Current index in XSS data
private :: JXS
private :: NXS
private :: XSS
contains
!===============================================================================
! READ_ACE_XS reads all the cross sections for the problem and stores them in
! nuclides and sab_tables arrays
!===============================================================================
subroutine read_ace_xs()
integer :: i ! index in materials array
integer :: j ! index over nuclides in material
integer :: k ! index over S(a,b) tables in material
integer :: n ! index over resonant scatterers
integer :: i_listing ! index in xs_listings array
integer :: i_nuclide ! index in nuclides
integer :: i_sab ! index in sab_tables
integer :: m ! position for sorting
integer :: temp_nuclide ! temporary value for sorting
integer :: temp_table ! temporary value for sorting
character(12) :: name ! name of isotope, e.g. 92235.03c
character(12) :: alias ! alias of nuclide, e.g. U-235.03c
logical :: mp_found ! if windowed multipole libraries were found
type(Material), pointer :: mat
type(Nuclide), pointer :: nuc
type(SAlphaBeta), pointer :: sab
type(SetChar) :: already_read
! allocate arrays for ACE table storage and cross section cache
allocate(nuclides(n_nuclides_total))
allocate(sab_tables(n_sab_tables))
!$omp parallel
allocate(micro_xs(n_nuclides_total))
!$omp end parallel
! ==========================================================================
! READ ALL ACE CROSS SECTION TABLES
! Loop over all files
MATERIAL_LOOP: do i = 1, n_materials
mat => materials(i)
NUCLIDE_LOOP: do j = 1, mat % n_nuclides
name = mat % names(j)
if (.not. already_read % contains(name)) then
i_listing = xs_listing_dict % get_key(to_lower(name))
i_nuclide = nuclide_dict % get_key(to_lower(name))
name = xs_listings(i_listing) % name
alias = xs_listings(i_listing) % alias
! Keep track of what listing is associated with this nuclide
nuc => nuclides(i_nuclide)
nuc % listing = i_listing
! Read the ACE table into the appropriate entry on the nuclides
! array
call read_ace_table(i_nuclide, i_listing)
! 0K resonant scatterer information, if treating resonance scattering
if (treat_res_scat) then
do n = 1, n_res_scatterers_total
if (name == nuclides_0K(n) % name) then
nuclides(i_nuclide) % resonant = .true.
nuclides(i_nuclide) % name_0K = nuclides_0K(n) % name_0K
nuclides(i_nuclide) % name_0K = trim(nuclides(i_nuclide) % &
& name_0K)
nuclides(i_nuclide) % scheme = nuclides_0K(n) % scheme
nuclides(i_nuclide) % scheme = trim(nuclides(i_nuclide) % &
& scheme)
nuclides(i_nuclide) % E_min = nuclides_0K(n) % E_min
nuclides(i_nuclide) % E_max = nuclides_0K(n) % E_max
if (.not. already_read % contains(nuclides(i_nuclide) % &
& name_0K)) then
i_listing = xs_listing_dict % get_key(nuclides(i_nuclide) % &
& name_0K)
call read_ace_table(i_nuclide, i_listing)
end if
exit
end if
end do
end if
! Read multipole file into the appropriate entry on the nuclides array
if (multipole_active) call read_multipole_data(i_nuclide)
! Add name and alias to dictionary
call already_read % add(name)
call already_read % add(alias)
end if
end do NUCLIDE_LOOP
SAB_LOOP: do k = 1, mat % n_sab
! Get name of S(a,b) table
name = mat % sab_names(k)
if (.not. already_read % contains(name)) then
i_listing = xs_listing_dict % get_key(to_lower(name))
i_sab = sab_dict % get_key(to_lower(name))
! Read the ACE table into the appropriate entry on the sab_tables
! array
call read_ace_table(i_sab, i_listing)
! Add name to dictionary
call already_read % add(name)
end if
end do SAB_LOOP
end do MATERIAL_LOOP
! ==========================================================================
! ASSIGN S(A,B) TABLES TO SPECIFIC NUCLIDES WITHIN MATERIALS
MATERIAL_LOOP2: do i = 1, n_materials
! Get pointer to material
mat => materials(i)
ASSIGN_SAB: do k = 1, mat % n_sab
! In order to know which nuclide the S(a,b) table applies to, we need to
! search through the list of nuclides for one which has a matching zaid
sab => sab_tables(mat % i_sab_tables(k))
! Loop through nuclides and find match
FIND_NUCLIDE: do j = 1, mat % n_nuclides
if (any(sab % zaid == nuclides(mat % nuclide(j)) % zaid)) then
mat % i_sab_nuclides(k) = j
exit FIND_NUCLIDE
end if
end do FIND_NUCLIDE
! Check to make sure S(a,b) table matched a nuclide
if (mat % i_sab_nuclides(k) == NONE) then
call fatal_error("S(a,b) table " // trim(mat % sab_names(k)) &
&// " did not match any nuclide on material " &
&// trim(to_str(mat % id)))
end if
end do ASSIGN_SAB
! If there are multiple S(a,b) tables, we need to make sure that the
! entries in i_sab_nuclides are sorted or else they won't be applied
! correctly in the cross_section module. The algorithm here is a simple
! insertion sort -- don't need anything fancy!
if (mat % n_sab > 1) then
SORT_SAB: do k = 2, mat % n_sab
! Save value to move
m = k
temp_nuclide = mat % i_sab_nuclides(k)
temp_table = mat % i_sab_tables(k)
MOVE_OVER: do
! Check if insertion value is greater than (m-1)th value
if (temp_nuclide >= mat % i_sab_nuclides(m-1)) exit
! Move values over until hitting one that's not larger
mat % i_sab_nuclides(m) = mat % i_sab_nuclides(m-1)
mat % i_sab_tables(m) = mat % i_sab_tables(m-1)
m = m - 1
! Exit if we've reached the beginning of the list
if (m == 1) exit
end do MOVE_OVER
! Put the original value into its new position
mat % i_sab_nuclides(m) = temp_nuclide
mat % i_sab_tables(m) = temp_table
end do SORT_SAB
end if
! Deallocate temporary arrays for names of nuclides and S(a,b) tables
if (allocated(mat % names)) deallocate(mat % names)
end do MATERIAL_LOOP2
! Avoid some valgrind leak errors
call already_read % clear()
! Loop around material
MATERIAL_LOOP3: do i = 1, n_materials
! Get material
mat => materials(i)
! Loop around nuclides in material
NUCLIDE_LOOP2: do j = 1, mat % n_nuclides
! Check for fission in nuclide
if (nuclides(mat % nuclide(j)) % fissionable) then
mat % fissionable = .true.
exit NUCLIDE_LOOP2
end if
end do NUCLIDE_LOOP2
end do MATERIAL_LOOP3
! Show which nuclide results in lowest energy for neutron transport
do i = 1, n_nuclides_total
if (nuclides(i) % energy(nuclides(i) % n_grid) == energy_max_neutron) then
call write_message("Maximum neutron transport energy: " // &
trim(to_str(energy_max_neutron)) // " MeV for " // &
trim(adjustl(nuclides(i) % name)), 6)
exit
end if
end do
! If the user wants multipole, make sure we found a multipole library.
if (multipole_active) then
mp_found = .false.
do i = 1, n_nuclides_total
if (nuclides(i) % mp_present) then
mp_found = .true.
exit
end if
end do
if (.not. mp_found) call warning("Windowed multipole functionality is &
&turned on, but no multipole libraries were found. Set the &
&<multipole_library> element in settings.xml or the &
&OPENMC_MULTIPOLE_LIBRARY environment variable.")
end if
end subroutine read_ace_xs
!===============================================================================
! READ_ACE_TABLE reads a single cross section table in either ASCII or binary
! format. This routine reads the header data for each table and then calls
! appropriate subroutines to parse the actual data.
!===============================================================================
subroutine read_ace_table(i_table, i_listing)
integer, intent(in) :: i_table ! index in nuclides/sab_tables
integer, intent(in) :: i_listing ! index in xs_listings
integer :: i ! loop index for XSS records
integer :: j, j1, j2 ! indices in XSS
integer :: record_length ! Fortran record length
integer :: location ! location of ACE table
integer :: entries ! number of entries on each record
integer :: length ! length of ACE table
integer :: unit_ace ! file unit
integer :: zaids(16) ! list of ZAIDs (only used for S(a,b))
integer :: filetype ! filetype (ASCII or BINARY)
real(8) :: kT ! temperature of table
real(8) :: awrs(16) ! list of atomic weight ratios (not used)
real(8) :: awr ! atomic weight ratio for table
logical :: file_exists ! does ACE library exist?
logical :: data_0K ! are we reading 0K data?
character(7) :: readable ! is ACE library readable?
character(10) :: name ! name of ACE table
character(10) :: date_ ! date ACE library was processed
character(10) :: mat ! material identifier
character(70) :: comment ! comment for ACE table
character(MAX_FILE_LEN) :: filename ! path to ACE cross section library
type(Nuclide), pointer :: nuc
type(SAlphaBeta), pointer :: sab
type(XsListing), pointer :: listing
! determine path, record length, and location of table
listing => xs_listings(i_listing)
filename = listing % path
record_length = listing % recl
location = listing % location
entries = listing % entries
filetype = listing % filetype
! Check if ACE library exists and is readable
inquire(FILE=filename, EXIST=file_exists, READ=readable)
if (.not. file_exists) then
call fatal_error("ACE library '" // trim(filename) // "' does not exist!")
elseif (readable(1:3) == 'NO') then
call fatal_error("ACE library '" // trim(filename) // "' is not readable!&
& Change file permissions with chmod command.")
end if
! display message
call write_message("Loading ACE cross section table: " // listing % name, 6)
if (filetype == ASCII) then
! =======================================================================
! READ ACE TABLE IN ASCII FORMAT
! Find location of table
open(NEWUNIT=unit_ace, FILE=filename, STATUS='old', ACTION='read')
rewind(UNIT=unit_ace)
do i = 1, location - 1
read(UNIT=unit_ace, FMT=*)
end do
! Read first line of header
read(UNIT=unit_ace, FMT='(A10,2G12.0,1X,A10)') name, awr, kT, date_
! Check that correct xs was found -- if cross_sections.xml is broken, the
! location of the table may be wrong
if(adjustl(name) /= adjustl(listing % name)) then
call fatal_error("XS listing entry " // trim(listing % name) // " did &
¬ match ACE data, " // trim(name) // " found instead.")
end if
! Read more header and NXS and JXS
read(UNIT=unit_ace, FMT=100) comment, mat, &
(zaids(i), awrs(i), i=1,16), NXS, JXS
100 format(A70,A10/4(I7,F11.0)/4(I7,F11.0)/4(I7,F11.0)/4(I7,F11.0)/&
,8I9/8I9/8I9/8I9/8I9/8I9)
! determine table length
length = NXS(1)
allocate(XSS(length))
! Read XSS array
read(UNIT=unit_ace, FMT='(4G20.0)') XSS
! Close ACE file
close(UNIT=unit_ace)
elseif (filetype == BINARY) then
! =======================================================================
! READ ACE TABLE IN BINARY FORMAT
! Open ACE file
open(NEWUNIT=unit_ace, FILE=filename, STATUS='old', ACTION='read', &
ACCESS='direct', RECL=record_length)
! Read all header information
read(UNIT=unit_ace, REC=location) name, awr, kT, date_, &
comment, mat, (zaids(i), awrs(i), i=1,16), NXS, JXS
! determine table length
length = NXS(1)
allocate(XSS(length))
! Read remaining records with XSS
do i = 1, (length + entries - 1)/entries
j1 = 1 + (i-1)*entries
j2 = min(length, j1 + entries - 1)
read(UNIT=UNIT_ACE, REC=location + i) (XSS(j), j=j1,j2)
end do
! Close ACE file
close(UNIT=unit_ace)
end if
! ==========================================================================
! PARSE DATA BASED ON NXS, JXS, AND XSS ARRAYS
select case(listing % type)
case (ACE_NEUTRON)
! only read in a resonant scatterers info once
nuc => nuclides(i_table)
data_0K = .false.
if (trim(adjustl(name)) == nuc % name_0K) then
data_0K = .true.
else
nuc % name = name
nuc % awr = awr
nuc % kT = kT
nuc % zaid = listing % zaid
end if
! read all blocks
call read_esz(nuc, data_0K)
! don't read unnecessary 0K data for resonant scatterers
if (data_0K) then
continue
else
call read_reactions(nuc)
call read_nu_data(nuc)
call read_energy_dist(nuc)
call read_angular_dist(nuc)
call read_unr_res(nuc)
end if
! for fissionable nuclides, precalculate microscopic nu-fission cross
! sections so that we don't need to call the nu_total function during
! cross section lookups (except if we're dealing w/ 0K data for resonant
! scatterers)
if (nuc % fissionable .and. .not. data_0K) then
call generate_nu_fission(nuc)
end if
case (ACE_THERMAL)
sab => sab_tables(i_table)
sab % name = name
sab % awr = awr
sab % kT = kT
! Find sab % n_zaid
do i = 1, 16
if (zaids(i) == 0) then
sab % n_zaid = i - 1
exit
end if
end do
allocate(sab % zaid(sab % n_zaid))
sab % zaid = zaids(1: sab % n_zaid)
call read_thermal_data(sab)
end select
deallocate(XSS)
end subroutine read_ace_table
!===============================================================================
! READ_MULTIPOLE_DATA checks for the existence of a multipole library in the
! directory and loads it using multipole_read
!===============================================================================
subroutine read_multipole_data(i_table)
integer, intent(in) :: i_table ! index in nuclides/sab_tables
logical :: file_exists ! Does multipole library exist?
character(7) :: readable ! Is multipole library readable?
character(6) :: zaid_string ! String of the ZAID
character(MAX_FILE_LEN+9) :: filename ! Path to multipole xs library
! For the time being, and I know this is a bit hacky, we just assume
! that the file will be zaid.h5.
associate (nuc => nuclides(i_table))
write(zaid_string, '(I6.6)') nuc % zaid
filename = trim(path_multipole) // zaid_string // ".h5"
! Check if Multipole library exists and is readable
inquire(FILE=filename, EXIST=file_exists, READ=readable)
if (.not. file_exists) then
nuc % mp_present = .false.
return
elseif (readable(1:3) == 'NO') then
call fatal_error("Multipole library '" // trim(filename) // "' is not &
&readable! Change file permissions with chmod command.")
end if
! Display message
call write_message("Loading Multipole XS table: " // filename, 6)
allocate(nuc % multipole)
! Call the read routine
call multipole_read(filename, nuc % multipole, i_table)
nuc % mp_present = .true.
! Recreate nu-fission tables
if (nuc % fissionable) then
call generate_nu_fission(nuc)
end if
end associate
end subroutine read_multipole_data
!===============================================================================
! READ_ESZ - reads through the ESZ block. This block contains the energy grid,
! total xs, absorption xs, elastic scattering xs, and heating numbers.
!===============================================================================
subroutine read_esz(nuc, data_0K)
type(Nuclide), intent(inout) :: nuc
logical, intent(in) :: data_0K ! are we reading 0K data?
integer :: NE ! number of energy points for total and elastic cross sections
integer :: i ! index in 0K elastic xs array for this nuclide
real(8) :: xs_cdf_sum = ZERO ! xs cdf value
! determine number of energy points
NE = NXS(3)
! allocate storage for energy grid and cross section arrays
! read in 0K data if we've already read in non-0K data
if (data_0K) then
nuc % n_grid_0K = NE
allocate(nuc % energy_0K(NE))
allocate(nuc % elastic_0K(NE))
allocate(nuc % xs_cdf(NE))
nuc % elastic_0K = ZERO
nuc % xs_cdf = ZERO
XSS_index = 1
nuc % energy_0K = get_real(NE)
! Skip total and absorption
XSS_index = XSS_index + 2*NE
! Continue reading elastic scattering and heating
nuc % elastic_0K = get_real(NE)
do i = 1, nuc % n_grid_0K - 1
! Negative cross sections result in a CDF that is not monotonically
! increasing. Set all negative xs values to ZERO.
if (nuc % elastic_0K(i) < ZERO) nuc % elastic_0K(i) = ZERO
! build xs cdf
xs_cdf_sum = xs_cdf_sum &
+ (sqrt(nuc % energy_0K(i)) * nuc % elastic_0K(i) &
+ sqrt(nuc % energy_0K(i+1)) * nuc % elastic_0K(i+1)) / TWO &
* (nuc % energy_0K(i+1) - nuc % energy_0K(i))
nuc % xs_cdf(i) = xs_cdf_sum
end do
else ! read in non-0K data
nuc % n_grid = NE
allocate(nuc % energy(NE))
allocate(nuc % total(NE))
allocate(nuc % elastic(NE))
allocate(nuc % fission(NE))
allocate(nuc % nu_fission(NE))
allocate(nuc % absorption(NE))
! initialize cross sections
nuc % total = ZERO
nuc % elastic = ZERO
nuc % fission = ZERO
nuc % nu_fission = ZERO
nuc % absorption = ZERO
! Read data from XSS -- only the energy grid, elastic scattering and heating
! cross section values are actually read from here. The total and absorption
! cross sections are reconstructed from the partial reaction data.
XSS_index = 1
nuc % energy = get_real(NE)
! Skip total and absorption
XSS_index = XSS_index + 2*NE
! Continue reading elastic scattering and heating
nuc % elastic = get_real(NE)
! Determine if minimum/maximum energy for this nuclide is greater/less
! than the previous
energy_min_neutron = max(energy_min_neutron, nuc%energy(1))
energy_max_neutron = min(energy_max_neutron, nuc%energy(NE))
end if
end subroutine read_esz
!===============================================================================
! READ_NU_DATA reads data given on the number of neutrons emitted from fission
! as a function of the incoming energy of a neutron. This data may be broken
! down into prompt and delayed neutrons emitted as well.
!===============================================================================
subroutine read_nu_data(nuc)
type(Nuclide), intent(inout) :: nuc
integer :: i, j ! loop index
integer :: idx ! index in XSS
integer :: KNU ! location for nu data
integer :: LNU ! type of nu data (polynomial or tabular)
integer :: NR ! number of interpolation regions
integer :: NE ! number of energies
integer :: NPCR ! number of delayed neutron precursor groups
integer :: LOCC ! location of energy distributions for given MT
integer :: LAW
integer :: IDAT
real(8) :: total_group_probability
type(Tabulated1D) :: yield_delayed
type(Tabulated1D) :: group_probability
if (JXS(2) == 0) then
! Nuclide is not fissionable
return
end if
! Determine number of delayed neutron precursors
if (JXS(24) > 0) then
NPCR = NXS(8)
else
NPCR = 0
end if
nuc % n_precursor = NPCR
! Check to make sure nuclide does not have more than the maximum number
! of delayed groups
if (NPCR > MAX_DELAYED_GROUPS) then
call fatal_error("Encountered nuclide with " // trim(to_str(NPCR)) &
// " delayed groups while the maximum number of delayed groups is " &
// trim(to_str(MAX_DELAYED_GROUPS)))
end if
associate (rx => nuc % reactions(nuc % index_fission(1)))
! Allocate space for prompt/delayed neutron products
allocate(rx % products(1 + NPCR))
rx % products(:) % particle = NEUTRON
if (XSS(JXS(2)) > 0) then
! =======================================================================
! PROMPT OR TOTAL NU DATA
! If delayed data is present, then prompt data must be present. Otherwise
! the product represents 'total' neutron emission
if (JXS(24) > 0) then
rx % products(1) % emission_mode = EMISSION_PROMPT
else
rx % products(1) % emission_mode = EMISSION_TOTAL
end if
KNU = JXS(2)
LNU = nint(XSS(KNU))
if (LNU == 1) then
! Polynomial data
allocate(Polynomial :: rx % products(1) % yield)
! determine order of polynomial and read coefficients
select type (yield => rx % products(1) % yield)
type is (Polynomial)
call yield % from_ace(XSS, KNU + 1)
end select
elseif (LNU == 2) then
! Tabulated data
allocate(Tabulated1D :: rx % products(1) % yield)
select type(yield => rx % products(1) % yield)
type is (Tabulated1D)
call yield % from_ace(XSS, KNU + 1)
end select
end if
elseif (XSS(JXS(2)) < 0) then
! =======================================================================
! PROMPT AND TOTAL NU DATA
rx % products(1) % emission_mode = EMISSION_PROMPT
KNU = JXS(2) + 1
LNU = nint(XSS(KNU))
if (LNU == 1) then
! Polynomial data
allocate(Polynomial :: rx % products(1) % yield)
! determine order of polynomial and read coefficients
select type (yield => rx % products(1) % yield)
type is (Polynomial)
call yield % from_ace(XSS, KNU + 1)
end select
elseif (LNU == 2) then
! Tabulated data
allocate(Tabulated1D :: rx % products(1) % yield)
select type(yield => rx % products(1) % yield)
type is (Tabulated1D)
call yield % from_ace(XSS, KNU + 1)
end select
end if
KNU = JXS(2) + nint(abs(XSS(JXS(2)))) + 1
LNU = nint(XSS(KNU))
if (LNU == 1) then
! Polynomial data
allocate(Polynomial :: nuc % total_nu)
! determine order of polynomial and read coefficients
select type (yield => nuc % total_nu)
type is (Polynomial)
call yield % from_ace(XSS, KNU + 1)
end select
elseif (LNU == 2) then
! Tabulated data
allocate(Tabulated1D :: nuc % total_nu)
select type(yield => nuc % total_nu)
type is (Tabulated1D)
call yield % from_ace(XSS, KNU + 1)
end select
end if
end if
if (JXS(24) > 0) then
! =======================================================================
! DELAYED NU DATA
! Read total yield of delayed neutrons
call yield_delayed % from_ace(XSS, JXS(24) + 1)
idx = JXS(25)
total_group_probability = ZERO
do i = 1, NPCR
! Set emission mode and decay rate
rx % products(1 + i) % emission_mode = EMISSION_DELAYED
rx % products(1 + i) % decay_rate = XSS(idx)
! Read probability for this precursor group
call group_probability % from_ace(XSS, idx + 1)
! Set yield based on product of group probability and delayed yield
if (all(group_probability % y == group_probability % y(1))) then
allocate(Tabulated1D :: rx % products(1 + i) % yield)
select type (yield => rx % products(1 + i) % yield)
type is (Tabulated1D)
yield = yield_delayed
yield % y(:) = yield % y(:) * group_probability % y(1)
total_group_probability = total_group_probability + group_probability % y(1)
end select
else
call fatal_error("Delayed neutron with energy-dependent group &
&probability not implemented")
end if
! Advance position
NR = nint(XSS(idx + 1))
NE = nint(XSS(idx + 2 + 2*NR))
idx = idx + 3 + 2*(NR + NE)
! =======================================================================
! DELAYED NEUTRON ENERGY DISTRIBUTION
! Read energy distribution
LOCC = nint(XSS(JXS(26) + i - 1))
! Determine law and location of data
LAW = nint(XSS(JXS(27) + LOCC))
IDAT = nint(XSS(JXS(27) + LOCC + 1))
! read energy distribution data
associate(p => rx % products(1 + i))
allocate(p % applicability(1))
allocate(p % distribution(1))
call get_energy_dist(p % distribution(1) % obj, LAW, JXS(27), IDAT, &
ZERO, ZERO)
select type (aedist => p % distribution(1) % obj)
type is (UncorrelatedAngleEnergy)
aedist % fission = .true.
end select
end associate
end do
! Renormalize delayed neutron yields to reflect fact that in ACE file, the
! sum of the group probabilities is not exactly one
do i = 1, NPCR
select type (yield => rx % products(1 + i) % yield)
type is (Tabulated1D)
yield % y(:) = yield % y(:) / total_group_probability
end select
end do
end if
! Assign products to other fission reactions
do i = 2, nuc % n_fission
j = nuc % index_fission(i)
allocate(nuc % reactions(j) % products(1 + NPCR))
nuc % reactions(j) % products(:) = rx % products(:)
end do
end associate
end subroutine read_nu_data
!===============================================================================
! READ_REACTIONS - Get the list of reaction MTs for this cross-section
! table. The MT values are somewhat arbitrary. Also read in Q-values, neutron
! multiplicities, and cross-sections.
!===============================================================================
subroutine read_reactions(nuc)
type(Nuclide), intent(inout) :: nuc
integer :: i ! loop indices
integer :: i_fission ! index in nuc % index_fission
integer :: LMT ! index of MT list in XSS
integer :: NMT ! Number of reactions
integer :: JXS4 ! index of Q values in XSS
integer :: JXS5 ! index of neutron multiplicities in XSS
integer :: JXS7 ! index of reactions cross-sections in XSS
integer :: LXS ! location of cross-section locators
integer :: LOCA ! location of cross-section for given MT
integer :: IE ! reaction's starting index on energy grid
integer :: NE ! number of energies
real(8) :: y
type(ListInt) :: MTs
LMT = JXS(3)
JXS4 = JXS(4)
JXS5 = JXS(5)
LXS = JXS(6)
JXS7 = JXS(7)
NMT = NXS(4)
! allocate array of reactions. Add one since we need to include an elastic
! scattering channel
nuc % n_reaction = NMT + 1
allocate(nuc % reactions(NMT+1))
! Store elastic scattering cross-section on reaction one -- note that the
! sigma array is not allocated or stored for elastic scattering since it is
! already stored in nuc % elastic
associate (rxn => nuc % reactions(1))
rxn % MT = 2
rxn % Q_value = ZERO
allocate(rxn % products(1))
rxn % products(1) % particle = NEUTRON
allocate(Constant1D :: rxn % products(1) % yield)
select type(yield => rxn % products(1) % yield)
type is (Constant1D)
yield % y = 1
end select
rxn % threshold = 1
rxn % scatter_in_cm = .true.
allocate(rxn % products(1) % distribution(1))
allocate(UncorrelatedAngleEnergy :: rxn % products(1) % distribution(1) % obj)
end associate
! Add contribution of elastic scattering to total cross section
nuc % total = nuc % total + nuc % elastic
! By default, set nuclide to not fissionable and then change if fission
! reactions are encountered
nuc % fissionable = .false.
nuc % has_partial_fission = .false.
nuc % n_fission = 0
i_fission = 0
do i = 1, NMT
associate (rxn => nuc % reactions(i+1))
! read MT number, Q-value, and neutrons produced
rxn % MT = int(XSS(LMT + i - 1))
rxn % Q_value = XSS(JXS4 + i - 1)
rxn % scatter_in_cm = (nint(XSS(JXS5 + i - 1)) < 0)
if (.not. is_fission(rxn % MT)) then
allocate(rxn % products(1))
rxn % products(1) % particle = NEUTRON
y = abs(nint(XSS(JXS5 + i - 1)))
if (y > 100) then
! Read energy-dependent multiplicities
! Set flag and allocate space for Tabulated1D to store yield
allocate(Tabulated1D :: rxn % products(1) % yield)
! Read yield function
select type (yield => rxn % products(1) % yield)
type is (Tabulated1D)
XSS_index = JXS(11) + int(y) - 101
call yield % from_ace(XSS, XSS_index)
end select
else
! Integral yield
allocate(Constant1D :: rxn % products(1) % yield)
select type (yield => rxn % products(1) % yield)
type is (Constant1D)
yield % y = y
end select
end if
end if
! read starting energy index
LOCA = int(XSS(LXS + i - 1))
IE = int(XSS(JXS7 + LOCA - 1))
rxn % threshold = IE
! read number of energies cross section values
NE = int(XSS(JXS7 + LOCA))
allocate(rxn % sigma(NE))
XSS_index = JXS7 + LOCA + 1
rxn % sigma = get_real(NE)
end associate
end do
! Create set of MT values
do i = 1, size(nuc % reactions)
call MTs % append(nuc % reactions(i) % MT)
call nuc%reaction_index%add_key(nuc%reactions(i)%MT, i)
end do
! Create total, absorption, and fission cross sections
do i = 2, size(nuc % reactions)
associate (rxn => nuc % reactions(i))
IE = rxn % threshold
NE = size(rxn % sigma)
! Skip total inelastic level scattering, gas production cross sections
! (MT=200+), etc.
if (rxn % MT == N_LEVEL .or. rxn % MT == N_NONELASTIC) cycle
if (rxn % MT > N_5N2P .and. rxn % MT < N_P0) cycle
! Skip level cross sections if total is available
if (rxn % MT >= N_P0 .and. rxn % MT <= N_PC .and. MTs % contains(N_P)) cycle
if (rxn % MT >= N_D0 .and. rxn % MT <= N_DC .and. MTs % contains(N_D)) cycle
if (rxn % MT >= N_T0 .and. rxn % MT <= N_TC .and. MTs % contains(N_T)) cycle
if (rxn % MT >= N_3HE0 .and. rxn % MT <= N_3HEC .and. MTs % contains(N_3HE)) cycle
if (rxn % MT >= N_A0 .and. rxn % MT <= N_AC .and. MTs % contains(N_A)) cycle
if (rxn % MT >= N_2N0 .and. rxn % MT <= N_2NC .and. MTs % contains(N_2N)) cycle
! Add contribution to total cross section
nuc % total(IE:IE+NE-1) = nuc % total(IE:IE+NE-1) + rxn % sigma
! Add contribution to absorption cross section
if (is_disappearance(rxn % MT)) then
nuc % absorption(IE:IE+NE-1) = nuc % absorption(IE:IE+NE-1) + rxn % sigma
end if
! Information about fission reactions
if (rxn % MT == N_FISSION) then
allocate(nuc % index_fission(1))
elseif (rxn % MT == N_F) then
allocate(nuc % index_fission(PARTIAL_FISSION_MAX))
nuc % has_partial_fission = .true.
end if
! Add contribution to fission cross section
if (is_fission(rxn % MT)) then
nuc % fissionable = .true.
nuc % fission(IE:IE+NE-1) = nuc % fission(IE:IE+NE-1) + rxn % sigma
! Also need to add fission cross sections to absorption
nuc % absorption(IE:IE+NE-1) = nuc % absorption(IE:IE+NE-1) + rxn % sigma
! If total fission reaction is present, there's no need to store the
! reaction cross-section since it was copied to nuc % fission
if (rxn % MT == N_FISSION) deallocate(rxn % sigma)
! Keep track of this reaction for easy searching later
i_fission = i_fission + 1
nuc % index_fission(i_fission) = i
nuc % n_fission = nuc % n_fission + 1
end if
end associate
end do
! Clear MTs set
call MTs % clear()
end subroutine read_reactions
!===============================================================================
! READ_ANGULAR_DIST parses the angular distribution for each reaction with
! secondary neutrons
!===============================================================================
subroutine read_angular_dist(nuc)
type(Nuclide), intent(inout) :: nuc
integer :: LOCB ! location of angular distribution for given MT
integer :: NE ! number of incoming energies
integer :: NP ! number of points for cosine distribution
integer :: i ! index in reactions array
integer :: j ! index over incoming energies
integer :: k ! index over energy distributions
integer :: interp
integer, allocatable :: LC(:) ! locator
! loop over all reactions with secondary neutrons -- NXS(5) does not include
! elastic scattering
do i = 1, NXS(5) + 1
associate (rxn => nuc%reactions(i))
! find location of angular distribution
LOCB = int(XSS(JXS(8) + i - 1))
! Angular distribution given as part of a correlated angle-energy distribution
if (LOCB == -1) cycle
! No angular distribution data are given for this reaction, isotropic
! scattering is assumed (in CM if TY < 0 and in LAB if TY > 0)
if (LOCB == 0) cycle
! Loop over each separate energy distribution. Even though there is only
! "one" angular distribution, it is repeated as many times as there are