kklmn / xrt

Package xrt (XRayTracer) is a python software library for ray tracing and wave propagation in x-ray regime. It is primarily meant for modeling synchrotron sources, beamlines and beamline elements.
MIT License
84 stars 30 forks source link

get_epsilon_h #109

Open hgretar opened 2 years ago

hgretar commented 2 years ago

Hi guys, the get_epsilon_h function in the Crystal class is giving me some strange results. SiO2(1,1,1) and (-1,-1,-1) have the same d-spacing and only differe in reflectivity. At 2840 eV XOP gives 60 meV bandwidth for both reflections, same happens if I simply use the get_amplitude function in XRT. However when using get_epsilonh (quicker) I get 60 meV and 30 meV for these two reflections. I've located the origin which comes from the Fhkl and Fhkl values - they get swapped between these two reflections (see results below). Could you have a look at this? Perhaps Fhkl_ should also be included in the function? get_Darwin_width works by the way fine.

Here is my test script:

`import numpy as np import os, sys; sys.path.append(r'C:\xrt-master'); import xrt.backends.raycing.materials as rm

hkl=[[ 1,1,1],[-1,-1,-1]] crystals={} for i in hkl: crystals['{0}{1}{2}'.format(i[0],i[1],i[2])]=rm.CrystalFromCell('alphaQuartz', (i[0], i[1], i[2]), a=4.91304, c=5.40463, gamma=120, atoms=[14, 14, 14, 8, 8, 8, 8, 8, 8],atomsXYZ=[[0.4697, 0., 0.], [-0.4697, -0.4697, 1./3],[0., 0.4697, 2./3], [0.4125, 0.2662, 0.1188],[-0.1463, -0.4125, 0.4521], [-0.2662, 0.1463, -0.2145],[0.1463, -0.2662, -0.1188], [-0.4125, -0.1463, 0.2145],[0.2662, 0.4125, 0.5479]])

print("Data for SiO2(111)") print("Energy bandwidth: " + str(crystals['111'].get_epsilon_h(2840)28401e3)+ " meV") print("d-spacing: "+str(crystals['111'].d)) print("Bragg: "+str(np.degrees((crystals['111'].get_Bragg_angle(2840)))))

print("\n") print("Data for SiO2(-1-1-1)") print("Energy bandwidth: " + str(crystals['-1-1-1'].get_epsilon_h(2840)28401e3)+ " meV") print("d-spacing: "+str(crystals['-1-1-1'].d)) print("Bragg: "+str(np.degrees((crystals['-1-1-1'].get_Bragg_angle(2840))))) `

And the output:

`Data for SiO2(111) Here is chiToFd2: 3.970687487484859e-07 Here is Fhkl: 13.058014554739122 Here is Fhkl_: 6.87713080669671 Energy bandwidth: 58.90079912442791 meV d-spacing: 2.236353722890521 Bragg: 77.4382525286798

Data for SiO2(-1-1-1) Here is chiToFd2: 3.970687487484859e-07 Here is Fhkl: 6.877130806696709 Here is Fhkl_: 13.058014554739112 Energy bandwidth: 31.020680709124104 meV d-spacing: 2.236353722890521 Bragg: 77.4382525286798`

kklmn commented 2 years ago

Hi, Simply don't use get_epsilon_h(). I put it there to test the Shvydko's Eq(2.119). It does the same calculations as get_Darwin_width() apart from being squared and having |F_h|² instead of F_h*Fh.

hgretar commented 2 years ago

Ok good to know