Exemple #1
0
def angularPointwiseEnergy2ENDF6(self, targetInfo, EinFactor=1):

    interpolation = gndToENDFInterpolationFlag(self.interpolation)
    if len(self) > 201:
        accuracy, angularData = self.thinToNumberOfPoints(201)
        assert len(angularData) <= 201
        angularData = angularData.normalize()
        print(
            "          WARNING: ENDF limited to 201 mu values. %d points removed for incident energy %g %s"
            % (len(self) - len(angularData), self.value, self.axes[-1].unit))
    else:
        angularData = self
    if (targetInfo['doMF4AsMF6']):
        interpolation += 10
        ENDFDataList = [
            endfFormatsModule.endfContLine(0, self.value * EinFactor,
                                           interpolation, 0,
                                           2 * len(angularData),
                                           len(angularData))
        ]
        ENDFDataList += endfFormatsModule.endfNdDataList(angularData)
    else:
        ENDFDataList = [
            endfFormatsModule.endfContLine(0, self.value * EinFactor, 0, 0, 1,
                                           len(angularData))
        ]
        ENDFDataList += endfFormatsModule.endfInterpolationList(
            [len(angularData), interpolation])
        ENDFDataList += endfFormatsModule.endfNdDataList(angularData)
    return (ENDFDataList)
Exemple #2
0
def toENDF6_MF6(MT, endfMFList, flags, targetInfo, LAW, frame, MF6):

    reactionSuite = targetInfo['reactionSuite']
    MF6or26 = {3: 6, 23: 26}[targetInfo['crossSectionMF']]
    targetInfo['MF6LCTs'].append({
        standardsModule.frames.labToken: 1,
        standardsModule.frames.centerOfMassToken: 2
    }[frame])
    LIP = 0
    if ((targetInfo['product'].id in targetInfo['metastables'])
            and not ((50 <= MT <= 91) or (600 <= MT <= 850))):
        # set LIP to metastable index of product UNLESS excited state of product is encoded in MT number:
        alias = targetInfo['metastables'][targetInfo['product'].id]
        LIP = int(alias.metaStableIndex)
    if (MT not in endfMFList[MF6or26]): endfMFList[MF6or26][MT] = []
    particleID = targetInfo['zapID']  # get ZAP for the outgoing particle
    if (particleID == IDsPoPsModule.electron):
        ZAP = 11
    else:
        ZAP = miscPoPsModule.ZA(reactionSuite.PoPs[particleID])
    productMass = targetInfo['particleMass']
    if ((particleID == IDsPoPsModule.neutron)
            and (MT in [18])):  # Special case when fission has MF = 6 data.
        nPoints = 2
        interpolationFlatData = [nPoints, 2]
        multiplicityList = endfFormatsModule.endfDataList(
            [[targetInfo['EMin'], 1.], [targetInfo['EMax'], 1.]])
    else:
        multiplicity = targetInfo['multiplicity']
        if (isinstance(multiplicity, multiplicityModule.component)):
            multiplicity = multiplicity[targetInfo['style']]
        interpolationFlatData, nPoints, multiplicityList = multiplicity.toENDF6List(
            targetInfo)
    if ((particleID == IDsPoPsModule.photon) and (LAW == 2)):
        projectileMass = reactionSuite.PoPs[reactionSuite.projectile].getMass(
            'eV/c**2')
        targetMass = reactionSuite.PoPs[reactionSuite.projectile].getMass(
            'eV/c**2')
        AWP = targetInfo['Q']
        AWP /= 1. + 0.5 * AWP / (
            projectileMass + targetMass
        )  # Should be divided by residual mass, but this is close.
    else:
        AWP = productMass
    ENDFHeaderList = [
        endfFormatsModule.endfContLine(ZAP, AWP, LIP, LAW,
                                       len(interpolationFlatData) / 2, nPoints)
    ]
    ENDFHeaderList += endfFormatsModule.endfInterpolationList(
        interpolationFlatData)
    ENDFHeaderList += multiplicityList
    endfMFList[MF6or26][MT] += ENDFHeaderList + MF6
