def calculateAverageProductData(self, style, indent='', **kwargs): raise 'FIXME, when am I called' energyUnit = kwargs['incidentEnergyUnit'] momentumDepositionUnit = energyUnit + '/c' massUnit = energyUnit + '/c**2' energyAccuracy = kwargs['energyAccuracy'] momentumAccuracy = kwargs['momentumAccuracy'] product = kwargs['product'] reactionSuite = kwargs['reactionSuite'] if (product.name != 'gamma'): raise Exception( 'For form %s, calculateAverageProductData is only for gammas, not %s' % (self.moniker, product.name)) depData = [] angularSubform = self.angularSubform Es = angularSubform.getEnergyArray(kwargs['EMin'], kwargs['EMax']) if (('discrete' in product.attributes) or ('primary' in product.attributes)): massRatio = 0. if ('discrete' in product.attributes): Eg = product.attributes['discrete'].getValueAs(energyUnit) else: Eg = product.attributes['primary'].getValueAs(energyUnit) mass1 = reactionSuite.projectile.getMass(massUnit) mass2 = reactionSuite.target.getMass(massUnit) massRatio = mass2 / (mass1 + mass2) depEnergy = [[E, Eg + massRatio * E] for E in Es] depMomentum = [[ E, (Eg + massRatio * E) * angularSubform.averageMu(E, accuracy=0.1 * momentumAccuracy) ] for E in Es] else: raise Exception( 'Unsupported gamma; gamma must be "discrete" or "primary"') axes = energyDepositionModule.XYs1d.defaultAxes( energyUnit=energyUnit, energyDepositionUnit=energyUnit) depData.append( energyDepositionModule.XYs1d(data=depEnergy, axes=axes, label=style.label, accuracy=energyAccuracy)) axes = momentumDepositionModule.XYs1d.defaultAxes( energyUnit=energyUnit, momentumDepositionUnit=momentumDepositionUnit) depData.append( momentumDepositionModule.XYs1d(data=depMomentum, axes=axes, label=style.label, accuracy=momentumAccuracy)) return (depData)
def calculateDepositionEnergyFromAngular_angularEnergy( processInfo, derivedStyles, angular, energy, multiplicity, doingGammaMomentum=False, accuracy=1e-6): raise 'FIXME' energyUnit = energy.axes[0].getUnit() energyPrimeUnit = energy.axes[2].getUnit() momentumDepositionUnit = energyPrimeUnit + '/c' sqrtP6 = 0.77459666924148337704 / 2. # sqrt( 0.6 ) / 2 depEnergy = [] for indexE, muEpPs in enumerate(energy): E = muEpPs.value I1MuP = angular[indexE] sum = 0. for indexMu, muEpP in enumerate(muEpPs): mu2, P2 = I1MuP[indexMu] mu2 = muEpP.value Ep2 = muEpP.integrateWithWeight_x() if (indexMu != 0): muMid = 0.5 * (mu1 + mu2) EpMid = muEpPs.interpolateAtW( muMid, unitBase=True).integrateWithWeight_x() if (doingGammaMomentum): dMu = sqrtP6 * (mu2 - mu1) muG1 = muMid - dMu muEpG1 = muG1 * muEpPs.interpolateAtW( muG1, unitBase=True).integrateWithWeight_x() muG2 = muMid + dMu muEpG2 = muG2 * muEpPs.interpolateAtW( muG2, unitBase=True).integrateWithWeight_x() sum += (mu2 - mu1) * (5. * (muEpG1 + muEpG2) + 8. * muMid * EpMid) else: sum += 3. * (mu2 - mu1) * ( P1 * Ep1 + 2 * (P1 + P2) * EpMid + P2 * Ep2 ) # 3 due to 18 instead of 6 below. P1 = P2 mu1 = mu2 Ep1 = Ep2 depEnergy.append([E, multiplicity.getValue(E) * sum / 18.]) if (doingGammaMomentum): return (depEnergy) axes = energyDepositionModule.XYs1d.defaultAxes( energyUnit=energyUnit, energyDepositionUnit=energyUnit) return (energyDepositionModule.XYs1d(data=depEnergy, axes=axes, label=processInfo.style.label, accuracy=accuracy))
def calculateAverageProductData(self, style, indent='', **kwargs): verbosity = kwargs.get('verbosity', 0) indent2 = indent + kwargs.get('incrementalIndent', ' ') energyUnit = kwargs['incidentEnergyUnit'] momentumDepositionUnit = kwargs['momentumDepositionUnit'] multiplicity = kwargs['multiplicity'] productMass = kwargs['productMass'] energyAccuracy = kwargs['energyAccuracy'] momentumAccuracy = kwargs['momentumAccuracy'] EMin = kwargs['EMin'] Legendre_l0, Legendre_l1 = self[0], None if (len(self) > 1): Legendre_l1 = self[1] if (isinstance(multiplicity, multiplicityModule.XYs1d) ): # If multiplicity as points not in Legendre_l0 add them. Es = set([EpP.value for EpP in Legendre_l0]) for E, m in multiplicity: Es.add(E) if (len(Es) > len(Legendre_l0)): Es = sorted(Es) Legendre_l0p = multiD_XYsModule.XYs2d() for energy in Es: Legendre_l0p.append( Legendre_l0.interpolateAtValue( energy, unitBase=True, extrapolation=standardsModule. flatExtrapolationToken)) Legendre_l0 = Legendre_l0p if (Legendre_l1 is not None): Legendre_l1p = multiD_XYsModule.XYs2d() for energy in Es: Legendre_l1p.append( Legendre_l1.interpolateAtValue( energy, unitBase=True, extrapolation=standardsModule. flatExtrapolationToken)) Legendre_l1 = Legendre_l1p calculateDepositionEnergyFromEpP = miscellaneousModule.calculateDepositionEnergyFromEpP depEnergy = [[ EpP.value, multiplicity.evaluate(EpP.value) * calculateDepositionEnergyFromEpP(EpP.value, EpP) ] for EpP in Legendre_l0] if (depEnergy[0][0] > EMin): depEnergy.insert(0, [EMin, 0.]) # Special case for bad data axes = energyDepositionModule.defaultAxes(energyUnit) energyDep = energyDepositionModule.XYs1d(data=depEnergy, axes=axes, label=style.label) if (Legendre_l1 is not None): depMomentum = [] const = math.sqrt(2. * productMass) for EpP in Legendre_l1: if (const == 0): # For gammas. depMomentum.append([ EpP.value, multiplicity.evaluate(EpP.value) * EpP.integrateWithWeight_x() ]) else: depMomentum.append([ EpP.value, const * multiplicity.evaluate(EpP.value) * EpP.integrateWithWeight_sqrt_x() ]) else: depMomentum = [[Legendre_l0[0].value, 0.], [Legendre_l0[-1].value, 0.]] axes = momentumDepositionModule.defaultAxes(energyUnit, momentumDepositionUnit) if (depMomentum[0][0] > EMin): depMomentum.insert(0, [EMin, 0.]) # Special case for bad data momentumDep = momentumDepositionModule.XYs1d(data=depMomentum, axes=axes, label=style.label) return ([energyDep], [momentumDep])
def calculateDepositionData(self, style, indent='', **kwargs): verbosity = kwargs.get('verbosity', 0) indent2 = indent + kwargs.get('incrementalIndent', ' ') energyUnit = kwargs['incidentEnergyUnit'] momentumDepositionUnit = energyUnit + '/c' massUnit = energyUnit + '/c**2' multiplicity = kwargs['multiplicity'] productMass = kwargs['product'].getMass(massUnit) energyAccuracy = kwargs['energyAccuracy'] momentumAccuracy = kwargs['momentumAccuracy'] EMin = kwargs['EMin'] depData = [] Legendre_l0, Legendre_l1 = self[0], None if (len(self) > 1): Legendre_l1 = self[1] if (isinstance(multiplicity, multiplicityModule.XYs1d)): Es = [EpP.value for EpP in Legendre_l0] doIt = False for E, m in multiplicity.getFormByToken( tokensModule.pointwiseFormToken): if (E < Es[0]): continue if (E not in Es): doIt = True Es.append(E) if (doIt): Es.sort() Legendre_l0p, Legendre_l1p = LLNLPointwiseEEpP( 0), LLNLPointwiseEEpP(1) indexE, EpP1 = 0, None for EpP2 in Legendre_l0: while ((indexE < len(Es)) and (EpP2.value > Es[indexE])): if (EpP1.value != Es[indexE]): EpP = XYs.pointwiseXY_C.unitbaseInterpolate( Es[indexE], EpP1.value, EpP1, EpP2.value, EpP2) axes = EpP1.axes.copy() Legendre_l0p.append( XYs.XYs(axes, EpP, EpP1.getAccuracy(), value=Es[indexE])) indexE += 1 Legendre_l0p.append(EpP2) EpP1 = EpP2 Legendre_l0 = Legendre_l0p if (Legendre_l1 is not None): for EpP2 in Legendre_l1: while ((indexE < len(Es)) and (EpP2.value > Es[indexE])): if (EpP1 is None): raise Exception( 'multiplicity energy = %s before Legendre l = 0 distribution energy = %s' % (Es[indexE], EpP2.value)) if (EpP1.value != Es[indexE]): EpP = XYs.pointwiseXY_C.unitbaseInterpolate( Es[indexE], EpP1.value, EpP1, EpP2.value, EpP2) axes = EpP1.axes.copy() Legendre_l1p.append( XYs.XYs(axes, EpP, EpP1.getAccuracy(), value=Es[indexE])) indexE += 1 Legendre_l1p.append(EpP2) EpP1 = EpP2 Legendre_l1 = Legendre_l1p depEnergy = [[ EpP.value, multiplicity.getValue(EpP.value) * miscellaneous.calculateDepositionEnergyFromEpP(EpP.value, EpP) ] for EpP in Legendre_l0] if (depEnergy[0][0] > EMin): depEnergy.insert(0, ['EMin', 0.]) # Special case for bad data axes = energyDepositionModule.XYs1d.defaultAxes( energyUnit=energyUnit, energyDepositionUnit=energyUnit) depData.append( energyDepositionModule.XYs1d(data=depEnergy, axes=axes, label=style.label, accuracy=energyAccuracy)) if (Legendre_l1 is not None): const = math.sqrt(2. * productMass) if (const == 0.): const = 1 # For gammas. depMomentum = [] EpP = Legendre_l1[0] for EpP in Legendre_l1: if (const == 0.): # For gammas. depMomentum.append([ EpP.value, const * multiplicity.getValue(EpP.value) * EpP.integrateWithWeight_x() ]) else: depMomentum.append([ EpP.value, const * multiplicity.getValue(EpP.value) * EpP.integrateWithWeight_sqrt_x() ]) else: depMomentum = [[Legendre_l0[0].value, 0.], [Legendre_l0[-1].value, 0.]] axes = momentumDepositionModule.XYs1d.defaultAxes( energyUnit=energyUnit, momentumDepositionUnit=momentumDepositionUnit) if (depMomentum[0][0] > EMin): depMomentum.insert(0, [EMin, 0.]) # Special case for bad data depData.append( momentumDepositionModule.XYs1d(data=depMomentum, axes=axes, label=style.label, accuracy=momentumAccuracy)) return (depData)