Example #1
0
def symOrNameForYoOrZA( yoOrZA, wantName, ASep = "", ZAOnly = 0, AddNatural = 1, m_to_m1 = False, suffixSeperator = None ) :
    """For internal use only (see symbolForYoOrZA or nameForYoOrZA)."""

    import endlmisc
    if( yoOrZA == 1 ) : return 'n'
    if( yoOrZA == 7 ) : return 'gamma'
    if ( ZAOnly == 0 ) :
        try :
            ZAyo = ZAToYo( yoOrZA )                         # Is ZA a valid yo.
        except :
            ZAOnly = 1
    if ( ZAOnly == 0 ) :
        if ( wantName == 0 ) : return endl_y.endl_yLabel( ZAyo )
        return endl_y.endl_yLongLabel( ZAyo )
    ZA, Suffix = endlmisc.intZASuffix( yoOrZA )
    if( m_to_m1 and ( Suffix == 'm' ) ) : Suffix = 'm1'
    if( ZA > 99000 ) and ( ZA <= 99200 ) : return "FissionProductENDL%d" % ZA
    if( suffixSeperator is None ) : suffixSeperator = ASep
    if( Suffix != "" ) : Suffix = suffixSeperator + Suffix
    Z, A = ZandAFromZA( ZA )
    if ( wantName == 0 ) :
        ZStr = endl_Z.endl_ZSymbol( Z )
        if ( ZStr is None ) : ZStr = "Unk"
    else : 
        ZStr = endl_Z.endl_ZLabel( Z )
        if ( ZStr is None ) : ZStr = "Unknown"
    if( A == 0 ) :
        if ( AddNatural ) : return ZStr + suffixSeperator + 'natural' + Suffix
        return ZStr
    return ZStr + ASep + `A` + Suffix
Example #2
0
    def targetList(self, Symbol=None, A=None, suffix=None):
        """Returns a list of target sub-directories in self's database matching Symbol, A and suffix."""

        if (self.database == None):
            raise Exception("No default database defined.")
        targetList = []
        targets = os.listdir(self.database)
        targets.sort()
        if ((type(Symbol) == type(None)) or (type(Symbol) == type(''))):
            Symbol = [Symbol]
        if ((type(A) == type(None)) or (type(A) == type(0))): A = [A]
        if ((type(suffix) == type(None)) or (type(suffix) == type(''))):
            suffix = [suffix]
        for target in targets:
            if (endlmisc.validZADirectoryName_(target)):
                S_ = None
                if (Symbol != [None]):
                    S_ = endl_Z.endl_ZSymbol(int(target[2:5]))
                A_ = None
                if (A != [None]): A_ = int(target[5:8])
                s_ = None
                if (suffix != [None]): s_ = target[8:]
                if ((S_ in Symbol) and (A_ in A) and (s_ in suffix)):
                    d = os.path.join(self.database, target)
                    if (os.path.exists(d)):
                        targetList.append(endl2.endlToGNDName(target))
        return targetList
Example #3
0
def ZInfo( w = 2 ) :
    """Prints a list of Z, symbol and name for most elements."""

    n = endl_Z.endl_nZs( )
    Zs = []
    Z = 0
    while( Z < n ) :
        Zs.append( "%4d %4s %15s" % ( Z, endl_Z.endl_ZSymbol( Z ), endl_Z.endl_ZLabel( Z ) ) )
        Z += 1
    brb.tylist( Zs, w = w, sep = "  |" )
Example #4
0
def processTDF_Reaction(target,
                        C,
                        S=None,
                        X1=None,
                        X2=None,
                        X3=None,
                        X4=None,
                        Q=None,
                        outputFile='tdfgen.out',
                        workDir=None,
                        bdflsFile=None):

    if (bdflsFile is None): bdflsFile = bdfls.getDefaultBdfls()
    AMUToMeV = bdflsFile.constant(4)
    xsec = target.findData(C=C, I=0, S=S, X1=X1, X2=X2, X3=X3, X4=X4, Q=Q)

    residualZA, yos, Q = endl2.residualZA_yos_Q(target.yi,
                                                target.ZA,
                                                C,
                                                bdflsFile=bdflsFile)
    projectileMass = bdflsFile.mass(target.yi)
    targetMass = bdflsFile.mass(target.ZA)

    yi = endl2.ZAToYo(target.yi)
    yiZA = endl2.yoToZA(yi)
    yiZ, yiA = endl2.ZandAFromZA(yiZA)

    ZA = target.ZA
    #    ZAZA = endl2.yoToZA( ZA )
    ZAZA = ZA
    ZAZ, ZAA = endl2.ZandAFromZA(ZAZA)

    if (projectileMass > targetMass):
        reaction = '%s%d__%s%d_' % (endl_Z.endl_ZSymbol(yiZ), yiA,
                                    endl_Z.endl_ZSymbol(ZAZ), ZAA)
    else:
        reaction = '%s%d__%s%d_' % (endl_Z.endl_ZSymbol(ZAZ), ZAA,
                                    endl_Z.endl_ZSymbol(yiZ), yiA)

    outGoing = []
    print yos
    for yo in yos:
        if (yo < 1000):
            outGoing.append([endl2.yoToZA(yo)])
        else:
            outGoing.append([yo])
    outGoing.append([residualZA])

    for i in outGoing:
        iZA = i[0]
        i.insert(0, bdflsFile.mass(iZA))
        Z, A = endl2.ZandAFromZA(iZA)
        i.append(Z)
        i.append(A)
    outGoing.sort()
    s = ''
    for mass, iZA, Z, A in outGoing:
        reaction += '%s%s%d' % (s, endl_Z.endl_ZSymbol(Z), A)
        s = '__'

    outputStr = ['## Fudge generated data for tdfgen version:0.9.9']
    outputStr.append('## Data generated from:fudge')
    outputStr.append('')
    outputStr.append('## Reaction:%s' % reaction)
    outputStr.append('')
    outputStr.append('# Masses of particles in MeV.')
    outputStr.append('## Mass of projectile:%.12e' %
                     (projectileMass * AMUToMeV))
    outputStr.append('## Mass of target:%.12e' % (targetMass * AMUToMeV))

    outputStr.append('')
    outputStr.append('## Number of final particles:%d' % len(outGoing))
    for mass, iZA, Z, A in outGoing:
        outputStr.append('## %.12e' % (mass * AMUToMeV))

    outputStr.append('')
    outputStr.append('## Lab of CM frame:Lab')
    outputStr.append('## Number of data points:%d' % len(xsec))
    outputStr.append('# E(MeV)    Sigma( barn )')
    outputStr.append('#------------------------')
    outputStr.append(xsec.toString())

    outputStr = '\n'.join(outputStr)

    inputFile = fudgeFileMisc.fudgeTempFile(dir=workDir)
    inputFile.write(outputStr)

    inputName = inputFile.getName()
    print inputName
    os.system('./tdfgen -i %s -o %s' % (inputFile.getName(), outputFile))