示例#1
0
文件: fetePy.py 项目: icmeyer/fudge
def gammaDeltaDistribution(energy):

    deltaEnergy = float("1e%s" % ("%.0e" % (energy * energyEps)).split('e')[1])
    eMin, eMax = energy - deltaEnergy, energy + deltaEnergy
    if (eMin < 0):
        return (XYsModule.XYs([[energy, 1.], [eMax, 0.]]).normalize())
    return (XYsModule.XYs([[eMin, 0.], [energy, 1], [eMax, 0.]]).normalize())
示例#2
0
文件: plot2d.py 项目: icmeyer/fudge
    def getW_XYs(self):

        from xData import axes as axesModule
        from xData import XYs as XYsModule
        from xData import multiD_XYs as multiD_XYsModule

        xUnit, yUnit, zUnit = '', '', ''
        if (self.xUnit is not None): xUnit = self.xUnit
        if (self.yUnit is not None): yUnit = self.yUnit
        if (self.zUnit is not None): zUnit = self.zUnit
        axes_3d = axesModule.axes(3)
        axes_3d[0] = axesModule.axis('z', 0, zUnit)
        axes_3d[1] = axesModule.axis('y', 0, yUnit)
        axes_3d[2] = axesModule.axis('x', 0, xUnit)
        w_xys = multiD_XYsModule.multiD_XYs(axes=axes_3d)

        axes_2d = axesModule.axes()
        axes_2d[0] = axes_3d[0]
        axes_2d[1] = axes_3d[1]

        for ix, x in enumerate(self.x):
            xys = [[y, self.z[iy][ix]] for iy, y in enumerate(self.y)]
            w_xys[ix] = XYsModule.XYs(xys,
                                      axes=axes_2d,
                                      accuracy=1e-3,
                                      value=x)
        return (w_xys)
示例#3
0
    def __init__(self, angularEnergy_):

        self.productFrame = angularEnergy_.getProductFrame()
        axes_ = axes.defaultAxes(3)
        axes_[0] = angularEnergy_.axes[0]
        axes_[1] = angularEnergy_.axes[1]
        axes_[2] = axes.axis("P(mu|energy_in)", 2, "")
        W_XYs.W_XYs.__init__(self, axes_)

        for w_xys in angularEnergy_:
            P_mu = [[xys.value, xys.integrate()] for xys in w_xys]
            self.append(
                XYs.XYs(XYs.XYs.defaultAxes(), P_mu, 1e-3, value=w_xys.value))
示例#4
0
文件: fetePy.py 项目: icmeyer/fudge
    def getDistribution(self, energy, energies, numberOfGammas, zeroTotal):

        energy_eV = 1e6 * energy
        if (self.multiplicity.domainMin() <= energy <=
                self.multiplicity.domainMax()):
            domainMin_eV, domainMax_eV = self.energyForm.domain()
            dE = energy_eV - domainMin_eV
            if (dE < 0):
                if (abs(dE) < 1e-15 * energy_eV):
                    energy_eV = domainMin_eV
                else:
                    return (None)
            dE = domainMax_eV - energy_eV
            if (dE < 0):
                if (abs(dE) < 1e-15 * energy_eV):
                    energy_eV = domainMin_eV
                else:
                    return (None)

            energyForm = self.energyForm
            if (isinstance(energyForm, (energyModule.piecewise, ))):
                for region in energyForm:
                    if (energy_eV < region.domainMax()): break
                energyForm = region
            energyForm = energyForm.evaluate(energy_eV, epsilon=3 * energyEps)
            energyForm = energyForm.toPointwise_withLinearXYs(
                accuracy=1e-4, lowerEps=energyEps, upperEps=energyEps)
            lowerEps = energyEps
            if (energyForm.domainMin() == 0): lowerEps = 0
            energyForm = energyForm.scaleOffsetXAndY(
                xScale=eV2MeV, yScale=1 / eV2MeV).dullEdges(lowerEps=lowerEps,
                                                            upperEps=energyEps)
            energyForm = XYsModule.XYs(energyForm)
            multiplicity = getMultiplicityForDistributionSum(
                self, energy, energies, numberOfGammas, zeroTotal)
            distribution = multiplicity * energyForm
            return (distribution)
        else:
            return (None)
