예제 #1
0
        xraylib.CS_FluorLine_Kissel_Radiative_Cascade(82, xraylib.MA1_LINE,
                                                      20.0)))
print(
    "Pb Malpha XRF production cs at 20.0 keV with non-radiative cascade effect: {}"
    .format(
        xraylib.CS_FluorLine_Kissel_Nonradiative_Cascade(
            82, xraylib.MA1_LINE, 20.0)))
print("Pb Malpha XRF production cs at 20.0 keV without cascade effect: {}".
      format(xraylib.CS_FluorLine_Kissel_no_Cascade(82, xraylib.MA1_LINE,
                                                    20.0)))
print("Al mass energy-absorption cs at 20.0 keV: {}".format(
    xraylib.CS_Energy(13, 20.0)))
print("Pb mass energy-absorption cs at 40.0 keV: {}".format(
    xraylib.CS_Energy(82, 40.0)))
print("CdTe mass energy-absorption cs at 40.0 keV: {}".format(
    xraylib.CS_Energy_CP("CdTe", 40.0)))

cryst = xraylib.Crystal_GetCrystal("Si")
if cryst is None:
    raise KeyError('Diamond crystal not found')

print("Si unit cell dimensions are {} {} {}".format(cryst['a'], cryst['b'],
                                                    cryst['c']))
print("Si unit cell angles are {} {} {}".format(cryst['alpha'], cryst['beta'],
                                                cryst['gamma']))
