{ "cells": [ { "cell_type": "markdown", "id": "digital-oriental", "metadata": {}, "source": [ "# Diffractometer Extra Solver Parameters\n", "\n", "Some of the diffractometer _modes_ use extra parameters. The {ref}`E4CV\n", "` geometry, for example, has a `double_diffraction` mode which requires a reference {math}`hkl_2` vector. The vector is set as a Python dictionary:\n", "\n", "action | `E4CV` method\n", ":--- | :---\n", "read | `e4cv.core.solver.extras`\n", "write | `e4cv.core.solver.extras =` dictionary\n", "\n", "**Objective**\n", "\n", "Show how to use the `double_diffraction` mode in the `E4CV` geometry." ] }, { "cell_type": "markdown", "id": "assigned-length", "metadata": {}, "source": [ "## `E4CV`, `hkl`, `double_diffraction`\n", "\n", "term | value\n", ":--- | :---\n", "geometry | `E4CV`\n", "engine | `hkl`\n", "mode | `double_diffraction`\n", "\n", "Using the standard `E4CV` geometry with simulated motors, we copy the [E4CV setup for the *LNO_LAO* sample](https://github.com/bluesky/hklpy/tree/main/docs/source/examples/notebooks/tst_e4cv_fourc.html#read-the-spec-scan-from-the-data-file). Using a kwarg, we can automatically compute the UB matrix once we define the second reflection. (This means we do not have to call `compute_UB()` on a separate line.)" ] }, { "cell_type": "code", "execution_count": 1, "id": "adapted-minnesota", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "diffractometer='e4cv'\n", "HklSolver(name='hkl_soleil', version='5.1.2', geometry='E4CV', engine_name='hkl', mode='bissector')\n", "Sample(name='LNO_LAO', lattice=Lattice(a=3.7817, b=3.7914, c=3.7989, alpha=90.2546, beta=90.0182, gamma=89.8997, system='triclinic'))\n", "Reflection(name='r_85d9', h=0.0, k=0.0, l=2.0)\n", "Reflection(name='r_bca7', h=1.0, k=1.0, l=3.0)\n", "Orienting reflections: ['r_85d9', 'r_bca7']\n", "U=[[-0.057509522654, -0.998327393204, 0.005922059067], [0.000158283449, 0.005922758763, 0.999982447783], [-0.998344945272, 0.057509450598, -0.000182596327]]\n", "UB=[[-0.095549901092, -1.654278634916, 0.002428444854], [0.000262981975, 0.009814839065, 1.65396180769], [-1.658712442301, 0.098200239641, -0.000389705577]]\n", "constraint: -180.0 <= omega <= 180.0\n", "constraint: -180.0 <= chi <= 180.0\n", "constraint: -50.0 <= phi <= 100.0\n", "constraint: -2.0 <= tth <= 180.0\n", "h=0, k=0, l=0\n", "wavelength=1.239424258\n", "omega=0, chi=0, phi=0, tth=0\n" ] } ], "source": [ "import hklpy2\n", "\n", "e4cv = hklpy2.creator(name=\"e4cv\")\n", "e4cv.restore(\"e4cv-LNO_LAO.yml\")\n", "e4cv.wh(full=True)" ] }, { "cell_type": "markdown", "id": "manual-harmony", "metadata": {}, "source": [ "Set the `double_diffraction` mode." ] }, { "cell_type": "code", "execution_count": 2, "id": "twelve-gathering", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "e4cv.core.solver.mode='double_diffraction'\n", "e4cv.core.solver.extras={'h2': 1.0, 'k2': 1.0, 'l2': 1.0}\n" ] } ], "source": [ "e4cv.core.solver.mode = \"double_diffraction\"\n", "print(f\"{e4cv.core.solver.mode=!r}\")\n", "print(f\"{e4cv.core.solver.extras=!r}\")" ] }, { "cell_type": "markdown", "id": "crucial-virus", "metadata": {}, "source": [ "Set $hkl_2=(2\\ 2\\ 0)$." ] }, { "cell_type": "code", "execution_count": 3, "id": "insured-petite", "metadata": {}, "outputs": [], "source": [ "e4cv.core.solver.extras = {'h2': 2.0, 'k2': 2.0, 'l2': 0}" ] }, { "cell_type": "markdown", "id": "detected-collapse", "metadata": {}, "source": [ "## Calculate (002) with (220) as second diffracting plane" ] }, { "cell_type": "code", "execution_count": 4, "id": "advance-there", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "e4cv.core.solver.extras={'h2': 2.0, 'k2': 2.0, 'l2': 0.0}\n", "(002) : Hklpy2DiffractometerRealPos(omega=19.125950423193, chi=89.98528785702, phi=19.056580679972, tth=38.084061000204)\n" ] } ], "source": [ "print(f\"{e4cv.core.solver.extras=!r}\")\n", "print(\"(002) :\", e4cv.forward(0, 0, 2))" ] }, { "cell_type": "markdown", "id": "adolescent-trust", "metadata": {}, "source": [ "## Calculate (002) with (222) as second diffracting plane" ] }, { "cell_type": "code", "execution_count": 5, "id": "proprietary-spray", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "e4cv.core.solver.extras={'h2': 2.0, 'k2': 2.0, 'l2': 2.0}\n", "(002) : Hklpy2DiffractometerRealPos(omega=19.125989270384, chi=89.985511037941, phi=18.904237535436, tth=38.084060988627)\n" ] } ], "source": [ "e4cv.core.solver.extras = {'h2': 2.0, 'k2': 2.0, 'l2': 2}\n", "print(f\"{e4cv.core.solver.extras=}\")\n", "print(\"(002) :\", e4cv.forward(0, 0, 2))" ] } ], "metadata": { "kernelspec": { "display_name": "hklpy2", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.2" } }, "nbformat": 4, "nbformat_minor": 5 }