{ "cells": [ { "cell_type": "markdown", "id": "edccddaa", "metadata": {}, "source": [ "# Crystallography\n", "Notebook to explore crystallography functions in Anri." ] }, { "cell_type": "code", "execution_count": null, "id": "ce75e4d1", "metadata": {}, "outputs": [], "source": [ "import anri\n", "\n", "import urllib.request" ] }, { "cell_type": "code", "execution_count": null, "id": "5a1b2102", "metadata": {}, "outputs": [], "source": [ "struc = anri.crystal.Structure.from_cif(\"../../../tests/data/cif/Fe.cif\")" ] }, { "cell_type": "markdown", "id": "c7bc2ecc", "metadata": {}, "source": [ "Now let's generate some HKLs up to a d-star limit (with a given wavelength): " ] }, { "cell_type": "code", "execution_count": null, "id": "e9c36779", "metadata": {}, "outputs": [], "source": [ "dsmax = 0.75\n", "wavelength = 0.18\n", "struc.make_hkls(dsmax=dsmax, wavelength=wavelength)" ] }, { "cell_type": "code", "execution_count": null, "id": "d92d7bfb", "metadata": {}, "outputs": [], "source": [ "struc.allhkls" ] }, { "cell_type": "markdown", "id": "a2c18e11", "metadata": {}, "source": [ "Because we have a structure with atoms, we can simulate intensities. Calling `rings_table` will get the intensities for each hkl, and filter out the ones with very low intensity:" ] }, { "cell_type": "code", "execution_count": null, "id": "e328e70d", "metadata": {}, "outputs": [], "source": [ "struc.rings_table" ] }, { "cell_type": "markdown", "id": "f1271279", "metadata": {}, "source": [ "We can also get a dictionary grouped by ring ID:" ] }, { "cell_type": "code", "execution_count": null, "id": "0d033119", "metadata": {}, "outputs": [], "source": [ "struc.rings_dict" ] }, { "cell_type": "markdown", "id": "51d66016", "metadata": {}, "source": [ "Each entry in the dict is an individual ring, grouped by $d^*$. This is useful for further indexing procedures etc. \n", "There are some other helpful methods:" ] }, { "cell_type": "code", "execution_count": null, "id": "3f42b354", "metadata": {}, "outputs": [], "source": [ "struc.ringhkls # dict, grouped by d-star" ] }, { "cell_type": "code", "execution_count": null, "id": "acd3e0df", "metadata": {}, "outputs": [], "source": [ "struc.ringhkls_arr # just a single array of all hkls with meaningful intensities" ] }, { "cell_type": "code", "execution_count": null, "id": "0462b0d3", "metadata": {}, "outputs": [], "source": [ "struc.ringtth # the unique two-theta values of the rings" ] }, { "cell_type": "code", "execution_count": null, "id": "68ba350d", "metadata": {}, "outputs": [], "source": [ "struc.ringds # the unique d* values of the rings" ] }, { "cell_type": "code", "execution_count": null, "id": "5d152c8c", "metadata": {}, "outputs": [], "source": [ "struc.ringmult # the multiplicities of the rings" ] }, { "cell_type": "markdown", "id": "2c494bb0", "metadata": {}, "source": [ "We can confirm against ImageD11 too:" ] }, { "cell_type": "code", "execution_count": null, "id": "ff00f455", "metadata": {}, "outputs": [], "source": [ "from ImageD11.unitcell import unitcell\n", "uc = unitcell(struc.lattice_parameters, struc.sgno)\n", "uc" ] }, { "cell_type": "code", "execution_count": null, "id": "cfb80944", "metadata": {}, "outputs": [], "source": [ "uc.makerings(dsmax, tol=0.0001)" ] }, { "cell_type": "code", "execution_count": null, "id": "ae9ccbb6", "metadata": {}, "outputs": [], "source": [ "import jax.numpy as jnp\n", "jnp.array(uc.ringds)" ] }, { "cell_type": "code", "execution_count": null, "id": "5188082f", "metadata": {}, "outputs": [], "source": [ "(struc.ringds - jnp.array(uc.ringds)).sum()" ] }, { "cell_type": "code", "execution_count": null, "id": "c29b8dce", "metadata": {}, "outputs": [], "source": [ "uc.ringhkls" ] }, { "cell_type": "code", "execution_count": null, "id": "c22867d3", "metadata": {}, "outputs": [], "source": [ "struc.ringhkls" ] }, { "cell_type": "code", "execution_count": null, "id": "2df9b0c3", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "anri", "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.14.2" } }, "nbformat": 4, "nbformat_minor": 5 }