{ "cells": [ { "cell_type": "markdown", "id": "bb7326aa-a9c8-4746-aafa-8f28f43f8b4f", "metadata": {}, "source": [ "# Sample - multilayer 1" ] }, { "cell_type": "code", "execution_count": 1, "id": "2a34bd4b", "metadata": {}, "outputs": [], "source": [ "import nexus as nx" ] }, { "cell_type": "code", "execution_count": 2, "id": "0991c1f3", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Sample\n", " .id: my multilayer\n", " .geometry: f\n", " .angle (deg) = 0.0\n", " .divergence (deg) = 0.0\n", " .length (mm) = 10.0\n", " .roughness (model): a\n", "-------|------------------------|---------------|-------------|-------------|--------|-----------|----------|-------------|\n", " index | Layer id | dens. (g/cm3) | thick. (nm) | rough. (nm) | abund. | LM factor | HI sites | dist points |\n", "-------|------------------------|---------------|-------------|-------------|--------|-----------|----------|-------------|\n", " 0 | lay Ta 1 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 1 | lay SiC 1 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 2 | lay Ta 2 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 3 | lay SiC 2 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 4 | lay Ta 3 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 5 | lay SiC 3 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 6 | lay Ta 4 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 7 | lay SiC 4 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 8 | lay Ta 5 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 9 | lay SiC 5 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 10 | lay Ta 6 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 11 | lay SiC 6 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 12 | lay Ta 7 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 13 | lay SiC 7 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 14 | lay Ta 8 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 15 | lay SiC 8 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 16 | lay Ta 9 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 17 | lay SiC 9 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 18 | lay Ta 10 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 19 | lay SiC 10 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 20 | substrate | 2.336 | inf | 0.1 | 0.0 | 0.0 | | |\n", "-------|------------------------|---------------|-------------|-------------|--------|-----------|----------|-------------|\n", "\n", "Sample\n", " .id: my multilayer\n", " .geometry: f\n", " .angle (deg) = 0.0\n", " .divergence (deg) = 0.0\n", " .length (mm) = 10.0\n", " .roughness (model): a\n", "-------|------------------------|---------------|-------------|-------------|--------|-----------|----------|-------------|\n", " index | Layer id | dens. (g/cm3) | thick. (nm) | rough. (nm) | abund. | LM factor | HI sites | dist points |\n", "-------|------------------------|---------------|-------------|-------------|--------|-----------|----------|-------------|\n", " 0 | lay Ta 1 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 1 | lay SiC 1 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 2 | lay Ta 2 | 13.0 | 7.0 | 0.2 |0.99988 | 0.0 | | |\n", " 3 | lay SiC 2 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 4 | lay Ta 3 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 5 | lay SiC 3 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 6 | lay Ta 4 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 7 | lay SiC 4 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 8 | lay Ta 5 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 9 | lay SiC 5 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 10 | lay Ta 6 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 11 | lay SiC 6 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 12 | lay Ta 7 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 13 | lay SiC 7 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 14 | lay Ta 8 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 15 | lay SiC 8 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 16 | lay Ta 9 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 17 | lay SiC 9 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 18 | lay Ta 10 | 16.69 | 2.0 | 0.2 |0.99988 | 0.0 | | |\n", " 19 | lay SiC 10 | 3.16 | 3.0 | 0.1 | 0.0 | 0.0 | | |\n", " 20 | substrate | 2.336 | inf | 0.1 | 0.0 | 0.0 | | |\n", "-------|------------------------|---------------|-------------|-------------|--------|-----------|----------|-------------|\n", "\n" ] } ], "source": [ "# function to create a Ta and SiC layer\n", "# the function returns two new layers each time it is called\n", "def create_layers(number):\n", " # for each material and layer we use number for indexing the id\n", " # this helps to find the layers in the outputs from Nexus\n", "\n", " # the instances mat_ta, layer_ta, mat_sic and layer_sic cannot be referenced outside the function as the names only exist in the function\n", "\n", " mat_ta = nx.Material.Template(nx.lib.material.Ta)\n", " mat_ta.id = \"mat Ta \"+ str(number)\n", "\n", " layer_ta = nx.Layer(id = \"lay Ta \"+str(number),\n", " thickness = nx.Var(2, min = 1, max = 3, fit = True, id = \"ta thickness \"+str(i)), # nm\n", " material = mat_ta,\n", " roughness = 0.2)\n", "\n", " mat_sic = nx.Material.Template(nx.lib.material.SiC)\n", " mat_sic.id = \"mat SiC \"+ str(number)\n", "\n", " layer_sic = nx.Layer(id = \"lay SiC \"+str(number),\n", " thickness = nx.Var(3, min = 2, max = 4, fit = True, id = \"sic thickness \"+str(i)), # nm\n", " material = mat_sic,\n", " roughness = 0.1)\n", "\n", " return [layer_ta, layer_sic]\n", "\n", "# we have to pass the complete list of objects to the Sample\n", "# so we create an empty list called multilayer\n", "multilayer = []\n", "\n", "# and add the two layers 10 times\n", "# index starts with 1\n", "for i in range(1, 11, 1):\n", " # use list.extend function and not .append here because the create function returns a list of layer objects\n", " multilayer.extend(create_layers(i))\n", "\n", "# define the substrate\n", "substrate = nx.Layer(id = \"substrate\",\n", " material = nx.Material.Template(nx.lib.material.Si),\n", " thickness = nx.inf,\n", " roughness = 0.1)\n", "\n", "# add the substrate\n", "# append a single layer object\n", "multilayer.append(substrate)\n", "\n", "# define the sample\n", "sample = nx.Sample(id = \"my multilayer\",\n", " layers = multilayer)\n", "\n", "print(sample)\n", "\n", "# you get an index for each layer use can use to reference tha layers in the sample\n", "# now we can access the layers in the sample like this\n", "# change the thickness and density of the second Ta layer \"lay Ta 2\"\n", "sample.layers[2].thickness = 7\n", "\n", "sample.layers[2].material.density = 13\n", "\n", "print(sample)\n", "\n", "# only the thickness and density of the second Ta layer has changed." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.12.0" } }, "nbformat": 4, "nbformat_minor": 5 }