This page was generated from docs/source/notebooks/resolution_example.ipynb. [Download notebook.]
Interactive online versions: Binder badge. Open In Colab

Resolution function demonstrationΒΆ

Using Ho2Ti2O7 as an example.

[ ]:
!pip install -q git+https://github.com/thallor1/pyMACS.git requests
[ ]:
import requests
def get_demo_cif(name: str):
  result = requests.get(f"https://bmaranville.github.io/pyMACS/_static/{name}")
  with open(name, 'wb') as output:
    output.write(result.content)
[1]:
#More complex example of pyMACS usage

from pyMACS.virtualMACS import VirtualMACS
import pyMACS

get_demo_cif('HTO.cif')

macs_instr = VirtualMACS('HTO_test',cifName='HTO.cif',useOld=True)
macs_instr.sample.formula_weight=432.7
macs_instr.sample.orient_u = [1,1,0]
macs_instr.sample.orient_v = [0,0,1]
macs_instr.sample.project_sample_realspace()
[1]:
1

This function pulls from a tabulated list of pre-calculated ellipsoids. I cannot guarantee the accuracy, if something seems strangely broad it likely means that the covariance matrix was not generated correctly.

[4]:
macs_Ef = 5.0
h = -1.0
k = -1.0
l = 0.0
E = 1.0 #energy transfer, i.e. Ei=6 meV
M,M_fwhms,Q_hkw = pyMACS.scripting.macs_resfunc(h,k,l,E,macs_Ef,macs_instr,gen_plot=True,verbose=True,calc_mode='load_cov')

 Qx, Qz, for hkl = [-0.87948, 0.0]
Covariance matrix in lab system:
[[ 0.00106006 -0.00058764  0.00430066]
 [-0.00058764  0.00163485 -0.00077156]
 [ 0.00430066 -0.00077156  0.03246623]]

Resolution matrix in lab system:
[[2901.93397622  871.43672721 -363.69709695]
 [ 871.43672721  880.3024156   -94.51506611]
 [-363.69709695  -94.51506611   76.73248463]]

Transformation into (Qpara, Qperp, E) system:
[[-6.123234e-17 -1.000000e+00  0.000000e+00]
 [-1.000000e+00  0.000000e+00  0.000000e+00]
 [ 0.000000e+00  0.000000e+00  1.000000e+00]]

Mean (Q, E) vector in (Qpara, Qperp, Qup, E) system:
[-6.63091133e-17  1.08291000e+00  1.00000000e+00]

Covariance matrix in (Qpara, Qperp, E) system:
[[ 0.00163485 -0.00058764  0.00077156]
 [-0.00058764  0.00106006 -0.00430066]
 [ 0.00077156 -0.00430066  0.03246623]]

Resolution matrix in (Qpara, Qperp, E) system:
[[ 880.3024156   871.43672721   94.51506611]
 [ 871.43672721 2901.93397622  363.69709695]
 [  94.51506611  363.69709695   76.73248463]]

3d resolution ellipsoid diagonal elements fwhm (coherent-elastic scattering) lengths:
[0.07936733 0.04371334 0.26882403]

3d resolution ellipsoid principal axes fwhm: [0.04337044 0.42525026]
Incoherent-elastic fwhm: 0.4243 meV

Qx,E sliced ellipse fwhm and slope angle: [0.09981989 0.04146147], 20.3825
Qz,E sliced ellipse fwhm and slope angle: [0.07887751 0.29037485], 6.6187
Qx,Qy sliced ellipse fwhm and slope angle: [0.04337044 0.42525026], 7.2191

Qx,E projected ellipse fwhm and slope angle: [0.1053531  0.06200404], 31.9691
Qz,E projected ellipse fwhm and slope angle: [0.0946496  0.42442669], 1.4326
Qx,Qy projected ellipse fwhm and slope angle: [0.05168759 0.42806265], 7.6581
[Errno 2] No such file or directory: '/mnt/c/Users/tjh/OneDrive - NIST/GitHub/pyMACS/docs/source/notebooks/Calculated_ellipsoid_pngs/MACS_resfunc_Ef_5.00meV_h_-1.00_k_-1.00_l_0.00_w_0.95.png'
Saving figure failed, ensure that the specfied figure directory exists.
../_images/notebooks_resolution_example_5_1.png
[ ]: