Exemplo n.º 1
0
def toENDF6(self, flags, targetInfo):

    MF6 = [endfFormatsModule.endfContLine(0, 0, 0, 0, 1, len(self))]
    EInInterpolation = gndToENDF6Module.gndToENDF2PlusDInterpolationFlag(
        self.interpolation, self.interpolationQualifier)
    energyConversionFactor = PQUModule.PQU(1,
                                           self.axes[-1].unit).getValueAs('eV')
    MF6 += endfFormatsModule.endfInterpolationList(
        [len(self), EInInterpolation])
    for oneEin in self:
        muInterpolation = gndToENDF6Module.gndToENDF2PlusDInterpolationFlag(
            self.interpolation, self.interpolationQualifier)
        Ein = oneEin.value * energyConversionFactor
        numMu = len(oneEin)
        MF6 += [endfFormatsModule.endfContLine(0, Ein, 0, 0, 1, numMu)]
        MF6 += endfFormatsModule.endfInterpolationList(
            [numMu, muInterpolation])
        for entries in oneEin:
            pdf_of_EpInterpolation = gndToENDF6Module.gndToENDFInterpolationFlag(
                self.interpolation)
            mu = entries.value
            numEout = len(entries)
            MF6 += [endfFormatsModule.endfContLine(0, mu, 0, 0, 1, numEout)]
            MF6 += endfFormatsModule.endfInterpolationList(
                [numEout, pdf_of_EpInterpolation])
            xys = entries.copyDataToXYs(xUnitTo='eV', yUnitTo='1/eV')
            MF6 += endfFormatsModule.endfNdDataList(xys)
    return (7, standardsModule.frames.labToken, MF6)
Exemplo n.º 2
0
def toENDF6(self, flags, targetInfo, weight=None, MT=None):

    NE = len(self)
    EInFactor = PQUModule.PQU(1, self.axes[-1].unit).getValueAs('eV')
    if (weight is None):
        weight = [[self[0].value * EInFactor, 1.0],
                  [self[-1].value * EInFactor, 1.0]]
    EInInterpolation = gndToENDF6Module.gndToENDF2PlusDInterpolationFlag(
        self.interpolation, self.interpolationQualifier)
    C1, C2, LAW, LANG = 0, 0, 0, 0
    if (MT == 527): C1, C2, LAW, LANG = 11, 5.438675e-4, 1, 2
    ENDFDataList = [ endfFormatsModule.endfContLine( C1, C2, 0, 1, 1, len( weight ) ) ] + \
        endfFormatsModule.endfInterpolationList( [ len( weight ), 2 ] ) + endfFormatsModule.endfNdDataList( weight ) + \
        [ endfFormatsModule.endfContLine( 0, 0, LAW, LANG, 1, NE ) ] + endfFormatsModule.endfInterpolationList( [ NE, EInInterpolation ] )
    for energy in self:
        if (MT == 527):
            ENDFDataList.append(
                endfFormatsModule.endfContLine(0, energy.value * EInFactor,
                                               0, 0, 2 * len(energy),
                                               len(energy)))
            ENDFDataList += endfFormatsModule.endfNdDataList(energy,
                                                             xUnit='eV',
                                                             yUnit='1/eV')
        else:
            if (isinstance(energy, regionsModule.regions1d)):
                interpolations, data = [], []
                for region in energy:
                    regionData = region.copyDataToXYs(xUnitTo='eV',
                                                      yUnitTo='1/eV')
                    if (len(data) > 0):
                        if (data[-1] == regionData[0]): regionData.pop(0)
                    data += regionData
                    interpolations.append(len(data))
                    interpolations.append(
                        gndToENDF6Module.gndToENDFInterpolationFlag(
                            region.interpolation))
                NR, NE = len(interpolations) / 2, interpolations[-2]
                ENDFDataList.append(
                    endfFormatsModule.endfContLine(0, energy.value * EInFactor,
                                                   0, 0, NR, NE))
                ENDFDataList += endfFormatsModule.endfInterpolationList(
                    interpolations)
                ENDFDataList += endfFormatsModule.endfNdDataList(data)
            else:
                interpolation = gndToENDF6Module.gndToENDFInterpolationFlag(
                    energy.interpolation)
                ENDFDataList.append(
                    endfFormatsModule.endfContLine(0, energy.value * EInFactor,
                                                   0, 0, 1, len(energy)))
                ENDFDataList += endfFormatsModule.endfInterpolationList(
                    [len(energy), interpolation])
                ENDFDataList += endfFormatsModule.endfNdDataList(energy,
                                                                 xUnit='eV',
                                                                 yUnit='1/eV')
    return (1, ENDFDataList)