示例#5
0
def toACE(self, fileName, evaluationId, temperature, productData,
          addAnnotation):

    massUnit = 'eV/c**2'
    projectile, target = self.projectile, self.target
    targetZ, targetA, targetSuffix, targetZA = target.getZ_A_SuffixAndZA()
    neutronMass = projectile.getMass(massUnit)
    targetMass = target.getMass(massUnit)
    target2NeutronMass = targetMass / neutronMass

    if (not (isinstance(temperature, PQU.PQU))):
        temperature = PQU.PQU(temperature)

    if (temperature.isTemperature()):
        temperature_MeV = temperature.getValueAs('MeV / k')
        temperature_K = temperature.getValueAs('K')
    else:
        temperature_MeV = temperature.getValueAs('MeV')
        temperature_K = temperature.getValueAs('k * K')

    processingTime = time.localtime()
    strRecords = [
        "%6d.%.2dc%12.7f %11.5E %.2d/%.2d/%.2d" %
        (targetZA, evaluationId, target2NeutronMass, temperature_MeV,
         processingTime[1], processingTime[2], processingTime[0])
    ]

    nonFissionEnergyDependentNeutronMultiplicities = []
    nonFissionEnergyDependentNeutronMultiplicitiesIndex = 100

    MAT = endf_endl.ZAAndMATFromParticleName(target.name)[1]
    MAT_ID = '  mat %d' % MAT
    HK = '%2d-%s at %.1fK from %s-%s Fudge.toACE' % \
        ( targetZ, target.name, temperature_K, self.styles['evaluated'].attributes['library'], self.styles['evaluated'].attributes['version'] )
    HK = "%-70s" % HK[:70]
    strRecords.append(HK + MAT_ID)
    for i in xrange(4):
        strRecords.append(
            '      0   0.000000      0   0.000000      0   0.000000      0   0.000000'
        )

    NXS = 16 * [0]
    JXS = 32 * [0]
    MRT, NU_prompt, NU_total, LQR, TYP, SigData, neutronAngular, neutronEnergies = [], None, None, [], [], {}, [], []
    NXS[2 - 1] = targetZA

    for MT, MTData in productData:
        if (MT == 2):  # Elastic (MT = 2) must always be present in ACE file.
            EMin = MTData['ESZ'].domainMin(unitTo='MeV')
            break
    totalXSec = XYs.XYs(
        axes.defaultAxes(labelsUnits={
            0: ('', 'MeV'),
            1: ('', 'b')
        }), [], 1e-3)
    absorptionXSec = XYs.XYs(
        axes.defaultAxes(labelsUnits={
            0: ('', 'MeV'),
            1: ('', 'b')
        }), [], 1e-3)
    sortedMTs = sorted([[MTData[0], i1]
                        for i1, MTData in enumerate(productData)
                        ])  # Sort MTs like NJOY.
    for MT, i1 in sortedMTs:
        MT_, MTData = productData[i1]
        XSec = MTData['ESZ']
        XSec = XSec.convertAxisToUnit(0, 'MeV')
        XSec = XSec.convertAxisToUnit(1, 'b')
        neutronDatas = MTData['n']
        multiplicity = 0
        if (MT == 2):
            elasticXSec = XSec
            if (len(neutronDatas) > 1):
                raise Exception(
                    'Only one type of neutron data is support for the elastic reaction.'
                )
            if (len(neutronDatas) > 0):
                neutronAngular.append((MT, neutronDatas[0]['angularData']))
        else:
            MRT.append(MT)
            LQR.append(MTData['Q'])
            if (XSec[0][0] != 0):
                if (XSec[0][0] > EMin): XSec = XSec.dullEdges(lowerEps=1e-8)
            SigData[MT] = XSec
            totalXSec = totalXSec + XSec
            if (len(neutronDatas) == 0):
                absorptionXSec = absorptionXSec + XSec
                neutronMultiplicity = 0
            else:
                NXS[5 - 1] += 1
                product = neutronDatas[0]['product']
                frame = neutronDatas[0]['frame']
                angularData = neutronDatas[0]['angularData']
                energyData = neutronDatas[0]['energyData']
                if (MTData['isFission']):
                    neutronMultiplicity = 19
                    totalPresent = False
                    for neutronData in neutronDatas:
                        product = neutronData['product']
                        if ((product.attributes['emissionMode']
                             == tokens.promptToken) or
                            (product.attributes['emissionMode'] == 'total')):
                            totalPresent = product.attributes[
                                'emissionMode'] == 'total'
                            NU_prompt = neutronData['multiplicity']
                            break
                    if (NU_prompt is None):
                        raise Exception('Missing prompt neutron')
                    if (len(neutronDatas) > 1):
                        if (totalPresent):
                            raise Exception(
                                'Total nu_bar present and delayed neutron data.'
                            )
                        NU_total = NU_prompt
                        for neutronData in neutronDatas:
                            product = neutronData['product']
                            if (product.attributes['emissionMode'] == 'delayed'
                                ):
                                NU_delayed = neutronData['multiplicity']
                                if (NU_delayed.domainMax() <
                                        NU_total.domainMax()):
                                    NU_delayed = NU_delayed.dullEdges(
                                        upperEps=1e-8)
                                NU_total = NU_total + NU_delayed
                else:
                    if (len(neutronDatas) == 1):
                        neutronMultiplicity = neutronDatas[0]['multiplicity']
                    else:
                        neutronMultiplicity, angularData, energyData = specialMF6.neutrons(
                            neutronDatas)
                    if (not (isinstance(neutronMultiplicity, int))):
                        nonFissionEnergyDependentNeutronMultiplicitiesIndex += 1
                        nonFissionEnergyDependentNeutronMultiplicities.append([
                            MT,
                            nonFissionEnergyDependentNeutronMultiplicitiesIndex,
                            neutronMultiplicity
                        ])
                        neutronMultiplicity = nonFissionEnergyDependentNeutronMultiplicitiesIndex

                    if (frame == axes.centerOfMassToken):
                        neutronMultiplicity *= -1  # Negative for COM frame.
                    if (energyData is None):
                        if (50 <= MT <= 91):
                            energyData = n_nPrimeEnergyData(
                                MT, target2NeutronMass, MTData['Q'])
                        else:
                            raise 'hell: but first implement energy for MT =' % MT
                    else:
                        if (isinstance(energyData,
                                       distributions.energy.NBodyPhaseSpace)):
                            angularData = None
                neutronAngular.append((MT, angularData))
                neutronEnergies.append(
                    [MT, XSec.xMin(), XSec.xMax(), energyData])
            TYP.append(neutronMultiplicity)
    totalXSec = elasticXSec + totalXSec
    annotates, XSS, energyGrid, totalSigma = [], [], [], []
    for E, sigma in totalXSec:
        energyGrid.append(E)
        totalSigma.append(sigma)