Exemple #3
0
def toENDF6_MF6(MT, endfMFList, flags, targetInfo, LAW, frame, MF6):

    MF6or26 = {3: 6, 23: 26}[targetInfo['crossSectionMF']]
    targetInfo['MF6LCTs'].append({
        standardsModule.frames.labToken: 1,
        standardsModule.frames.centerOfMassToken: 2
    }[frame])
    LIP = 0
    if ((targetInfo['product'].particle.name in targetInfo['metastables'])
            and not ((50 <= MT <= 91) or (600 <= MT <= 850))):
        # set LIP to metastable index of product UNLESS excited state of product is encoded in MT number:
        alias, = [
            alias for alias in targetInfo['reactionSuite'].aliases.values()
            if alias.getValue() == targetInfo['product'].particle.name
        ]
        LIP = int(alias.getAttribute('nuclearMetaStable'))
    if (MT not in endfMFList[MF6or26]): endfMFList[MF6or26][MT] = []
    particleID = targetInfo['zapID']  # get ZAP for the outgoing particle
    if (particleID == 'gamma'):
        ZAP = 0
    if (particleID == 'e-'):
        ZAP = 11
    else:
        Z, A, suffix, ZAP = nuclear.getZ_A_suffix_andZAFromName(particleID)
    productMass = targetInfo['particleMass']
    if ((particleID == 'n')
            and (MT in [18])):  # Special case when fission has MF = 6 data.
        nPoints = 2
        interpolationFlatData = [nPoints, 2]
        multiplicityList = endfFormatsModule.endfDataList(
            [[targetInfo['EMin'], 1.], [targetInfo['EMax'], 1.]])
    else:
        multiplicity = targetInfo['multiplicity']
        if (isinstance(multiplicity, multiplicityModule.component)):
            multiplicity = multiplicity[targetInfo['style']]
        interpolationFlatData, nPoints, multiplicityList = multiplicity.toENDF6List(
            targetInfo)
    if ((particleID == 'gamma')
            and ('primaryGammaEnergy' in targetInfo.keys())):
        AWP = targetInfo.dict.pop('primaryGammaEnergy')
    else:
        AWP = productMass / targetInfo['neutronMass']
    ENDFHeaderList = [
        endfFormatsModule.endfContLine(ZAP, AWP, LIP, LAW,
                                       len(interpolationFlatData) / 2, nPoints)
    ]
    ENDFHeaderList += endfFormatsModule.endfInterpolationList(
        interpolationFlatData)
    ENDFHeaderList += multiplicityList
    endfMFList[MF6or26][MT] += ENDFHeaderList + MF6
Exemple #4
0
def angularPointwiseEnergy2ENDF6(self, targetInfo):

    interpolation = gndToENDFInterpolationFlag(self.interpolation)
    if (targetInfo['doMF4AsMF6']):
        interpolation += 10
        ENDFDataList = [
            endfFormatsModule.endfContLine(0, self.value, interpolation, 0,
                                           2 * len(self), len(self))
        ]
        ENDFDataList += endfFormatsModule.endfNdDataList(self)
    else:
        ENDFDataList = [
            endfFormatsModule.endfContLine(0, self.value, 0, 0, 1, len(self))
        ]
        ENDFDataList += endfFormatsModule.endfInterpolationList(
            [len(self), interpolation])
        ENDFDataList += endfFormatsModule.endfNdDataList(self)
    return (ENDFDataList)