Exemplo n.º 3
0
def toENDF6(self, flags, targetInfo, weight=None):

    U, EFL, EFH = 0, 0, 0
    if (self.LF == 12):
        EFL, EFH = self.EFL.getValueAs('eV'), self.EFH.getValueAs('eV')
    else:
        U = self.U.getValueAs('eV')
    parameter1 = self.parameter1.data
    energyFactor = float(
        PQUModule.PQU('1 eV') / PQUModule.PQU(1, parameter1.axes[1].unit))
    if (weight is None):
        weight = [[energyFactor * parameter1[0][0], 1.0],
                  [energyFactor * parameter1[-1][0], 1.0]]
        interpolation = 2
    elif (hasattr(weight, 'axes')):
        interpolation = gndToENDF6Module.gndToENDFInterpolationFlag(
            weight.interpolation)
    else:
        interpolation = 2
    ENDFDataList = [ endfFormatsModule.endfContLine( U, 0, 0, self.LF, 1, len( weight ) ) ] + \
        endfFormatsModule.endfInterpolationList( [ len( weight ), interpolation ] ) + endfFormatsModule.endfNdDataList( weight )
    ENDFDataList += endfFormatsModule.toTAB1(parameter1,
                                             'eV',
                                             'eV',
                                             C1=EFL,
                                             C2=EFH)
    if (self.parameter2 is not None):
        parameter2 = self.parameter2.data
        yUnit = ''
        if (self.LF in [5, 11]): yUnit = '1/eV'
        ENDFDataList += endfFormatsModule.toTAB1(parameter2, 'eV', yUnit)
    return (1, ENDFDataList)
Exemplo n.º 4
0
def toENDF6( self, flags, targetInfo ) :

    MT = 5
    EInInterpolation = gndToENDF6Module.gndToENDF2PlusDInterpolationFlag( self.interpolation, self.interpolationQualifier )
    EpInterpolation0 = gndToENDF6Module.gndToENDF2PlusDInterpolationFlag( self[0].interpolation, self[0].interpolationQualifier )
    if( EpInterpolation0 == 1 ) :       # flat interpolation
        LEP = 1
    elif( EpInterpolation0 == 2 ) :     # lin-lin interpolation
        LEP = 2
    else :
        raise 'hell - fix me'
    ENDFDataList = [ endfFormatsModule.endfContLine( 0, 0, 1, LEP, 1, len( self ) ) ]
    ENDFDataList += endfFormatsModule.endfInterpolationList( [ len( self ), EInInterpolation ] )
    energyInFactor = PQUModule.PQU( 1, self.axes[3].unit ).getValueAs( 'eV' )
    energyPFactor = PQUModule.PQU( 1, self.axes[2].unit ).getValueAs( 'eV' )
    for energyIn in self :
        if( not( isinstance( energyIn, multiD_XYsModule.XYs2d ) ) ) : raise 'hell - fix me'
        EpInterpolation = gndToENDF6Module.gndToENDF2PlusDInterpolationFlag( energyIn.interpolation, energyIn.interpolationQualifier )
        if( EpInterpolation != EpInterpolation0 ) : raise 'hell - fix me'
        NA, data = 0, []
        for energy_p in energyIn :
            if( not( isinstance( energy_p, series1dModule.LegendreSeries ) ) ) : raise 'hell - fix me'
            NA = max( len( energy_p ) , NA )
            coefficients = [ coefficient / energyPFactor for coefficient in energy_p ]
            data += [ energy_p.value * energyPFactor ] + coefficients
        ENDFDataList.append( endfFormatsModule.endfContLine( 0, energyIn.value * energyInFactor, 0, NA - 1, len( data ), len( data ) / ( NA + 1 ) ) )
        ENDFDataList += endfFormatsModule.endfDataList( data )
    LAW = 1
    return( LAW, ENDFDataList )
Exemplo n.º 5
0
def toENDF6( self, MT, endfMFList, flags, targetInfo ) :

    LAW, LEP = 1, 2
    EInInterpolation = gndToENDF6Module.axisToEndfInterpolationFlag( self.axes[1] )
    E_ins = [ [ EpCl.value, {} ] for EpCl in self[0].EpP ]
    for l_EEpCl in self :
        for indexE, EpCl in enumerate( l_EEpCl ) :
            if( EpCl.value != E_ins[indexE][0] ) :
                raise Exception( "E_in = %s not in list E_ins" % EpCl.value )
            for Ep, Cl in EpCl :
                if( Ep not in E_ins[indexE][1] ) :
                    E_ins[indexE][1][Ep] = []
                    for l in xrange( l_EEpCl.l ) : E_ins[indexE][1][Ep].append( 0. )
                E_ins[indexE][1][Ep].append( Cl )
    ENDFDataList = [ endfFormatsModule.endfContLine( 0, 0, 1, LEP, 1, len( E_ins ) ) ]
    ENDFDataList += endfFormatsModule.endfInterpolationList( [ len( E_ins ), EInInterpolation ] )
    for Es in E_ins :
        NA, data = 0, []
        for key in sorted( Es[1] ) :
            LegendreSeries = Es[1][key]
            NA = max( len( LegendreSeries ) , NA )
            data += [ key ] + LegendreSeries
        ENDFDataList.append( endfFormatsModule.endfContLine( 0, Es[0], 0, NA - 1, len( data ), len( data ) / ( NA + 1 ) ) )
        ENDFDataList += endfFormatsModule.endfDataList( data )
    gndToENDF6Module.toENDF6_MF6( MT, endfMFList, flags, targetInfo, LAW, self.productFrame, ENDFDataList )