# 1) Add the ESZ block.
    NXS[3 - 1] = len(energyGrid)
    updateXSSInfo('energyGrid', annotates, XSS, energyGrid)
    updateXSSInfo('totalSigma', annotates, XSS, totalSigma)
    if (len(absorptionXSec) == 0):
        updateXSSInfo('absorption cross section', annotates, XSS,
                      len(energyGrid) * [0.])
    else:
        updateXSSInfo('absorption cross section', annotates, XSS,
                      mapEnergyToTotal(totalXSec, absorptionXSec))
    updateXSSInfo('elastic cross section', annotates, XSS,
                  mapEnergyToTotal(totalXSec, elasticXSec))
    averageHeating = len(energyGrid) * [0.]
    updateXSSInfo('average heating', annotates, XSS, averageHeating)

    # 2) Add the NU block.
    if (NU_prompt is not None):
        JXS[2 - 1] = len(XSS) + 1
        NU_prompt = NU_prompt.toACE()
        if (NU_total is not None): NU_prompt.insert(0, -len(NU_prompt))
        updateXSSInfo('NU', annotates, XSS, NU_prompt)
        if (NU_total is not None):
            NU_total = NU_total.toACE()
            updateXSSInfo('NU(total)', annotates, XSS, NU_total)

# 3) Add the MRT block.
    NXS[4 - 1] = len(MRT)
    JXS[3 - 1] = len(XSS) + 1
    updateXSSInfo('MRT', annotates, XSS, MRT)

    # 4) Add the LQR block.
    JXS[4 - 1] = len(XSS) + 1
    updateXSSInfo('LQR', annotates, XSS, LQR)

    # 5) Add the TYP block.
    JXS[5 - 1] = len(XSS) + 1
    updateXSSInfo('TYP', annotates, XSS, TYP)

    # 6 and 7) Add the LSIG and SIG blocks.
    SIG = []
    for MT, MTData in productData:
        if (MT not in [2]): addSigData(MT, SIG, energyGrid, SigData[MT])
    JXS[6 - 1] = len(XSS) + 1
    LSIG = [1]
    for MT, firstNonZero, reactionSIG in SIG[:-1]:
        LSIG.append(LSIG[-1] + len(reactionSIG) + 2)
    updateXSSInfo('LSIG', annotates, XSS, LSIG)
    JXS[7 - 1] = len(XSS) + 1
    for MT, firstNonZero, reactionSIG in SIG:
        reactionSIG_ = [firstNonZero + 1, len(reactionSIG)] + reactionSIG
        updateXSSInfo('SIG(MT=%s)' % MT, annotates, XSS, reactionSIG_)