Exemple #5
0
def toENDF6(self, flags, targetInfo, verbosityIndent=''):

    endf = []
    AP = self.scatteringRadius
    if AP.isEnergyDependent():
        scatRadius = AP.form
        NR, NP = 1, len(scatRadius)
        endf.append(endfFormatsModule.endfHeadLine(0, 0, 0, 0, NR, NP))
        endf += endfFormatsModule.endfInterpolationList(
            (NP,
             gndToENDF6.gndToENDFInterpolationFlag(scatRadius.interpolation)))
        endf += endfFormatsModule.endfNdDataList(
            scatRadius.convertAxisToUnit(0, '10*fm'))
        AP = 0
    else:
        AP = AP.getValueAs('10*fm')

    NLS = len(self.L_values)
    LFW = targetInfo['unresolved_LFW']
    LRF = targetInfo['unresolved_LRF']

    def v(val):  # get value back from PhysicalQuantityWithUncertainty
        if type(val) == type(None): return
        return val.getValueAs('eV')

    if LFW == 0 and LRF == 1:  # 'Case A' from ENDF 2010 manual pg 70
        endf.append(
            endfFormatsModule.endfHeadLine(targetInfo['spin'], AP,
                                           self.forSelfShieldingOnly, 0, NLS,
                                           0))
        for Lval in self.L_values:
            NJS = len(Lval.J_values)
            endf.append(
                endfFormatsModule.endfHeadLine(targetInfo['mass'], 0, Lval.L,
                                               0, 6 * NJS, NJS))
            for Jval in Lval.J_values:
                # here we only have one width per J:
                ave = Jval.constantWidths
                endf.append(
                    endfFormatsModule.endfDataLine([
                        v(ave.levelSpacing), Jval.J.value, Jval.neutronDOF,
                        v(ave.neutronWidth),
                        v(ave.captureWidth), 0
                    ]))

    elif LFW == 1 and LRF == 1:  # 'Case B'
        energies = self.L_values[0].J_values[
            0].energyDependentWidths.getColumn('energy', units='eV')
        NE = len(energies)
        endf.append(
            endfFormatsModule.endfHeadLine(targetInfo['spin'], AP,
                                           self.forSelfShieldingOnly, 0, NE,
                                           NLS))
        nlines = int(math.ceil(NE / 6.0))
        for line in range(nlines):
            endf.append(
                endfFormatsModule.endfDataLine(energies[line * 6:line * 6 +
                                                        6]))
        for Lval in self.L_values:
            NJS = len(Lval.J_values)
            endf.append(
                endfFormatsModule.endfHeadLine(targetInfo['mass'], 0, Lval.L,
                                               0, NJS, 0))
            for Jval in Lval.J_values:
                cw = Jval.constantWidths
                endf.append(
                    endfFormatsModule.endfHeadLine(0, 0, Lval.L,
                                                   Jval.fissionDOF, NE + 6, 0))
                endf.append(
                    endfFormatsModule.endfDataLine([
                        v(cw.levelSpacing), Jval.J.value, Jval.neutronDOF,
                        v(cw.neutronWidth),
                        v(cw.captureWidth), 0
                    ]))
                fissWidths = Jval.energyDependentWidths.getColumn(
                    'fissionWidthA', units='eV')
                for line in range(nlines):
                    endf.append(
                        endfFormatsModule.endfDataLine(
                            fissWidths[line * 6:line * 6 + 6]))

    elif LRF == 2:  # 'Case C', most common in ENDF
        endf.append(
            endfFormatsModule.endfHeadLine(targetInfo['spin'], AP,
                                           self.forSelfShieldingOnly, 0, NLS,
                                           0))
        INT = gndToENDF6.gndToENDFInterpolationFlag(self.interpolation)
        for Lval in self.L_values:
            NJS = len(Lval.J_values)
            endf.append(
                endfFormatsModule.endfHeadLine(targetInfo['mass'], 0, Lval.L,
                                               0, NJS, 0))
            for Jval in Lval.J_values:
                NE = len(Jval.energyDependentWidths)
                useConstant = not NE
                if useConstant: NE = 2
                endf.append(
                    endfFormatsModule.endfHeadLine(Jval.J.value, 0, INT, 0,
                                                   6 * NE + 6, NE))
                endf.append(
                    endfFormatsModule.endfDataLine([
                        0, 0, Jval.competitiveDOF, Jval.neutronDOF,
                        Jval.gammaDOF, Jval.fissionDOF
                    ]))
                cws = Jval.constantWidths
                if useConstant:
                    # widths are all stored in 'constantWidths' instead. get energies from parent class
                    NE = 2
                    useConstant = True
                    eLow, eHigh = targetInfo['regionEnergyBounds']
                    for e in (eLow, eHigh):
                        endf.append(
                            endfFormatsModule.endfDataLine([
                                v(e),
                                v(cws.levelSpacing),
                                v(cws.competitiveWidth),
                                v(cws.neutronWidth),
                                v(cws.captureWidth),
                                v(cws.fissionWidthA)
                            ]))

                else:
                    table = [
                        Jval.energyDependentWidths.getColumn('energy',
                                                             units='eV')
                    ]
                    for attr in ('levelSpacing', 'competitiveWidth',
                                 'neutronWidth', 'captureWidth',
                                 'fissionWidthA'):
                        # find each attribute, in energy-dependent or constant width section
                        column = (Jval.energyDependentWidths.getColumn(
                            attr, units='eV') or [v(getattr(cws, attr))] * NE)
                        if not any(column): column = [0] * NE
                        table.append(column)
                    for row in zip(*table):
                        endf.append(endfFormatsModule.endfDataLine(row))
    return endf