Exemplo n.º 6
0
def toENDF6(self, MT, endfMFList, flags, targetInfo):

    data = []
    for xy in self.copyDataToXYs(xUnitTo='eV', yUnitTo='eV'):
        data += xy
    NE = len(self)
    EInInterpolation = gndToENDF6Module.gndToENDFInterpolationFlag(
        self.interpolation)
    ENDFDataList = [ endfFormatsModule.endfContLine( 0, 0, 0, 0, 1, NE ) ] + \
            endfFormatsModule.endfInterpolationList( [ NE, EInInterpolation ] )
    ENDFDataList += endfFormatsModule.endfDataList(data)
    return (standardsModule.frames.labToken, ENDFDataList)
Exemplo n.º 7
0
def toENDF6(self, MT, endfMFList, flags, targetInfo):

    if (MT == 502): MT = self.ancestor.ENDFMT
    Z = targetInfo['ZA'] / 1000

    endfInterpolation = gndToENDF6Module.gndToENDFInterpolationFlag(
        self.interpolation)
    data = []
    for xy in self.copyDataToXYs(xUnitTo='eV', yUnitTo=''):
        data += xy
    endfMFList[27][MT] = [ endfFormatsModule.endfHeadLine( targetInfo['ZA'], targetInfo['mass'],  0, 0, 0, 0 ),
                           endfFormatsModule.endfContLine( 0, Z,  0, 0, 1, len( data ) / 2 ) ] + \
                           endfFormatsModule.endfInterpolationList( ( len( data ) / 2, endfInterpolation ) ) + \
                           endfFormatsModule.endfDataList( data ) + [ endfFormatsModule.endfSENDLineNumber( ) ]
Exemplo n.º 8
0
def toENDF6(self, flags, targetInfo, weight=None):

    interpolations, ENDFDataList, length = [], [], 0
    EInFactor = PQUModule.PQU(1, self.axes[-1].unit).getValueAs('eV')
    for ridx, region in enumerate(self):
        startingIndex = 0
        if ridx > 0 and region[0].copyDataToXYs() == self[
                ridx - 1][-1].copyDataToXYs():
            startingIndex = 1
        lengthSub, EInInterpolation, ENDFDataListSub = toENDF6_oneRegion(
            region, EInFactor, startingIndex)
        length += lengthSub
        interpolations += [length, EInInterpolation]
        ENDFDataList += ENDFDataListSub
    if (weight is None):
        weight = [[self[0][0].value * EInFactor, 1.0],
                  [self[-1][-1].value * EInFactor, 1.0]]
    NR = len(interpolations) / 2
    NE = interpolations[-2]
    ENDFDataList = [ endfFormatsModule.endfContLine( 0, 0, 0, 1, 1, len( weight ) ) ] + \
            endfFormatsModule.endfInterpolationList( [ len( weight ), 2 ] ) + endfFormatsModule.endfNdDataList( weight ) + \
            [ endfFormatsModule.endfContLine( 0, 0, 0, 0, NR, NE ) ] + endfFormatsModule.endfInterpolationList( interpolations ) + \
            ENDFDataList
    return (1, ENDFDataList)
Exemplo n.º 9
0
def fissionNeutronsToENDF6(MT, multiplicity, endfMFList, flags, targetInfo):

    if (isinstance(multiplicity, multiplicityModule.polynomial)):
        multiplicity.toENDF6(MT, endfMFList, flags, targetInfo)
    else:
        interpolation, n1, data = multiplicity.toENDF6List(targetInfo)
        if (MT not in endfMFList[1]):
            endfMFList[1][MT] = [
                endfFormatsModule.endfHeadLine(targetInfo['ZA'],
                                               targetInfo['mass'], 0, 2, 0, 0)
            ]
        endfMFList[1][MT] += [
            endfFormatsModule.endfHeadLine(0, 0, 0, 0,
                                           len(interpolation) / 2, n1)
        ]
        endfMFList[1][MT] += endfFormatsModule.endfInterpolationList(
            interpolation)
        endfMFList[1][MT] += data + [endfFormatsModule.endfSENDLineNumber()]
