Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorial of generation of calibrant using xrayutilities #2344

Open
kif opened this issue Nov 26, 2024 · 0 comments
Open

Tutorial of generation of calibrant using xrayutilities #2344

kif opened this issue Nov 26, 2024 · 0 comments
Assignees
Labels
doc Related to documentation easy First contribution welcome enhancement

Comments

@kif
Copy link
Member

kif commented Nov 26, 2024

The library allow and easy way to generate a list of allowed reflections.

import xrayutilities as xu
import numpy as np

cif_file = r'SRM660s-LaB6.cif'
crystal = xu.materials.cif.CIFFile(cif_file)
sg = crystal.SGLattice()

print('Content of the .cif file:')
print(crystal)

# Lattice parameters
print('a, b, c, alpha, beta, gamma:', sg.a, sg.b, sg.c, sg.alpha, sg.beta, sg.gamma)

# Space group number
sg_number = sg.space_group_nr
print('space group:', sg_number)

# List of allowed hkl
Qmax = 5 # in Angstrom^-1
hkls = sg.get_allowed_hkl(Qmax)
print(f'hkl list (Qmax={Qmax}Angst): {list(hkls)}')

# List of equivalent reflections hkl
ehkl = sg.equivalent_hkls((1,1,1))
print('equiv hkl:', ehkl)

# Check whether a reflection is allowed
hkl=(28,0,0)
check = sg.hkl_allowed(hkl)
print(hkl, 'allowed:', check)

# Reflection conditions (rules)
print(sg.reflection_conditions())

# Check whether 2 reflections are equivalent
hkl1 = (1,1,1)
hkl2 = (1,2,-1)
print(f'{hkl1} and {hkl2} are equivalent: {sg.isequivalent(hkl1, hkl2)}')

# Sorted list of hkl reflections for powder diffraction
sortedhkls = sorted(hkls, reverse=True) # sort by decreasing h, then k, then l.
print(f'Sorted hkl list: {sortedhkls}')
phkl = []
for hkl1 in sortedhkls:
    alreadyIncluded = False
    for hkl2 in phkl:
        if sg.isequivalent(hkl1, hkl2):
            alreadyIncluded = True
    if not alreadyIncluded:
        phkl.append(hkl1)
phkl = sorted(phkl) # finally by increasing hkl values
print(f'phkl = {phkl}')
@kif kif added enhancement doc Related to documentation labels Nov 26, 2024
@kif kif self-assigned this Nov 26, 2024
@kif kif added the easy First contribution welcome label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Related to documentation easy First contribution welcome enhancement
Projects
None yet
Development

No branches or pull requests

1 participant