print("Si unit cell volume is {}".format(cryst['volume']))
print("Si atoms at:")
print("   Z  fraction    X        Y        Z")
for i in range(cryst['n_atom']):
    atom = cryst['atom'][i]
    print("  {} {} {} {} {}".format(atom['Zatom'], atom['fraction'], atom['x'],
예제 #2
0
print("Sr anomalous scattering factor Fi at 10.0 keV: {}".format(xraylib.Fi(38, 10.0)))
print("Sr anomalous scattering factor Fii at 10.0 keV: {}".format(xraylib.Fii(38, 10.0)))

symbol = xraylib.AtomicNumberToSymbol(26)
print("Symbol of element 26 is: {}".format(symbol))
print("Number of element Fe is: {}".format(xraylib.SymbolToAtomicNumber("Fe")))
Z = np.array([26])
symbol = xraylib.AtomicNumberToSymbol(Z[0])
print("Symbol of element 26 is: {}".format(symbol))
print("Pb Malpha XRF production cs at 20.0 keV with cascade effect: {}".format(xraylib.CS_FluorLine_Kissel(82, xraylib.MA1_LINE,20.0)))
print("Pb Malpha XRF production cs at 20.0 keV with radiative cascade effect: {}".format(xraylib.CS_FluorLine_Kissel_Radiative_Cascade(82, xraylib.MA1_LINE,20.0)))
print("Pb Malpha XRF production cs at 20.0 keV with non-radiative cascade effect: {}".format(xraylib.CS_FluorLine_Kissel_Nonradiative_Cascade(82, xraylib.MA1_LINE,20.0)))
print("Pb Malpha XRF production cs at 20.0 keV without cascade effect: {}".format(xraylib.CS_FluorLine_Kissel_no_Cascade(82, xraylib.MA1_LINE,20.0)))
print("Al mass energy-absorption cs at 20.0 keV: {}".format(xraylib.CS_Energy(13, 20.0)))
print("Pb mass energy-absorption cs at 40.0 keV: {}".format(xraylib.CS_Energy(82, 40.0)))
print("CdTe mass energy-absorption cs at 40.0 keV: {}".format(xraylib.CS_Energy_CP("CdTe", 40.0)))

cryst = xraylib.Crystal_GetCrystal("Si")
if cryst is None:
    raise KeyError('Diamond crystal not found')

print("Si unit cell dimensions are {} {} {}".format(cryst['a'],cryst['b'],cryst['c']))
print("Si unit cell angles are {} {} {}".format(cryst['alpha'],cryst['beta'],cryst['gamma']))
print("Si unit cell volume is {}".format(cryst['volume']))
print("Si atoms at:")
print("   Z  fraction    X        Y        Z")
for i in range(cryst['n_atom']):
    atom =  cryst['atom'][i]
    print("  {} {} {} {} {}".format(atom['Zatom'], atom['fraction'], atom['x'], atom['y'], atom['z']))
print("")
예제 #3
0
	print ("Au Ma1 XRF production cs at 10.0 keV (Kissel): %f" % xraylib.CS_FluorLine_Kissel(79,xraylib.MA1_LINE,10.0))
	print ("Au Mb XRF production cs at 10.0 keV (Kissel): %f" % xraylib.CS_FluorLine_Kissel(79,xraylib.MB_LINE,10.0))
	print ("Au Mg XRF production cs at 10.0 keV (Kissel): %f" % xraylib.CS_FluorLine_Kissel(79,xraylib.MG_LINE,10.0))
	print ("K atomic level width for Fe: %g" % xraylib.AtomicLevelWidth(26,xraylib.K_SHELL))
	print ("Bi L2-M5M5 Auger non-radiative rate: %g" % xraylib.AugerRate(86,xraylib.L2_M5M5_AUGER))
	print ("Bi L3 Auger yield: %g" % xraylib.AugerYield(86, xraylib.L3_SHELL))
	symbol = xraylib.AtomicNumberToSymbol(26)
	print ("Symbol of element 26 is: %s" % symbol)
	print ("Number of element Fe is: %i" % xraylib.SymbolToAtomicNumber("Fe"))
	print ("Pb Malpha XRF production cs at 20.0 keV with cascade effect: %g" % xraylib.CS_FluorLine_Kissel(82,xraylib.MA1_LINE,20.0))
	print ("Pb Malpha XRF production cs at 20.0 keV with radiative cascade effect: %g" % xraylib.CS_FluorLine_Kissel_Radiative_Cascade(82,xraylib.MA1_LINE,20.0))
	print ("Pb Malpha XRF production cs at 20.0 keV with non-radiative cascade effect: %g" % xraylib.CS_FluorLine_Kissel_Nonradiative_Cascade(82,xraylib.MA1_LINE,20.0))
	print ("Pb Malpha XRF production cs at 20.0 keV without cascade effect: %g" % xraylib.CS_FluorLine_Kissel_no_Cascade(82,xraylib.MA1_LINE,20.0))
	print ("Al mass energy-absorption cs at 20.0 keV: %f" % xraylib.CS_Energy(13, 20.0))
	print ("Pb mass energy-absorption cs at 40.0 keV: %f" % xraylib.CS_Energy(82, 40.0))
	print ("CdTe mass energy-absorption cs at 40.0 keV: %f" % xraylib.CS_Energy_CP("CdTe", 40.0))


	cryst = xraylib.Crystal_GetCrystal("Si")
	if (cryst == None):
		sys.exit(1)
	print ("Si unit cell dimensions are %f %f %f" % (cryst['a'],cryst['b'],cryst['c']))
	print ("Si unit cell angles are %f %f %f" % (cryst['alpha'],cryst['beta'],cryst['gamma']))
	print ("Si unit cell volume is %f" % cryst['volume'] )
	print ("Si atoms at:")
	print ("   Z  fraction    X        Y        Z")
	for i in range(cryst['n_atom']):
		atom =  cryst['atom'][i]
		print ("  %3i %f %f %f %f" % (atom['Zatom'], atom['fraction'], atom['x'], atom['y'], atom['z']))
	print ("")
예제 #4
0
def xoppy_calc_xraylib_widget(FUNCTION=0,ELEMENT=26,ELEMENTORCOMPOUND="FeSO4",COMPOUND="Ca5(PO4)3",TRANSITION_IUPAC_OR_SIEGBAHN=1,\
                              TRANSITION_IUPAC_TO=0,TRANSITION_IUPAC_FROM=0,TRANSITION_SIEGBAHN=0,SHELL=0,ENERGY=10.0):

    functions = [
        '0 Fluorescence line energy', '1 Absorption edge energy',
        '2 Atomic weight', '3 Elemental density',
        '4 Total absorption cross section', '5 Photoionization cross section',
        '6 Partial photoionization cross section',
        '7 Rayleigh scattering cross section',
        '8 Compton scattering cross section', '9 Klein-Nishina cross section',
        '10 Mass energy-absorption cross section',
        '11 Differential unpolarized Klein-Nishina cross section',
        '12 Differential unpolarized Thomson cross section',
        '13 Differential unpolarized Rayleigh cross section',
        '14 Differential unpolarized Compton cross section',
        '15 Differential polarized Klein-Nishina cross section',
        '16 Differential polarized Thomson cross section',
        '17 Differential polarized Rayleigh cross section',
        '18 Differential polarized Compton cross section',
        '19 Atomic form factor', '20 Incoherent scattering function',
        '21 Momentum transfer function',
        '22 Coster-Kronig transition probability', '23 Fluorescence yield',
        '24 Jump factor', '25 Radiative transition probability',
        '26 Energy after Compton scattering',
        '27 Anomalous scattering factor φ′',
        '28 Anomalous scattering factor φ″',
        '29 Electronic configuration',
        '30 X-ray fluorescence production cross section (with full cascade)',
        '31 X-ray fluorescence production cross section (with radiative cascade)',
        '32 X-ray fluorescence production cross section (with non-radiative cascade)',
        '33 X-ray fluorescence production cross section (without cascade)',
        '34 Atomic level width', '35 Auger yield', '36 Auger rate',
        '37 Refractive index', '38 Compton broadening profile',
        '39 Partial Compton broadening profile',
        '40 List of NIST catalog compounds',
        '41 Get composition of NIST catalog compound',
        '42 List of X-ray emitting radionuclides',
        '43 Get excitation profile of X-ray emitting radionuclide',
        '44 Compoundparser'
    ]

    print("\nInside xoppy_calc_xraylib with FUNCTION = %s. " %
          (functions[FUNCTION]))

    if FUNCTION == 0:
        if TRANSITION_IUPAC_OR_SIEGBAHN == 0:
            lines = [
                'K', 'L1', 'L2', 'L3', 'M1', 'M2', 'M3', 'M4', 'M5', 'N1',
                'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'O1', 'O2', 'O3', 'O4',
                'O5', 'O6', 'O7', 'P1', 'P2', 'P3', 'P4', 'P5', 'Q1', 'Q2',
                'Q3'
            ]
            line = lines[TRANSITION_IUPAC_TO] + lines[
                TRANSITION_IUPAC_FROM] + "_LINE"
            command = "result = xraylib.LineEnergy(%d,xraylib.%s)" % (ELEMENT,
                                                                      line)
            print("executing command: ", command)
            line = getattr(xraylib, line)
            result = xraylib.LineEnergy(ELEMENT, line)
            print("result: %f keV" % (result))
        if TRANSITION_IUPAC_OR_SIEGBAHN == 1:
            lines = [
                'KA1_LINE', 'KA2_LINE', 'KB1_LINE', 'KB2_LINE', 'KB3_LINE',
                'KB4_LINE', 'KB5_LINE', 'LA1_LINE', 'LA2_LINE', 'LB1_LINE',
                'LB2_LINE', 'LB3_LINE', 'LB4_LINE', 'LB5_LINE', 'LB6_LINE',
                'LB7_LINE', 'LB9_LINE', 'LB10_LINE', 'LB15_LINE', 'LB17_LINE',
                'LG1_LINE', 'LG2_LINE', 'LG3_LINE', 'LG4_LINE', 'LG5_LINE',
                'LG6_LINE', 'LG8_LINE', 'LE_LINE', 'LL_LINE', 'LS_LINE',
                'LT_LINE', 'LU_LINE', 'LV_LINE'
            ]
            line = lines[TRANSITION_SIEGBAHN]
            command = "result = xraylib.LineEnergy(%d,xraylib.%s)" % (ELEMENT,
                                                                      line)
            print("executing command: ", command)
            line = getattr(xraylib, line)
            result = xraylib.LineEnergy(ELEMENT, line)
            print("result: %f keV" % (result))
        if TRANSITION_IUPAC_OR_SIEGBAHN == 2:
            lines = [
                'K', 'L1', 'L2', 'L3', 'M1', 'M2', 'M3', 'M4', 'M5', 'N1',
                'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'O1', 'O2', 'O3', 'O4',
                'O5', 'O6', 'O7', 'P1', 'P2', 'P3', 'P4', 'P5', 'Q1', 'Q2',
                'Q3'
            ]
            for i1, l1 in enumerate(lines):
                for i2, l2 in enumerate(lines):
                    if i1 != i2:
                        line = l1 + l2 + "_LINE"

                        try:
                            line = getattr(xraylib, line)
                            result = xraylib.LineEnergy(ELEMENT, line)
                        except:
                            pass
                        else:
                            if result != 0.0:
                                print("%s%s  %f   keV" % (l1, l2, result))
    elif FUNCTION == 1:
        shells = [
            'All shells', 'K_SHELL', 'L1_SHELL', 'L2_SHELL', 'L3_SHELL',
            'M1_SHELL', 'M2_SHELL', 'M3_SHELL', 'M4_SHELL', 'M5_SHELL',
            'N1_SHELL', 'N2_SHELL', 'N3_SHELL', 'N4_SHELL', 'N5_SHELL',
            'N6_SHELL', 'N7_SHELL', 'O1_SHELL', 'O2_SHELL', 'O3_SHELL',
            'O4_SHELL', 'O5_SHELL', 'O6_SHELL', 'O7_SHELL', 'P1_SHELL',
            'P2_SHELL', 'P3_SHELL', 'P4_SHELL', 'P5_SHELL', 'Q1_SHELL',
            'Q2_SHELL', 'Q3_SHELL'
        ]
        if SHELL == 0:  #"all"
            for i, myshell in enumerate(shells):
                if i >= 1:
                    # command = "result = xraylib.EdgeEnergy(%d,xraylib.%s)"%(ELEMENT,myshell)
                    # print("executing command: ",command)
                    shell_index = getattr(xraylib, myshell)
                    try:
                        result = xraylib.EdgeEnergy(ELEMENT, shell_index)
                    except:
                        pass
                    else:
                        if result != 0.0:
                            print("%s  %f   keV" % (myshell, result))
                        else:
                            print("No result")
        else:
            shell_index = getattr(xraylib, shells[SHELL])
            try:
                command = "result = xraylib.EdgeEnergy(%d,xraylib.%s)" % (
                    ELEMENT, shells[SHELL])
                print("executing command: ", command)
                result = xraylib.EdgeEnergy(ELEMENT, shell_index)
            except:
                pass
            else:
                if result != 0.0:
                    print("Z=%d %s : %f   keV" %
                          (ELEMENT, shells[SHELL], result))
                else:
                    print("No result")
    elif FUNCTION == 2:
        result = xraylib.AtomicWeight(ELEMENT)
        if result != 0.0:
            print("Atomic weight for Z=%d : %f  g/mol" % (ELEMENT, result))
    elif FUNCTION == 3:
        result = xraylib.ElementDensity(ELEMENT)
        if result != 0.0:
            print("Element density for Z=%d : %f  g/cm3" % (ELEMENT, result))
        else:
            print("No result")
    elif FUNCTION == 4:
        command = "result = xraylib.CS_Total_CP('%s',%f)" % (ELEMENTORCOMPOUND,
                                                             ENERGY)
        print("executing command: ", command)
        result = xraylib.CS_Total_CP(ELEMENTORCOMPOUND, ENERGY)
        if result != 0.0:
            print("Total absorption cross section: %f  g/cm3" % (result))
        else:
            print("No result")
    elif FUNCTION == 5:
        command = "result = xraylib.CS_Photo_CP('%s',%f)" % (ELEMENTORCOMPOUND,
                                                             ENERGY)
        print("executing command: ", command)
        result = xraylib.CS_Photo_CP(ELEMENTORCOMPOUND, ENERGY)
        if result != 0.0:
            print("Photoionization cross section: %f  g/cm3" % (result))
        else:
            print("No result")
    elif FUNCTION == 6:
        shells = [
            'All shells', 'K_SHELL', 'L1_SHELL', 'L2_SHELL', 'L3_SHELL',
            'M1_SHELL', 'M2_SHELL', 'M3_SHELL', 'M4_SHELL', 'M5_SHELL',
            'N1_SHELL', 'N2_SHELL', 'N3_SHELL', 'N4_SHELL', 'N5_SHELL',
            'N6_SHELL', 'N7_SHELL', 'O1_SHELL', 'O2_SHELL', 'O3_SHELL',
            'O4_SHELL', 'O5_SHELL', 'O6_SHELL', 'O7_SHELL', 'P1_SHELL',
            'P2_SHELL', 'P3_SHELL', 'P4_SHELL', 'P5_SHELL', 'Q1_SHELL',
            'Q2_SHELL', 'Q3_SHELL'
        ]
        if SHELL == 0:  #"all"
            for index in range(1, len(shells)):
                shell_index = getattr(xraylib, shells[index])
                try:
                    command = "result = xraylib.xraylib.CS_Photo_Partial('%d',xraylib.%s,%f)" % (
                        ELEMENT, shells[index], ENERGY)
                    print("executing command: ", command)
                    result = xraylib.CS_Photo_Partial(ELEMENT, shell_index,
                                                      ENERGY)
                except:
                    pass
                else:
                    if result != 0.0:
                        print("Z=%d, %s at E=%f keV: %f   cm2/g" %
                              (ELEMENT, shells[index], ENERGY, result))
                    else:
                        print("No result")
        else:
            shell_index = getattr(xraylib, shells[SHELL])
            try:
                command = "result = xraylib.xraylib.CS_Photo_Partial('%d',xraylib.%s,%f)" % (
                    ELEMENT, shells[SHELL], ENERGY)
                print("executing command: ", command)
                result = xraylib.CS_Photo_Partial(ELEMENT, shell_index, ENERGY)
            except:
                pass
            else:
                if result != 0.0:
                    print("Z=%d, %s at E=%f keV: %f   cm2/g" %
                          (ELEMENT, shells[SHELL], ENERGY, result))
                else:
                    print("No result")
    elif FUNCTION == 7:
        command = "result = xraylib.CS_Rayl_CP('%s',%f)" % (ELEMENTORCOMPOUND,
                                                            ENERGY)
        print("executing command: ", command)
        result = xraylib.CS_Rayl_CP(ELEMENTORCOMPOUND, ENERGY)
        if result != 0.0: print("Rayleigh cross section: %f  cm2/g" % (result))
        else: print("No result")
    elif FUNCTION == 8:
        command = "result = xraylib.CS_Compt_CP('%s',%f)" % (ELEMENTORCOMPOUND,
                                                             ENERGY)
        print("executing command: ", command)
        result = xraylib.CS_Compt_CP(ELEMENTORCOMPOUND, ENERGY)
        if result != 0.0: print("Compton cross section: %f  cm2/g" % (result))
        else: print("No result")
    elif FUNCTION == 9:
        command = "result = xraylib.CS_KN(%f)" % (ENERGY)
        print("executing command: ", command)
        result = xraylib.CS_KN(ENERGY)
        if result != 0.0:
            print("Klein Nishina cross section: %f  cm2/g" % (result))
        else:
            print("No result")
    elif FUNCTION == 10:
        command = "result = xraylib.CS_Energy_CP('%s',%f)" % (
            ELEMENTORCOMPOUND, ENERGY)
        print("executing command: ", command)
        result = xraylib.CS_Energy_CP(ELEMENTORCOMPOUND, ENERGY)
        if result != 0.0:
            print("Mass-energy absorption cross section: %f  cm2/g" % (result))
        else:
            print("No result")
    else:
        print("\n#### NOT YET IMPLEMENTED ####")