hikari.scripts.hkl_potency ========================== .. py:module:: hikari.scripts.hkl_potency Attributes ---------- .. autoapisummary:: hikari.scripts.hkl_potency.laue_space_groups hikari.scripts.hkl_potency.laue_class_names Functions --------- .. autoapisummary:: hikari.scripts.hkl_potency.potency_map hikari.scripts.hkl_potency.potency_vs_dac_opening_angle hikari.scripts.hkl_potency.potency_violin_plot hikari.scripts.hkl_potency.dac_potency_around_axis Module Contents --------------- .. py:function:: potency_map(a, b, c, al, be, ga, space_group='P1', axis='', fix_scale=False, histogram=True, opening_angle=35, orientation=None, path='~/sortav.lst', output_quality=3, resolution=1.2, wavelength='MoKa') Calculate and draw a potency map for a given crystal in diamond anvil cell (DAC) with a given opening angle, as a function of crystal orientation. For details see `this paper `_. The script accepts unit cell & space group information, and predicts max completeness of fully merged data for investigated crystal in said group. Results are logged into text files and drawn with gnuplot or matplotlib. Potency is calculated and visualised on a unit-sphere orientation heatmap. Each point **p** is associated with a certain crystal orientation in DAC, such that vector **v** from **0** to **p** acts as a symmetry axis for the dac-accessible volume traced in the reciprocal space up to `resolution`. Red / green / blue vectors represent crystallographic directions **X\***, **Y\*** and **Z\***, respectively. Since the distribution has some inherent symmetry, only a representative part of sphere (usually an octant) is shown. As an example, let's assume a orthorhombic cell with *a* = *b* = *c* = 10 and laue group "mmm". Running the script and generating the potency the map yields the lowest values close to **X\***, **Y\*** and **Z\*** vector, while the highest values are observed between those vectors. Placing the crystal on its [100] face inside the dac will cause the dac-accessible plane to be placed perpendicularly to (100) direction in reciprocal space. Since the values close to **X\*** ((100) direction) are low, such a placement will allow us to collect data with low coverage. On the other hand, placing the crystal on its [111] face will cause the dac-accessible plane to be placed perpendicularly to (100) direction in reciprocal space. As on the sphere the values tend to rise the further we are from of **X\***, **Y\*** and **Z\***, we expect this crystal orientation to warrant a high completeness of collected data. The potency is calculated as a ratio of the number of unique reflections inside the DAC-accessible space to the number of unique reflections inside a reference sphere of a radius equal to `resolution`. Visualisation is performed using an extended rainbow heatmap, which utilises a wide color range to emphasize even small differences. Dy default, the color scale is dynamic and adapts to the range of calculated potency, but it can be fixed to 0-100% range using `fix_scale=True`. Since the orientation is given in spherical coordinates, the exact positions of individual points is given using *theta* and *phi* angles instead of crystallographic coordinates. The *theta* and *phi* angles here follow the physical definition (ISO 80000-2:2019). For a given DAC-axis vector **v**: - *theta* is the azimuth angle found between vector **Z\*** and **v**. It can assume values between zero and *pi* (*pi/2* in one octant). - *phi* is the rotational angle denoting rotation of **v** around **Z\***. It can assume values between zero and *2 pi* (*pi/2* in one octant). Finally it must be noted that higher potency setting is not always better. For example, for opening angle below 45 degrees, most potent orientation in laue class mmm renders all 0kl, h0l, hk0 reflections inaccessible. Potency map should be consulted before a high-pressure experiment, but it should not be treated as an universal quality indicator of given set-up. :param a: Unit cell parameter *a* in Angstrom. :type a: float :param b: Unit cell parameter *b* in Angstrom. :type b: float :param c: Unit cell parameter *c* in Angstrom. :type c: float :param al: Unit cell parameter *alpha* in degrees. :type al: float :param be: Unit cell parameter *alpha* in degrees. :type be: float :param ga: Unit cell parameter *alpha* in degrees. :type ga: float :param space_group: Short Hermann-Mauguin name or index of space group. For details see :py:mod:`hikari.symmetry.space_groups`. :type space_group: str or int :param axis: domain to calculate potency in. Accepts 'x'/ 'y'/ 'z' for h00/ 0k0/ 00l, 'xy'/'xz'/'yz' for hk0/ h0l/ 0kl, or '' for all reflections. :type axis: string :param fix_scale: If true, the colour scheme will fix to 0 - 100% range. :type fix_scale: bool :param histogram: If true, potency distribution will be plotted as histogram :type histogram: bool :param opening_angle: Value of single opening angle as defined in :meth:`hikari.dataframes.HklFrame.dac`. :type opening_angle: float :param orientation: either a cif-style 3x3 matrix of crystal orientation or a 3-length array with a diamond-perpendicular face to be marked on a map :type orientation: np.ndarray :param path: Path to a file where script is to be run. Extension is ignored, but file name will and must be the same for all input and output files. :type path: str :param output_quality: Density of individual orientations to be considered. Should be in range from 1 (every 15 degrees) to 5 (every 1 degree). :type output_quality: int :param resolution: Upper limit of reflection resolution, given as a distance from zero to node in reciprocal space (one over plane spacing) in A-1. :type resolution: float :param wavelength: Wavelength of radiation to be simulated. :type wavelength: float or str :return: None :rtype: None .. py:function:: potency_vs_dac_opening_angle(output_path='~/output.txt', precision=91, resolution=1.2, wavelength='MoKa', theta=None) Calculate potency in P1 space group as a function of DAC opening angle, assuming certain resolution and wavelength used. :param output_path: Path of created file containing calculated data. :type output_path: str :param precision: Number of probed opening angles between 0 and 90 degrees. :type precision: int :param resolution: Maximum distance from the origin in reciprocal space to reflection (twice the resolution in reciprocal angstrom). Default 1.2. :type resolution: float :param wavelength: Wavelength of radiation to be simulated. :type wavelength: float or str :param theta: If given, use max theta in degrees (instead of radius in A-1). :type theta: float :return: None .. py:data:: laue_space_groups :value: ('P-1', 'P2/m', 'Pmmm', 'P4/m', 'P4/mmm', 'P-3', 'P-3m1', 'P6/m', 'P6/mmm', 'Pm-3', 'Pm-3m') .. py:data:: laue_class_names :value: ('$\\overline{1}$', '$2/m$', '$mmm$', '$4/m$', '$4/mmm$', '$\\overline{3}$', '$\\overline{3}m$',... .. py:function:: potency_violin_plot(job_name='violin', directory='~', opening_angle=35, precision=1000, space_groups=laue_space_groups, labels=laue_class_names, resolution=None, wavelength='MoKa') Calculate potency distribution for selected space groups and multiple sample orientations in a DAC, log it, and (re)draw appropriate violin plot. :param job_name: Base name for created files, defaults to 'violin'. If a .csv file with this name already exists, redraw instead of calculating. :type job_name: str :param directory: Target directory for saving or reading, defaults to '~'. :type directory: str :param opening_angle: Value of single opening angle as defined in :meth:`hikari.dataframes.HklFrame.dac`. Defaults to 35. :type opening_angle: float :param precision: Number of orientations to investigate, defaults to 1000. :type precision: int :param space_groups: List of space groups to investigate, strings or ints (see :class:`hikari.symmetry.Group`). Defaults to 11 "Laue" groups. :type space_groups: tuple[int] or tuple[str] :param labels: List of tex-style labels to be used for logging and plotting. :type labels: tuple[str] :param resolution: If given, additionally limit data resolution to given value. Please provide the resolution as a distance from the origin in reciprocal space (twice the resolution in reciprocal angstrom). :type resolution: float :param wavelength: Wavelength of radiation to be simulated. :type wavelength: float or str :return: None :rtype: None .. py:function:: dac_potency_around_axis(a, b, c, al, be, ga, space_group='P1', opening_angle=35.0, wavelength='MoKa', vector=(1, 0, 0), topple_angle=5) For a given crystal, opening angle, and wavelength calculate average potency obtained by toppling the crystal by "topple_angle"° from the "vector" axis. :param a: Unit cell parameter *a* in Angstrom. :type a: float :param b: Unit cell parameter *b* in Angstrom. :type b: float :param c: Unit cell parameter *c* in Angstrom. :type c: float :param al: Unit cell parameter *alpha* in degrees. :type al: float :param be: Unit cell parameter *beta* in degrees. :type be: float :param ga: Unit cell parameter *gamma* in degrees. :type ga: float :param space_group: Short Hermann-Mauguin name or index of space group. For details see :py:mod:`hikari.symmetry.space_groups`. :type space_group: str or int :param wavelength: Wavelength of radiation utilised in experiment. :type wavelength: float or str :param opening_angle: Value of single opening angle as defined in :meth:`hikari.dataframes.HklFrame.dac`. :type opening_angle: float :param vector: Direction from which a theoretical crystal will be toppled. :type vector: tuple :param topple_angle: Angle by which theoretical crystal will be toppled. :type topple_angle: float :return: None