def getW_XYs(self): from xData import axes as axesModule from xData import XYs as XYsModule from xData import multiD_XYs as multiD_XYsModule xUnit, yUnit, zUnit = '', '', '' if (self.xUnit is not None): xUnit = self.xUnit if (self.yUnit is not None): yUnit = self.yUnit if (self.zUnit is not None): zUnit = self.zUnit axes_3d = axesModule.axes(3) axes_3d[0] = axesModule.axis('z', 0, zUnit) axes_3d[1] = axesModule.axis('y', 0, yUnit) axes_3d[2] = axesModule.axis('x', 0, xUnit) w_xys = multiD_XYsModule.multiD_XYs(axes=axes_3d) axes_2d = axesModule.axes() axes_2d[0] = axes_3d[0] axes_2d[1] = axes_3d[1] for ix, x in enumerate(self.x): xys = [[y, self.z[iy][ix]] for iy, y in enumerate(self.y)] w_xys[ix] = XYsModule.XYs(xys, axes=axes_2d, accuracy=1e-3, value=x) return (w_xys)
def defaultAxes(energyUnit): axes = axesModule.axes(rank=3) axes[0] = axesModule.axis('P(mu|energy_in)', 0, '') axes[1] = axesModule.axis('mu', 1, '') axes[2] = axesModule.axis('energy_in', 2, energyUnit) return (axes)
def toEnergyFunctionalData(info, dataLine, MF5Data, LF, moniker, unit, xLabel='energy_in', xUnit='eV'): import fudge.gnd.productData.distributions.energy as energyModule axes = axesModule.axes(labelsUnits={ 0: (moniker, unit), 1: (xLabel, xUnit) }) dataLine, TAB1, data = getTAB1Regions(dataLine, MF5Data, logFile=info.logs, axes=axes) EFclass = None for tmp in (energyModule.a, energyModule.b, energyModule.theta, energyModule.g, energyModule.T_M): if (tmp.moniker == moniker): EFclass = tmp if (len(data) == 1): oneD = data[0] else: oneD = regionsModule.regions1d(axes=data[0].axes) for datum in data: oneD.append(datum) return (dataLine, TAB1, EFclass(oneD))
def toMultiGroup1d( cls, style, tempInfo, _axes, data, addLabel = True ) : """ This function takes 1-d multi-group data as a list of floats and return to 1-d gridded instance containing the multi-group data. The list of data must contain n values where n is the number of groups. """ reactionSuite = tempInfo['reactionSuite'] axes = axesModule.axes( rank = 2 ) axes[0] = axesModule.axis( _axes[0].label, 0, _axes[0].unit ) energyInGrid = style.transportables[reactionSuite.projectile].group.boundaries.values.copy( ) axes[1] = axesModule.grid( _axes[1].label, 1, _axes[1].unit, axesModule.boundariesGridToken, energyInGrid ) shape = [ len( data ) ] data = valuesModule.values( data ) for start, datum in enumerate( data ) : if( datum != 0 ) : break end = 0 for i1, datum in enumerate( data ) : if( datum != 0 ) : end = i1 if( start > end ) : # Only happens when all values are 0. start = 0 else : end += 1 data = data[start:end] starts = valuesModule.values( [ start ], valueType = standardsModule.types.integer32Token ) lengths = valuesModule.values( [ len( data ) ], valueType = standardsModule.types.integer32Token ) flattened = arrayModule.flattened( shape = shape, data = data, starts = starts, lengths = lengths ) label = None if( addLabel ) : label = style.label return( cls( label = label, axes = axes, array = flattened ) )
def defaultAxes(energyUnit='eV', crossSectionUnit='b'): axes = axesModule.axes(rank=2) axes[0] = axesModule.axis(baseModule.crossSectionToken, 0, crossSectionUnit) axes[1] = axesModule.axis('energy_in', 1, energyUnit) return (axes)
def defaultAxes( energyUnit ) : axes = axesModule.axes( ) # BRB6 make 'energy_in' a token axes[1] = axesModule.axis( 'energy_in', 0, energyUnit ) axes[0] = axesModule.axis( component.moniker, 1, energyUnit ) return( axes )
def calculateMomentumPoints( massInE, EMin, EMax, energyUnit, accuracy = 1e-4 ) : """ This is a temporary function (hopefully) to calculate momentum vs E. What is really needed is a function like rriint in mcfgen. """ import math momentum = [] def insertPointIfNeeded( Ep1, Ep2 ) : E1, p1 = Ep1 E2, p2 = Ep2 s = ( p2 - p1 ) / ( E2 - E1 ) Em = massInE / ( 2. * s * s ) pc = math.sqrt( 2 * massInE * Em ) pi = s * ( Em - E1 ) + p1 if( abs( pi / pc - 1 ) > accuracy ) : m = [ Em, pc ] momentum.append( m ) insertPointIfNeeded( Ep1, m ) insertPointIfNeeded( m, Ep2 ) if( massInE == 0 ) : # gammas momentum.append( [ EMin, EMin ] ) momentum.append( [ EMax, EMax ] ) else : momentum.append( [ EMin, math.sqrt( 2 * massInE * EMin ) ] ) momentum.append( [ EMax, math.sqrt( 2 * massInE * EMax ) ] ) insertPointIfNeeded( momentum[0], momentum[1] ) momentum.sort( ) axes = axesModule.axes( labelsUnits = { 0 : [ 'energy_in', energyUnit ], 1 : [ 'momentum', energyUnit + '/c' ] } ) return( XYsModule.XYs1d( data = momentum, axes = axes, accuracy = accuracy ) )
def defaultAxes(energyUnit, momentumDepositionUnit): axes = axesModule.axes(rank=2) axes[0] = axesModule.axis('averageProductMomentum', 0, momentumDepositionUnit) axes[1] = axesModule.axis('energy_in', 1, energyUnit) return (axes)
def defaultAxes(energyUnit): axes = axesModule.axes(rank=4) axes[3] = axesModule.axis('l', 3, '') axes[2] = axesModule.axis('energy_in', 2, energyUnit) axes[1] = axesModule.axis('energy_out', 1, energyUnit) axes[0] = axesModule.axis('c_l', 0, '1/' + energyUnit) return (axes)
def defaultAxes( energyUnit, probabilityLabel = 'P(mu,energy_out|energy_in)' ) : axes = axesModule.axes( rank = 4 ) axes[3] = axesModule.axis( 'energy_in', 3, energyUnit ) axes[2] = axesModule.axis( 'mu', 2, '' ) axes[1] = axesModule.axis( 'energy_out', 1, energyUnit ) axes[0] = axesModule.axis( probabilityLabel, 0, '1/' + energyUnit ) return( axes )
def getFluxAtLegendreOrder(self, order): axes = axesModule.axes() axes[1] = self.axes[2].copy([]) axes[0] = self.axes[0].copy([]) for LS in self: if (len(LS) > 1): raise Exception('FIXME -- next line is wrong.') return (XYsModule.XYs1d([[LS.value, LS[0]] for LS in self], axes=axes))
def defaultAxes(): axes = axesModule.axes(rank=4) axes[0] = axesModule.axis('c_l', 0, '1/MeV') axes[1] = axesModule.axis('energy_out', 1, 'MeV') axes[2] = axesModule.axis('energy_in', 2, 'MeV') axes[3] = axesModule.axis('l', 3, '') return (axes)
def defaultAxes(energyUnit='eV'): axes = axesModule.axes(rank=3) axes[0] = axesModule.axis('P(energy_out|energy_in)', 0, '1/' + energyUnit) axes[1] = axesModule.axis('energy_out', 1, energyUnit) axes[2] = axesModule.axis('energy_in', 2, energyUnit) return (axes)
def energyFunctionToString( energyData, weight = None ) : def getParameter( data, label ) : _linlin = data.toPointwise_withLinearXYs( lowerEps = lowerEps, upperEps = upperEps ) sData = [ startOfNewData, "%s: n = %d" % ( label, len( _linlin ) ) ] sData.append( 'Interpolation: %s' % linlin ) for x, y in _linlin : sData.append( '%s %s' % ( x, y ) ) return( sData ) sData = [] if( isinstance( energyData, ( energyModule.simpleMaxwellianFissionSpectrum, energyModule.evaporationSpectrum, energyModule.WattSpectrum ) ) ) : sData.append( 'U: %s' % energyData.U.getValueAs( energyData.parameter1.data.axes[-1].unit ) ) parameter1 = energyData.parameter1.data.toPointwise_withLinearXYs( accuracy = 1e-5, lowerEps = lowerEps, upperEps = upperEps ) if( energyData.parameter2 is not None ) : parameter2 = energyData.parameter2.data.toPointwise_withLinearXYs( accuracy = 1e-5, lowerEps = lowerEps, upperEps = upperEps ) if( weight is None ) : axes = axesModule.axes( ) weight = XYsModule.XYs1d( data = [ [ parameter1.domainMin, 1. ], [ parameter1.domainMax, 1. ] ], axes = axes ) else : weight = weight.weight sData += twoDToString( "weight", weight, addExtraBlankLine = False ) if( isinstance( energyData, energyModule.generalEvaporationSpectrum ) ) : sProcess = 'Process: general evaporation\n' sSpecific = '' sData += getParameter( parameter1, 'Theta' ) sData += getParameter( parameter2, 'g' ) elif( isinstance( energyData, energyModule.simpleMaxwellianFissionSpectrum ) ) : sProcess = 'Process: Maxwell spectrum\n' sSpecific = '' sData += getParameter( parameter1, 'Theta' ) elif( isinstance( energyData, energyModule.evaporationSpectrum ) ) : sProcess = 'Process: Evaporation spectrum\n' sSpecific = 'Interpolate Eout integrals: false\n' sSpecific += 'Quadrature method: Gauss6\n' sData += getParameter( parameter1, 'Theta' ) elif( isinstance( energyData, energyModule.WattSpectrum ) ) : sProcess = 'Process: Watt spectrum\n' sSpecific = 'Interpolate Eout integrals: false\n' sSpecific += 'Conserve: number\n' sData += getParameter( parameter1, 'a' ) sData += getParameter( parameter2, 'b' ) elif( isinstance( energyData, energyModule.MadlandNix ) ) : sProcess = 'Process: Madland-Nix spectrum\n' sSpecific = 'Quadrature method: adaptive\n' sSpecific += 'Interpolate Eout integrals: false\n' sSpecific += 'Conserve: number\n' sSpecific += 'EFL: %s\n' % energyData.EFL.getValueAs( energyData.parameter1.data.axes[-1].unit ) sSpecific += 'EFH: %s\n' % energyData.EFH.getValueAs( energyData.parameter1.data.axes[-1].unit ) sData += getParameter( parameter1, 'TM' ) else : raise Exception( 'Unsupport energy functional = %s' % energyData.moniker ) sData.append( '' ) return( sProcess, sSpecific, startOfNewData + '\n'.join( sData ) )
def TMs2Form( style, tempInfo, TM_1, TM_E ) : from fudge.processing import transportables as transportablesModule from fudge.gnd.productData.distributions import multiGroup as multiGroupModule reactionSuite = tempInfo['reactionSuite'] productName = tempInfo['productName'] transportable = style.transportables[productName] conserve = transportable.conserve energyUnit = tempInfo['incidentEnergyUnit'] # BRB hardwired. crossSectionUnit = 'b' # ?????? 'b' should not be hardwired. axes = axesModule.axes( rank = 4 ) axes[0] = axesModule.axis( 'C_l(energy_in,energy_out)', 0, crossSectionUnit ) lMaxPlus1 = len( TM_1[0][0] ) lGrid = valuesModule.values( [ i1 for i1 in range( lMaxPlus1 ) ], valueType = standardsModule.types.integer32Token ) axes[1] = axesModule.grid( 'l', 1, '', axesModule.parametersGridToken, lGrid ) energyOutGrid = style.transportables[productName].group.boundaries.values.copy( ) axes[2] = axesModule.grid( 'energy_out', 2, energyUnit, axesModule.boundariesGridToken, energyOutGrid ) energyInGrid = style.transportables[reactionSuite.projectile].group.boundaries.values.copy( ) axes[3] = axesModule.grid( 'energy_in', 3, energyUnit, axesModule.boundariesGridToken, energyInGrid ) if( conserve == transportablesModule.conserve.number ) : TM = TM_1 else : raise NotImplementedError( 'Need to implement' ) n1 = len( TM ) n2 = len( TM[0] ) n3 = len( TM[0][0] ) data, starts, lengths = [], [], [] for i1 in sorted( TM.keys( ) ) : TM_i1 = TM[i1] start, length = None, 0 for i2 in sorted( TM_i1.keys( ) ) : TM_i1_i2 = TM_i1[i2] cellMin = min( TM_i1_i2 ) cellMax = max( TM_i1_i2 ) if( ( cellMin != 0 ) or ( cellMax != 0 ) ) : if( start is None ) : start = n3 * ( n2 * i1 + i2 ) length += n3 data += TM_i1_i2 else : if( start is not None ) : starts.append( start ) lengths.append( length ) start, length = None, 0 if( start is not None ) : starts.append( start ) lengths.append( length ) shape = [ n1, n2, n3 ] data = valuesModule.values( data ) starts = valuesModule.values( starts, valueType = standardsModule.types.integer32Token ) lengths = valuesModule.values( lengths, valueType = standardsModule.types.integer32Token ) flattened = arrayModule.flattened( shape = shape, data = data, starts = starts, lengths = lengths, dataToString = multiGroupModule.gridded3d.dataToString ) gridded3d = multiGroupModule.gridded3d( axes = axes, array = flattened ) return( multiGroupModule.form( style.label, standardsModule.frames.labToken, gridded3d ) )
def defaultAxes( moniker ) : axes = axesModule.axes( rank = 3 ) axes[2] = axesModule.axis( 'energy_in', 2, 'eV' ) axes[1] = axesModule.axis( 'energy_out', 1, 'eV' ) x0Unit = '' if( moniker == 'f' ) : x0Unit = '1/eV' axes[0] = axesModule.axis( moniker, 0, x0Unit ) return( axes )
def defaultAxes(energyUnit='eV', momentumDepositionName=averageProductMomentumToken, momentumDepositionUnit='eV/c'): axes = axesModule.axes(rank=2) axes[0] = axesModule.axis(momentumDepositionName, 0, momentumDepositionUnit) axes[1] = axesModule.axis('energy_in', 1, energyUnit) return (axes)
def defaultAxes(energyUnit='eV', energyDepositionName=averageProductEnergyToken, energyDepositionUnit=None): if (energyDepositionUnit is None): energyDepositionUnit = energyUnit axes = axesModule.axes(rank=2) axes[0] = axesModule.axis(energyDepositionName, 0, energyDepositionUnit) axes[1] = axesModule.axis('energy_in', 1, energyUnit) return (axes)
def calculateDepositionEnergyFromEpP(E, EpP): "EpP is a list of [ E', P(E') ]" axes = axesModule.axes() axes[0] = axesModule.axis('a', 0, EpP.axes[0].unit) axes[1] = axesModule.axis('b', 1, EpP.axes[1].unit) Ep = XYsModule.XYs1d(data=[[EpP[0][0], EpP[0][0]], [EpP[-1][0], EpP[-1][0]]], axes=axes) return (float(EpP.integrateTwoFunctions(Ep)))
def defaultAxes(moniker, energyUnit): axes = axesModule.axes(rank=3) axes[2] = axesModule.axis('energy_in', 2, energyUnit) axes[1] = axesModule.axis('energy_out', 1, energyUnit) if (moniker == 'f'): axes[0] = axesModule.axis(moniker, 0, '1/' + energyUnit) else: axes[0] = axesModule.axis(moniker, 0, '') return (axes)
def defaultAxes(energyUnit='eV', energy_outUnit='eV', probabilityUnit='1/eV'): axes = axesModule.axes(rank=4) axes[0] = axesModule.axis('P(mu,energy_out|energy_in)', 0, probabilityUnit) axes[1] = axesModule.axis('mu', 1, '') axes[2] = axesModule.axis('energy_out', 2, energy_outUnit) axes[3] = axesModule.axis('energy_in', 3, energyUnit) return (axes)
def defaultAxes(energyUnit='eV', probabilityUnit='', asLegendre=False): axes = axesModule.axes(rank=3) if (asLegendre): axes[0] = axesModule.axis('C_l(energy_in)', 0, '') axes[1] = axesModule.axis('l', 1, '') else: axes[0] = axesModule.axis('P(mu|energy_in)', 0, probabilityUnit) axes[1] = axesModule.axis('mu', 1, '') axes[2] = axesModule.axis('energy_in', 2, energyUnit) return (axes)
def toPointwise_withLinearXYs(self, accuracy=None, lowerEps=0, upperEps=0): from numericalFunctions import specialFunctions def MadlandNixFunc(Ep, parameters): def g(Ep, E_F, T_M): u1 = (math.sqrt(Ep) - math.sqrt(E_F)) u1 *= u1 / T_M u2 = (math.sqrt(Ep) + math.sqrt(E_F)) u2 *= u2 / T_M E1 = 0 # u1^3/2 * E1 is zero for u1 = 0. but E1 is infinity, whence, the next test. if (u1 != 0): E1 = specialFunctions.exponentialIntegral(1, u1) E2 = specialFunctions.exponentialIntegral(1, u2) complementary = (u1 > 2.) gamma1 = specialFunctions.incompleteGamma( 1.5, u1, complementary) gamma2 = specialFunctions.incompleteGamma( 1.5, u2, complementary) signG = 1 if (complementary): signG = -1 return ((u2 * math.sqrt(u2) * E2 - u1 * math.sqrt(u1) * E1 + signG * (gamma2 - gamma1)) / (3 * math.sqrt(E_F * T_M))) EFL, EFH, T_M = parameters return (0.5 * (g(Ep, EFL, T_M) + g(Ep, EFH, T_M))) if (accuracy is None): accuracy = 1e-3 axes = XYs2d.defaultAxes(energyUnit=self.parameter1.data.axes[0].unit) pwl = XYs2d(axes=axes) E_in_unit = self.parameter1.data.axes[-1].unit EFL, EFH = self.EFL.getValueAs(E_in_unit), self.EFH.getValueAs( E_in_unit) factor = PQU.PQU(1, 'eV').getValueAs(E_in_unit) xs_ = [1e-5, 1e-3, 1e-1, 1e1, 1e3, 1e5, 3e7] xs = [factor * x for x in xs_] axes1d = axesModule.axes() axes1d[0] = axes[0] axes1d[1] = axes[1] for E, T_M in self.parameter1.data: # This logic ignores the interpolation of parameter1 as the only two subforms in ENDF/B-VII shows parameters = [ EFL, EFH, T_M ] # that linear-linear is better than the 'log-log' given in the ENDF/B-VII/data. g_Ep = XYs1d.createFromFunction(axes1d, xs, MadlandNixFunc, parameters, accuracy, biSectionMax=12) g_Ep.value = E # ????????? Class XYs1d does not the a proper setValue method. One should be added. g_Ep.normalize(insitu=True) pwl.append(g_Ep) return (pwl)
def uncorrelated_EMuP_EEpP_TransferMatrix( style, tempInfo, crossSection, productFrame, angularData, energyData, multiplicity, comment = None, weight = None ) : logFile = tempInfo['logFile'] workDir = tempInfo['workDir'] sSpecific = '' if( isinstance( energyData, energyModule.functionalBase ) ) : sProcess, sSpecific, sData = energyFunctionToString( energyData, weight = weight ) weight = None elif( isinstance( energyData, energyModule.weightedFunctionals ) ) : TM1s, TMEs = [], [] for weight in energyData : TM1, TME = uncorrelated_EMuP_EEpP_TransferMatrix( style, tempInfo, crossSection, productFrame, angularData, weight.functional, multiplicity, comment = comment, weight = weight ) TM1s.append( TM1 ) TMEs.append( TME ) TM1 = addTMs( TM1s ) TME = addTMs( TMEs ) return( TM1, TME ) elif( isinstance( energyData, energyModule.regions2d ) ) : TM1s, TMEs = [], [] axes = axesModule.axes( ) for i1, region in enumerate( energyData ) : weight = XYsModule.XYs1d( data = [ [ region.domainMin, 1. ], [ region.domainMax, 1. ] ], axes = axes ) tempInfo['workFile'].append( 'r%s' % i1 ) try : TM1, TME = uncorrelated_EMuP_EEpP_TransferMatrix( style, tempInfo, crossSection, productFrame, angularData, region, multiplicity, comment = comment, weight = weight ) except : del tempInfo['workFile'][-1] raise del tempInfo['workFile'][-1] TM1s.append( TM1 ) TMEs.append( TME ) TM1 = addTMs( TM1s ) TME = addTMs( TMEs ) return( TM1, TME ) elif( isinstance( energyData, energyModule.primaryGamma ) ) : return( primaryGammaAngularData( style, tempInfo, crossSection, energyData, angularData, multiplicity = multiplicity, comment = comment ) ) else : if( angularData.isIsotropic() ) : sProcess = "Process: isotropic table\n" sData = EEpPDataToString( energyData ) else: sProcess = "Process: 'Uncorrelated energy-angle data transfer matrix'\n" sData = angularToString( angularData, crossSection ) sData += EEpPDataToString( energyData ) sCommon = commonDataToString( comment, style, tempInfo, crossSection, productFrame, multiplicity = multiplicity, weight = weight ) s = versionStr + '\n' + sProcess + sSpecific + sCommon + sData return( executeCommand( logFile, transferMatrixExecute, s, workDir, tempInfo['workFile'] ) )
def getUncertaintyVector( self, theData=None, relative=True ): """ Get an XYs1d object containing uncertainty for this matrix. Convert relative/absolute if requested (if so, must also pass central values as theData) Examples: - if the covariance matrix is relative and we want relative uncertainty vector, just do: > matrix.getUncertaintyVector() - if we want the absolute matrix instead: > matrix.getUncertaintyVector( theData=<XYs1d instance>, relative=False ) """ if not self.isSymmetric(): raise ValueError("getUncertaintyVector only applies to symmetric matrices!") energies = list( self.matrix.axes[-1].values ) diag = numpy.diagonal( self.matrix.array.constructArray() ).copy() diag[ diag < 0.0 ] = 0.0 diag = list( numpy.sqrt( diag ) ) diag.append( diag[-1] ) # point corresponding to final energy bin yunit = self.matrix.axes[0].unit if yunit != '': # get square root of the unit yunit = PQU.PQU(1,yunit).sqrt().getUnitSymbol() axes_ = axesModule.axes( labelsUnits={1:('energy_in',self.matrix.axes[2].unit), 0:('uncertainty',yunit)} ) uncert = XYsModule.XYs1d( zip(energies,copy.deepcopy(diag)), axes=axes_, interpolation='flat', accuracy=0.0001, ) # what should accuracy be set to? uncert = uncert.changeInterpolation('lin-lin',None,1e-8,1e-8) # do we need to convert absolute->relative or vice versa? if (relative and self.type==tokens.absoluteToken) or (not relative and self.type==tokens.relativeToken): if theData is None: theData = self.ancestor.rowData.link.toPointwise_withLinearXYs(1e-8,1e-8) try: theData = theData.toPointwise_withLinearXYs(1e-8,1e-8) uncert, theData = uncert.mutualify(1e-8, 1e-8, False, theData, 1e-8, 1e-8, False) if relative: #convert absolute to relative uncert /= theData else: #relative to absolute uncert *= theData except Exception as err: print len( uncert ), uncert.copyDataToXYs()[0], uncert.copyDataToXYs()[-1] print len( theData ), theData.copyDataToXYs()[0], theData.copyDataToXYs()[-1] raise Exception( err.message ) return uncert
def multiGroupInverseSpeed(style, tempInfo): _groupBoundaries, flux = miscellaneousModule._groupFunctionsAndFluxInit( style, tempInfo, None) groupBoundaries = _groupBoundaries.values.values # cm/sh const = 2. / (3. * math.sqrt(2) * 2.99792458e+02 ) # BRB - speed-of-light should not be hardwired. const *= math.sqrt( float(PQUModule.PQU(1, 'MeV').convertToUnit(_groupBoundaries.unit))) const *= math.sqrt( tempInfo['projectileMass']) # Mass is in energy unit / c^2. numberOfGroups = len(groupBoundaries) - 1 E1 = groupBoundaries[0] inverseSpeeds = [] for i1 in range(numberOfGroups): E2 = groupBoundaries[i1 + 1] fluxSlice = flux.domainSlice(domainMin=E1, domainMax=E2, fill=True) fluxIntegral = 0 inverseSpeedIntegral = 0 _E1 = None for _E2, _flux2 in fluxSlice: if (_E1 is not None): fluxIntegral += (_E2 - _E1) * (_flux2 + _flux1) x1 = math.sqrt(_E1) x2 = math.sqrt(_E2) inverseSpeedIntegral += (x2 - x1) * (_flux1 + _flux2 + (_flux1 * x2 + _flux2 * x1) / (x1 + x2)) _E1 = _E2 _flux1 = _flux2 inverseSpeed = 0 if (fluxIntegral != 0): inverseSpeed = const * inverseSpeedIntegral / (fluxIntegral / 2) inverseSpeeds.append(inverseSpeed) E1 = E2 axes = axesModule.axes(rank=2) axes[0] = axesModule.axis(label="inverse speed", unit="sh/cm", index=0) axes[1] = flux.axes[1] return (groupModule.toMultiGroup1d(gridded1d, style, tempInfo, axes, inverseSpeeds, addLabel=False))
def readT_effective(line, mf7): line, dat = endfFileToGNDMisc.getTAB1(line, mf7) e_interp = dat['interpolationInfo'] if len(e_interp) > 1: raise ValueError( "only one interpolation region allowed for T_eff data") e_interp = endfFileToGNDMisc.ENDFInterpolationToGND1d(e_interp[0][1]) t_axes = axesModule.axes(labelsUnits={ 1: ('temperature', 'K'), 0: ('t_effective', 'K') }) return line, TS.T_effective(dat['data'], axes=t_axes, interpolation=e_interp)
def makeGrouped(self, processInfo, tempInfo): projectile, target = processInfo.getProjectileName( ), processInfo.getTargetName() groups = processInfo.getParticleGroups(projectile) energyUnit = tempInfo['crossSection'].domainUnit() axes = axesModule.axes(labelsUnits={ 0: ['energy_in', energyUnit], 1: ['energy', energyUnit] }) domainMin, domainMax = tempInfo['crossSection'].domain() energy = XYsModule.XYs1d(data=[[domainMin, domainMin], [domainMax, domainMax]], axes=axes, accuracy=1e-8) axes, grouped_ = miscellaneousModule.makeGrouped( self, processInfo, tempInfo, energy) self.addForm(grouped(axes, grouped_)) axes, grouped_ = miscellaneousModule.makeGrouped( self, processInfo, tempInfo, energy, normType='groupedFlux') self.addForm(groupedWithCrossSection(axes, grouped_))
def check(self, info): from fudge.gnd import warning from pqu import PQU warnings = [] axes = axesModule.axes() axes[0] = self.axes[-2] axes[1] = self.axes[-1] for index, energy_in in enumerate(self): integral = float( XYsModule.XYs1d([(eout.value, eout.coefficients[0]) for eout in energy_in], axes=axes, accuracy=0.001).integrate()) if abs(integral - 1.0) > info['normTolerance']: warnings.append( warning.unnormalizedDistribution( PQU.PQU(energy_in.value, axes[0].unit), index, integral, self.toXLink())) minProb = min([ xy.toPointwise_withLinearXYs(0.001).rangeMin() for xy in energy_in ]) if minProb < 0: warnings.append( warning.negativeProbability(PQU.PQU( energy_in.value, axes[0].unit), value=minProb, obj=energy_in)) if self.interpolationQualifier is standardsModule.interpolation.unitBaseToken: # check for more than one outgoing distribution integrating to 0 at high end of incident energies integrals = [eout.integrate() for eout in energy_in] for idx, integral in enumerate(integrals[::-1]): if integral != 0: break if idx > 1: warnings.append( warning.extraOutgoingEnergy(PQU.PQU( energy_in.value, axes[-1].unit), obj=energy_in)) return warnings
def twoBodyTransferMatrix( style, tempInfo, productFrame, crossSection, angularData, Q, weight = None, comment = None ) : """ Generate input and call processing code to generate a transfer matrix for two-body angular distribution. If the distribution is actually made up of two different forms in different energy regions, this function calls itself in the two regions and sums the result. """ if( isinstance( angularData, angularModule.isotropic ) ) : angularData = angularData.toPointwise_withLinearXYs( ) if( isinstance( angularData, angularModule.XYs2d ) ) : TM1, TME = twoBodyTransferMatrix2( style, tempInfo, crossSection, angularData, Q, productFrame, comment = comment ) elif( isinstance( angularData, angularModule.regions2d ) ) : TM1s, TMEs = [], [] lowestBound, highestBound = angularData[0].domainMin, angularData[-1].domainMax weightAxes = axesModule.axes( ) for iRegion, region in enumerate( angularData ) : if( iRegion == 0 ) : weightData = [ [ lowestBound, 1 ], [ region.domainMax, 0 ], [ highestBound, 0 ] ] elif( iRegion == len( angularData ) - 1 ) : weightData = [ [ lowestBound, 0 ], [ region.domainMin, 1 ], [ highestBound, 1 ] ] else : weightData = [ [ lowestBound, 0 ], [ region.domainMin, 1 ], [ region.domainMax, 0 ], [ highestBound, 0 ] ] _weight = XYsModule.XYs1d( data = weightData, axes = weightAxes ) tempInfo['workFile'].append( 'r%s' % iRegion ) try : TM1, TME = twoBodyTransferMatrix2( style, tempInfo, crossSection, region, Q, productFrame, weight = _weight, comment = comment ) except : del tempInfo['workFile'][-1] raise del tempInfo['workFile'][-1] TM1s.append( TM1 ) TMEs.append( TME ) TM1 = addTMs( TM1s ) TME = addTMs( TMEs ) else : raise Exception( 'Unsupported P(mu|E) = %s' % angularData.moniker ) return( TM1, TME )