Exemplo n.º 10
0
def toENDF6(self, MT, endfMFList, flags, targetInfo):

    fSubform = self.fSubform.data
    rSubform = self.rSubform.data
    aSubform = self.aSubform
    if (not (aSubform.isEmptyASubform())): raise 'hell - FIXME'

    outgoingInterpolation = set([val.interpolation for val in fSubform] +
                                [val.interpolation for val in rSubform])
    if len(outgoingInterpolation) != 1:
        raise NotImplementedError(
            "Only one outgoing interpolation supported when writing Kalbach-Mann to ENDF-6"
        )

    LEP = {'flat': 1, 'lin-lin': 2}[outgoingInterpolation.pop()]
    ENDFDataList = [
        endfFormatsModule.endfContLine(0, 0, 2, LEP, 1, len(fSubform))
    ]
    ENDFDataList += endfFormatsModule.endfInterpolationList([len(fSubform), 2])
    EInUnit = fSubform.axes[2].unit
    EpUnit = fSubform.axes[1].unit
    fUnit = fSubform.axes[0].unit
    EInFactor = PQUModule.PQU(1, EInUnit).getValueAs('eV')
    EpFactor = PQUModule.PQU(1, EpUnit).getValueAs('eV')
    fFactor = PQUModule.PQU(1, fUnit).getValueAs('1/eV')
    for i1, fAtEnergy in enumerate(fSubform):
        rAtEnergy = rSubform[i1]
        if (not (isinstance(fAtEnergy, XYsModule.XYs1d))): raise 'hell - FIXME'
        if (not (isinstance(rAtEnergy, XYsModule.XYs1d))): raise 'hell - FIXME'
        value = fAtEnergy.value
        if (value != rAtEnergy.value): raise 'hell - FIXME'
        value *= EInFactor
        coefficients = []
        for i1, (Ep1, f1) in enumerate(fAtEnergy):
            Ep2, r1 = rAtEnergy[i1]
            if (Ep1 != Ep2): raise 'hell - FIXME'
            coefficients += [EpFactor * Ep1, fFactor * f1, r1]
        length = len(coefficients)
        ENDFDataList += [
            endfFormatsModule.endfContLine(0, value, 0, 1, length, length / 3)
        ]
        ENDFDataList += endfFormatsModule.endfDataList(coefficients)
    gndToENDF6Module.toENDF6_MF6(MT, endfMFList, flags, targetInfo, 1,
                                 self.productFrame, ENDFDataList)
Exemplo n.º 11
0
def toENDF6(self, flags, targetInfo):

    ENDFDataList = [endfFormatsModule.endfContLine(0, 0, 0, 0, 1, len(self))]
    interpolation = gndToENDF6Module.gndToENDF2PlusDInterpolationFlag(
        self.interpolation, self.interpolationQualifier)
    ENDFDataList += endfFormatsModule.endfInterpolationList(
        [len(self), interpolation])
    for energy_in in self:
        if (isinstance(energy_in, XYsModule.XYs1d)):
            ENDFDataList += gndToENDF6Module.angularPointwiseEnergy2ENDF6(
                energy_in, targetInfo)
        elif (isinstance(energy_in, series1dModule.LegendreSeries)):
            ENDFDataList += gndToENDF6Module.angularLegendreEnergy2ENDF6(
                energy_in, targetInfo)
        else:
            raise 'hell - fix me'
    if (not (targetInfo['doMF4AsMF6'])):
        ENDFDataList.append(endfFormatsModule.endfSENDLineNumber())
    return (0, 2, ENDFDataList)
Exemplo n.º 12
0
def toENDF6( self, MT, endfMFList, flags, targetInfo ) :

    EInInterpolation = gndToENDF6Module.axisToEndfInterpolationFlag( self.axes[0] )
    independent, dependent, qualifier = self.axes[1].interpolation.getInterpolationTokens( )
    if( dependent == standardsModule.interpolation.flatToken ) :
        LEP = 1  # interpolation for Eout
    else :
        LEP = 2
    ENDFDataList = [ endfFormatsModule.endfContLine( 0, 0, 1, LEP, 1, len( self ) ) ]
    ENDFDataList += endfFormatsModule.endfInterpolationList( [ len( self ), EInInterpolation ] )
    for energy_in in self :
        NA, data = 0, []
        for w_xys_LegendreSeries in energy_in :
            NA = max( len( w_xys_LegendreSeries) , NA )
            data += [ w_xys_LegendreSeries.value ] + w_xys_LegendreSeries.coefficients
        ENDFDataList.append( endfFormatsModule.endfContLine( 0, energy_in.value, 0, NA - 1, len( data ), len( data ) / ( NA + 1 ) ) )
        ENDFDataList += endfFormatsModule.endfDataList( data )
    LAW = 1
    gndToENDF6Module.toENDF6_MF6( MT, endfMFList, flags, targetInfo, LAW, self.productFrame, ENDFDataList )
Exemplo n.º 13
0
def toENDF6_oneRegion(self, EInFactor, startingIndex=0):

    ENDFDataList = []
    for index, energy_in in enumerate(self[startingIndex:]):
        ENDFDataList += [
            endfFormatsModule.endfContLine(0., energy_in.value * EInFactor, 0,
                                           0, 1, len(energy_in))
        ]
        ENDFDataList += endfFormatsModule.endfInterpolationList([
            len(energy_in),
            gndToENDF6Module.gndToENDFInterpolationFlag(
                energy_in.interpolation)
        ])
        ENDFDataList += endfFormatsModule.endfNdDataList(energy_in,
                                                         xUnit='eV',
                                                         yUnit='1/eV')
    EInInterpolation = gndToENDF6Module.gndToENDF2PlusDInterpolationFlag(
        self.interpolation, self.interpolationQualifier)
    return (len(self[startingIndex:]), EInInterpolation, ENDFDataList)
Exemplo n.º 14
0
    def angularPointwiseEnergy2ENDF6(self, targetInfo):

        interpolation = gndToENDF6Module.gndToENDFInterpolationFlag(
            self.interpolation)
        energy_in_eV = self.value * energyConversionFactor
        if (targetInfo['doMF4AsMF6']):
            ENDFDataList = [
                endfFormatsModule.endfContLine(0, energy_in_eV,
                                               interpolation + 10, 0,
                                               2 * len(self), len(self))
            ]
        else:
            ENDFDataList = [
                endfFormatsModule.endfContLine(0, energy_in_eV, 0, 0, 1,
                                               len(self))
            ]
            ENDFDataList += endfFormatsModule.endfInterpolationList(
                [len(self), interpolation])
        ENDFDataList += endfFormatsModule.endfNdDataList(self)
        return (ENDFDataList)
