Repository navigation
Expand file tree
/
Copy pathmgxs_library.py
More file actions
2643 lines (2167 loc) · 105 KB
/
Copy pathmgxs_library.py
File metadata and controls
2643 lines (2167 loc) · 105 KB
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
import copy
from numbers import Real, Integral
import h5py
import numpy as np
import scipy.integrate
from scipy.interpolate import interp1d
from scipy.special import eval_legendre
import openmc
import openmc.mgxs
from openmc.mgxs import SCATTER_TABULAR, SCATTER_LEGENDRE, SCATTER_HISTOGRAM
from .checkvalue import check_type, check_value, check_greater_than, \
check_iterable_type, check_less_than, check_filetype_version, PathLike
ROOM_TEMPERATURE_KELVIN = 294.0
# Supported incoming particle MGXS angular treatment representations
REPRESENTATION_ISOTROPIC = 'isotropic'
REPRESENTATION_ANGLE = 'angle'
_REPRESENTATIONS = {
REPRESENTATION_ISOTROPIC,
REPRESENTATION_ANGLE
}
# Supported scattering angular distribution representations
_SCATTER_TYPES = {
SCATTER_TABULAR,
SCATTER_LEGENDRE,
SCATTER_HISTOGRAM
}
# Number of mu points for conversion between scattering formats
_NMU = 257
# Filetype name of the MGXS Library
_FILETYPE_MGXS_LIBRARY = 'mgxs'
# Current version of the MGXS Library Format
_VERSION_MGXS_LIBRARY = 1
class XSdata:
"""A multi-group cross section data set providing all the
multi-group data necessary for a multi-group OpenMC calculation.
Parameters
----------
name : str
Name of the mgxs data set.
energy_groups : openmc.mgxs.EnergyGroups
Energy group structure
representation : {'isotropic', 'angle'}, optional
Method used in generating the MGXS (isotropic or angle-dependent flux
weighting). Defaults to 'isotropic'
temperatures : Iterable of float
Temperatures (in units of Kelvin) of the provided datasets. Defaults
to a single temperature at 294K.
num_delayed_groups : int
Number of delayed groups
Attributes
----------
name : str
Unique identifier for the xsdata object
atomic_weight_ratio : float
Atomic weight ratio of an isotope. That is, the ratio of the mass
of the isotope to the mass of a single neutron.
temperatures : numpy.ndarray
Temperatures (in units of Kelvin) of the provided datasets. Defaults
to a single temperature at 294K.
energy_groups : openmc.mgxs.EnergyGroups
Energy group structure
num_delayed_groups : int
Num delayed groups
fissionable : bool
Whether or not this is a fissionable data set.
scatter_format : {'legendre', 'histogram', or 'tabular'}
Angular distribution representation (legendre, histogram, or tabular)
order : int
Either the Legendre order, number of bins, or number of points used to
describe the angular distribution associated with each group-to-group
transfer probability.
representation : {'isotropic', 'angle'}
Method used in generating the MGXS (isotropic or angle-dependent flux
weighting).
num_azimuthal : int
Number of equal width angular bins that the azimuthal angular domain is
subdivided into. This only applies when :attr:`XSdata.representation`
is "angle".
num_polar : int
Number of equal width angular bins that the polar angular domain is
subdivided into. This only applies when :attr:`XSdata.representation`
is "angle".
total : list of numpy.ndarray
Group-wise total cross section.
absorption : list of numpy.ndarray
Group-wise absorption cross section.
scatter_matrix : list of numpy.ndarray
Scattering moment matrices presented with the columns representing
incoming group and rows representing the outgoing group. That is,
down-scatter will be above the diagonal of the resultant matrix.
multiplicity_matrix : list of numpy.ndarray
Ratio of neutrons produced in scattering collisions to the neutrons
which undergo scattering collisions; that is, the multiplicity provides
the code with a scaling factor to account for neutrons produced in
(n,xn) reactions.
fission : list of numpy.ndarray
Group-wise fission cross section.
kappa_fission : list of numpy.ndarray
Group-wise kappa_fission cross section.
chi : list of numpy.ndarray
Group-wise fission spectra ordered by increasing group index (i.e.,
fast to thermal). This attribute should be used if making the common
approximation that the fission spectra does not depend on incoming
energy. If the user does not wish to make this approximation, then
this should not be provided and this information included in the
:attr:`XSdata.nu_fission` attribute instead.
chi_prompt : list of numpy.ndarray
Group-wise prompt fission spectra ordered by increasing group index
(i.e., fast to thermal). This attribute should be used if chi from
prompt and delayed neutrons is being set separately.
chi_delayed : list of numpy.ndarray
Group-wise delayed fission spectra ordered by increasing group index
(i.e., fast to thermal). This attribute should be used if chi from
prompt and delayed neutrons is being set separately.
nu_fission : list of numpy.ndarray
Group-wise fission production cross section vector (i.e., if ``chi`` is
provided), or is the group-wise fission production matrix.
prompt_nu_fission : list of numpy.ndarray
Group-wise prompt fission production cross section vector.
delayed_nu_fission : list of numpy.ndarray
Group-wise delayed fission production cross section vector.
beta : list of numpy.ndarray
Delayed-group-wise delayed neutron fraction cross section vector.
decay_rate : list of numpy.ndarray
Delayed-group-wise decay rate vector.
inverse_velocity : list of numpy.ndarray
Inverse of velocity, in units of sec/cm.
xs_shapes : dict of iterable of int
Dictionary with keys of _XS_SHAPES and iterable of int values with the
corresponding shapes where "Order" corresponds to the pn scattering
order, "G" corresponds to incoming energy group, "G'" corresponds to
outgoing energy group, and "DG" corresponds to delayed group.
Notes
-----
The parameters containing cross section data have dimensionalities which
depend upon the value of :attr:`XSdata.representation` as well as the
number of Legendre or other angular dimensions as described by
:attr:`XSdata.order`. The :attr:`XSdata.xs_shapes` are provided to obtain
the dimensionality of the data for each temperature.
The following are cross sections which should use each of the properties.
Note that some cross sections can be input in more than one shape so they
are listed multiple times:
[G][G'][Order]: scatter_matrix
[G]: total, absorption, fission, kappa_fission, nu_fission,
prompt_nu_fission, delayed_nu_fission, inverse_velocity
[G']: chi, chi_prompt, chi_delayed
[G][G']: multiplicity_matrix, nu_fission, prompt_nu_fission
[DG]: beta, decay_rate
[DG][G]: delayed_nu_fission, beta, decay_rate
[DG][G']: chi_delayed
[DG][G][G']: delayed_nu_fission
"""
def __init__(self, name, energy_groups, temperatures=[ROOM_TEMPERATURE_KELVIN],
representation=REPRESENTATION_ISOTROPIC, num_delayed_groups=0):
# Initialize class attributes
self.name = name
self.energy_groups = energy_groups
self.num_delayed_groups = num_delayed_groups
self.temperatures = temperatures
self.representation = representation
self._atomic_weight_ratio = None
self._fissionable = False
self._scatter_format = SCATTER_LEGENDRE
self._order = None
self._num_polar = None
self._num_azimuthal = None
self._total = len(temperatures) * [None]
self._absorption = len(temperatures) * [None]
self._scatter_matrix = len(temperatures) * [None]
self._multiplicity_matrix = len(temperatures) * [None]
self._fission = len(temperatures) * [None]
self._nu_fission = len(temperatures) * [None]
self._prompt_nu_fission = len(temperatures) * [None]
self._delayed_nu_fission = len(temperatures) * [None]
self._kappa_fission = len(temperatures) * [None]
self._chi = len(temperatures) * [None]
self._chi_prompt = len(temperatures) * [None]
self._chi_delayed = len(temperatures) * [None]
self._beta = len(temperatures) * [None]
self._decay_rate = len(temperatures) * [None]
self._inverse_velocity = len(temperatures) * [None]
self._xs_shapes = None
def __deepcopy__(self, memo):
existing = memo.get(id(self))
# If this is the first time we have tried to copy this object, copy it
if existing is None:
clone = type(self).__new__(type(self))
clone._name = self.name
clone._energy_groups = copy.deepcopy(self.energy_groups, memo)
clone._num_delayed_groups = self.num_delayed_groups
clone._temperatures = copy.deepcopy(self.temperatures, memo)
clone._representation = self.representation
clone._atomic_weight_ratio = self._atomic_weight_ratio
clone._fissionable = self._fissionable
clone._scatter_format = self._scatter_format
clone._order = self._order
clone._num_polar = self._num_polar
clone._num_azimuthal = self._num_azimuthal
clone._total = copy.deepcopy(self._total, memo)
clone._absorption = copy.deepcopy(self._absorption, memo)
clone._scatter_matrix = copy.deepcopy(self._scatter_matrix, memo)
clone._multiplicity_matrix = \
copy.deepcopy(self._multiplicity_matrix, memo)
clone._fission = copy.deepcopy(self._fission, memo)
clone._nu_fission = copy.deepcopy(self._nu_fission, memo)
clone._prompt_nu_fission = \
copy.deepcopy(self._prompt_nu_fission, memo)
clone._delayed_nu_fission = \
copy.deepcopy(self._delayed_nu_fission, memo)
clone._kappa_fission = copy.deepcopy(self._kappa_fission, memo)
clone._chi = copy.deepcopy(self._chi, memo)
clone._chi_prompt = copy.deepcopy(self._chi_prompt, memo)
clone._chi_delayed = copy.deepcopy(self._chi_delayed, memo)
clone._beta = copy.deepcopy(self._beta, memo)
clone._decay_rate = copy.deepcopy(self._decay_rate, memo)
clone._inverse_velocity = \
copy.deepcopy(self._inverse_velocity, memo)
clone._xs_shapes = copy.deepcopy(self._xs_shapes, memo)
memo[id(self)] = clone
return clone
# If this object has been copied before, return the first copy made
else:
return existing
@property
def name(self):
return self._name
@name.setter
def name(self, name):
check_type('name for XSdata', name, str)
self._name = name
@property
def energy_groups(self):
return self._energy_groups
@energy_groups.setter
def energy_groups(self, energy_groups):
check_type('energy_groups', energy_groups, openmc.mgxs.EnergyGroups)
if energy_groups.group_edges is None:
msg = 'Unable to assign an EnergyGroups object ' \
'with uninitialized group edges'
raise ValueError(msg)
self._energy_groups = energy_groups
@property
def num_delayed_groups(self):
return self._num_delayed_groups
@num_delayed_groups.setter
def num_delayed_groups(self, num_delayed_groups):
check_type('num_delayed_groups', num_delayed_groups, Integral)
check_less_than('num_delayed_groups', num_delayed_groups,
openmc.mgxs.MAX_DELAYED_GROUPS, equality=True)
check_greater_than('num_delayed_groups', num_delayed_groups, 0,
equality=True)
self._num_delayed_groups = num_delayed_groups
@property
def representation(self):
return self._representation
@representation.setter
def representation(self, representation):
check_value('representation', representation, _REPRESENTATIONS)
self._representation = representation
@property
def atomic_weight_ratio(self):
return self._atomic_weight_ratio
@atomic_weight_ratio.setter
def atomic_weight_ratio(self, atomic_weight_ratio):
check_type('atomic_weight_ratio', atomic_weight_ratio, Real)
check_greater_than('atomic_weight_ratio', atomic_weight_ratio, 0.0)
self._atomic_weight_ratio = atomic_weight_ratio
@property
def fissionable(self):
return self._fissionable
@property
def temperatures(self):
return self._temperatures
@temperatures.setter
def temperatures(self, temperatures):
check_iterable_type('temperatures', temperatures, Real)
self._temperatures = np.array(temperatures)
@property
def scatter_format(self):
return self._scatter_format
@scatter_format.setter
def scatter_format(self, scatter_format):
check_value('scatter_format', scatter_format, _SCATTER_TYPES)
self._scatter_format = scatter_format
@property
def order(self):
return self._order
@order.setter
def order(self, order):
check_type('order', order, Integral)
check_greater_than('order', order, 0, equality=True)
self._order = order
@property
def num_polar(self):
return self._num_polar
@num_polar.setter
def num_polar(self, num_polar):
check_type('num_polar', num_polar, Integral)
check_greater_than('num_polar', num_polar, 0)
self._num_polar = num_polar
@property
def num_azimuthal(self):
return self._num_azimuthal
@num_azimuthal.setter
def num_azimuthal(self, num_azimuthal):
check_type('num_azimuthal', num_azimuthal, Integral)
check_greater_than('num_azimuthal', num_azimuthal, 0)
self._num_azimuthal = num_azimuthal
@property
def total(self):
return self._total
@property
def absorption(self):
return self._absorption
@property
def scatter_matrix(self):
return self._scatter_matrix
@property
def multiplicity_matrix(self):
return self._multiplicity_matrix
@property
def fission(self):
return self._fission
@property
def nu_fission(self):
return self._nu_fission
@property
def prompt_nu_fission(self):
return self._prompt_nu_fission
@property
def delayed_nu_fission(self):
return self._delayed_nu_fission
@property
def kappa_fission(self):
return self._kappa_fission
@property
def chi(self):
return self._chi
@property
def chi_prompt(self):
return self._chi_prompt
@property
def chi_delayed(self):
return self._chi_delayed
@property
def beta(self):
return self._beta
@property
def decay_rate(self):
return self._decay_rate
@property
def inverse_velocity(self):
return self._inverse_velocity
@property
def num_orders(self):
if self._order is None:
raise ValueError('Order has not been set.')
if self._scatter_format in (None, SCATTER_LEGENDRE):
return self._order + 1
else:
return self._order
@property
def xs_shapes(self):
if self._xs_shapes is None:
self._xs_shapes = {}
self._xs_shapes["[G]"] = (self.energy_groups.num_groups,)
self._xs_shapes["[G']"] = (self.energy_groups.num_groups,)
self._xs_shapes["[G][G']"] = (self.energy_groups.num_groups,
self.energy_groups.num_groups)
self._xs_shapes["[DG]"] = (self.num_delayed_groups,)
self._xs_shapes["[DG][G]"] = (self.num_delayed_groups,
self.energy_groups.num_groups)
self._xs_shapes["[DG][G']"] = (self.num_delayed_groups,
self.energy_groups.num_groups)
self._xs_shapes["[DG][G][G']"] = (self.num_delayed_groups,
self.energy_groups.num_groups,
self.energy_groups.num_groups)
self._xs_shapes["[G][G'][Order]"] \
= (self.energy_groups.num_groups,
self.energy_groups.num_groups, self.num_orders)
# If representation is by angle prepend num polar and num azim
if self.representation == REPRESENTATION_ANGLE:
for key, shapes in self._xs_shapes.items():
self._xs_shapes[key] \
= (self.num_polar, self.num_azimuthal) + shapes
return self._xs_shapes
def add_temperature(self, temperature):
"""This method re-sizes the attributes of this XSdata object so that it
can accommodate an additional temperature. Note that the set_* methods
will still need to be executed.
Parameters
----------
temperature : float
Temperature (in units of Kelvin) of the provided dataset.
"""
check_type('temperature', temperature, Real)
temp_store = self.temperatures.tolist()
temp_store.append(temperature)
self.temperatures = temp_store
self._total.append(None)
self._absorption.append(None)
self._scatter_matrix.append(None)
self._multiplicity_matrix.append(None)
self._fission.append(None)
self._nu_fission.append(None)
self._prompt_nu_fission.append(None)
self._delayed_nu_fission.append(None)
self._kappa_fission.append(None)
self._chi.append(None)
self._chi_prompt.append(None)
self._chi_delayed.append(None)
self._beta.append(None)
self._decay_rate.append(None)
self._inverse_velocity.append(None)
def _check_temperature(self, temperature):
check_type('temperature', temperature, Real)
check_value('temperature', temperature, self.temperatures)
def _temperature_index(self, temperature):
return np.where(self.temperatures == temperature)[0][0]
def _set_fissionable(self, array):
if np.sum(array) > 0:
self._fissionable = True
def add_temperature_data(self, other):
"""This method adds temperature-dependent cross section
values from another XSdata object to this XSdata object.
Note: if a temperature datapoint from 'other' already exists in this
object, it will be overridden.
Parameters
----------
other: openmc.XSdata
The other XSdata object to fetch data from
"""
# Sanity check to make sure they have the same name, energy group structure,
# and delayed group structure
check_value('name', other.name, self.name)
check_value('energy_groups', other.energy_groups, [self.energy_groups])
check_value('delayed_groups', other.num_delayed_groups, [self.num_delayed_groups])
# Add the temperature data.
for temp in other.temperatures:
if temp not in self.temperatures:
self.add_temperature(temp)
if np.all(other.absorption[other._temperature_index(temp)] != None):
self.set_absorption(other.absorption[other._temperature_index(temp)], temp)
if np.all(other.beta[other._temperature_index(temp)] != None):
self.set_beta(other.beta[other._temperature_index(temp)], temp)
if np.all(other.chi[other._temperature_index(temp)] != None):
self.set_chi(other.chi[other._temperature_index(temp)], temp)
if np.all(other.chi_delayed[other._temperature_index(temp)] != None):
self.set_chi_delayed(other.chi_delayed[other._temperature_index(temp)], temp)
if np.all(other.chi_prompt[other._temperature_index(temp)] != None):
self.set_chi_prompt(other.chi_prompt[other._temperature_index(temp)], temp)
if np.all(other.decay_rate[other._temperature_index(temp)] != None):
self.set_decay_rate(other.decay_rate[other._temperature_index(temp)], temp)
if np.all(other.delayed_nu_fission[other._temperature_index(temp)] != None):
self.set_delayed_nu_fission(other.delayed_nu_fission[other._temperature_index(temp)], temp)
if np.all(other.fission[other._temperature_index(temp)] != None):
self.set_fission(other.fission[other._temperature_index(temp)], temp)
if np.all(other.inverse_velocity[other._temperature_index(temp)] != None):
self.set_inverse_velocity(other.inverse_velocity[other._temperature_index(temp)], temp)
if np.all(other.kappa_fission[other._temperature_index(temp)] != None):
self.set_kappa_fission(other.kappa_fission[other._temperature_index(temp)], temp)
if np.all(other.multiplicity_matrix[other._temperature_index(temp)] != None):
self.set_multiplicity_matrix(other.multiplicity_matrix[other._temperature_index(temp)], temp)
if np.all(other.nu_fission[other._temperature_index(temp)] != None):
self.set_nu_fission(other.nu_fission[other._temperature_index(temp)], temp)
if np.all(other.prompt_nu_fission[other._temperature_index(temp)] != None):
self.set_prompt_nu_fission(other.prompt_nu_fission[other._temperature_index(temp)], temp)
if np.all(other.scatter_matrix[other._temperature_index(temp)] != None):
self.set_scatter_matrix(other.scatter_matrix[other._temperature_index(temp)], temp)
if np.all(other.fission[other._temperature_index(temp)] != None):
self.set_total(other.total[other._temperature_index(temp)], temp)
def set_total(self, total, temperature=ROOM_TEMPERATURE_KELVIN):
"""This method sets the cross section for this XSdata object at the
provided temperature.
Parameters
----------
total: np.ndarray
Total Cross Section
temperature : float
Temperature (in Kelvin) of the data. Defaults to room temperature
(294K).
See also
--------
openmc.mgxs_library.set_total_mgxs()
"""
# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G]"]]
# Convert to a numpy array so we can easily get the shape for checking
total = np.asarray(total)
check_value('total shape', total.shape, shapes)
self._check_temperature(temperature)
i = self._temperature_index(temperature)
self._total[i] = total
def set_absorption(self, absorption, temperature=ROOM_TEMPERATURE_KELVIN):
"""This method sets the cross section for this XSdata object at the
provided temperature.
Parameters
----------
absorption: np.ndarray
Absorption Cross Section
temperature : float
Temperature (in Kelvin) of the data. Defaults to room temperature
(294K).
See also
--------
openmc.mgxs_library.set_absorption_mgxs()
"""
# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G]"]]
# Convert to a numpy array so we can easily get the shape for checking
absorption = np.asarray(absorption)
check_value('absorption shape', absorption.shape, shapes)
self._check_temperature(temperature)
i = self._temperature_index(temperature)
self._absorption[i] = absorption
def set_fission(self, fission, temperature=ROOM_TEMPERATURE_KELVIN):
"""This method sets the cross section for this XSdata object at the
provided temperature.
Parameters
----------
fission: np.ndarray
Fission Cross Section
temperature : float
Temperature (in Kelvin) of the data. Defaults to room temperature
(294K).
See also
--------
openmc.mgxs_library.set_fission_mgxs()
"""
# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G]"]]
# Convert to a numpy array so we can easily get the shape for checking
fission = np.asarray(fission)
check_value('fission shape', fission.shape, shapes)
self._check_temperature(temperature)
i = self._temperature_index(temperature)
self._fission[i] = fission
self._set_fissionable(fission)
def set_kappa_fission(self, kappa_fission, temperature=ROOM_TEMPERATURE_KELVIN):
"""This method sets the cross section for this XSdata object at the
provided temperature.
Parameters
----------
kappa_fission: np.ndarray
Kappa-Fission Cross Section
temperature : float
Temperature (in Kelvin) of the data. Defaults to room temperature
(294K).
See also
--------
openmc.mgxs_library.set_kappa_fission_mgxs()
"""
# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G]"]]
# Convert to a numpy array so we can easily get the shape for checking
kappa_fission = np.asarray(kappa_fission)
check_value('kappa fission shape', kappa_fission.shape, shapes)
self._check_temperature(temperature)
i = self._temperature_index(temperature)
self._kappa_fission[i] = kappa_fission
self._set_fissionable(kappa_fission)
def set_chi(self, chi, temperature=ROOM_TEMPERATURE_KELVIN):
"""This method sets the cross section for this XSdata object at the
provided temperature.
Parameters
----------
chi: np.ndarray
Fission Spectrum
temperature : float
Temperature (in Kelvin) of the data. Defaults to room temperature
(294K).
See also
--------
openmc.mgxs_library.set_chi_mgxs()
"""
# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G']"]]
# Convert to a numpy array so we can easily get the shape for checking
chi = np.asarray(chi)
check_value('chi shape', chi.shape, shapes)
self._check_temperature(temperature)
i = self._temperature_index(temperature)
self._chi[i] = chi
def set_chi_prompt(self, chi_prompt, temperature=ROOM_TEMPERATURE_KELVIN):
"""This method sets the cross section for this XSdata object at the
provided temperature.
Parameters
----------
chi_prompt : np.ndarray
Prompt fission Spectrum
temperature : float
Temperature (in units of Kelvin) of the provided dataset. Defaults
to 294K
See also
--------
openmc.mgxs_library.set_chi_prompt_mgxs()
"""
# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G']"]]
# Convert to a numpy array so we can easily get the shape for checking
chi_prompt = np.asarray(chi_prompt)
check_value('chi prompt shape', chi_prompt.shape, shapes)
self._check_temperature(temperature)
i = self._temperature_index(temperature)
self._chi_prompt[i] = chi_prompt
def set_chi_delayed(self, chi_delayed, temperature=ROOM_TEMPERATURE_KELVIN):
"""This method sets the cross section for this XSdata object at the
provided temperature.
Parameters
----------
chi_delayed : np.ndarray
Delayed fission Spectrum
temperature : float
Temperature (in units of Kelvin) of the provided dataset. Defaults
to 294K
See also
--------
openmc.mgxs_library.set_chi_delayed_mgxs()
"""
# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G']"], self.xs_shapes["[DG][G']"]]
# Convert to a numpy array so we can easily get the shape for checking
chi_delayed = np.asarray(chi_delayed)
check_value('chi delayed shape', chi_delayed.shape, shapes)
self._check_temperature(temperature)
check_type('temperature', temperature, Real)
check_value('temperature', temperature, self.temperatures)
i = self._temperature_index(temperature)
self._chi_delayed[i] = chi_delayed
def set_beta(self, beta, temperature=ROOM_TEMPERATURE_KELVIN):
"""This method sets the cross section for this XSdata object at the
provided temperature.
Parameters
----------
beta : np.ndarray
Delayed fission spectrum
temperature : float
Temperature (in units of Kelvin) of the provided dataset. Defaults
to 294K
See also
--------
openmc.mgxs_library.set_beta_mgxs()
"""
# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[DG]"], self.xs_shapes["[DG][G]"]]
# Convert to a numpy array so we can easily get the shape for checking
beta = np.asarray(beta)
check_value('beta shape', beta.shape, shapes)
self._check_temperature(temperature)
i = self._temperature_index(temperature)
self._beta[i] = beta
def set_decay_rate(self, decay_rate, temperature=ROOM_TEMPERATURE_KELVIN):
"""This method sets the cross section for this XSdata object at the
provided temperature.
Parameters
----------
decay_rate : np.ndarray
Delayed neutron precursor decay rate
temperature : float
Temperature (in units of Kelvin) of the provided dataset. Defaults
to 294K
See also
--------
openmc.mgxs_library.set_decay_rate_mgxs()
"""
# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[DG]"]]
# Convert to a numpy array so we can easily get the shape for checking
decay_rate = np.asarray(decay_rate)
check_value('decay rate shape', decay_rate.shape, shapes)
self._check_temperature(temperature)
i = self._temperature_index(temperature)
self._decay_rate[i] = decay_rate
def set_scatter_matrix(self, scatter, temperature=ROOM_TEMPERATURE_KELVIN):
"""This method sets the cross section for this XSdata object at the
provided temperature.
Parameters
----------
scatter: np.ndarray
Scattering Matrix Cross Section
temperature : float
Temperature (in Kelvin) of the data. Defaults to room temperature
(294K).
See also
--------
openmc.mgxs_library.set_scatter_matrix_mgxs()
"""
# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G][G'][Order]"]]
# Convert to a numpy array so we can easily get the shape for checking
scatter = np.asarray(scatter)
check_iterable_type('scatter', scatter, Real,
max_depth=len(scatter.shape))
check_value('scatter shape', scatter.shape, shapes)
self._check_temperature(temperature)
i = self._temperature_index(temperature)
self._scatter_matrix[i] = scatter
def set_multiplicity_matrix(self, multiplicity, temperature=ROOM_TEMPERATURE_KELVIN):
"""This method sets the cross section for this XSdata object at the
provided temperature.
Parameters
----------
multiplicity: np.ndarray
Multiplicity Matrix Cross Section
temperature : float
Temperature (in Kelvin) of the data. Defaults to room temperature
(294K).
See also
--------
openmc.mgxs_library.set_multiplicity_matrix_mgxs()
"""
# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G][G']"]]
# Convert to a numpy array so we can easily get the shape for checking
multiplicity = np.asarray(multiplicity)
check_iterable_type('multiplicity', multiplicity, Real,
max_depth=len(multiplicity.shape))
check_value('multiplicity shape', multiplicity.shape, shapes)
self._check_temperature(temperature)
i = self._temperature_index(temperature)
self._multiplicity_matrix[i] = multiplicity
def set_nu_fission(self, nu_fission, temperature=ROOM_TEMPERATURE_KELVIN):
"""This method sets the cross section for this XSdata object at the
provided temperature.
Parameters
----------
nu_fission: np.ndarray
Nu-fission Cross Section
temperature : float
Temperature (in Kelvin) of the data. Defaults to room temperature
(294K).
See also
--------
openmc.mgxs_library.set_nu_fission_mgxs()
"""
# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G]"], self.xs_shapes["[G][G']"]]
# Convert to a numpy array so we can easily get the shape for checking
nu_fission = np.asarray(nu_fission)
check_value('nu_fission shape', nu_fission.shape, shapes)
check_iterable_type('nu_fission', nu_fission, Real,
max_depth=len(nu_fission.shape))
self._check_temperature(temperature)
i = self._temperature_index(temperature)
self._nu_fission[i] = nu_fission
self._set_fissionable(nu_fission)
def set_prompt_nu_fission(self, prompt_nu_fission, temperature=ROOM_TEMPERATURE_KELVIN):
"""This method sets the cross section for this XSdata object at the
provided temperature.
Parameters
----------
prompt_nu_fission: np.ndarray
Prompt-nu-fission Cross Section
temperature : float
Temperature (in units of Kelvin) of the provided dataset. Defaults
to 294K
See also
--------
openmc.mgxs_library.set_prompt_nu_fission_mgxs()
"""
# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[G]"], self.xs_shapes["[G][G']"]]
# Convert to a numpy array so we can easily get the shape for checking
prompt_nu_fission = np.asarray(prompt_nu_fission)
check_value('prompt_nu_fission shape', prompt_nu_fission.shape, shapes)
check_iterable_type('prompt_nu_fission', prompt_nu_fission, Real,
max_depth=len(prompt_nu_fission.shape))
self._check_temperature(temperature)
i = self._temperature_index(temperature)
self._prompt_nu_fission[i] = prompt_nu_fission
self._set_fissionable(prompt_nu_fission)
def set_delayed_nu_fission(self, delayed_nu_fission, temperature=ROOM_TEMPERATURE_KELVIN):
"""This method sets the cross section for this XSdata object at the
provided temperature.
Parameters
----------
delayed_nu_fission: np.ndarray
Delayed-nu-fission Cross Section
temperature : float
Temperature (in units of Kelvin) of the provided dataset. Defaults
to 294K
See also
--------
openmc.mgxs_library.set_delayed_nu_fission_mgxs()
"""
# Get the accepted shapes for this xs
shapes = [self.xs_shapes["[DG][G]"], self.xs_shapes["[DG][G][G']"]]