Dans_Diffraction.classes_properties (version 1.9)
index
c:\users\grp66007\onedrive - diamond light source ltd\pythonprojects\dans_diffraction\dans_diffraction\classes_properties.py

Properties Class "classes_properties.py"
 functions for calculating various properties, working with the Crystal class.
 
By Dan Porter, PhD
Diamond
2017
 
Version 1.9
Last updated: 20/07/23
 
Version History:
10/11/17 0.1    Program created
06/01/18 1.0    Program renamed
11/03/18 1.1    Added properties.info(), element.info()
23/02/19 1.2    Added xray_edges
15/08/19 1.3    Added molcharge
30/03/20 1.4    Added latex_table, info returns str, removed getattr from xray_edges, check if element exists
12/05/20 1.5    Added orbitals function, exchange_paths
15/10/20 1.6    Added scattering lengths + factors
26/01/21 1.7    Added calculation of xray attenuation, transmission and refractive index
16/05/23 1.8    Fixed reflectivity calculation
20/07/23 1.9    Added FDMNES indata writer
 
@author: DGPorter

 
Modules
       
Dans_Diffraction.functions_crystallography
Dans_Diffraction.functions_general
numpy

 
Classes
       
builtins.object
Element
Properties

 
class Element(builtins.object)
    Element(element='Co')
 
Element Class
 
  Methods defined here:
__init__(self, element='Co')
Initialise properties
__repr__(self)
Return repr(self).
info(self)
Display atomic properties

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Properties(builtins.object)
    Properties(xtl)
 
Properties functions for the Crystal Object
Example Usage:
    xtl = Crystal('file.cif')
    print(xtl.Properties)
    xtl.Properties.density()
    print(xtl.Properties.molcharge())
    xtl.Properties.Co.K  # returns K edge of element Co (if Co in Crystal)
 
  Methods defined here:
__init__(self, xtl)
initialise
__repr__(self)
Return repr(self).
absorption(self, energy_kev=None)
Returns the sample absorption coefficient in um^-1 at the requested energy in keV
atomic_neighbours(self, structure_index=0, radius=2.5, disp=False, return_str=False)
Returns the relative positions of atoms within a radius of the selected atom
    vector, label = atomic_distances(idx, radius)
        idx = index of central atom, choosen from xtl.Structrue.info()
        radius = radius about the central atom to find other ions, in Angstroms
        disp = False*/True display the output
        vector = [nx3] array of atomic positions relative to central atom
        label = labels of the neighboring ions
atoms_per_volume(self)
Return no. atoms per volume in atoms per A^3
beamline_info(self, energy_kev=None)
Prints various properties useful for experiments
density(self)
Return the density in g/cm
diamagnetic_susceptibility(self, atom_type='volume')
Calculate diamagnetic contribution to susceptibility
 