# 8 and 9) Add the LAND and AND blocks.
    LAND, MT_AND, length = [], [], 0
    for MT, angular in neutronAngular:
        if (angular is None):
            LAND.append(-1)
        elif (angular.isIsotropic()):
            LAND.append(0)
        elif (isinstance(angular, (distributions.angular.linear,
                                   angularEnergy.angularFor_angularEnergy))):
            LAND.append(length + 1)
            length += 2 * len(angular) + 1
            energies_in = [len(angular)]
            LCs, Ps = [], []
            for xys in angular:
                energy_in = PQU.PQU(
                    xys.value, angular.axes[0].getUnit()).getValueAs('MeV')
                energies_in.append(energy_in)
                LCs.append(-length - 1)
                xys = xys.normalize()
                mus, pdf = [], []
                for x, y in xys:
                    mus.append(x)
                    pdf.append(y)
                cdf = xys.runningIntegral()
                cdf[-1] = 1.  # Make sure last point is really 1.
                Ps += [2, len(mus)] + mus + pdf + cdf
                length += 3 * len(xys) + 2
            MT_AND.append((MT, energies_in + LCs + Ps))
        else:
            raise Exception(
                'Unsupport neutron angular distribution type = %s' %
                type(angular))
    JXS[8 - 1] = len(XSS) + 1
    updateXSSInfo('LAND', annotates, XSS, LAND)
    JXS[9 - 1] = len(XSS) + 1
    for MT, AND in MT_AND:
        updateXSSInfo('AND(MT=%s)' % MT, annotates, XSS, AND)

    # 10 and 11) Add the LDLW and DLW blocks.
    LDLW, MT_DLW = processEnergyData(massUnit, neutronMass, neutronEnergies)
    JXS[10 - 1] = len(XSS) + 1
    updateXSSInfo('LDLW', annotates, XSS, LDLW)
    JXS[11 - 1] = len(XSS) + 1
    for MT, DLW in MT_DLW:
        updateXSSInfo('DLW(MT=%s)' % MT, annotates, XSS, DLW)

    # Now fixup the TYP data whose abs( value ) is greater than 100.
    for MT, index, multiplicity in nonFissionEnergyDependentNeutronMultiplicities:
        i1, found = JXS[5 - 1], False
        for i2 in range(NXS[4 - 1]):
            if (abs(XSS[i1 + i2 - 1]) == index):
                n_multiplicity = multiplicity.toACE()
                LNU, n_multiplicity = n_multiplicity[0], n_multiplicity[1:]
                if (LNU != 2):
                    raise Exception(
                        'Only tabular neutron multiplicity is allowed, not LNU = %d'
                        % LNU)
                offset = len(XSS) - JXS[11 - 1] + 101 + 1
                if (XSS[i1 + i2 - 1] < 0): offset *= -1
                XSS[i1 + i2 - 1] = offset
                updateXSSInfo('Neutron Yields(MT=%s)' % MT, annotates, XSS,
                              n_multiplicity)
                found = True
                break
        if (not (found)):
            raise Exception(
                'Neutron multiplicity for index %s not found in TYP table' %
                index)


# Time to wrap it all up.
    NXS[1 - 1] = len(XSS)
    JXS[1 - 1] = 1
    JXS[22 - 1] = len(
        XSS) + 1  # Location of the last word of XSS (i.e., its length).

    strRecords += intArrayToRecords(NXS)
    strRecords += intArrayToRecords(JXS)
    strRecords += XSSToStrings(annotates, XSS, addAnnotation)

    strRecords.append('')
    fOut = open(fileName, 'w')
    fOut.write('\n'.join(strRecords))
    fOut.close()
