# crystal_toolkit.components.diffraction module

class crystal_toolkit.components.diffraction.TEMDiffractionComponent(*args, initial_structure=None, **kwargs)

  Bases: `MPComponent`

  generate_callbacks(app, cache)

    Generate all callbacks associated with the layouts in this app. Assume that “suppress_callback_exceptions” is True, since it is not always guaranteed that all layouts will be displayed to the end user at all times, but it’s important the callbacks are defined on the server.

  layout()
    Returns

      A Dash layout for the full component. Basic implementation

    provided, but should in general be overridden.

class crystal_toolkit.components.diffraction.XRayDiffractionComponent(*args, initial_structure=None, **kwargs)

  Bases: `MPComponent`

  static G(x, c, alpha)

    Return c-centered Gaussian line shape at x with HWHM alpha

  static L(x, c, gamma)

    Return c-centered Lorentzian line shape at x with HWHM gamma

  static V(x, c, alphagamma)

    Return the c-centered Voigt line shape at x, scaled to match HWHM of Gaussian and Lorentzian profiles.

  default_xrd_plot_style = {'autosize': True, 'height': 225, 'hovermode': 'x', 'margin': {'b': 50, 'l': 60, 'pad': 0, 'r': 30, 't': 50}, 'paper_bgcolor': 'rgba(0,0,0,0)', 'plot_bgcolor': 'rgba(0,0,0,0)', 'showlegend': False, 'template': 'simple_white', 'title': 'X-ray Diffraction Pattern', 'xaxis': {'anchor': 'y', 'nticks': 8, 'showgrid': True, 'showline': True, 'side': 'bottom', 'tickfont': {'size': 16.0}, 'ticks': 'inside', 'title': '2𝜃 / º', 'titlefont': {'size': 16.0}, 'type': 'linear', 'zeroline': False}, 'yaxis': {'anchor': 'x', 'nticks': 7, 'showgrid': True, 'showline': True, 'side': 'left', 'tickfont': {'size': 16.0}, 'ticks': 'inside', 'title': 'Intensity / arb. units', 'titlefont': {'size': 16.0}, 'type': 'linear', 'zeroline': False}}
  empty_plot_style = {'paper_bgcolor': 'rgba(0,0,0,0)', 'plot_bgcolor': 'rgba(0,0,0,0)', 'xaxis': {'visible': False}, 'yaxis': {'visible': False}}
  generate_callbacks(app, cache)

    Generate all callbacks associated with the layouts in this app. Assume that “suppress_callback_exceptions” is True, since it is not always guaranteed that all layouts will be displayed to the end user at all times, but it’s important the callbacks are defined on the server.

  static get_figure(peak_profile, K, rad_source, grain_size, x_peak, y_peak, d_hkls, hkls, x_axis)
  static grain_to_hwhm(tau, two_theta, K=0.9, wavelength='CuKa')
    Parameters

      - tau – grain size in nm

      - two_theta – angle (in 2-theta)

      - K – shape factor (default 0.9)

      - wavelength – wavelength radiation in nm

    Returns

      half-width half-max (alpha or gamma), for line profile

  layout(static_image=False)

    Get the standard XRD diffraction pattern layout.

    Parameters

      static_image – If True, will show a static image instead of an interactive graph.

    Returns

  static twotheta_to_q(twotheta, xray_wavelength)

    Convert twotheta to Q.

    Parameters

      - twotheta – in degrees

      - xray_wavelength – in Ångstroms

    Returns