예제 #1
0
파일: product.py 프로젝트: alhajri/FUDGE
def toACE(self, MTData, MT, verbose):

    if (verbose > 2): print '        %s: label = %s' % (self.name, self.label)
    if (self.name in ['n', 'gamma']):
        if (self.multiplicity.isConstant()):
            multiplicity = self.multiplicity.evaluate(0)
        else:
            multiplicity = self.multiplicity.evaluated

    if (self.name == 'n'):
        angularForm, energyData = None, None
        evaluated = self.distribution.evaluated
        if ((MT == 18)
                and isinstance(evaluated,
                               (unspecifiedModule.form, unknownModule.form))):
            pass
        else:
            if (isinstance(evaluated, angularModule.twoBodyForm)):
                angularForm = evaluated.angularSubform
            elif (isinstance(evaluated, uncorrelatedModule.form)):
                angularForm = evaluated.angularSubform.data
                energyData = evaluated.energySubform.data
            elif (isinstance(evaluated, energyAngularModule.form)):
                energyData = evaluated.energyAngularSubform
            elif (isinstance(evaluated, KalbachMannModule.form)):
                energyData = evaluated
            elif (isinstance(evaluated, angularEnergyModule.form)):
                angularForm = angularEnergy.angularFor_angularEnergy(evaluated)
                energyData = evaluated
            else:
                raise Exception('Unsupported distribution form = %s' %
                                evaluated.moniker)

        if (angularForm is None):
            angularData = angularForm
        elif (isinstance(angularForm, angularEnergyModule.XYs3d)):
            angularData = angularForm
        elif (isinstance(angularForm, angularModule.isotropic)):
            angularData = angularForm
        elif (isinstance(angularForm, angularEnergy.angularFor_angularEnergy)):
            angularData = angularForm
        elif (isinstance(angularForm, angularModule.subform)):
            angularData = angularForm.toPointwise_withLinearXYs(accuracy=1e-3,
                                                                upperEps=1e-6)
        else:
            brb.objectoutline(angularForm)
            raise Exception("angular form '%s' not supported" %
                            angularForm.moniker)

        frame = evaluated.productFrame
        MTData['n'].append({
            'product': self,
            'frame': frame,
            'multiplicity': multiplicity,
            'angularData': angularData,
            'energyData': energyData
        })

        if ('decayRate' in self.attributes):
            MTData['n_fissionDelayed'].append(self)
예제 #2
0
def _toLinear(func):

    if (isinstance(func, XYsModule.XYs1d)):
        if (func.interpolation == standardsModule.interpolation.linlinToken):
            return (func)
        func = func.copy()
        return (func.toPointwise_withLinearXYs(accuracy=accuracy,
                                               upperEps=1e-8))
    elif (isinstance(func, regionsModule.regions1d)):
        return (func.toPointwise_withLinearXYs(accuracy=accuracy,
                                               upperEps=1e-8))
    from fudge.core.utilities import brb
    brb.objectoutline(func)
    raise Exception('FIX ME')
예제 #3
0
def twoDToString( label, data, addHeader = True, addExtraBlankLine = True ) :

    if( isinstance( data, XYsModule.XYs1d ) ) :
        if( data.interpolation not in [ linlin, flat ] ) :
            data = data.toPointwise_withLinearXYs( lowerEps = lowerEps, upperEps = upperEps )
        interpolationStr = 'Interpolation: %s' % data.interpolation
    elif( isinstance( data, regionsModule.regions1d ) ) :
        data = data.toPointwise_withLinearXYs( lowerEps = lowerEps, upperEps = upperEps )
        interpolationStr = 'Interpolation: %s' % data.interpolation
    else :
        print 'ERROR from', __file__
        try :
            brb.objectoutline( data )
        except :
            pass
        raise TypeError( 'Unsupported data type: see prior output' )
    fmt = " %s %s" % ( doubleFmt, doubleFmt )
    a = [ fmt % ( x, y ) for x, y in data ]
    if( not( addHeader ) ) : return( interpolationStr, a )
    a.insert( 0, interpolationStr )
    a.insert( 0, "%s: n = %d" % ( label, len( data ) ) )
    if( addExtraBlankLine ) : a.append( '' )
    return( a )