示例#6
0
文件: plot2d.py 项目: icmeyer/fudge
def plotTests(tests=11 * [False]):

    from fudge import fudgeParameters
    fudgeParameters.VerboseMode = 0
    from fudge.legacy.endl.endlProject import endlProject
    from fudge.legacy.endl.endl3dmathClasses import endl3dmath
    from fudge import __path__
    from xData import axes as axesModule
    from xData import XYs as XYsModule
    from xData import multiD_XYs as multiD_XYsModule

    testData = '''
        #  Authors:   T.S.Suzuki, Y.Nagai, T.Shima, T.Kikuchi, H.Sato, T.Kii, M.Igashira
        #  Title:     First Measurement Of A P(N,Gamma)D Reaction Cross Section Between 10 And 80 Kev
        #  Year:      1995
        #  Institute: Tokyo Inst.of Technology, Tokyo
        #  Reference: Astrophysical Journal 439, (L), 59 (1995)
        #  Subent:    22310002
        #  Reaction:  Cross section for 1H(n,gamma)2H 
        # Note: the d(Energy) errorbars are fake and are used for plot testing
        #   Energy        Data          d(Energy)     d(Data)       
        #   MeV           barns         MeV           barns         
            0.02          0.000353      0.001         2.6e-05       
            0.02          0.000329      0.001         2.6e-05       
            0.02          0.000287      0.0           2.2e-05       
            0.02          0.000304      0.0           1.8e-05       
            0.04          0.00023       0.001         1.5e-05       
            0.04          0.000198      0.001         1.2e-05      
            0.04          0.000177      0.0015        1e-05         
            0.04          0.000207      0.0           1.3e-05       
            0.064         0.000156      0.0           1.1e-05       
            0.064         0.00015       0.0           7e-06         
            0.064         0.000158      0.0           1.1e-05       
            0.064         0.00014       0.0           9e-06
    '''

    e = endlProject(__path__[0] + "/legacy/endl/test/testdb")
    za = e.readZA(1001)
    za.read()
    xAxis = AxisSettings(isLog=True,
                         label='$E_n$',
                         axisMin=0.5e-2,
                         axisMax=1.5e-1,
                         gridOn=True,
                         autoscale=False,
                         unit='MeV')
    yAxis = AxisSettings(isLog=True,
                         label='$\sigma(E_n)$',
                         gridOn=True,
                         unit='b')
    d = []
    u = []
    for line in testData.split('\n'):
        if line.strip().startswith('#'): continue
        sline = map(float, line.split())
        if len(sline) != 0:
            d.append(sline[0:2])
            u.append(sline[2:4])

    xyAxes = axesModule.axes(labelsUnits={
        1: (xAxis.label, xAxis.unit),
        0: (yAxis.label, yAxis.unit)
    })

    # Simple test, here we make a plot of one set

    if tests[0]:
        xSec = za.findData(I=0, C=46)
        makePlot2d([xSec],
                   xAxisSettings=xAxis,
                   yAxisSettings=yAxis,
                   title='$^1$H$(n,\gamma)$ Cross Section',
                   outFile=None)
        xys = XYsModule.XYs(xSec.data, axes=xyAxes, accuracy=1e-3)
        makePlot2d((xys),
                   xAxisSettings=xAxis,
                   yAxisSettings=yAxis,
                   title='$^1$H$(n,\gamma)$ Cross Section',
                   outFile=None)
        dataset = DataSet2d(xys, xUnit=xAxis.unit, yUnit=yAxis.unit)
        dataset.convertUnits('eV', 'mb')
        makePlot2d((dataset),
                   xAxisSettings=xAxis,
                   yAxisSettings=yAxis,
                   title='$^1$H$(n,\gamma)$ Cross Section',
                   outFile=None)

    # Plot all the cross section data in the fudge2 test library, but unthemed!
    if tests[1]:
        makePlot2d(za.findDatas(I=0), outFile=None)

    # Plot all the cross section data in the fudge2 test library
    if tests[2]:
        xSecs = za.findDatas(I=0)
        makePlot2d(xSecs,
                   xAxisSettings=xAxis,
                   yAxisSettings=yAxis,
                   title='$^1$H$(n,*)$ Cross Sections',
                   outFile=None)
        xySecs = [
            XYsModule.XYs(xSec.data, axes=xyAxes, accuracy=1e-3)
            for xSec in xSecs
        ]
        xySecs = (xySecs[0], xySecs[1], xySecs[2])
        makePlot2d(xySecs,
                   xAxisSettings=xAxis,
                   yAxisSettings=yAxis,
                   title='$^1$H$(n,*)$ Cross Sections',
                   outFile=None)

    # Fancy test, here we make a plot of one dataset (the testData above)
    if tests[3]:
        endfData = za.findData(I=0,
                               C=46)  #.slicex(domainMin=1e-2,domainMax=1e-1)
        endfUnc = 0.1 * endfData  # 10% error bars
        makePlot2d( [ \
                DataSet2d( data = endfData, uncertainty = endfUnc, legend = 'ENDF/B-VII.0', color='g', lineStyle = '-' ),
                DataSet2d( data = d, uncertainty = u, legend = 'T.S.Suzuki, et al. (1995) EXFOR entry # 22310002', color='g', symbol = 'o' ),
            ], xAxisSettings = xAxis, yAxisSettings = yAxis, title = '$^1$H$(n,\gamma)$ Cross Section', legendOn = True, outFile = None )

    # Contour test
    if tests[
            4]:  # Contour plots are meaningful if there is only one dataset plotted, how do we enforce this?
        endfData = za.findData(yo=1, I=1, C=10)
        EAxis = AxisSettings(isLog=False,
                             label='$E_n$ (MeV)',
                             axisMin=1.0,
                             axisMax=20.0,
                             gridOn=True,
                             autoscale=False,
                             unit='MeV')
        muAxis = AxisSettings(isLog=False,
                              label='$\mu$ = cos( $\\theta$ )',
                              axisMin=-1.0,
                              axisMax=1.0,
                              autoscale=False,
                              gridOn=True)
        makePlot2dContour(DataSet3d(data=endfData,
                                    legend='ENDF/B-VII.0',
                                    xUnit=EAxis.unit,
                                    yUnit=muAxis.unit),
                          xAxisSettings=EAxis,
                          yAxisSettings=muAxis,
                          title='$^1$H$(n,el)$ Angular Distribution',
                          outFile=None)
        w_xys = multiD_XYsModule.multiD_XYs(
            axes=axesModule.axes(rank=3, labelsUnits={2: ('$E_n$', 'MeV')}))
        for w, xy in endfData.data:
            w_xys.append(
                XYsModule.XYs(xy,
                              axes=axesModule.axes(),
                              accuracy=1e-3,
                              value=w))
        dataset = DataSet3d(data=w_xys, legend='ENDF/B-VII.0')
        dataset.convertUnits('eV', None, None)
        makePlot2dContour(dataset,
                          xAxisSettings=EAxis,
                          yAxisSettings=muAxis,
                          title='$^1$H$(n,el)$ Angular Distribution',
                          outFile=None)

    # Slice tests
    if (tests[5] or tests[6] or tests[7] or tests[8] or tests[9]):
        endfDataI0 = za.findData(yo=0, I=0,
                                 C=10).slicex(1.0, 20.0)  # simplify the plot
        endfDataI1 = za.findData(yo=1, I=1, C=10)
        Es = [p[0] for p in endfDataI0.data]  # in [MeV]
        mus = []  # in [mu]
        for t in endfDataI1.data:
            mus += [p[0] for p in t[1]]
        mus = sorted(uniquify(mus))
        table = []
        for E in Es:
            muDist = []
            for mu in mus:
                muDist.append(
                    [mu,
                     endfDataI0.getValue(E) * endfDataI1.getValue(E, mu)])
            table.append([E, muDist])
        endfDataCombined = endl3dmath(data=table)
        EAxis = AxisSettings(isLog=True,
                             label='$E_n$ (MeV)',
                             axisMin=1.0,
                             axisMax=20.0,
                             gridOn=True,
                             autoscale=False)
        muAxis = AxisSettings(isLog=False,
                              label='$\mu = \cos{( \\theta )}$',
                              axisMin=-1.0,
                              axisMax=1.0,
                              autoscale=False,
                              gridOn=True)
        zAxis = AxisSettings(isLog=True,
                             label='$d\sigma(E)/d\mu$ (b)',
                             axisMin=0.0,
                             axisMax=5.0,
                             autoscale=False,
                             gridOn=True)

        # unthemed slice tests
        if tests[5]:
            makePlot2dSlice(
                endfDataCombined,
                xyAxisSettings=EAxis,
                zAxisSettings=zAxis,
                sliceXCoords=None,
                sliceYCoords=[-1.0, -0.75, -0.5, -.25, 0.0, .25, .5, .75, 1.0],
                title='',
                outFile=None)
            dataSet3d = DataSet3d(data=endfDataCombined, legend='ENDF/B-VII.0')
            makePlot2dSlice(
                dataSet3d.getW_XYs(),
                xyAxisSettings=EAxis,
                zAxisSettings=zAxis,
                sliceXCoords=None,
                sliceYCoords=[-1.0, -0.75, -0.5, -.25, 0.0, .25, .5, .75, 1.0],
                title='',
                outFile=None)
        if tests[6]:
            makePlot2dSlice(endfDataCombined,
                            xyAxisSettings=muAxis,
                            zAxisSettings=zAxis,
                            sliceXCoords=[1.0, 5.0, 10.0, 15.0, 20.0],
                            sliceYCoords=None,
                            title='',
                            outFile=None)

        # themed slice test and contour test
        if tests[7]:
            makePlot2dContour(DataSet3d(data=endfDataCombined,
                                        legend='ENDF/B-VII.0'),
                              xAxisSettings=EAxis,
                              yAxisSettings=muAxis,
                              numContours=10,
                              title='$d\sigma(E)/d\mu$ for $^1$H$(n,el)$',
                              outFile=None)
        if tests[8]:
            makePlot2dSlice(
                DataSet3d(data=endfDataCombined, legend='ENDF/B-VII.0'),
                xyAxisSettings=EAxis,
                zAxisSettings=zAxis,
                sliceXCoords=None,
                sliceYCoords=[-1.0, -0.75, -0.5, -.25, 0.0, .25, .5, .75, 1.0],
                title='',
                outFile=None)

        # themed slice test, with test 2d experimental data
        if tests[9]:
            makePlot2dSlice( [ \
                DataSet3d( data = endfDataCombined, legend = 'ENDF/B-VII.0' ), \
                DataSet2d( data = d, uncertainty = u, legend = 'T.S.Suzuki, et al. (1995) EXFOR entry # 22310002', color='g', symbol = 'o' ),\
            ], xyAxisSettings = muAxis, zAxisSettings = zAxis, sliceXCoords = [ 1.0, 5.0, 10.0, 15.0, 20.0 ], sliceYCoords = None, sliceUnits = 'MeV', title = 'Slice test', outFile = None )
