예제 #1
0
파일: xParticle.py 프로젝트: icmeyer/fudge
def toENDF6(self, baseMT, endfMFList, flags, targetInfo):

    MF, MT, LP = 12, baseMT + int(self.label), 0
    nGammas, gammaData, levelEnergy_eV = len(
        self.gammas), [], self.energy.getValueAs('eV')
    for gamma in self.gammas:
        gammaData.append(gamma.toENDF6List())
    LGp = len(gammaData[0])
    for gamma in gammaData:
        gamma[0] = levelEnergy_eV - gamma[0]
    endfMFList[MF][MT] = [
        endfFormatsModule.endfHeadLine(targetInfo['ZA'], targetInfo['mass'], 2,
                                       LGp - 1, MT - baseMT, 0),
        endfFormatsModule.endfHeadLine(levelEnergy_eV, 0., LP, 0,
                                       LGp * nGammas, nGammas)
    ]
    gammaData.sort(reverse=True)
    endfMFList[MF][MT] += endfFormatsModule.endfNdDataList(gammaData)
    endfMFList[MF][MT].append(endfFormatsModule.endfSENDLineNumber())

    # Currently, assume all distributions are isotropic
    endfMFList[14][MT] = [
        endfFormatsModule.endfHeadLine(targetInfo['ZA'], targetInfo['mass'], 1,
                                       0, nGammas, 0)
    ]
    endfMFList[14][MT].append(endfFormatsModule.endfSENDLineNumber())
예제 #2
0
def toENDF6(self, endfMFList, flags, targetInfo, verbosityIndent=''):

    ZAM, AWT = targetInfo['ZA'], targetInfo['mass']
    NIS, ABN = 1, 1.0
    ZAI = ZAM  # assuming only one isotope per file

    # get target spin from the particle list:
    target = targetInfo['reactionSuite'].getParticle(
        targetInfo['reactionSuite'].target.name)
    targetInfo['spin'] = target.getSpin().value

    endf = [endfFormatsModule.endfHeadLine(ZAM, AWT, 0, 0, NIS, 0)]
    resolvedCount, unresolvedCount = 0, 0
    # resolved may have multiple energy regions:
    if self.resolved is not None:
        resolvedCount = max(1, len(self.resolved.regions))
    if self.unresolved is not None: unresolvedCount = 1

    # resonances may only contain a scattering radius:
    if not (resolvedCount + unresolvedCount) and self.scatteringRadius:
        scatRadius = self.scatteringRadius.form
        lowerBound, upperBound = scatRadius.bounds
        endf.append(endfFormatsModule.endfHeadLine(ZAM, ABN, 0, 0, 1, 0))
        endf.append(
            endfFormatsModule.endfHeadLine(lowerBound.getValueAs('eV'),
                                           upperBound.getValueAs('eV'), 0, 0,
                                           0, 0))
        AP = scatRadius.value.getValueAs('10*fm')
        endf.append(
            endfFormatsModule.endfHeadLine(targetInfo['spin'], AP, 0, 0, 0, 0))
        endf.append(endfFormatsModule.endfSENDLineNumber())
        endfMFList[2][151] = endf
        return

    # For now I'm storing the LRF/LFW flags in xml, since they are tricky to compute
    # LFW is a pain: only applies to unresolved, but must be written at the start of MF2
    LRFurr, LFW = 0, 0
    if unresolvedCount != 0:
        LRF_LFW = self.unresolved.evaluated.ENDFconversionFlag
        LRFurr, LFW = map(int, LRF_LFW.split('=')[-1].split(','))
    NER = resolvedCount + unresolvedCount
    endf.append(endfFormatsModule.endfHeadLine(ZAI, ABN, 0, LFW, NER, 0))
    for idx in range(resolvedCount):
        if resolvedCount == 1: region = self.resolved
        else: region = self.resolved.regions[idx]
        LRU = 1  #resolved
        LRF = {
            resonancesModule.SLBW.moniker: 1,
            resonancesModule.MLBW.moniker: 2,
            resonancesModule.RM.moniker: 3,
            resonancesModule.RMatrix.moniker: 7
        }[region.evaluated.moniker]
        EL, EH = region.lowerBound.getValueAs(
            'eV'), region.upperBound.getValueAs('eV')
        if LRF == 7: NRO = 0
        else: NRO = region.evaluated.scatteringRadius.isEnergyDependent()
        NAPS = not (region.evaluated.calculateChannelRadius)
        endf.append(endfFormatsModule.endfHeadLine(EL, EH, LRU, LRF, NRO,
                                                   NAPS))
        endf += region.evaluated.toENDF6(flags, targetInfo, verbosityIndent)
    if unresolvedCount != 0:
        LRU = 2  #unresolved
        region = self.unresolved
        EL, EH = region.lowerBound.getValueAs(
            'eV'), region.upperBound.getValueAs('eV')
        NRO, NAPS = 0, 0
        if region.evaluated.scatteringRadius.isEnergyDependent(): NRO = 1
        endf.append(
            endfFormatsModule.endfHeadLine(EL, EH, LRU, LRFurr, NRO, NAPS))
        # pass LFW/LRF so we don't have to calculate twice:
        targetInfo['unresolved_LFW'] = LFW
        targetInfo['unresolved_LRF'] = LRFurr
        targetInfo['regionEnergyBounds'] = (region.lowerBound,
                                            region.upperBound)
        endf += region.evaluated.toENDF6(flags, targetInfo, verbosityIndent)
    endf.append(endfFormatsModule.endfSENDLineNumber())
    endfMFList[2][151] = endf