예제 #4
0
    def toPointwise_withLinearXYs(self, **kwargs):

        brb.objectoutline(self.data)
        raise 'Hell'
예제 #5
0
파일: product.py 프로젝트: icmeyer/fudge
def toACE(self, MTData, MT):

    from fudge.gnd.productData import distributions
    from fudge.gnd.productData.distributions import angular

    name = self.name
    if (name in ['n', 'gamma']):
        if (self.multiplicity.isConstant()):
            multiplicity = self.multiplicity.getValue(0)
        else:
            multiplicity = self.multiplicity.getNativeData()
    if (self.name == 'n'):
        nativeDataToken = self.distributions.getNativeDataToken()
        angularForm, energyData = None, None
        if ((MT == 18) and
            (nativeDataToken == distributions.base.unspecifiedComponentToken)):
            pass
        else:
            nativeData = self.distributions.getNativeData()
            if (nativeDataToken == distributions.base.angularComponentToken):
                angularForm = nativeData
            elif (nativeDataToken ==
                  distributions.base.uncorrelatedComponentToken):
                angularForm = nativeData.angularComponent.getNativeData()
                energyData = nativeData.energyComponent.getNativeData()
            elif (nativeDataToken ==
                  distributions.base.energyAngularComponentToken):
                if (isinstance(nativeData,
                               distributions.energyAngular.KalbachMann)):
                    energyData = nativeData
                else:
                    raise Exception('%s is not implemented' % nativeDataToken)
            elif (nativeDataToken == distributions.base.LegendreComponentToken
                  ):
                accuracy = 1e-3
                if (nativeData.axes[1].isFlat(qualifierOk=True)):
                    accuracy = 1e-6
                energyData = nativeData.toPointwise_withLinearXYs(accuracy)
            elif (nativeDataToken ==
                  distributions.base.angularEnergyComponentToken):
                angularForm = angularEnergy.angularFor_angularEnergy(
                    nativeData)
                energyData = nativeData
            else:
                print 'token', self.distributions.getNativeDataToken()
                raise Exception('Unsupported nativeData = %s' % nativeData)

        if (angularForm is None):
            angularData = angularForm
        elif (isinstance(angularForm, distributions.angularEnergy.pointwise)):
            angularData = angularForm
        elif (isinstance(angularForm, angular.isotropic)):
            angularData = angularForm
        elif (isinstance(angularForm, angularEnergy.angularFor_angularEnergy)):
            angularData = angularForm
        elif (isinstance(angularForm,
                         (angular.pointwise, angular.linear, angular.piecewise,
                          angular.LegendrePointwise, angular.LegendrePiecewise,
                          angular.mixedRanges))):
            angularData = angularForm.toPointwise_withLinearXYs(accuracy=1e-4)
        else:
            from fudge.core.utilities import brb
            brb.objectoutline(angularForm)
            raise Exception("angular form '%s' not supported" %
                            angularForm.moniker)

        frame = axes.labToken
        if (angularData is not None):
            frame = angularData.getProductFrame()
        else:
            if (energyData is not None): frame = energyData.getProductFrame()
        MTData['n'].append({
            'product': self,
            'frame': frame,
            'multiplicity': multiplicity,
            'angularData': angularData,
            'energyData': energyData
        })
예제 #6
0
def toENDF6(self, MT, endfMFList, flags, targetInfo):

    if (MT == 455): return  # No angular data for delayed neutrons in ENDF
    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)
예제 #7
0
    def toPointwise_withLinearXYs( self, lowerEps, upperEps ) :

        brb.objectoutline( self.data )
        raise 'Hell'