Exemple #6
0
def toENDF6(self, flags, targetInfo, verbosityIndent=''):

    endf = []
    AP = getattr(self, 'scatteringRadius')
    if AP.isEnergyDependent():
        scatRadius = AP.form
        NR, NP = 1, len(scatRadius)
        endf.append(endfFormatsModule.endfHeadLine(0, 0, 0, 0, NR, NP))
        endf += endfFormatsModule.endfInterpolationList(
            (NP,
             gndToENDF6.gndToENDFInterpolationFlag(scatRadius.interpolation)))
        endf += endfFormatsModule.endfNdDataList(
            scatRadius.convertAxisToUnit(0, '10*fm'))
        AP = 0
    else:
        AP = self.scatteringRadius.getValueAs('10*fm')
    L_list = self.resonanceParameters.table.getColumn('L')
    NLS = len(set(L_list))
    LAD = getattr(self, 'computeAngularDistribution') or 0
    NLSC = getattr(self, 'LvaluesNeededForConvergence') or 0
    endf += [
        endfFormatsModule.endfHeadLine(targetInfo['spin'], AP, LAD, 0, NLS,
                                       NLSC)
    ]

    table = [
        self.resonanceParameters.table.getColumn('energy', units='eV'),
        self.resonanceParameters.table.getColumn('J')
    ]
    NE = len(table[0])
    if isinstance(self, (resonancesModule.SLBW, resonancesModule.MLBW)):
        attrList = ('totalWidth', 'neutronWidth', 'captureWidth',
                    'fissionWidthA')
    elif isinstance(self, resonancesModule.RM):
        attrList = ('neutronWidth', 'captureWidth', 'fissionWidthA',
                    'fissionWidthB')
    for attr in attrList:
        column = self.resonanceParameters.table.getColumn(attr, units='eV')
        if not column: column = [0] * NE
        table.append(column)
    CS = self.resonanceParameters.table.getColumn('channelSpin')
    if CS is not None:  # ENDF hack: J<0 -> use lower available channel spin
        targetSpin = targetInfo['spin']
        CS = [2 * (cs - targetSpin) for cs in CS]
        Js = [v[0] * v[1] for v in zip(table[1], CS)]
        table[1] = Js
    table = zip(*table)

    for L in set(L_list):
        APL = 0
        if self.scatteringRadius.isLdependent(
        ) and L in self.scatteringRadius.form.lvals:
            APL = self.scatteringRadius.getValueAs('10*fm', L=L)
        resonances = [table[i] for i in range(NE) if L_list[i] == L]
        NRS = len(resonances)
        endf.append(
            endfFormatsModule.endfHeadLine(targetInfo['mass'], APL, L, 0,
                                           6 * NRS, NRS))
        for row in resonances:
            endf.append(endfFormatsModule.endfDataLine(row))
    return endf