示例#7
0
文件: fetePy.py 项目: icmeyer/fudge
def processGamma(gamma, gammas, crossSection):

    distribution = gamma.distribution[style]
    if (isinstance(distribution, unspecifiedModule.form)):
        if (args.verbose > 1): print '            No distribution data'
        return

    MF13 = False
    if ('ENDFconversionFlag' in gamma.attributes):
        MF13 = gamma.attributes['ENDFconversionFlag'] == 'MF13'
    multiplicity = gamma.multiplicity[style]
    if (isinstance(multiplicity, (multiplicityModule.constant))):
        domainMin, domainMax = multiplicity.domain()
        multiplicity = XYsModule.XYs([[float(domainMin), multiplicity.value],
                                      [float(domainMax), multiplicity.value]],
                                     axes=XYsModule.XYs.defaultAxes(
                                         labelsUnits={1: ('energy_in', 'eV')}))
    elif (isinstance(
            multiplicity,
        (multiplicityModule.pointwise, multiplicityModule.piecewise))):
        if (isinstance(multiplicity, multiplicityModule.piecewise) and MF13):
            for region in multiplicity:
                if (region.interpolation ==
                        standardsModule.interpolation.flatToken):
                    print '    WARNING: This may need to be fixed.'
        if (MF13 and isinstance(multiplicity, multiplicityModule.pointwise)):
            pass
        else:
            multiplicity = multiplicity.toPointwise_withLinearXYs(
                lowerEps=energyEps, upperEps=energyEps)
    else:
        raise Exception('Unsupported multiplicity form "%s"' %
                        multiplicity.moniker)
    multiplicity = multiplicity.convertAxisToUnit(1, 'MeV')
    multiplicity = multiplicity.domainSlice(domainMax=args.EMax)
    if ((len(multiplicity) < 2) or (multiplicity.rangeMax() == 0)):
        print '''INFO: not writing reaction's gamma data as gamma multiplicity is 0. below EMax = %s''' % args.EMax
        return

    if (crossSection is not None):
        if (MF13):
            values = [[E1, m1 * crossSection.evaluate(E1)]
                      for E1, m1 in multiplicity]
            multiplicity = XYsModule.XYs(
                values,
                axes=multiplicity.axes,
                interpolation=multiplicity.interpolation)
            multiplicity = multiplicity.toPointwise_withLinearXYs(
                lowerEps=energyEps, upperEps=energyEps)
        else:
            crossSection = crossSection.domainSlice(domainMax=args.EMax)
            crossSection.setInfill(False)
            multiplicity.setInfill(False)
            try:
                multiplicity = multiplicity * crossSection
            except:
                print 'multiplicity'
                print multiplicity.toString()
                print 'crossSection'
                print crossSection.toString()
                print multiplicity.domain(), crossSection.domain()
                raise
            multiplicity = multiplicity.trim()

    if (isinstance(distribution, uncorrelatedModule.form)):
        angularForm = distribution.angularSubform.data
        energyForm = distribution.energySubform.data
        if (isinstance(angularForm, angularModule.pointwise)):
            if (not (angularForm.isIsotropic())):
                print 'WARNING: treating angular pointwise as isotropic'
            isIsotropic = True
        else:
            isIsotropic = angularForm.isIsotropic()
            if (not (isIsotropic)):
                raise Exception('unsupported angular distribution')
        if (isIsotropic):
            if (isinstance(energyForm, energyModule.primaryGamma)):
                gammas['primaries'].append(
                    primaryGamma(multiplicity,
                                 energyForm.value.getValueAs('MeV'),
                                 float(energyForm.massRatio), angularForm))
            elif (isinstance(energyForm, energyModule.constant)):
                gammas['discretes'].append(
                    discreteGamma(multiplicity,
                                  energyForm.value.getValueAs('MeV'),
                                  angularForm))
            else:
                if (isinstance(
                        energyForm,
                    (energyModule.pointwise, energyModule.piecewise))):
                    pass
                else:
                    raise Exception('Unsupported energy form "%s"' %
                                    energyForm.moniker)
                gammas['continuum'].append(
                    continuumGammaIsotropic(multiplicity, energyForm))
        else:
            raise Exception('Unsupported angular form "%s"' %
                            angularForm.moniker)
    else:
        raise Exception('Unsupported distribution type "%s"' %
                        distribution.moniker)
示例#8
0
文件: fetePy.py 项目: icmeyer/fudge
                                                  gammaList)

    if (multiplicity is not None):
        if (len(gammas['branchingGammas']) != 0):
            raise Exception(
                'Currently, branching gammas are not support with other gammas.'
            )
        fullDistribution = sumDistributions(multiplicity, gammaList)
    else:
        if (len(gammas['branchingGammas']) not in (0, 1)):
            raise Exception('need to support this')
        for levelName, (gammaMultiplicity,
                        spectrum) in gammas['branchingGammas']:
            domainMin, domainMax = reaction.domain()
            multiplicity = XYsModule.XYs(
                [[eV2MeV * domainMin, gammaMultiplicity],
                 [eV2MeV * domainMax, gammaMultiplicity]])
            fullDistribution = [[eV2MeV * domainMin, spectrum],
                                [eV2MeV * domainMax, spectrum]]

    if (multiplicity is not None):
        if (MT in multiplicitySums): multiplicity = multiplicitySums[MT]
        writeGammas(ENDLFiles, C, S, Q, X1, multiplicity, fullDistribution)

gammas = {'continuum': [], 'discretes': [], 'primaries': []}

productionMT = None
for production in productionReactions:
    MT = production.ENDF_MT
    if (args.verbose): print '    %-40s: MT = %3s C = 55' % (production, MT)
    if (productionMT is None): MT = productionMT