forked from openmc-dev/openmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput_xml.F90
5560 lines (4740 loc) · 201 KB
/
input_xml.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 input_xml
use algorithm, only: find
use cmfd_input, only: configure_cmfd
use constants
use dict_header, only: DictIntInt, DictCharInt, ElemKeyValueCI
use distribution_multivariate
use distribution_univariate
use endf, only: reaction_name
use energy_grid, only: grid_method, n_log_bins
use error, only: fatal_error, warning
use geometry_header, only: Cell, Lattice, RectLattice, HexLattice, &
get_temperatures, root_universe
use global
use hdf5_interface
use list_header, only: ListChar, ListInt, ListReal
use mesh_header, only: RegularMesh
use message_passing
use mgxs_data, only: create_macro_xs, read_mgxs
use multipole, only: multipole_read
use output, only: write_message, title, header
use plot_header
use random_lcg, only: prn, seed
use surface_header
use set_header, only: SetChar
use stl_vector, only: VectorInt, VectorReal, VectorChar
use string, only: to_lower, to_str, str_to_int, str_to_real, &
starts_with, ends_with, tokenize, split_string, &
zero_padded
use tally_header, only: TallyObject
use tally_filter_header, only: TallyFilterContainer
use tally_filter
use tally_initialize, only: add_tallies
use xml_interface
implicit none
save
contains
!===============================================================================
! READ_INPUT_XML calls each of the separate subroutines for reading settings,
! geometry, materials, and tallies.
!===============================================================================
subroutine read_input_xml()
call read_settings_xml()
call read_geometry_xml()
call read_materials()
call read_tallies_xml()
if (cmfd_run) call configure_cmfd()
if (.not. run_CE) then
! Create material macroscopic data for MGXS
call time_read_xs % start()
call read_mgxs()
call create_macro_xs()
call time_read_xs % stop()
end if
! Normalize atom/weight percents
if (run_mode /= MODE_PLOTTING) call normalize_ao()
end subroutine read_input_xml
!===============================================================================
! READ_SETTINGS_XML reads data from a settings.xml file and parses it, checking
! for errors and placing properly-formatted data in the right data structures
!===============================================================================
subroutine read_settings_xml()
character(MAX_LINE_LEN) :: temp_str
integer :: i
integer :: n
integer :: temp_int
integer :: temp_int_array3(3)
integer, allocatable :: temp_int_array(:)
real(8), allocatable :: temp_real(:)
integer :: n_tracks
logical :: file_exists
character(MAX_WORD_LEN) :: type
character(MAX_LINE_LEN) :: filename
type(XMLDocument) :: doc
type(XMLNode) :: root
type(XMLNode) :: node_mode
type(XMLNode) :: node_source
type(XMLNode) :: node_space
type(XMLNode) :: node_angle
type(XMLNode) :: node_dist
type(XMLNode) :: node_cutoff
type(XMLNode) :: node_entropy
type(XMLNode) :: node_ufs
type(XMLNode) :: node_sp
type(XMLNode) :: node_output
type(XMLNode) :: node_res_scat
type(XMLNode) :: node_trigger
type(XMLNode) :: node_vol
type(XMLNode) :: node_tab_leg
type(XMLNode), allocatable :: node_source_list(:)
type(XMLNode), allocatable :: node_vol_list(:)
! Check if settings.xml exists
filename = trim(path_input) // "settings.xml"
inquire(FILE=filename, EXIST=file_exists)
if (.not. file_exists) then
if (run_mode /= MODE_PLOTTING) then
call fatal_error("Settings XML file '" // trim(filename) // "' does &
¬ exist! In order to run OpenMC, you first need a set of input &
&files; at a minimum, this includes settings.xml, geometry.xml, &
&and materials.xml. Please consult the user's guide at &
&http://mit-crpg.github.io/openmc for further information.")
else
! The settings.xml file is optional if we just want to make a plot.
return
end if
end if
! Parse settings.xml file
call doc % load_file(filename)
root = doc % document_element()
! Verbosity
if (check_for_node(root, "verbosity")) then
call get_node_value(root, "verbosity", verbosity)
end if
! To this point, we haven't displayed any output since we didn't know what
! the verbosity is. Now that we checked for it, show the title if necessary
if (master) then
if (verbosity >= 2) call title()
end if
call write_message("Reading settings XML file...", 5)
! Find if a multi-group or continuous-energy simulation is desired
if (check_for_node(root, "energy_mode")) then
call get_node_value(root, "energy_mode", temp_str)
temp_str = trim(to_lower(temp_str))
if (temp_str == "mg" .or. temp_str == "multi-group") then
run_CE = .false.
else if (temp_str == "ce" .or. temp_str == "continuous-energy") then
run_CE = .true.
end if
end if
! Look for deprecated cross_sections.xml file in settings.xml
if (check_for_node(root, "cross_sections")) then
call warning("Setting cross_sections in settings.xml has been deprecated.&
& The cross_sections are now set in materials.xml and the &
&cross_sections input to materials.xml and the OPENMC_CROSS_SECTIONS&
& environment variable will take precendent over setting &
&cross_sections in settings.xml.")
call get_node_value(root, "cross_sections", path_cross_sections)
end if
! Look for deprecated windowed_multipole file in settings.xml
if (run_mode /= MODE_PLOTTING) then
if (check_for_node(root, "multipole_library")) then
call warning("Setting multipole_library in settings.xml has been &
&deprecated. The multipole_library is now set in materials.xml and&
& the multipole_library input to materials.xml and the &
&OPENMC_MULTIPOLE_LIBRARY environment variable will take &
&precendent over setting multipole_library in settings.xml.")
call get_node_value(root, "multipole_library", path_multipole)
end if
if (.not. ends_with(path_multipole, "/")) &
path_multipole = trim(path_multipole) // "/"
end if
if (.not. run_CE) then
! Scattering Treatments
if (check_for_node(root, "max_order")) then
call get_node_value(root, "max_order", max_order)
else
! Set to default of largest int - 1, which means to use whatever is
! contained in library.
! This is largest int - 1 because for legendre scattering, a value of
! 1 is added to the order; adding 1 to huge(0) gets you the largest
! negative integer, which is not what we want.
max_order = huge(0) - 1
end if
else
max_order = 0
end if
! Check for a trigger node and get trigger information
if (check_for_node(root, "trigger")) then
node_trigger = root % child("trigger")
! Check if trigger(s) are to be turned on
call get_node_value(node_trigger, "active", trigger_on)
if (trigger_on) then
if (check_for_node(node_trigger, "max_batches") )then
call get_node_value(node_trigger, "max_batches", n_max_batches)
else
call fatal_error("The max_batches must be specified with triggers")
end if
! Get the batch interval to check triggers
if (.not. check_for_node(node_trigger, "batch_interval"))then
pred_batches = .true.
else
call get_node_value(node_trigger, "batch_interval", temp_int)
n_batch_interval = temp_int
if (n_batch_interval <= 0) then
call fatal_error("The batch interval must be greater than zero")
end if
end if
end if
end if
! Check run mode if it hasn't been set from the command line
if (run_mode == NONE) then
if (check_for_node(root, "run_mode")) then
call get_node_value(root, "run_mode", temp_str)
select case (to_lower(temp_str))
case ("eigenvalue")
run_mode = MODE_EIGENVALUE
case ("fixed source")
run_mode = MODE_FIXEDSOURCE
case ("plot")
run_mode = MODE_PLOTTING
case ("particle restart")
run_mode = MODE_PARTICLE
case ("volume")
run_mode = MODE_VOLUME
case default
call fatal_error("Unrecognized run mode: " // &
trim(temp_str) // ".")
end select
! Assume XML specifics <particles>, <batches>, etc. directly
node_mode = root
else
call warning("<run_mode> should be specified.")
! Make sure that either eigenvalue or fixed source was specified
node_mode = root % child("eigenvalue")
if (node_mode % associated()) then
if (run_mode == NONE) run_mode = MODE_EIGENVALUE
else
node_mode = root % child("fixed_source")
if (node_mode % associated()) then
if (run_mode == NONE) run_mode = MODE_FIXEDSOURCE
else
call fatal_error("<eigenvalue> or <fixed_source> not specified.")
end if
end if
end if
end if
if (run_mode == MODE_EIGENVALUE .or. run_mode == MODE_FIXEDSOURCE) then
! Read run parameters
call get_run_parameters(node_mode)
! Check number of active batches, inactive batches, and particles
if (n_active <= 0) then
call fatal_error("Number of active batches must be greater than zero.")
elseif (n_inactive < 0) then
call fatal_error("Number of inactive batches must be non-negative.")
elseif (n_particles <= 0) then
call fatal_error("Number of particles must be greater than zero.")
end if
end if
! Copy random number seed if specified
if (check_for_node(root, "seed")) call get_node_value(root, "seed", seed)
! Number of bins for logarithmic grid
if (check_for_node(root, "log_grid_bins")) then
call get_node_value(root, "log_grid_bins", n_log_bins)
if (n_log_bins < 1) then
call fatal_error("Number of bins for logarithmic grid must be &
&greater than zero.")
end if
else
n_log_bins = 8000
end if
! Number of OpenMP threads
if (check_for_node(root, "threads")) then
#ifdef _OPENMP
if (n_threads == NONE) then
call get_node_value(root, "threads", n_threads)
if (n_threads < 1) then
call fatal_error("Invalid number of threads: " // to_str(n_threads))
end if
call omp_set_num_threads(n_threads)
end if
#else
if (master) call warning("Ignoring number of threads.")
#endif
end if
! ==========================================================================
! EXTERNAL SOURCE
! Get point to list of <source> elements and make sure there is at least one
call get_node_list(root, "source", node_source_list)
n = size(node_source_list)
if (n == 0) then
! Default source is isotropic point source at origin with Watt spectrum
allocate(external_source(1))
external_source % strength = ONE
allocate(SpatialPoint :: external_source(1) % space)
select type (space => external_source(1) % space)
type is (SpatialPoint)
space % xyz(:) = [ZERO, ZERO, ZERO]
end select
allocate(Isotropic :: external_source(1) % angle)
external_source(1) % angle % reference_uvw(:) = [ZERO, ZERO, ONE]
allocate(Watt :: external_source(1) % energy)
select type(energy => external_source(1) % energy)
type is (Watt)
energy % a = 0.988e6_8
energy % b = 2.249e-6_8
end select
else
! Allocate array for sources
allocate(external_source(n))
end if
! Read each source
do i = 1, n
! Get pointer to source
node_source = node_source_list(i)
! Check if we want to write out source
if (check_for_node(node_source, "write_initial")) then
call get_node_value(node_source, "write_initial", write_initial_source)
end if
! Check for source strength
if (check_for_node(node_source, "strength")) then
call get_node_value(node_source, "strength", external_source(i)%strength)
else
external_source(i)%strength = ONE
end if
! Check for external source file
if (check_for_node(node_source, "file")) then
! Copy path of source file
call get_node_value(node_source, "file", path_source)
! Check if source file exists
inquire(FILE=path_source, EXIST=file_exists)
if (.not. file_exists) then
call fatal_error("Source file '" // trim(path_source) &
// "' does not exist!")
end if
else
! Spatial distribution for external source
if (check_for_node(node_source, "space")) then
! Get pointer to spatial distribution
node_space = node_source % child("space")
! Check for type of spatial distribution
type = ''
if (check_for_node(node_space, "type")) &
call get_node_value(node_space, "type", type)
select case (to_lower(type))
case ('cartesian')
allocate(CartesianIndependent :: external_source(i)%space)
case ('box')
allocate(SpatialBox :: external_source(i)%space)
case ('fission')
allocate(SpatialBox :: external_source(i)%space)
select type(space => external_source(i)%space)
type is (SpatialBox)
space%only_fissionable = .true.
end select
case ('point')
allocate(SpatialPoint :: external_source(i)%space)
case default
call fatal_error("Invalid spatial distribution for external source: "&
// trim(type))
end select
select type (space => external_source(i)%space)
type is (CartesianIndependent)
! Read distribution for x coordinate
if (check_for_node(node_space, "x")) then
node_dist = node_space % child("x")
call distribution_from_xml(space%x, node_dist)
else
allocate(Discrete :: space%x)
select type (dist => space%x)
type is (Discrete)
allocate(dist%x(1), dist%p(1))
dist%x(1) = ZERO
dist%p(1) = ONE
end select
end if
! Read distribution for y coordinate
if (check_for_node(node_space, "y")) then
node_dist = node_space % child("y")
call distribution_from_xml(space%y, node_dist)
else
allocate(Discrete :: space%y)
select type (dist => space%y)
type is (Discrete)
allocate(dist%x(1), dist%p(1))
dist%x(1) = ZERO
dist%p(1) = ONE
end select
end if
if (check_for_node(node_space, "z")) then
node_dist = node_space % child("z")
call distribution_from_xml(space%z, node_dist)
else
allocate(Discrete :: space%z)
select type (dist => space%z)
type is (Discrete)
allocate(dist%x(1), dist%p(1))
dist%x(1) = ZERO
dist%p(1) = ONE
end select
end if
type is (SpatialBox)
! Make sure correct number of parameters are given
if (node_word_count(node_space, "parameters") /= 6) then
call fatal_error('Box/fission spatial source must have &
&six parameters specified.')
end if
! Read lower-right/upper-left coordinates
allocate(temp_real(6))
call get_node_array(node_space, "parameters", temp_real)
space%lower_left(:) = temp_real(1:3)
space%upper_right(:) = temp_real(4:6)
deallocate(temp_real)
type is (SpatialPoint)
! Make sure correct number of parameters are given
if (node_word_count(node_space, "parameters") /= 3) then
call fatal_error('Point spatial source must have &
&three parameters specified.')
end if
! Read location of point source
allocate(temp_real(3))
call get_node_array(node_space, "parameters", temp_real)
space%xyz(:) = temp_real
deallocate(temp_real)
end select
else
! If no spatial distribution specified, make it a point source
allocate(SpatialPoint :: external_source(i) % space)
select type (space => external_source(i) % space)
type is (SpatialPoint)
space % xyz(:) = [ZERO, ZERO, ZERO]
end select
end if
! Determine external source angular distribution
if (check_for_node(node_source, "angle")) then
! Get pointer to angular distribution
node_angle = node_source % child("angle")
! Check for type of angular distribution
type = ''
if (check_for_node(node_angle, "type")) &
call get_node_value(node_angle, "type", type)
select case (to_lower(type))
case ('isotropic')
allocate(Isotropic :: external_source(i)%angle)
case ('monodirectional')
allocate(Monodirectional :: external_source(i)%angle)
case ('mu-phi')
allocate(PolarAzimuthal :: external_source(i)%angle)
case default
call fatal_error("Invalid angular distribution for external source: "&
// trim(type))
end select
! Read reference directional unit vector
if (check_for_node(node_angle, "reference_uvw")) then
n = node_word_count(node_angle, "reference_uvw")
if (n /= 3) then
call fatal_error('Angular distribution reference direction must have &
&three parameters specified.')
end if
call get_node_array(node_angle, "reference_uvw", &
external_source(i)%angle%reference_uvw)
else
! By default, set reference unit vector to be positive z-direction
external_source(i)%angle%reference_uvw(:) = [ZERO, ZERO, ONE]
end if
! Read parameters for angle distribution
select type (angle => external_source(i)%angle)
type is (Monodirectional)
call get_node_array(node_angle, "reference_uvw", &
external_source(i)%angle%reference_uvw)
type is (PolarAzimuthal)
if (check_for_node(node_angle, "mu")) then
node_dist = node_angle % child("mu")
call distribution_from_xml(angle%mu, node_dist)
else
allocate(Uniform :: angle%mu)
select type (mu => angle%mu)
type is (Uniform)
mu%a = -ONE
mu%b = ONE
end select
end if
if (check_for_node(node_angle, "phi")) then
node_dist = node_angle % child("phi")
call distribution_from_xml(angle%phi, node_dist)
else
allocate(Uniform :: angle%phi)
select type (phi => angle%phi)
type is (Uniform)
phi%a = ZERO
phi%b = TWO*PI
end select
end if
end select
else
! Set default angular distribution isotropic
allocate(Isotropic :: external_source(i)%angle)
external_source(i)%angle%reference_uvw(:) = [ZERO, ZERO, ONE]
end if
! Determine external source energy distribution
if (check_for_node(node_source, "energy")) then
node_dist = node_source % child("energy")
call distribution_from_xml(external_source(i)%energy, node_dist)
else
! Default to a Watt spectrum with parameters 0.988 MeV and 2.249 MeV^-1
allocate(Watt :: external_source(i)%energy)
select type(energy => external_source(i)%energy)
type is (Watt)
energy%a = 0.988e6_8
energy%b = 2.249e-6_8
end select
end if
end if
end do
! Survival biasing
if (check_for_node(root, "survival_biasing")) then
call get_node_value(root, "survival_biasing", survival_biasing)
end if
! Probability tables
if (check_for_node(root, "ptables")) then
call get_node_value(root, "ptables", urr_ptables_on)
end if
! Cutoffs
if (check_for_node(root, "cutoff")) then
node_cutoff = root % child("cutoff")
if (check_for_node(node_cutoff, "weight")) then
call get_node_value(node_cutoff, "weight", weight_cutoff)
end if
if (check_for_node(node_cutoff, "weight_avg")) then
call get_node_value(node_cutoff, "weight_avg", weight_survive)
end if
if (check_for_node(node_cutoff, "energy")) then
call get_node_value(node_cutoff, "energy", energy_cutoff)
end if
end if
! Particle trace
if (check_for_node(root, "trace")) then
call get_node_array(root, "trace", temp_int_array3)
trace_batch = temp_int_array3(1)
trace_gen = temp_int_array3(2)
trace_particle = int(temp_int_array3(3), 8)
end if
! Particle tracks
if (check_for_node(root, "track")) then
! Make sure that there are three values per particle
n_tracks = node_word_count(root, "track")
if (mod(n_tracks, 3) /= 0) then
call fatal_error("Number of integers specified in 'track' is not &
&divisible by 3. Please provide 3 integers per particle to be &
&tracked.")
end if
! Allocate space and get list of tracks
allocate(temp_int_array(n_tracks))
call get_node_array(root, "track", temp_int_array)
! Reshape into track_identifiers
allocate(track_identifiers(3, n_tracks/3))
track_identifiers = reshape(temp_int_array, [3, n_tracks/3])
end if
! Shannon Entropy mesh
if (check_for_node(root, "entropy")) then
! Get pointer to entropy node
node_entropy = root % child("entropy")
! Check to make sure enough values were supplied
if (node_word_count(node_entropy, "lower_left") /= 3) then
call fatal_error("Need to specify (x,y,z) coordinates of lower-left &
&corner of Shannon entropy mesh.")
elseif (node_word_count(node_entropy, "upper_right") /= 3) then
call fatal_error("Need to specify (x,y,z) coordinates of upper-right &
&corner of Shannon entropy mesh.")
end if
! Allocate mesh object and coordinates on mesh
allocate(entropy_mesh)
allocate(entropy_mesh % lower_left(3))
allocate(entropy_mesh % upper_right(3))
allocate(entropy_mesh % width(3))
! Copy values
call get_node_array(node_entropy, "lower_left", &
entropy_mesh % lower_left)
call get_node_array(node_entropy, "upper_right", &
entropy_mesh % upper_right)
! Check on values provided
if (.not. all(entropy_mesh % upper_right > entropy_mesh % lower_left)) &
&then
call fatal_error("Upper-right coordinate must be greater than &
&lower-left coordinate for Shannon entropy mesh.")
end if
! Check if dimensions were specified -- if not, they will be calculated
! automatically upon first entry into shannon_entropy
if (check_for_node(node_entropy, "dimension")) then
! If so, make sure proper number of values were given
if (node_word_count(node_entropy, "dimension") /= 3) then
call fatal_error("Dimension of entropy mesh must be given as three &
&integers.")
end if
! Allocate dimensions
entropy_mesh % n_dimension = 3
allocate(entropy_mesh % dimension(3))
! Copy dimensions
call get_node_array(node_entropy, "dimension", entropy_mesh % dimension)
! Calculate width
entropy_mesh % width = (entropy_mesh % upper_right - &
entropy_mesh % lower_left) / entropy_mesh % dimension
end if
! Turn on Shannon entropy calculation
entropy_on = .true.
end if
! Uniform fission source weighting mesh
if (check_for_node(root, "uniform_fs")) then
! Get pointer to ufs node
node_ufs = root % child("uniform_fs")
! Check to make sure enough values were supplied
if (node_word_count(node_ufs, "lower_left") /= 3) then
call fatal_error("Need to specify (x,y,z) coordinates of lower-left &
&corner of UFS mesh.")
elseif (node_word_count(node_ufs, "upper_right") /= 3) then
call fatal_error("Need to specify (x,y,z) coordinates of upper-right &
&corner of UFS mesh.")
elseif (node_word_count(node_ufs, "dimension") /= 3) then
call fatal_error("Dimension of UFS mesh must be given as three &
&integers.")
end if
! Allocate mesh object and coordinates on mesh
allocate(ufs_mesh)
allocate(ufs_mesh % lower_left(3))
allocate(ufs_mesh % upper_right(3))
allocate(ufs_mesh % width(3))
! Allocate dimensions
ufs_mesh % n_dimension = 3
allocate(ufs_mesh % dimension(3))
! Copy dimensions
call get_node_array(node_ufs, "dimension", ufs_mesh % dimension)
! Copy values
call get_node_array(node_ufs, "lower_left", ufs_mesh % lower_left)
call get_node_array(node_ufs, "upper_right", ufs_mesh % upper_right)
! Check on values provided
if (.not. all(ufs_mesh % upper_right > ufs_mesh % lower_left)) then
call fatal_error("Upper-right coordinate must be greater than &
&lower-left coordinate for UFS mesh.")
end if
! Calculate width
ufs_mesh % width = (ufs_mesh % upper_right - &
ufs_mesh % lower_left) / ufs_mesh % dimension
! Calculate volume fraction of each cell
ufs_mesh % volume_frac = ONE/real(product(ufs_mesh % dimension),8)
! Turn on uniform fission source weighting
ufs = .true.
! Allocate source_frac
allocate(source_frac(1, ufs_mesh % dimension(1), &
ufs_mesh % dimension(2), ufs_mesh % dimension(3)))
end if
! Check if the user has specified to write state points
if (check_for_node(root, "state_point")) then
! Get pointer to state_point node
node_sp = root % child("state_point")
! Determine number of batches at which to store state points
if (check_for_node(node_sp, "batches")) then
n_state_points = node_word_count(node_sp, "batches")
else
n_state_points = 0
end if
if (n_state_points > 0) then
! User gave specific batches to write state points
allocate(temp_int_array(n_state_points))
call get_node_array(node_sp, "batches", temp_int_array)
do i = 1, n_state_points
call statepoint_batch % add(temp_int_array(i))
end do
deallocate(temp_int_array)
else
! If neither were specified, write state point at last batch
n_state_points = 1
call statepoint_batch % add(n_batches)
end if
else
! If no <state_point> tag was present, by default write state point at
! last batch only
n_state_points = 1
call statepoint_batch % add(n_batches)
end if
! Check if the user has specified to write source points
if (check_for_node(root, "source_point")) then
! Get pointer to source_point node
node_sp = root % child("source_point")
! Determine number of batches at which to store source points
if (check_for_node(node_sp, "batches")) then
n_source_points = node_word_count(node_sp, "batches")
else
n_source_points = 0
end if
if (n_source_points > 0) then
! User gave specific batches to write source points
allocate(temp_int_array(n_source_points))
call get_node_array(node_sp, "batches", temp_int_array)
do i = 1, n_source_points
call sourcepoint_batch % add(temp_int_array(i))
end do
deallocate(temp_int_array)
else
! If neither were specified, write source points with state points
n_source_points = n_state_points
do i = 1, n_state_points
call sourcepoint_batch % add(statepoint_batch % get_item(i))
end do
end if
! Check if the user has specified to write binary source file
if (check_for_node(node_sp, "separate")) then
call get_node_value(node_sp, "separate", source_separate)
end if
if (check_for_node(node_sp, "write")) then
call get_node_value(node_sp, "write", source_write)
end if
if (check_for_node(node_sp, "overwrite_latest")) then
call get_node_value(node_sp, "overwrite_latest", source_latest)
source_separate = source_latest
end if
else
! If no <source_point> tag was present, by default we keep source bank in
! statepoint file and write it out at statepoints intervals
source_separate = .false.
n_source_points = n_state_points
do i = 1, n_state_points
call sourcepoint_batch % add(statepoint_batch % get_item(i))
end do
end if
! If source is not seperate and is to be written out in the statepoint file,
! make sure that the sourcepoint batch numbers are contained in the
! statepoint list
if (.not. source_separate) then
do i = 1, n_source_points
if (.not. statepoint_batch % contains(sourcepoint_batch % &
get_item(i))) then
call fatal_error('Sourcepoint batches are not a subset&
& of statepoint batches.')
end if
end do
end if
! Check if the user has specified to not reduce tallies at the end of every
! batch
if (check_for_node(root, "no_reduce")) then
call get_node_value(root, "no_reduce", reduce_tallies)
end if
! Check if the user has specified to use confidence intervals for
! uncertainties rather than standard deviations
if (check_for_node(root, "confidence_intervals")) then
call get_node_value(root, "confidence_intervals", confidence_intervals)
end if
! Check for output options
if (check_for_node(root, "output")) then
! Get pointer to output node
node_output = root % child("output")
! Check for summary option
if (check_for_node(node_output, "summary")) then
call get_node_value(node_output, "summary", output_summary)
end if
! Check for ASCII tallies output option
if (check_for_node(node_output, "tallies")) then
call get_node_value(node_output, "tallies", output_tallies)
end if
! Set output directory if a path has been specified
if (check_for_node(node_output, "path")) then
call get_node_value(node_output, "path", path_output)
if (.not. ends_with(path_output, "/")) &
path_output = trim(path_output) // "/"
end if
end if
! Check for cmfd run
if (check_for_node(root, "run_cmfd")) then
call get_node_value(root, "run_cmfd", cmfd_run)
end if
! Resonance scattering parameters
if (check_for_node(root, "resonance_scattering")) then
node_res_scat = root % child("resonance_scattering")
! See if resonance scattering is enabled
if (check_for_node(node_res_scat, "enable")) then
call get_node_value(node_res_scat, "enable", res_scat_on)
else
res_scat_on = .true.
end if
! Determine what method is used
if (check_for_node(node_res_scat, "method")) then
call get_node_value(node_res_scat, "method", temp_str)
select case(to_lower(temp_str))
case ('ares')
res_scat_method = RES_SCAT_ARES
case ('dbrc')
res_scat_method = RES_SCAT_DBRC
case ('wcm')
res_scat_method = RES_SCAT_WCM
case default
call fatal_error("Unrecognized resonance elastic scattering method: " &
// trim(temp_str) // ".")
end select
end if
! Minimum energy for resonance scattering
if (check_for_node(node_res_scat, "energy_min")) then
call get_node_value(node_res_scat, "energy_min", res_scat_energy_min)
end if
if (res_scat_energy_min < ZERO) then
call fatal_error("Lower resonance scattering energy bound is negative")
end if
! Maximum energy for resonance scattering
if (check_for_node(node_res_scat, "energy_max")) then
call get_node_value(node_res_scat, "energy_max", res_scat_energy_max)
end if
if (res_scat_energy_max < res_scat_energy_min) then
call fatal_error("Upper resonance scattering energy bound is below the &
&lower resonance scattering energy bound.")
end if
! Get nuclides that resonance scattering should be applied to
if (check_for_node(node_res_scat, "nuclides")) then
n = node_word_count(node_res_scat, "nuclides")
allocate(res_scat_nuclides(n))
if (n > 0) then
call get_node_array(node_res_scat, "nuclides", res_scat_nuclides)
end if
end if
end if
call get_node_list(root, "volume_calc", node_vol_list)
n = size(node_vol_list)
allocate(volume_calcs(n))
do i = 1, n
node_vol = node_vol_list(i)
call volume_calcs(i) % from_xml(node_vol)
end do
! Get temperature settings
if (check_for_node(root, "temperature_default")) then
call get_node_value(root, "temperature_default", temperature_default)
end if
if (check_for_node(root, "temperature_method")) then
call get_node_value(root, "temperature_method", temp_str)
select case (to_lower(temp_str))
case ('nearest')
temperature_method = TEMPERATURE_NEAREST
case ('interpolation')
temperature_method = TEMPERATURE_INTERPOLATION
case default
call fatal_error("Unknown temperature method: " // trim(temp_str))
end select
end if
if (check_for_node(root, "temperature_tolerance")) then
call get_node_value(root, "temperature_tolerance", temperature_tolerance)
end if
if (check_for_node(root, "temperature_multipole")) then
call get_node_value(root, "temperature_multipole", temperature_multipole)
end if
! Check for tabular_legendre options
if (check_for_node(root, "tabular_legendre")) then
! Get pointer to tabular_legendre node
node_tab_leg = root % child("tabular_legendre")
! Check for enable option
if (check_for_node(node_tab_leg, "enable")) then
call get_node_value(node_tab_leg, "enable", legendre_to_tabular)
end if
! Check for the number of points
if (check_for_node(node_tab_leg, "num_points")) then
call get_node_value(node_tab_leg, "num_points", &
legendre_to_tabular_points)
if (legendre_to_tabular_points <= 1 .and. (.not. run_CE)) then
call fatal_error("The 'num_points' subelement/attribute of the &
&'tabular_legendre' element must contain a value greater than 1")
end if
end if
end if
! Check whether create fission sites
if (run_mode == MODE_FIXEDSOURCE) then
if (check_for_node(root, "create_fission_neutrons")) then
call get_node_value(root, "create_fission_neutrons", &
create_fission_neutrons)
end if
end if
! Close settings XML file
call doc % clear()
end subroutine read_settings_xml
!===============================================================================
! GET_RUN_PARAMETERS
!===============================================================================
subroutine get_run_parameters(node_base)
type(XMLNode), intent(in) :: node_base
character(MAX_LINE_LEN) :: temp_str
type(XMLNode) :: node_keff_trigger
! Check number of particles