Exemple #7
0
def gammasToENDF6_MF12_13(MT, MF, endfMFList, flags, targetInfo, gammas):
    """
    MF=12 stores the multiplicity for gamma products, can be converted directly to/from GND.
    MF=13 stores 'gamma production cross section', equal to cross section * multiplicity.
    ENDF-to-GND translator converts to multiplicity (dividing by reaction cross section).
    When writing back to ENDF-6 MF=13, need to convert back using adjustMF13Multiplicity.
    """

    doMF4AsMF6 = targetInfo['doMF4AsMF6']
    targetInfo['doMF4AsMF6'] = False
    ZA, mass, MFGammas, NI, continuum, NK, NKp = targetInfo['ZA'], targetInfo[
        'mass'], [], 0, None, len(gammas), 0

    total, piecewise, recomputeTotal = None, None, False

    crossSection = None
    if (MF == 13):
        crossSection = targetInfo['crossSection']
        crossSection = crossSection.toPointwise_withLinearXYs(accuracy=1e-3,
                                                              upperEps=1e-8)

    if (NK > 1):
        # If more than one gamma is present, both MF=12 and MF=13 start with the sum over all gammas.
        # Search for the correct multiplicitySum in reactionSuite/sums section

        total = [
            tmp for tmp in targetInfo['reactionSuite'].sums.multiplicities
            if tmp.ENDF_MT == MT
        ]
        if len(total) > 1:
            raise Exception(
                "Cannot find unique gamma multiplicity sum for MT%d" % MT)
        elif not total:  # total multiplicity is missing from sums section, need to recompute from parts
            recomputeTotal = True
        else:
            total = total[0].multiplicity.evaluated

    for gammaIndex, gamma in enumerate(gammas):
        distribution = gamma.distribution
        component = distribution[targetInfo['style']]
        if (isinstance(component, unspecifiedModule.form)): continue
        NKp += 1

        originationLevel = 0
        if ('originationLevel' in gamma.attributes):
            originationLevel = PQUModule.PQU(
                gamma.getAttribute('originationLevel')).getValueAs('eV')

        isPrimary, isDiscrete = False, False
        if (isinstance(component, uncorrelatedModule.form)):
            energySubform = component.energySubform.data
            if (isinstance(energySubform, energyModule.primaryGamma)):
                isPrimary = True
            elif (isinstance(energySubform, energyModule.discreteGamma)):
                isDiscrete = True
            angularSubform = component.angularSubform.data
        else:
            raise 'hell - fix me'
        LP, LF, levelEnergy = 0, 2, 0.
        if (isPrimary):
            gammaEnergy = PQUModule.PQU(
                energySubform.value,
                energySubform.axes[1].unit).getValueAs('eV')
            LP = 2
        elif (isDiscrete):
            gammaEnergy = PQUModule.PQU(
                energySubform.value,
                energySubform.axes[1].unit).getValueAs('eV')
            if (originationLevel != 0): LP = 1
        else:
            if (continuum is not None):
                raise Exception(
                    'Multiple continuum gammas detected for MT=%s' % (MT))
            continuum = gamma
            energySubform = component.energySubform.data
            gammaEnergy, LP, LF = 0, 0, 1
            NC, MF15 = energySubform.toENDF6(flags, targetInfo)
            endfMFList[15][MT] = [
                endfFormatsModule.endfContLine(ZA, mass, 0, 0, NC, 0)
            ]
            endfMFList[15][MT] += MF15
            endfMFList[15][MT].append(endfFormatsModule.endfSENDLineNumber())

        isNotIsotropic = 0
        if (isinstance(angularSubform, angularModule.isotropic)):
            MF14 = None
            LI, LTT = 1, 0
        elif (isinstance(angularSubform, angularModule.XYs2d)):
            isNotIsotropic = 1
            targetInfo['doProductionGamma'] = True
            dummy, dummy, MF14 = angularSubform.toENDF6(flags, targetInfo)
            del targetInfo['doProductionGamma']
            del MF14[-1]
            MF14[0] = endfFormatsModule.floatToFunky(
                gammaEnergy) + endfFormatsModule.floatToFunky(
                    originationLevel) + MF14[0][22:]
            LI, LTT = 0, 1
        else:
            raise 'hell - fix me'

        multiplicity = gamma.multiplicity.evaluated

        if recomputeTotal:
            if (isinstance(multiplicity, multiplicityModule.regions1d)):
                if (piecewise is not None):
                    if (len(piecewise) != len(multiplicity)):
                        raise Exception(
                            'MF=12/13 piecewise multiplicities must all have same number of regions'
                        )
                    for i1, region in enumerate(piecewise):
                        region.setData(
                            (region + multiplicity[i1]).copyDataToXYs())
                else:
                    piecewise = multiplicity
                total = piecewise[
                    0]  # BRB, FIXME, this is a kludge until total is put into sums.
            elif (total is None):
                total = multiplicity
            else:
                total = total + multiplicity

        if (MF == 12):
            LO = 1
            NR, NP, MF12or13Data = multiplicity.toENDF6List(targetInfo)
            if (type(NR) == type([])):
                for index, NRsub in enumerate(
                        endfFormatsModule.endfInterpolationList(NR)):
                    MF12or13Data.insert(index, NRsub)
                NR = len(NR) / 2
            MF12 = [
                endfFormatsModule.endfContLine(gammaEnergy, originationLevel,
                                               LP, LF, NR, NP)
            ] + MF12or13Data
            MFGammas.append(
                [isNotIsotropic, gammaEnergy, originationLevel, MF12, MF14])

        elif (MF == 13):
            LO = 0

            interpolationInfo = []
            xsec_mult = []
            if (isinstance(multiplicity, multiplicityModule.XYs1d)):
                adjustMF13Multiplicity(interpolationInfo, xsec_mult,
                                       multiplicity, crossSection)
            elif (isinstance(multiplicity, multiplicityModule.regions1d)):
                for region in multiplicity:
                    adjustMF13Multiplicity(interpolationInfo, xsec_mult,
                                           region, crossSection)
            else:
                raise Exception('Unsupport multiplicity "%s" for MF=13' %
                                multiplicity.moniker)

            NR = len(interpolationInfo) / 2
            NP = len(xsec_mult) / 2
            MF13 = [
                endfFormatsModule.endfContLine(gammaEnergy, originationLevel,
                                               LP, LF, NR, NP)
            ]
            MF13 += [
                endfFormatsModule.endfInterpolationLine(interpolationInfo)
            ]
            MF13 += endfFormatsModule.endfNdDataList(xsec_mult)
            MFGammas.append(
                [isNotIsotropic, gammaEnergy, originationLevel, MF13, MF14])
        else:
            pass
    if (NKp == 0): return

    endfMFList[MF][MT] = [
        endfFormatsModule.endfContLine(ZA, mass, LO, 0, NK, 0)
    ]
    if (
            NK > 1
    ):  # If more than one gamma is present, both MF=12 and MF=13 start with the sum over all gammas.

        totalInterpolationInfo = []
        xsec_mult = []
        if (isinstance(total, multiplicityModule.XYs1d)):
            adjustMF13Multiplicity(totalInterpolationInfo, xsec_mult, total,
                                   crossSection)
        elif (isinstance(total, multiplicityModule.regions1d)):
            for region in total:
                adjustMF13Multiplicity(totalInterpolationInfo, xsec_mult,
                                       region, crossSection)
        else:
            raise Exception(
                'Unsupported total multiplicity type "%s" for MF=13' %
                total.moniker)

        NR = len(totalInterpolationInfo) / 2
        NP = len(xsec_mult) / 2
        endfMFList[MF][MT].append(
            endfFormatsModule.endfContLine(0, 0, 0, 0, NR, NP))
        endfMFList[MF][MT] += [
            endfFormatsModule.endfInterpolationLine(totalInterpolationInfo)
        ]
        endfMFList[MF][MT] += endfFormatsModule.endfNdDataList(xsec_mult)

    MFGammas12_13 = [[gammaEnergy, originationLevel, MF12_13]
                     for isNotIsotropic, gammaEnergy, originationLevel,
                     MF12_13, MF14 in MFGammas]
    MFGammas12_13.sort(reverse=True)
    for gammaEnergy, originationLevel, MF12_13 in MFGammas12_13:
        endfMFList[MF][MT] += MF12_13  # Store MF 12 or 13 before sorting.
    MFGammas.sort(reverse=True)
    for isNotIsotropic, gammaEnergy, originationLevel, MF12_13, MF14 in MFGammas:
        if (isNotIsotropic): break
        NI += 1
    if (LI == 1): NI = 0
    endfMFList[MF][MT].append(endfFormatsModule.endfSENDLineNumber())

    # if any gammas are anisotropic, MF14 data must be supplied for all gammas:
    isotropic = [gamma for gamma in MFGammas if not gamma[0]]
    anisotropic = [gamma for gamma in MFGammas if gamma[0]]
    if anisotropic:
        LI, LTT, NI = 0, 1, len(isotropic)
        endfMFList[14][MT] = [
            endfFormatsModule.endfContLine(ZA, mass, LI, LTT, NK, NI)
        ]
        for gamma in isotropic:
            endfMFList[14][MT].append(
                endfFormatsModule.endfContLine(gamma[1], gamma[2], 0, 0, 0, 0))
        for gamma in anisotropic:
            endfMFList[14][MT] += gamma[-1]
        endfMFList[14][MT].append(endfFormatsModule.endfSENDLineNumber())
    else:
        endfMFList[14][MT] = [
            endfFormatsModule.endfContLine(ZA, mass, LI, LTT, NK, NI),
            endfFormatsModule.endfSENDLineNumber()
        ]

    targetInfo['doMF4AsMF6'] = doMF4AsMF6