예제 #3
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
예제 #4
0
def toENDF6( self, style, flags, verbosityIndent = '', covarianceSuite = None ) :

    evaluatedStyle = self.styles.getEvaluatedStyle( )
    if( evaluatedStyle is None ) : raise ValueError( 'no evaluation style found' )

    if( flags['verbosity'] >= 10 ) : print '%s%s' % ( verbosityIndent, self.inputParticlesToReactionString( suffix = " -->" ) )
    verbosityIndent2 = verbosityIndent + ' ' * ( len( self.inputParticlesToReactionString( suffix = " -->" ) ) + 1 )
    projectile, target = self.projectile, self.target
    projectileZA = projectile.getZ_A_SuffixAndZA( )[-1]
    IPART = projectileZA
    if( projectile.name == 'e-' ) : IPART = 11
    targetZA, MAT = endf_endl.ZAAndMATFromParticleName( target.name )
    targetZ, targetA = divmod( targetZA, 1000 )
    targetInfo = processingInfoModule.tempInfo( )
    targetInfo['style'] = style
    targetInfo['reactionSuite'] = self
    targetInfo['ZA'] = targetZA
    if( self.particles.hasID( 'n' ) ) :       # Need neutron mass in eV/c**2, but it may not be in the particle list.
        targetInfo['neutronMass'] = self.getParticle( 'n' ).getMass( 'eV/c**2' )
    else :
        neutronAmu = masses.getMassFromZA( 1 )
        targetInfo['neutronMass'] = PQU.PQU( neutronAmu, 'amu' ).getValueAs('eV/c**2')
    if( isinstance( target, fudge.gnd.xParticle.element ) ) :
        targetInfo['mass'] = elementalMass[targetZA]
    else :
        targetInfo['mass'] = target.getMass( 'eV/c**2' ) / targetInfo['neutronMass']

    try :
        targetInfo['LIS'] = target['levelIndex']
    except :
        targetInfo['LIS'] = 0
    targetInfo['metastables'] = []
    targetInfo['LISO'] = 0
    for key, alias in self.aliases.items( ) :
        if( alias.hasAttribute( 'nuclearMetaStable' ) ) :
            targetInfo['metastables'].append( alias.getValue() )
            if( alias.getValue() == target.name ) :
                targetInfo['LISO'] = int( alias.getAttribute( 'nuclearMetaStable' ) )
    MAT += targetInfo['LISO']
    if( self.MAT is not None ) : MAT = self.MAT

    ITYPE = 0                   # Other ITYPE sublibraries not yet supported. BRB is this still true
    for reaction in self.reactions :
        if( 500 <= reaction.ENDF_MT < 573 ) : ITYPE = 3
    targetInfo['crossSectionMF'] = { 0 : 3, 3 : 23 }[ITYPE]

    targetInfo['delayedRates'] = []
    targetInfo['totalDelayedNubar'] = None
    targetInfo['MTs'], targetInfo['MF8'], targetInfo['LRs'] = {}, {}, {}
    endfMFList = { 1 : { 451 : [] }, 2 : {}, 3 : {}, 4 : {}, 5 : {}, 6 : {}, 8 : {}, 9 : {}, 10 : {}, 12 : {}, 13 : {},
            14 : {}, 15 : {}, 23 : {}, 26 : {}, 27 : {}, 31 : {}, 32 : {}, 33 : {}, 34 : {}, 35 : {}, 40 : {} }
    if( self.resonances is not None ) :      # Add resonances, independent of reaction channels
        self.resonances.toENDF6( endfMFList, flags, targetInfo, verbosityIndent=verbosityIndent2 )

    targetInfo['production_gammas'] = {}

    for reaction in self :
        reaction.toENDF6( endfMFList, flags, targetInfo, verbosityIndent = verbosityIndent2 )
    gndToENDF6Module.upDateENDFMF8Data( endfMFList, targetInfo )
    for MT, production_gammas in targetInfo['production_gammas'].items( ) :
        MF, production_gammas = production_gammas[0], production_gammas[1:]
        for productionReaction in production_gammas :
            gammas = [ gamma for gamma in productionReaction.outputChannel ]
            targetInfo['crossSection'] = productionReaction.crossSection[targetInfo['style']]
            gndToENDF6Module.gammasToENDF6_MF12_13( MT, MF, endfMFList, flags, targetInfo, gammas )

    for particle in self.particles :              # gamma decay data.
        if( isinstance( particle, fudge.gnd.xParticle.isotope ) ) :
            for level in particle :
                if( level.gammas ) :                        # non-empty gamma information
                    for baseMT in [ 50, 600, 650, 700, 750, 800 ] :
                        residualZA = endf_endl.ENDF_MTZAEquation( projectileZA, targetZA, baseMT )[0][-1]
                        if( nuclear.nucleusNameFromZA( residualZA ) == particle.name ) : break
                    level.toENDF6( baseMT, endfMFList, flags, targetInfo )

    MFs = sorted( endfMFList.keys( ) )
    endfList = []

    totalNubar = None
    totalDelayedNubar = targetInfo['totalDelayedNubar']
    if( 455 in endfMFList[5] ) :
        MF5MT455s = endfMFList[5][455]

        endfMFList[1][455]  = [ endfFormatsModule.endfHeadLine( targetZA, targetInfo['mass'], 0, 2, 0, 0 ) ] # Currently, only LDG = 0, LNU = 2 is supported.
        endfMFList[1][455] += [ endfFormatsModule.endfHeadLine( 0, 0, 0, 0, len( targetInfo['delayedRates'] ), 0 ) ]
        endfMFList[1][455] += endfFormatsModule.endfDataList( targetInfo['delayedRates'] )

        multiplicityModule.fissionNeutronsToENDF6( 455, totalDelayedNubar, endfMFList, flags, targetInfo )

        MF5MT455List = [ endfFormatsModule.endfHeadLine( targetZA, targetInfo['mass'], 0, 0, len( MF5MT455s ), 0 ) ]
        for MF5MT455 in MF5MT455s : MF5MT455List += MF5MT455
        if( len( MF5MT455s ) == 0 ) :
            del endfMFList[5][455]
        else :
            endfMFList[5][455] = MF5MT455List + [ endfFormatsModule.endfSENDLineNumber( ) ]
    if(   'promptNubar' in targetInfo.dict ) :
        promptNubar = targetInfo['promptNubar']
        multiplicityModule.fissionNeutronsToENDF6( 456, promptNubar, endfMFList, flags, targetInfo )
        totalNubar = promptNubar
        try :
            if( not( totalDelayedNubar is None ) ) : totalNubar = totalNubar + totalDelayedNubar
        except :                                # The following is a kludge for some "bad" data.
            if( ( totalNubar.domainMax( unitTo = 'MeV' ) == 30. ) and
                ( totalDelayedNubar.domainMax( unitTo = 'MeV' ) == 20. ) ) :
                    totalDelayedNubar[-1] = [ totalNubar.domainMax( ), totalDelayedNubar.getValue( totalDelayedNubar.domainMax( ) ) ]
            totalNubar = totalNubar + totalDelayedNubar
    elif( 'totalNubar' in targetInfo.dict ) :
        totalNubar = targetInfo['totalNubar']
    if( totalNubar is not None ) :
        multiplicityModule.fissionNeutronsToENDF6( 452, totalNubar, endfMFList, flags, targetInfo )

    if( covarianceSuite ) : covarianceSuite.toENDF6( endfMFList, flags, targetInfo )

    endfDoc = self.documentation.get( 'endfDoc' )
    if( endfDoc is None ) :
        docHeader2 = [  ' %2d-%-2s-%3d LLNL       EVAL-OCT03 Unknown' % ( targetZ, fudge.particles.nuclear.elementSymbolFromZ( targetZ ), targetA ),
                        '                      DIST-DEC99                       19990101   ',
                        '----ENDL              MATERIAL %4d' % MAT,
                        '-----INCIDENT %s DATA' %
                            { 1 : 'NEUTRON', 1001 : 'PROTON', 1002 : 'DEUTERON', 1003 : 'TRITON', 2003 : 'HELION', 2004 : 'ALPHA' }[projectileZA],
                        '------ENDF-6 FORMAT' ]
        endfDoc = [ 'LLNL ENDL file translated to ENDF6 by FUDGE.', '' ' ************************ C O N T E N T S ***********************' ]
    else :
        docHeader2 = []
        endfDoc = endfDoc.getLines( )

        # update the documentation, including metadata on first 4 lines:
    try :
        self.getReaction( 'fission' )
        LFI = True
    except KeyError :
        LFI = False
    LRP = -1
    if( self.resonances is not None ) :
        if( self.resonances.scatteringRadius ) :
            LRP = 0
        elif( self.resonances.reconstructCrossSection ) :
            LRP = 1
        elif( self.resonances.unresolved and not( self.resonances.resolved )
                and self.resonances.unresolved.tabulatedWidths.forSelfShieldingOnly ) :
            LRP = 1
        else :
            LRP = 2
    EMAX = max( [ reaction.crossSection.domainMax( unitTo = 'eV' ) for reaction in self.reactions ] )

    temperature = self.styles[style].temperature.getValueAs( 'K' )
    library = evaluatedStyle.library
    version = evaluatedStyle.version
    if( library == 'ENDL' ) :           # Additional ENDF meta-data. If the library is unknown, use NLIB = -1
        NVER, LREL, NMOD = 1, 1, 1
        NLIB = -1
    else :
        NVER, LREL, NMOD = map( int, version.split( '.' ) )    # Version stored as '7.2.1'
        NLIB = { "ENDF/B" :  0,     "ENDF/A" :  1,      "JEFF"                 :  2,    "EFF"      :  3,    "ENDF/B (HE)" :  4,
                 "CENDL"  :  5,     "JENDL"  :  6,      "SG-23"                : 21,    "INDL/V"   : 31,    "INDL/A"      : 32,
                 "FENDL"  : 33,     "IRDF"   : 34,      "BROND (IAEA version)" : 35,    "INGDB-90" : 36,    "FENDL/A"     : 37,
                 "BROND"  : 41 }.get( library, -1 )

    NFOR = 6    # ENDF-6 format
    NSUB = 10 * IPART + ITYPE
    LDRV = 0
    STA = 0
    if( isinstance( self.target, fudge.gnd.xParticle.nuclearLevel ) or self.target.attributes.get( 'unstable' ) ) : STA = 1
    if( targetInfo['LISO'] ) : STA = 1
    levelIndex, level_eV = 0, 0.
    if( hasattr( self.target, 'getLevelIndex' ) ) : levelIndex, level_eV = self.target.getLevelIndex( ), self.target.getLevelAsFloat( 'eV' )
    docHeader = [ endfFormatsModule.endfHeadLine( targetZA, targetInfo['mass'], LRP, LFI, NLIB, NMOD ),
            endfFormatsModule.endfHeadLine( level_eV, STA, levelIndex, targetInfo['LISO'], 0, NFOR ),
            endfFormatsModule.endfHeadLine( self.projectile.getMass( 'eV/c**2' ) / targetInfo['neutronMass'], EMAX, LREL, 0, NSUB, NVER ),
            endfFormatsModule.endfHeadLine( temperature, 0, LDRV, 0, len( endfDoc ), -1 ) ]
    new_doc = fudge.gnd.documentation.documentation( 'endf', '\n'.join( docHeader + docHeader2 + endfDoc ) )
    endfMFList[1][451] += endfFormatsModule.toEndfStringList( new_doc )

    return( endfFormatsModule.endfMFListToFinalFile( endfMFList, MAT, lineNumbers = True ) )
예제 #5
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())