hexrd.material.utils module

hexrd.material.utils.calculate_coherent_scattering_factor(element: str, Q: ndarray) ndarray[source]
hexrd.material.utils.calculate_energy_absorption_length(density, formula, energy_vector)[source]

this function calculates the absorption length (in mm) based on the total energy absorbed by the medium. this function is used in calculating the scintillator response to x-rays

@author Saransh Singh, LLNL @date 04/25/2023 1.0 original

Parameters

densityfloat

density of material in g/cm^3.

formulastr/dict

chemical formula of compound either as a string or a dict. eg. “H2O” and {“H”:2, “O”:1} are both acceptable

energy_vector: list/numpy.ndarray

energy (units keV) list or array of 1D vector for which beta values are calculated for.

Returns

numpy.ndarray

the attenuation length in microns

hexrd.material.utils.calculate_f_mean_squared(composition: str, Q: ndarray) ndarray[source]
hexrd.material.utils.calculate_f_squared_mean(composition: str, Q: ndarray) ndarray[source]
hexrd.material.utils.calculate_incoherent_scattering(composition: str, Q: ndarray) ndarray[source]
hexrd.material.utils.calculate_incoherent_scattering_factor(element: str, Q: ndarray) ndarray[source]
hexrd.material.utils.calculate_linear_absorption_length(density, formula, energy_vector)[source]

this function calculates the absorption length (in mm) based on both coherent and incoherent scattering cross sections. This gives the total absorption length, instead of the one due to only photoeffect cross-section

linear attenuation coefficient = 1/linear absorption length

@author Saransh Singh, LLNL @date 04/19/2023 1.0 original

Parameters

densityfloat

density of material in g/cm^3.

formulastr/dict

chemical formula of compound either as a string or a dict. eg. “H2O” and {“H”:2, “O”:1} are both acceptable

energy_vector: list/numpy.ndarray

energy (units keV) list or array of 1D vector for which beta values are calculated for.

Returns

numpy.ndarray

the attenuation length in microns

hexrd.material.utils.calculate_molecular_mass(formula)[source]

interpret the formula as either a dictionary or a chemical formula

hexrd.material.utils.calculate_number_density(density, formula)[source]
hexrd.material.utils.convert_density_to_atoms_per_cubic_angstrom(composition: dict[str, float] | None, density: float) float[source]

Converts densities given in g/cm3 into atoms per A^3

Parameters:
  • composition – dictionary with elements as key and abundances as relative numbers

  • density – density in g/cm^3

Returns:

density in atoms/A^3

hexrd.material.utils.interpret_formula(formula)[source]

first interpret if the formula is a dictionary or just a string and get number of different elements in the formula

hexrd.material.utils.normalize_composition(composition: dict[str, float]) dict[str, float][source]

normalizes elemental abundances to 1

Parameters:

composition – dictionary with elements as key and abundances as relative numbers

Returns:

normalized elemental abundances dictionary