type = 'volume' > returns volume susceptiblity in -dimensionless-
type = 'cgs volume' > returns volume susceptiblity in emu/cm^3
type = 'mass' > returns mass susceptiblity in m^3/kg
type = 'cgs mass' > returns mass susceptiblity in emu/g
type = 'molar' > returns molar susceptiblity in m^3/mol
type = 'cgs molar' > returns molar susceptiblity in emu/mol
exchange_paths(self, cen_idx=None, nearest_neighbor_distance=7.0, exchange_type='O', bond_angle=90.0, search_in_cell=True, group_neighbors=True, disp=False, return_str=False)
Calcualte likely exchange pathways between neighboring ions within a certain radius
Ions in exchange path are selected by being close to the bond between neighboring atoms of the same type to the
central atom.
:param cen_idx: index of central ion in xtl.Structure, or None to select 1st magnetic ion in list
:param nearest_neighbor_distance: Maximum radius to serach to
:param exchange_type: str or None. Exchange path only incoroporates these elements, or None for any
:param bond_angle: float. Search for exchange ions withing this angle to the bond, in degrees
:param search_in_cell: Bool. If True, only looks for neighbors within the unit cell
:param group_neighbors: Bool. If True, only shows neighbors with the same bond distance once
:param disp: Bool. If True, prints details of the calcualtion
:param return_str: Bool. If True, returns a formatted string of the results
:return: exchange_path, excange_distance (, output_str)
fdmnes_runfile(self, output_path=None, comment='', energy_range=None, radius=4.0, edge='K', absorber=None, green=True, scf=False, quadrupole=False, magnetism=False, spinorbit=False, azi_ref=(1, 0, 0), correct_azi=False, hkl_reflections=(1, 0, 0))
Write FDMNES run file
:param output_path: Specify the output filename, e.g. 'Sim/Crystal/out'
:param comment: A comment written in the input file
:param energy_range: str energy range in eV relative to Fermi energy
:param radius: calculation radius
:param edge: absorptin edge, 'K', 'L3', 'L2', 'L23'
:param absorber: absorbing element, 'Co'
:param green: True/False, Green's function (muffin-tin potential)
:param scf: True/False, Self consistent solution
:param quadrupole: False/True, E1E2 terms allowed
:param magnetism: False/True, allow magnetic calculation
:param spinorbit: False/True, allow magnetic calculation with spin-orbit coupling
:param azi_ref: azimuthal reference, [1,0,0]
:param correct_azi: if True, correct azimuthal reference for real cell (use in hexagonal systems)
:param hkl_reflections: list of hkl reflections [[1,0,0],[0,1,0]]
:return: None
info(self)
Prints various properties of the crystal
latex_table(self)
Return latex table of structure properties from CIF
magnetic_form_factor(self, hkl)
Return the magnetic form factor for given hkl reflections
:param hkl: [nx3] array of (h,k,l) reflections
:return: [nxm] array of scattering factors for each atom and reflection
molcharge(self, element=None, element_no=None, latex=False)
Generate molecular charge composition of crystal
    element : str : specify element that will have a coordination number
    element_no : float : The coordination number of element
    latex : True/False : if true, outputs in latex format
    charge: True/False : if true, outputs chemical charge format
:return: str
molfraction(self, Z=1)
Display the molecular weight of a compound and atomic fractions
:param Z: filling number
:return: str
molname(self, element=None, element_no=None, latex=False)
Generate molecular name of crystal
    element : str : specify element that will have a coordination number
    element_no : float : The coordination number of element
    latex : True/False : if true, outputs in latex format
:return: str
neutron_scatteringlengths(self)
Return the bound coherent neutron scattering length for each atom in the structure
:return: [m] array of scattering lengths for each atom
orbitals(self)
Return orbital Compound from classes_orbitals
resonant_element(self)
Returns the likely x-ray absorbing element in this material
  Returns the first d or f block element,
  otherwise returns the first element
update_cif(self, cifvals)
Update cif dict with new values
:param cifvals: cif dict from readcif
:return: cifvals
volume(self)
Returns the volume in A^3
weight(self)
Return the molecular weight in g/mol
xray_attenuation_length(self, energy_kev=None, grazing_angle=90)
Calcualte X-Ray Attenuation Length
Equivalent to: https://henke.lbl.gov/optical_constants/atten2.html
Based on formulas from: Henke, Gullikson, and Davis, Atomic Data and Nuclear Data Tables 54 no.2, 181-342 (July 1993)
:param energy_kev: float or array, x-ray energy in keV
:param grazing_angle: incidence angle relative to the surface, in degrees
:return: float or array, in microns
xray_edges(self)
Returns the x-ray absorption edges available and their energies
string, energies = self.xray_edges()
E.G.
string = ['Ru K', 'Ru L1', 'Ru L2' ...]
energies = [22., ...]
xray_reflectivity(self, energy_kev=None, grazing_angle=2)
Calculate the specular reflectivity of a material
From: https://xdb.lbl.gov/Section4/Sec_4-2.html
:param energy_kev: float array
:param grazing_angle: incidence angle relative to the surface, in degrees
:return: float or array
xray_scattering_factor(self, hkl)
Return the x-ray scattering factor for given hkl reflections
:param hkl: [nx3] array of (h,k,l) reflections
:return: [nxm] array of scattering factors for each atom and reflection
xray_transmission(self, energy_kev=None, thickness_um=100)
Calculate transmission of x-ray through a slab of material
Equivalent to https://henke.lbl.gov/optical_constants/filter2.html
Based on formulas from: Henke, Gullikson, and Davis, Atomic Data and Nuclear Data Tables 54 no.2, 181-342 (July 1993)
:param energy_kev: float or array, x-ray energy in keV
:param thickness_um: slab thickness in microns
:return: float or array

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)