Exemplo n.º 15
0
def toENDF6(self, MT, endfMFList, targetInfo, level, LR):
    """
    Convert self into ENDF format

    :param int MT: The ENDF reaction designator, MT
    :param endfMFList:
    :param targetInfo:
    :param level:
    :param LR:
    """

    ZA, mass, QI, QM = targetInfo['ZA'], targetInfo['mass'], targetInfo[
        'Q'], targetInfo['QM']
    if ('EFL' in targetInfo):
        QM = QI
        QI = targetInfo['EFL']
    else:
        if (QM is None):
            if (MT in (2, 5)):
                QM = QI
            elif (MT == 4):  # Q should be 0 except for excited-state targets:
                QM = 0
                if (hasattr(targetInfo['reactionSuite'].target,
                            'getLevelIndex')):
                    if (targetInfo['reactionSuite'].target.getLevelIndex() >
                            0):
                        QM = QI
            else:
                QM = QI + level
    interpolationFlatData, crossSectionFlatData = self[
        targetInfo['style']].toENDF6Data(MT, endfMFList, targetInfo, level)
    MF = targetInfo['crossSectionMF']
    endfMFList[MF][MT] = [endfFormatsModule.endfHeadLine(ZA, mass, 0, 0, 0, 0)]
    endfMFList[MF][MT].append(
        endfFormatsModule.endfContLine(QM, QI, 0, LR,
                                       len(interpolationFlatData) / 2,
                                       len(crossSectionFlatData) / 2))
    endfMFList[MF][MT] += endfFormatsModule.endfInterpolationList(
        interpolationFlatData)
    endfMFList[MF][MT] += endfFormatsModule.endfDataList(crossSectionFlatData)
    endfMFList[MF][MT].append(endfFormatsModule.endfSENDLineNumber())
Exemplo n.º 16
0
def toAngularPointwise(angularSubform, targetInfo, insertSENDL):

    energyConversionFactor = PQUModule.PQU(
        1, angularSubform.axes[-1].unit).getValueAs('eV')

    def angularPointwiseEnergy2ENDF6(self, targetInfo):

        interpolation = gndToENDF6Module.gndToENDFInterpolationFlag(
            self.interpolation)
        energy_in_eV = self.value * energyConversionFactor
        if (targetInfo['doMF4AsMF6']):
            ENDFDataList = [
                endfFormatsModule.endfContLine(0, energy_in_eV,
                                               interpolation + 10, 0,
                                               2 * len(self), len(self))
            ]
        else:
            ENDFDataList = [
                endfFormatsModule.endfContLine(0, energy_in_eV, 0, 0, 1,
                                               len(self))
            ]
            ENDFDataList += endfFormatsModule.endfInterpolationList(
                [len(self), interpolation])
        ENDFDataList += endfFormatsModule.endfNdDataList(self)
        return (ENDFDataList)

    ENDFDataList = [
        endfFormatsModule.endfContLine(0, 0, 0, 0, 1, len(angularSubform))
    ]
    interpolation = (gndToENDF6Module.gndToENDFInterpolationFlag(
        angularSubform.interpolation))
    ENDFDataList += endfFormatsModule.endfInterpolationList(
        [len(angularSubform), interpolation])
    start = 0
    if targetInfo.get('skipFirstEnergy'): start = 1
    for energy_in in angularSubform[start:]:
        ENDFDataList += angularPointwiseEnergy2ENDF6(energy_in, targetInfo)
    if (insertSENDL):
        ENDFDataList.append(endfFormatsModule.endfSENDLineNumber())
    return (0, 2, ENDFDataList)
Exemplo n.º 17
0
def toENDF6(self, MT, endfMFList, flags, targetInfo, energyUnit='eV'):

    if (MT == 502): MT = self.ancestor.ENDFMT
    Z = targetInfo['ZA'] / 1000

    endfInterpolation, data = [], []
    counter, lastX, lastY = 0, None, None
    for region in self:
        ENDFInterpolation = gndToENDF6Module.gndToENDFInterpolationFlag(
            region.interpolation)
        regionData = region.copyDataToXYs(xUnitTo=energyUnit, yUnitTo='')
        if (lastX is not None):
            if (lastY == regionData[0][1]): del regionData[0]
        counter += len(regionData)
        endfInterpolation.append(counter)
        endfInterpolation.append(ENDFInterpolation)
        for xy in regionData:
            data += xy
        lastX, lastY = regionData[-1]

    endfMFList[27][MT] = [ endfFormatsModule.endfHeadLine( targetInfo['ZA'], targetInfo['mass'],  0, 0, 0, 0 ),
                           endfFormatsModule.endfContLine( 0, Z,  0, 0, len( endfInterpolation ) / 2, len( data ) / 2 ) ] + \
                           endfFormatsModule.endfInterpolationList( endfInterpolation ) + \
                           endfFormatsModule.endfDataList( data ) + [ endfFormatsModule.endfSENDLineNumber( ) ]