Exemple #8
0
def upDateENDF_MT_MF8Data(MT, endfMFList, targetInfo):

    reactionSuite = targetInfo['reactionSuite']
    MF8Channels = targetInfo['MF8'][MT]
    ZA, mass = targetInfo['ZA'], targetInfo['mass']
    LIS, LISO, NO, NS = targetInfo['LIS'], targetInfo['LISO'], 1, len(
        MF8Channels)
    firstReaction = MF8Channels[0]
    residual = firstReaction.outputChannel[0]

    crossSection_ = firstReaction.crossSection[
        targetInfo['style']]  # LMF determines which MF section to write to.
    if (isinstance(crossSection_, crossSectionModule.reference)):
        multiplicity = residual.multiplicity[targetInfo['style']]
        if (isinstance(multiplicity, multiplicityModule.constant1d)):
            LMF = 3
        elif (isinstance(multiplicity, multiplicityModule.reference)):
            LMF = 6
        else:
            LMF = 9
    else:
        LMF = 10

    level = 0
    if (hasattr(residual, 'getLevelAsFloat')):
        level = residual.getLevelAsFloat('eV')
    endfMFList[8][MT] = [
        endfFormatsModule.endfHeadLine(ZA, mass, LIS, LISO, NS, NO)
    ]
    if (LMF not in [3, 6]):
        endfMFList[LMF][MT] = [
            endfFormatsModule.endfHeadLine(ZA, mass, LIS, 0, NS, 0)
        ]

    for reaction in MF8Channels:
        outputChannel = reaction.outputChannel
        if (len(outputChannel) != 1):
            raise Exception(
                'Currently, production channel can only have one product; not %d'
                % len(outputChannel))
        product = outputChannel[0]

        particle = reactionSuite.PoPs[product.id]
        ZAP = miscPoPsModule.ZA(particle)

        QI = outputChannel.getConstantQAs('eV', final=True)
        LFS2, level2 = 0, 0
        if (isinstance(particle, nuclearLevelModule.particle)):
            LFS2 = particle.intIndex
            level2 = particle.energy[0].float('eV')
        QM = QI + level2

        endfMFList[8][MT].append(
            endfFormatsModule.endfHeadLine(ZAP, level2, LMF, LFS2, 0, 0))

        if (
                LMF == 9
        ):  # Currenty, multiplicity.toENDF6List only has one interpolation and its linear.
            multiplicity = product.multiplicity[targetInfo['style']]
            interpolationFlatData, nPoints, multiplicityList = multiplicity.toENDF6List(
                targetInfo)
            endfMFList[LMF][MT].append(
                endfFormatsModule.endfHeadLine(QM, QI, ZAP, LFS2,
                                               len(interpolationFlatData) / 2,
                                               nPoints))
            endfMFList[LMF][MT] += endfFormatsModule.endfInterpolationList(
                interpolationFlatData)
            endfMFList[LMF][MT] += multiplicityList
        elif (LMF == 10):
            interpolationFlatData, flatData = reaction.crossSection[
                targetInfo['style']].toENDF6Data(MT, endfMFList, targetInfo,
                                                 level2)
            endfMFList[LMF][MT].append(
                endfFormatsModule.endfHeadLine(QM, QI, ZAP, LFS2,
                                               len(interpolationFlatData) / 2,
                                               len(flatData) / 2))
            endfMFList[LMF][MT] += endfFormatsModule.endfInterpolationList(
                interpolationFlatData)
            endfMFList[LMF][MT] += endfFormatsModule.endfDataList(flatData)

    endfMFList[8][MT].append(endfFormatsModule.endfSENDLineNumber())
    if (LMF not in [3, 6]):
        endfMFList[LMF][MT].append(endfFormatsModule.endfSENDLineNumber())