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
def yInfo( ) : """Prints a list of y-id, symbol and name for supported projectiles.""" ls = endl_y.endl_yLabelMaxWidth( ) ll = endl_y.endl_yLongLabelMaxWidth( ) Fmt = " y %%%ds %%%ds" % ( ls, ll ) print Fmt % ( "Symbol", "Name" ) dashes = ( 6 + ls + ll ) * "-" print dashes Fmt = "%%4d %%%ds %%%ds" % ( ls, ll ) y = 1 while( 1 ) : ls = endl_y.endl_yLabel( y ) if( ls is None ) : break ll = endl_y.endl_yLongLabel( y ) print Fmt % ( y, ls, ll ) y += 1
def reactionEquations( yi_, ZA_, C, level = None, specialCases = 1, printQWarning = True, NameASeperator = "", bdflsFile = None ) : """Given the incident particle yi, target ZA and reaction type C, this routine returns a list of three string for the reaction's equation. The first string is of the form 'yi + ZA -> products + residual + Q' and the second is of the form ZA(yi,products)residual. The third string is of the form (yi,products). For example, reactionEquations( 1, 94239, 13 ) returns the list [ 'n + Pu239n -> 3n + Pu237 + -12.64503 MeV', 'Pu239(n,3n)Pu237', '(n,3n)' ]. If level is not None, """ import endlmisc yi = endlmisc.incidentParticleTags( yi_ )[0] ZA, Suffix = endlmisc.intZASuffix( ZA_ ) Z, A = ZandAFromZA( ZA ) s1 = endl_y.endl_yLabel( ZAToYo( yi ) ) + " + " + symbolForYoOrZA( ZA_, ZAOnly = 1, AddNatural = 0, NameASeperator = NameASeperator ) + " ->" s2 = symbolForYoOrZA( ZA_, ZAOnly = 1, AddNatural = 0, NameASeperator = NameASeperator ) + "(" + endl_y.endl_yLabel( ZAToYo( yi ) ) + "," ZAr, yos, q = residualZA_yos_Q( yi, ZA, C, specialCases = specialCases, printQWarning = printQWarning, bdflsFile = bdflsFile ) if ( ( len( yos ) > 0 ) and ( yos[0] < 0 ) ) : if ( yos[0] == -1 ) : # yo is unknown s1 += " ?" s2 += "?)?" elif ( yos[0] == -2 ) : # yo = yi s1 += " %s + %s" % ( endl_y.endl_yLabel( ZAToYo( yi ) ), symbolForYoOrZA( ZA_, ZAOnly = 1, AddNatural = 0, NameASeperator = NameASeperator ) ) s2 += "%s)%s" % ( endl_y.endl_yLabel( ZAToYo( yi ) ), symbolForYoOrZA( ZA_, ZAOnly = 1, AddNatural = 0, NameASeperator = NameASeperator ) ) elif ( yos[0] == -3 ) : # fission s1 += " fission + ?" s2 += "fission)?" elif ( yos[0] == -4 ) : # Xyo s1 += " X%s + ?" % endl_y.endl_yLabel( ZAToYo( yos[1] ) ) s2 += "X%s)?" % endl_y.endl_yLabel( ZAToYo( yos[1] ) ) else : raise Exception( "\nError in reactionName: invalid yos[0] = %s" % `yos[0]` ) else : n = 1 yo_ = None syo = "" for yo in yos : if ( yo_ is None ) : yo_ = yo elif ( yo != yo_ ) : syo += " + " if ( n > 1 ) : syo += `n` s2 += `n` syo += symbolForYoOrZA( yo_, NameASeperator = NameASeperator ) s2 += symbolForYoOrZA( yo_, NameASeperator = NameASeperator ) + " " n = 1 yo_ = yo else : n += 1 if ( yo_ is not None ) : syo += " + " if ( n > 1 ) : syo += `n` s2 += `n` syo += endl_y.endl_yLabel( ZAToYo( yo_ ) ) s2 += endl_y.endl_yLabel( ZAToYo( yo_ ) ) + " " if ( ( yi == 1 ) and ( C == 11 ) ) or ( ( yi == 2 ) and ( C == 40 ) ) or ( ( yi == 3 ) and ( C == 41 ) ) or \ ( ( yi == 4 ) and ( C == 42 ) ) or ( ( yi == 5 ) and ( C == 44 ) ) or ( ( yi == 6 ) and ( C == 45 ) ) : syo += "'" s2 = s2[:-1] + "'" syo = syo[2:] # remove first " +" if ( q is None ) : qStr = "?" else : qStr = "%.8g MeV" % q if( ZA > 99000 ) and ( ZA <= 99200 ) or ( ZAr is None ) : ZArStr = "?" else : ZArStr = symbolForYoOrZA( ZAr, ZAOnly = 1, AddNatural = 0, NameASeperator = NameASeperator ) if( level is not None ) : ZArStr += '[' + str( level ) + ']' s1 += syo + " + " + ZArStr + " + " + qStr if ( s2[-1] == " " ) : s2 = s2[:-1] s2 += ")" + ZArStr s3 = "" if ( s2.find( "(" ) != -1 ) : s3 = "(" + s2.split( "(" )[1].split( ")" )[0] + ")" return [ s1, s2, s3 ]