Exemplo n.º 18
0
def toENDF6(self, MT, endfMFList, flags, targetInfo):
    def LTP_oneSubParsing(LTP, LIDP, nuclear, interferenceReal,
                          interferenceImaginary, lineData):

        if LIDP:
            NL = len(nuclear) - 1
            NW = 3 * NL + 3
        else:
            NL = (len(nuclear) - 1) // 2
            NW = 4 * NL + 3
        lineData.append(
            endfFormatsModule.endfContLine(0, nuclear.value, LTP, 0, NW, NL))
        legendreDat = nuclear.coefficients
        for j, r in enumerate(interferenceReal.coefficients):
            legendreDat.append(r)
            legendreDat.append(interferenceImaginary[j])
        lineData += endfFormatsModule.endfDataList(legendreDat)

    counts, interpolationFlagsList, lineData = 0, [], []
    LTP = 1  # indicates this is a nuclear + interference section
    target, projectile = targetInfo['reactionSuite'].target, targetInfo[
        'reactionSuite'].projectile
    LIDP = target == projectile
    if (isinstance(self.nuclear_term, angularModule.XYs2d)):
        for ridx in xrange(len(self.nuclear_term)):
            counts += 1
            nuclear, interferenceReal, interferenceImaginary = self.nuclear_term[
                ridx], self.interferenceReal_term[
                    ridx], self.interferenceImaginary_term[ridx]
            LTP_oneSubParsing(LTP, LIDP, nuclear, interferenceReal,
                              interferenceImaginary, lineData)
        interpolationFlagsList += [
            counts,
            gndToENDF6Module.gndToENDFInterpolationFlag(
                self.nuclear_term.interpolation)
        ]
    elif (isinstance(self.nuclear_term, angularModule.regions2d)):
        for regionIndex, region in enumerate(self.nuclear_term):
            interferenceReal, interferenceImaginary = self.interferenceReal_term[
                regionIndex], self.interferenceImaginary_term[regionIndex]
            for energyIndex, nuclear in enumerate(region):
                if ((regionIndex != 0) and (energyIndex == 0)): continue
                counts += 1
                LTP_oneSubParsing(LTP, LIDP, nuclear,
                                  interferenceReal[energyIndex],
                                  interferenceImaginary[energyIndex], lineData)
            interpolationFlagsList += [
                counts,
                gndToENDF6Module.gndToENDFInterpolationFlag(
                    region.interpolation)
            ]
    else:
        raise NotImplementedError(
            "Unknown data storage inside CoulombExpansion: %s" %
            type(self.nuclear_term))
    interpolationFlags = endfFormatsModule.endfInterpolationList(
        interpolationFlagsList)
    ENDFDataList = [
        endfFormatsModule.endfContLine(projectile.getSpin().value, 0, LIDP, 0,
                                       len(interpolationFlagsList) / 2, counts)
    ] + interpolationFlags + lineData
    if (not (targetInfo['doMF4AsMF6'])):
        ENDFDataList.append(endfFormatsModule.endfSENDLineNumber())
    LAW = 5
    gndToENDF6Module.toENDF6_MF6(MT, endfMFList, flags, targetInfo, LAW,
                                 self.productFrame, ENDFDataList)
