@@ -533,14 +533,15 @@ def get_photon_contact_dose_rate(self, by_nuclide: bool = False) -> float | dic
533533 mu_en_x , mu_en_y = mu_en_coefficients ("air" , data_source = "nist126" )
534534 mu_en_air = Tabulated1D (mu_en_x , mu_en_y , breakpoints = [len (mu_en_x )], interpolation = [5 ])
535535
536- mu_en_x_low = mu_en_air .x [0 ]
537- mu_en_x_high = mu_en_air .x [- 1 ]
538536
539537 # photon mass attenuation distribution as a function of energy
540538 # distribution values in [cm2/g]
541539 mass_attenuation_dist = self .get_photon_mass_attenuation ()
542540 if mass_attenuation_dist is None :
543541 raise ValueError ("Cannot compute photon mass attenuation for material" )
542+ mass_attenuation_e_lists = []
543+ for photon_xs in mass_attenuation_dist .functions :
544+ mass_attenuation_e_lists .append (photon_xs .x )
544545
545546 # CDR computation
546547 cdr = {}
@@ -579,8 +580,19 @@ def get_photon_contact_dose_rate(self, by_nuclide: bool = False) -> float | dic
579580 e_vals = np .array (photon_source_per_atom .x )
580581 p_vals = np .array (photon_source_per_atom .p )
581582
582- # clip distributions for values outside the air tabulated values
583- mask = (e_vals >= mu_en_x_low ) & (e_vals <= mu_en_x_high )
583+ # remove initial zero value
584+ if p_vals [0 ] == 0.0 :
585+ p_vals = p_vals [1 :]
586+ e_vals = e_vals [1 :]
587+
588+ e_lists = [e_vals , mu_en_air .x ]
589+ e_lists .extend (mass_attenuation_e_lists )
590+
591+ # clip distributions for values outside the tabulated values
592+ left_bound = max (a .min () for a in e_lists ) # 10
593+ right_bound = min (a .max () for a in e_lists )
594+
595+ mask = (e_vals >= left_bound ) & (e_vals <= right_bound )
584596 e_vals = e_vals [mask ]
585597 p_vals = p_vals [mask ]
586598
@@ -602,11 +614,8 @@ def get_photon_contact_dose_rate(self, by_nuclide: bool = False) -> float | dic
602614
603615 elif isinstance (photon_source_per_atom , Tabular ):
604616
605- # fix zero p values in tabular spectrum
617+ # fix zero p values in last tabular value - histogram formalism
606618 p_vals [- 1 ] = p_vals [- 2 ] if p_vals [- 1 ] == 0.0 else p_vals [- 1 ]
607- if p_vals [0 ] == 0.0 :
608- p_vals = p_vals [1 :]
609- e_vals = e_vals [1 :]
610619
611620 # generate the tabulated1D functions
612621 e_p_dist = Tabulated1D (
@@ -616,15 +625,10 @@ def get_photon_contact_dose_rate(self, by_nuclide: bool = False) -> float | dic
616625 e_vals , e_vals , breakpoints = [len (e_vals )], interpolation = [2 ]
617626 )
618627
619- # generate a union of abscissae
620- e_lists = [e_vals , mu_en_air .x ]
621- for photon_xs in mass_attenuation_dist .functions :
622- e_lists .append (photon_xs .x )
623- e_union = reduce (np .union1d , e_lists )
624628
625629 # limit the computation to the tabulated mu_en_air range
626- mask = ( e_union >= mu_en_x_low ) & ( e_union <= mu_en_x_high )
627- e_union = e_union [mask ]
630+ e_union = reduce ( np . union1d , e_lists )
631+ e_union = e_union [( e_union >= left_bound ) & ( e_union <= right_bound ) ]
628632 if len (e_union ) < 2 :
629633 raise ValueError ("Not enough overlapping energy points to compute CDR" )
630634
0 commit comments