Exemplo n.º 19
0
def toENDF6(self, MT, endfMFList, flags, targetInfo):

    if (MT == 455) and (MT in endfMFList[4]):
        return  # only write one 'isotropic' section for all delayed neutron groups
    angularSubform = self.angularSubform
    if (hasattr(angularSubform, 'toENDF6')):

        doMF4AsMF6 = targetInfo['doMF4AsMF6']
        MF = 4
        NM = 0
        frame = self.productFrame
        if (frame is None):
            frame = self.ancestor.productFrame  # Happens for uncorrelated distribution.
        if (isinstance(angularSubform, multiD_XYsModule.XYs2d)):
            if (isinstance(angularSubform[0], XYsModule.XYs1d)):
                LI, LTT, MF4 = toAngularPointwise(angularSubform, targetInfo,
                                                  not (doMF4AsMF6))
            elif (isinstance(angularSubform[0],
                             series1dModule.LegendreSeries)):
                interpolation, numberOfPoints, LI, LTT, NM, MF4Sub = toAngularLegendre(
                    angularSubform, targetInfo, not (doMF4AsMF6))
                MF4 = [ endfFormatsModule.endfContLine( 0, 0, 0, 0, 1, numberOfPoints ) ] + \
                        endfFormatsModule.endfInterpolationList( [ len( angularSubform ), interpolation ] )
                MF4 += MF4Sub
            else:
                raise 'hell - fix me'
        elif (isinstance(angularSubform, regionsModule.regions2d)):
            LTT, MF4, numberOfPoints, LegendreInterpolations, LegendreData  = None, [], 0, [], []
            for ridx, region in enumerate(angularSubform):
                targetInfo['skipFirstEnergy'] = False
                if ridx > 0 and type(angularSubform[ridx][0]) == type(
                        angularSubform[ridx - 1][-1]):
                    # FIXME: following should work once __eq__ fixed for xData. Shows up in ENDF-VII.1 Cu evaluations
                    #if angularSubform[ridx-1][-1] == angularSubform[ridx][0]: targetInfo['skipFirstEnergy'] = True
                    if isinstance(angularSubform[ridx][0],
                                  series1dModule.LegendreSeries):
                        if angularSubform[ridx][
                                0].coefficients == angularSubform[
                                    ridx - 1][-1].coefficients:
                            targetInfo['skipFirstEnergy'] = True
                    else:
                        raise NotImplementedError
                if (isinstance(region, angularModule.XYs2d)):
                    if (isinstance(region[0], series1dModule.LegendreSeries)):
                        interpolation, numberOfPointsSub, LI, LTTSub, NMtmp, MF4Sub = toAngularLegendre(
                            region, targetInfo, not (doMF4AsMF6))
                        numberOfPoints += numberOfPointsSub
                        NM = max(NM, NMtmp)
                        LegendreInterpolations += [
                            numberOfPoints, interpolation
                        ]
                    elif (isinstance(region[0], XYsModule.XYs1d)):
                        LI, LTTSub, MF4Sub = toAngularPointwise(
                            region, targetInfo, not (doMF4AsMF6))
                    else:
                        raise 'hell - fix me'
                    if (len(MF4) > 0): MF4.pop(-1)
                    MF4 += MF4Sub
                    if (LTT is None): LTT = LTTSub
                    if (LTT != LTTSub):
                        if ((LTT == 1) and (LTTSub == 2)):
                            LTT = 3
                        else:
                            raise 'hell - fix me'
                else:
                    raise 'hell - fix me'
                del targetInfo['skipFirstEnergy']
            if (len(LegendreInterpolations) > 0):
                MF4 = [ endfFormatsModule.endfContLine( 0, 0, 0, 0, len( LegendreInterpolations ) / 2, LegendreInterpolations[-2] ) ] + \
                        endfFormatsModule.endfInterpolationList( LegendreInterpolations ) + MF4
            ENDFDataList = [
                endfFormatsModule.endfContLine(0, 0, 0, 0, 1,
                                               len(angularSubform))
            ]
            ENDFDataList += endfFormatsModule.endfInterpolationList(
                [len(angularSubform), interpolation])
            LI = 0
        elif (isinstance(angularSubform, angularModule.recoil)):
            if not targetInfo['doMF4AsMF6']:
                return  # recoil partners only get written to file 6
            LI, LTT, MF4 = angularSubform.toENDF6(flags, targetInfo)
            MF = 6
        elif (isinstance(angularSubform, angularModule.isotropic)):
            LI, LTT, MF4 = angularSubform.toENDF6(flags, targetInfo)
            MF = 4
            if (doMF4AsMF6): MF = 6
        else:
            brb.objectoutline(angularSubform)
            raise 'hell - fix me'
        if (doMF4AsMF6):
            if (LTT in [0]):
                LAW = 3
            elif (LTT in [1, 2]):
                LAW = 2
            elif (LTT in [4]):
                LAW = 4
            else:
                raise Exception('LTT = %s needs a LAW' % LTT)
            gndToENDF6Module.toENDF6_MF6(MT, endfMFList, flags, targetInfo,
                                         LAW, frame, MF4)
        else:
            LCT = {
                standardsModule.frames.labToken: 1,
                standardsModule.frames.centerOfMassToken: 2
            }[frame]
            if (MT not in endfMFList[MF]): endfMFList[MF][MT] = []
            if LTT != 3: NM = 0
            endfMFList[MF][MT] += [
                endfFormatsModule.endfHeadLine(
                    targetInfo['ZA'], targetInfo['mass'], 0, LTT, 0, 0),
                endfFormatsModule.endfHeadLine(0, targetInfo['mass'], LI, LCT,
                                               0, NM)
            ] + MF4
    else:
        print 'WARNING: subform %s does not have method toENDF6 for form %s' % (
            targetInfo['style'], self.moniker)
Exemplo n.º 20
0
def toENDF6( self, MT, endfMFList, flags, targetInfo ) :
    """
    In ENDF MF=6, some distributions should really be treated as uncorrelated: NBodyPhaseSpace, and also 
    Legendre expansions when only L=0 is listed.
    For GND we split these into uncorrelated angular (isotropic) and energy distributions.
    Must put back in original format when writing back to ENDF.
    """

    frame = self.productFrame
    energySubform = self.energySubform.data
    angularSubform = self.angularSubform.data
    if( isinstance( energySubform, energyModule.NBodyPhaseSpace ) ) :
        energySubform.toENDF6( MT, endfMFList, flags, targetInfo )
    elif( isinstance( energySubform, energyModule.energyLoss ) ) :
        frame, ENDFDataList = energySubform.toENDF6( MT, endfMFList, flags, targetInfo )
        gndToENDF6Module.toENDF6_MF6( MT, endfMFList, flags, targetInfo, 8, frame, ENDFDataList )
    elif( targetInfo['product'].getAttribute( 'ENDFconversionFlag' ) in [ 'MF6', 'MF26' ] ) :
        if( isinstance( energySubform, energyModule.constant ) ) :
# BRB - this needs to be checked.
            if( targetInfo['product'].name != 'gamma' ) : raise ValueError( 'This logic is only for discete gammas' )
            energyForm = energyModule.form( self.label, frame, energySubform )
            angularForm = angularModule.form( self.label, frame, angularSubform )
            energyForm.toENDF6( MT, endfMFList, flags, targetInfo )
            angularForm.toENDF6( MT, endfMFList, flags, targetInfo )
        elif( isinstance( angularSubform, angularModule.isotropic ) ) :                # Change to energyAngular with Legendre
            if( not( isinstance( energySubform, energyModule.XYs2d ) ) ) : raise 'hell - fix me'
            axes = axesModule.axes( rank = 4 )
            axes[3] = axesModule.axis( 'energy_in', 3, 'eV' )
            axes[2] = axesModule.axis( 'energy_out', 2, 'eV' )
            axes[1] = axesModule.axis( 'l', 1, '' )
            axes[0] = axesModule.axis( 'C_l(energy_out|energy_in)', 0, '1/eV' )
            energyAngularSubform = energyAngularModule.XYs3d( axes = axes, interpolation = energySubform.interpolation,
                    interpolationQualifier = energySubform.interpolationQualifier )
            EInFactor = PQUModule.PQU( 1, energySubform.axes[2].unit ).getValueAs( 'eV' )

            for EIn in energySubform :
                if isinstance( EIn, regionsModule.regions1d ):
                    # writing to MF6 LAW=1, LANG=1 doesn't support multiple regions, must recombine.
                    if( len( set( [ ein.interpolation for ein in EIn ] ) ) != 1 ) :
                        raise NotImplemented, "ENDF MF6 LAW=1 LANG=1 doesn't support multiple E' interpolations!"
                    xyvals = EIn[0].copyDataToXYs()
                    for region in EIn[1:]:
                        xynew = region.copyDataToXYs()
                        xynew[0][0] *= 1.00000001
                        xyvals.extend( xynew )
                    EIn_copy = EIn[0].copy( value=EIn.value, axes=EIn.axes )
                    EIn_copy.setData( xyvals )
                    EIn = EIn_copy
                multiD_2d = energyAngularModule.XYs2d( value = EIn.value * EInFactor, interpolation = EIn.interpolation )
                EpCls = EIn.copyDataToXYs( xUnitTo = 'eV', yUnitTo = '1/eV' )
                for e_out, Cls in EpCls :
                    multiD_2d.append( energyAngularModule.Legendre( [ Cls ], value = e_out ) )
                energyAngularSubform.append( multiD_2d )
            form = energyAngularModule.form( '', self.productFrame, energyAngularSubform )
            if( targetInfo.dict.get( "gammaToENDF6" ) ) : return( form )
            form.toENDF6( MT, endfMFList, flags, targetInfo )
        elif( isinstance( energySubform, energyModule.XYs2d ) and isinstance( angularSubform, angularModule.XYs2d ) ) :

            LANG, LEP = 12, 2
            if( energySubform.interpolation == standardsModule.interpolation.flatToken ) :
                LEP = 1  # interpolation for E_out
                LANG = 11
            elif( energySubform.interpolation in (standardsModule.interpolation.loglinToken,
                standardsModule.interpolation.loglogToken ) ) :
                LANG = 14
            MF6 = [ endfFormatsModule.endfContLine( 0, 0, LANG, LEP, 1, len( energySubform ) ) ]
            EInInterpolation = gndToENDF6Module.gndToENDFInterpolationFlag( energySubform.interpolation )
            MF6 +=  endfFormatsModule.endfInterpolationList( [ len( energySubform ), EInInterpolation ] )
            for indexE, EEpP in enumerate( energySubform ) :
                EMuP = angularSubform[indexE]
                if( EEpP.value != EMuP.value ) : raise Exception( "EEpP.value = %s != EMuP.value = %s" % ( EEpP.value, EMuP.value ) )
                NA, NEP = 2 * len( EMuP ), len( EEpP )
                MF6.append( endfFormatsModule.endfContLine( 0, EEpP.value, 0, NA, NEP * ( NA + 2 ), NEP ) )
                data = []
                for EpP in EEpP :
                    data = [ EpP[0], EpP[1] ]
                    for muP in EMuP : data += muP
                    MF6 += endfFormatsModule.endfDataList( data )
            LAW = 1
            gndToENDF6Module.toENDF6_MF6( MT, endfMFList, flags, targetInfo, LAW, frame, MF6 )
        else :
            raise Exception( 'uncorrelated.toENDF6 not supported for energy subform = %s and angular subform = %s' %
                ( energySubform.label, angularSubform.label ) )
    else :                          # original data is in uncorrelated form
        if( MT not in [ 527, 528 ] ) :
            angularForm = angularModule.form( "", frame, self.angularSubform.data )
            angularForm.toENDF6( MT, endfMFList, flags, targetInfo )
        energyForm = energyModule.form( "", frame, self.energySubform.data )
        energyForm.toENDF6( MT, endfMFList, flags, targetInfo )
        if( MT == 527 ) : endfMFList[26][MT][0]