{ "cells": [ { "cell_type": "raw", "id": "0", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "Coating Study\n", "=============\n", "\n", "The primary mirror and the gratings of ESIS-II are coated with a multilayer\n", "of Si and Sc,\n", ":func:`~esis.flights.f2.optics.materials.multilayer_SiSc`.\n", "Its design has seven periods.\n", "More periods reflect more of the two lines,\n", "but make a thicker coating,\n", "with more stress in it,\n", "so seven periods balance the two.\n", "The test sample which Eric Gullikson measured,\n", ":func:`~esis.flights.f2.optics.materials.multilayer_SiSc_sample_measured`,\n", "has ten.\n", "\n", "This report compares coatings with different numbers of periods,\n", "finds how closely the period of each has to be held,\n", "checks the fraction of each period which is Sc,\n", "and collects the parameters of the design into a specification which can be\n", "sent to the coater." ] }, { "cell_type": "code", "execution_count": null, "id": "1", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "import dataclasses\n", "import numpy as np\n", "import scipy.optimize\n", "import matplotlib.ticker\n", "import matplotlib.pyplot as plt\n", "import astropy.units as u\n", "import astropy.visualization\n", "import pandas\n", "import named_arrays as na\n", "import optika\n", "import esis" ] }, { "cell_type": "raw", "id": "2", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "The Design\n", "----------\n", "\n", "Load the design of the coating and draw its layers.\n", "Its top layer is Si under a native oxide,\n", "and the widths of its interfaces are those fit to the measurement of the\n", "sample,\n", ":func:`~esis.flights.f2.optics.materials.multilayer_SiSc_sample_fit`." ] }, { "cell_type": "code", "execution_count": null, "id": "3", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "design = esis.flights.f2.optics.materials.multilayer_SiSc()\n", "\n", "with astropy.visualization.quantity_support():\n", " fig, ax = plt.subplots(constrained_layout=True)\n", " design.plot_layers(\n", " ax=ax,\n", " thickness_substrate=20 * u.nm,\n", " )\n", " ax.set_axis_off()\n", " ax.autoscale_view()" ] }, { "cell_type": "raw", "id": "4", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "To change the number of periods, the period,\n", "or the fraction of each period which is Sc,\n", "replace the thicknesses of the layers of the design,\n", "keeping the thickness of the top Si layer which the oxide consumed." ] }, { "cell_type": "code", "execution_count": null, "id": "5", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "oxide, top, Sc, periodic = design.layers\n", "Si_period, Sc_period = periodic.layers\n", "\n", "period_design = Si_period.thickness + Sc_period.thickness\n", "num_periods_design = periodic.num_periods + 1\n", "fraction_Sc = (Sc_period.thickness / period_design).to(u.dimensionless_unscaled)\n", "thickness_consumed = Si_period.thickness - top.thickness\n", "\n", "\n", "def coating(\n", " num_periods: int,\n", " period: u.Quantity,\n", " fraction: float | u.Quantity = fraction_Sc,\n", ") -> optika.materials.MultilayerMirror:\n", " \"\"\"\n", " The design, with the given number of periods, period and fraction of Sc.\n", "\n", " Parameters\n", " ----------\n", " num_periods\n", " The number of periods, at least two.\n", " period\n", " The thickness of a period, a layer of Si and a layer of Sc.\n", " fraction\n", " The thickness of the Sc layer of a period divided by the period.\n", " \"\"\"\n", " thickness_Si = (1 - fraction) * period\n", " thickness_Sc = fraction * period\n", " return dataclasses.replace(\n", " design,\n", " layers=[\n", " oxide,\n", " dataclasses.replace(top, thickness=thickness_Si - thickness_consumed),\n", " dataclasses.replace(Sc, thickness=thickness_Sc),\n", " dataclasses.replace(\n", " periodic,\n", " layers=[\n", " dataclasses.replace(Si_period, thickness=thickness_Si),\n", " dataclasses.replace(Sc_period, thickness=thickness_Sc),\n", " ],\n", " num_periods=num_periods - 1,\n", " ),\n", " ],\n", " )\n", "\n", "\n", "def period(multilayer: optika.materials.MultilayerMirror) -> u.Quantity:\n", " \"\"\"\n", " The period of a multilayer made by :func:`coating`.\n", "\n", " Parameters\n", " ----------\n", " multilayer\n", " The multilayer to measure.\n", " \"\"\"\n", " return sum(layer.thickness for layer in multilayer.layers[~0].layers).to(u.nm)\n", "\n", "\n", "def thickness(multilayer: optika.materials.MultilayerMirror) -> u.Quantity:\n", " \"\"\"\n", " The total thickness of the layers of a multilayer, its oxide included.\n", "\n", " Parameters\n", " ----------\n", " multilayer\n", " The multilayer to measure.\n", " \"\"\"\n", " return sum(layer.thickness for layer in multilayer.layers).to(u.nm)\n", "\n", "\n", "def reflectivity(\n", " multilayer: optika.materials.MultilayerMirror,\n", " wavelength: u.Quantity | na.AbstractScalar,\n", " angle: u.Quantity | na.AbstractScalar = 0 * u.deg,\n", ") -> na.AbstractScalar:\n", " \"\"\"\n", " The reflectivity of a multilayer to unpolarized light.\n", "\n", " Parameters\n", " ----------\n", " multilayer\n", " The multilayer which reflects the light.\n", " wavelength\n", " The wavelength of the light in vacuum.\n", " angle\n", " The angle of incidence.\n", " \"\"\"\n", " rays = optika.rays.RayVectorArray(\n", " wavelength=wavelength,\n", " direction=na.Cartesian3dVectorArray(np.sin(angle), 0, np.cos(angle)),\n", " )\n", " return multilayer.efficiency(\n", " rays=rays,\n", " normal=na.Cartesian3dVectorArray(0, 0, -1),\n", " )\n", "\n", "\n", "print(f\"{num_periods_design} periods of {period_design:.2f}, Sc fraction {fraction_Sc:.2f}\")" ] }, { "cell_type": "raw", "id": "6", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "The two lines ESIS-II observes are Ne VII 46.5 nm and Si XII 49.9 nm.\n", "The coating should also reflect little at He II 25.6 nm,\n", "since the gratings send its second order to where they send the first order\n", "of a wavelength twice as long,\n", "which is inside the passband." ] }, { "cell_type": "code", "execution_count": null, "id": "7", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "f2 = esis.flights.f2\n", "\n", "wavelength_He_II = 256.317 * u.AA\n", "wavelength = na.ScalarArray(\n", " ndarray=u.Quantity(\n", " [\n", " wavelength_He_II,\n", " f2.wavelength_Ne_VII,\n", " f2.wavelength_Si_XII,\n", " ]\n", " ).to(u.nm),\n", " axes=\"line\",\n", ")\n", "names = [\"He II\", \"Ne VII\", \"Si XII\"]\n", "\n", "instrument = f2.optics.design_single(num_distribution=0)\n", "print(\n", " f\"passband: {na.as_named_array(instrument.wavelength_min).ndarray.to(u.nm):.1f} \"\n", " f\"to {na.as_named_array(instrument.wavelength_max).ndarray.to(u.nm):.1f}\"\n", ")\n", "print(f\"second order of He II: {2 * wavelength_He_II.to(u.nm):.1f}\")" ] }, { "cell_type": "raw", "id": "8", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "Angles of Incidence\n", "-------------------\n", "\n", "The coating reflects the light a few degrees from the normal.\n", "Trace rays at both lines through one channel of the design,\n", "from every position in the field and the pupil,\n", "and take the angle of incidence on each optic as half the angle through which\n", "it turns the rays,\n", "which on a mirror is the angle of incidence itself." ] }, { "cell_type": "code", "execution_count": null, "id": "9", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "system = instrument.system\n", "rays = system.raytrace(\n", " wavelength=wavelength[{\"line\": slice(1, None)}],\n", " efficiency=False,\n", ").outputs\n", "names_surface = [surface.name for surface in system.surfaces_all]\n", "unvignetted = rays.unvignetted[{system.axis_surface: ~0}]\n", "\n", "\n", "def angle_incidence(name: str) -> na.AbstractScalar:\n", " \"\"\"\n", " Half the angle through which the named surface turns the rays, or NaN\n", " for the rays which do not reach the sensor.\n", "\n", " Parameters\n", " ----------\n", " name\n", " The name of the surface.\n", " \"\"\"\n", " index = names_surface.index(name)\n", " before = rays.direction[{system.axis_surface: index - 1}]\n", " after = rays.direction[{system.axis_surface: index}]\n", " cos = -(before @ after) / (before.length * after.length)\n", " angle = (np.arccos(cos) / 2).to(u.deg)\n", " return np.where(unvignetted, angle, np.nan * u.deg)\n", "\n", "\n", "angle = {name: angle_incidence(name) for name in [\"primary\", \"grating\"]}\n", "\n", "pandas.DataFrame(\n", " {\n", " \"min (deg)\": [np.nanmin(a).ndarray.value for a in angle.values()],\n", " \"mean (deg)\": [np.nanmean(a).ndarray.value for a in angle.values()],\n", " \"max (deg)\": [np.nanmax(a).ndarray.value for a in angle.values()],\n", " },\n", " index=list(angle),\n", ").round(2)" ] }, { "cell_type": "raw", "id": "10", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "Compare the reflectivity of the design at the largest of these angles with\n", "that at normal incidence." ] }, { "cell_type": "code", "execution_count": null, "id": "11", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "angle_max = max(np.nanmax(a).ndarray for a in angle.values())\n", "ratio = reflectivity(design, wavelength, angle_max) / reflectivity(design, wavelength)\n", "\n", "print(f\"at {angle_max:.2f}, relative to normal incidence:\")\n", "for name, r in zip(names, ratio.ndarray):\n", " print(f\" {name}: {r:.3f}\")" ] }, { "cell_type": "raw", "id": "12", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "The change is small, so the rest of this report computes the reflectivity at\n", "normal incidence.\n", "\n", "Number of Periods\n", "-----------------\n", "\n", "More periods narrow the peak of the reflectivity,\n", "so for each number of periods,\n", "choose the period which maximizes the geometric mean of the reflectivity at\n", "the two lines,\n", "keeping the fraction of each period which is Sc." ] }, { "cell_type": "code", "execution_count": null, "id": "13", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "def period_best(\n", " num_periods: int,\n", " fraction: float | u.Quantity = fraction_Sc,\n", ") -> u.Quantity:\n", " \"\"\"\n", " The period which maximizes the geometric mean of the reflectivity at\n", " Ne VII and Si XII, for the given number of periods and fraction of Sc.\n", "\n", " Parameters\n", " ----------\n", " num_periods\n", " The number of periods.\n", " fraction\n", " The thickness of the Sc layer of a period divided by the period.\n", " \"\"\"\n", "\n", " def merit(period: float) -> float:\n", " r = reflectivity(coating(num_periods, period * u.nm, fraction), wavelength)\n", " return -np.sqrt(r[{\"line\": 1}] * r[{\"line\": 2}]).ndarray\n", "\n", " result = scipy.optimize.minimize_scalar(\n", " merit,\n", " bounds=(24, 28),\n", " method=\"bounded\",\n", " options=dict(xatol=1e-3),\n", " )\n", " return result.x * u.nm\n", "\n", "\n", "num_periods = list(range(2, 21))\n", "coatings = {n: coating(n, period_best(n)) for n in num_periods}\n", "\n", "reflectivities = na.stack(\n", " [reflectivity(c, wavelength) for c in coatings.values()],\n", " axis=\"num_periods\",\n", ")" ] }, { "cell_type": "raw", "id": "14", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "Tabulate the period, the total thickness,\n", "and the reflectivity at each line of each coating.\n", "The throughput of the two bounces, off the primary mirror and off the grating,\n", "is the square of the reflectivity of one,\n", "and is given relative to that of the design.\n", "The last column is the throughput at He II relative to that at Si XII,\n", "which scales the light of He II which leaks into the image of Si XII." ] }, { "cell_type": "code", "execution_count": null, "id": "15", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "r_design = reflectivity(design, wavelength)\n", "throughput = np.square(reflectivities / r_design)\n", "r = reflectivities\n", "\n", "table = pandas.DataFrame(\n", " {\n", " \"period (nm)\": [period(c).value for c in coatings.values()],\n", " \"thickness (nm)\": [thickness(c).value for c in coatings.values()],\n", " \"R Ne VII\": r[{\"line\": 1}].ndarray,\n", " \"R Si XII\": r[{\"line\": 2}].ndarray,\n", " \"R He II\": r[{\"line\": 0}].ndarray,\n", " \"throughput Ne VII\": throughput[{\"line\": 1}].ndarray,\n", " \"throughput Si XII\": throughput[{\"line\": 2}].ndarray,\n", " \"(R He II / R Si XII)^2\": np.square(r[{\"line\": 0}] / r[{\"line\": 2}]).ndarray,\n", " },\n", " index=pandas.Index(num_periods, name=\"periods\"),\n", ")\n", "table.style.format(\n", " {\n", " \"period (nm)\": \"{:.2f}\",\n", " \"thickness (nm)\": \"{:.0f}\",\n", " \"R Ne VII\": \"{:.3f}\",\n", " \"R Si XII\": \"{:.3f}\",\n", " \"R He II\": \"{:.4f}\",\n", " \"throughput Ne VII\": \"{:.3f}\",\n", " \"throughput Si XII\": \"{:.3f}\",\n", " \"(R He II / R Si XII)^2\": \"{:.1e}\",\n", " }\n", ")" ] }, { "cell_type": "raw", "id": "16", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "The period of the design is the best one for its number of periods,\n", "rounded to 0.01 nm." ] }, { "cell_type": "code", "execution_count": null, "id": "17", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "print(f\"design: {period(design):.3f}\")\n", "print(f\"best for {num_periods_design} periods: {period(coatings[num_periods_design]):.3f}\")" ] }, { "cell_type": "raw", "id": "18", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "Plot the throughput of the two bounces at each line against the number of\n", "periods." ] }, { "cell_type": "code", "execution_count": null, "id": "19", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "n = na.ScalarArray(np.array(num_periods), axes=\"num_periods\")\n", "\n", "fig, ax = plt.subplots(constrained_layout=True)\n", "for i, color in [(1, \"tab:blue\"), (2, \"tab:orange\")]:\n", " na.plt.plot(\n", " n,\n", " throughput[{\"line\": i}],\n", " ax=ax,\n", " marker=\"o\",\n", " color=color,\n", " label=names[i],\n", " )\n", "ax.xaxis.set_major_locator(matplotlib.ticker.MaxNLocator(integer=True))\n", "ax.set_xlabel(\"number of periods\")\n", "ax.set_ylabel(\"throughput relative to the design\")\n", "ax.legend();" ] }, { "cell_type": "raw", "id": "20", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "Compare the design with the coatings with five and ten periods.\n", "Plot their reflectivities across the passband and around He II." ] }, { "cell_type": "code", "execution_count": null, "id": "21", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "candidates = {\n", " 5: coatings[5],\n", " num_periods_design: design,\n", " 10: coatings[10],\n", "}\n", "colors = {\n", " 5: \"tab:blue\",\n", " num_periods_design: \"tab:orange\",\n", " 10: \"tab:green\",\n", "}\n", "\n", "\n", "def label(num: int) -> str:\n", " \"\"\"\n", " The label of the candidate coating with the given number of periods.\n", "\n", " Parameters\n", " ----------\n", " num\n", " The number of periods.\n", " \"\"\"\n", " if num == num_periods_design:\n", " return f\"{num} periods (design)\"\n", " return f\"{num} periods\"\n", "\n", "\n", "wavelength_plot = na.linspace(24, 55, axis=\"wavelength\", num=621) * u.nm\n", "\n", "with astropy.visualization.quantity_support():\n", " fig, ax = plt.subplots(constrained_layout=True)\n", " for num, multilayer in candidates.items():\n", " na.plt.plot(\n", " wavelength_plot,\n", " reflectivity(multilayer, wavelength_plot),\n", " ax=ax,\n", " color=colors[num],\n", " label=label(num),\n", " )\n", " # label He II at the top and the two lines at the bottom, where the\n", " # curves are not\n", " for name, w, y, va in [\n", " (names[0], wavelength.ndarray[0], 0.97, \"top\"),\n", " (names[1], wavelength.ndarray[1], 0.03, \"bottom\"),\n", " (names[2], wavelength.ndarray[2], 0.03, \"bottom\"),\n", " ]:\n", " ax.axvline(w, color=\"gray\", linestyle=\":\")\n", " ax.text(\n", " w,\n", " y,\n", " f\" {name}\",\n", " rotation=90,\n", " va=va,\n", " color=\"gray\",\n", " transform=ax.get_xaxis_transform(),\n", " )\n", " ax.set_xlabel(f\"wavelength ({ax.get_xlabel()})\")\n", " ax.set_ylabel(\"reflectivity\")\n", " ax.legend();" ] }, { "cell_type": "raw", "id": "22", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "Tolerance on the Period\n", "-----------------------\n", "\n", "A coating is never deposited with exactly the period it was designed for,\n", "and the more periods it has, the narrower its peak.\n", "Scale the period of each of the three coatings by up to 4% either way,\n", "the same on the primary mirror and the grating,\n", "and compare the throughput of the two bounces at each line with that of the\n", "design with no error." ] }, { "cell_type": "code", "execution_count": null, "id": "23", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "error = na.linspace(-4, 4, axis=\"error\", num=161) * u.percent\n", "\n", "throughput_error = {}\n", "for num, multilayer in candidates.items():\n", " r = na.stack(\n", " [\n", " reflectivity(coating(num, period(multilayer) * (1 + e)), wavelength)\n", " for e in error.ndarray\n", " ],\n", " axis=\"error\",\n", " )\n", " throughput_error[num] = np.square(r / r_design)\n", "\n", "fig, axs = plt.subplots(\n", " ncols=2,\n", " sharey=True,\n", " constrained_layout=True,\n", " figsize=(8, 3.5),\n", ")\n", "for ax, i in zip(axs, [1, 2]):\n", " for num in candidates:\n", " na.plt.plot(\n", " error,\n", " throughput_error[num][{\"line\": i}],\n", " ax=ax,\n", " color=colors[num],\n", " label=label(num),\n", " )\n", " ax.set_title(names[i])\n", " ax.set_xlabel(\"error in the period (%)\")\n", "axs[0].set_ylabel(\"throughput relative to the design\")\n", "axs[0].legend();" ] }, { "cell_type": "raw", "id": "24", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "An error in the period moves the peak toward one line and away from the\n", "other, and the more periods a coating has, the narrower its peak.\n", "Find the range of errors over which each coating has more throughput at both\n", "lines than the one with fewer periods would have with the same error." ] }, { "cell_type": "code", "execution_count": null, "id": "25", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "for more, fewer in [(num_periods_design, 5), (10, num_periods_design)]:\n", " ratio = throughput_error[more] / throughput_error[fewer]\n", " better = (ratio[{\"line\": slice(1, None)}] > 1).all(axis=\"line\")\n", " e = error.ndarray.value[better.ndarray]\n", " print(f\"{more} periods beat {fewer} from {e.min():+.2f}% to {e.max():+.2f}%\")" ] }, { "cell_type": "raw", "id": "26", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "Take the tolerance on the period of each coating to be the range of errors\n", "over which its throughput at both lines stays within 10% of its own\n", "throughput with no error." ] }, { "cell_type": "code", "execution_count": null, "id": "27", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "def tolerance(\n", " throughput: na.AbstractScalar,\n", " error: na.AbstractScalar,\n", " minimum: float = 0.9,\n", ") -> tuple[float | u.Quantity, float | u.Quantity]:\n", " \"\"\"\n", " The smallest and largest errors at which the throughput at Ne VII and\n", " Si XII is at least the given fraction of the throughput with no error.\n", "\n", " Parameters\n", " ----------\n", " throughput\n", " The throughput at each line as a function of the error.\n", " error\n", " The errors, along one axis, with no error in the middle.\n", " minimum\n", " The least acceptable fraction of the throughput with no error.\n", " \"\"\"\n", " (axis,) = error.axes\n", " throughput = throughput[{\"line\": slice(1, None)}]\n", " nominal = throughput[{axis: error.shape[axis] // 2}]\n", " ok = (throughput / nominal >= minimum).all(axis=\"line\")\n", " e = error.ndarray[ok.ndarray]\n", " return e.min(), e.max()\n", "\n", "\n", "for num in candidates:\n", " low, high = tolerance(throughput_error[num], error)\n", " print(f\"{label(num)}: {low.value:+.2f}% to {high.value:+.2f}%\")" ] }, { "cell_type": "raw", "id": "28", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "Fraction of Sc\n", "--------------\n", "\n", "Half of each period of the design is Sc.\n", "For fractions of Sc from 0.3 to 0.7,\n", "choose the best period for the number of periods of the design,\n", "as above,\n", "and tabulate the throughput at each line relative to the design,\n", "and the throughput at He II relative to that at Si XII." ] }, { "cell_type": "code", "execution_count": null, "id": "29", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "fractions = np.linspace(0.3, 0.7, num=9)\n", "coatings_fraction = [\n", " coating(num_periods_design, period_best(num_periods_design, f), f)\n", " for f in fractions\n", "]\n", "r = na.stack(\n", " [reflectivity(c, wavelength) for c in coatings_fraction],\n", " axis=\"fraction\",\n", ")\n", "throughput_fraction = np.square(r / r_design)\n", "\n", "table = pandas.DataFrame(\n", " {\n", " \"period (nm)\": [period(c).value for c in coatings_fraction],\n", " \"throughput Ne VII\": throughput_fraction[{\"line\": 1}].ndarray,\n", " \"throughput Si XII\": throughput_fraction[{\"line\": 2}].ndarray,\n", " \"(R He II / R Si XII)^2\": np.square(r[{\"line\": 0}] / r[{\"line\": 2}]).ndarray,\n", " },\n", " index=pandas.Index(fractions, name=\"Sc fraction\"),\n", ")\n", "table.style.format(\n", " {\n", " \"period (nm)\": \"{:.2f}\",\n", " \"throughput Ne VII\": \"{:.3f}\",\n", " \"throughput Si XII\": \"{:.3f}\",\n", " \"(R He II / R Si XII)^2\": \"{:.1e}\",\n", " }\n", ").format_index(\"{:.2f}\")" ] }, { "cell_type": "raw", "id": "30", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "Find the fraction and the period which together maximize the geometric mean of\n", "the reflectivity at the two lines." ] }, { "cell_type": "code", "execution_count": null, "id": "31", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "def merit(x: np.ndarray) -> float:\n", " \"\"\"\n", " The negative of the geometric mean of the reflectivity at Ne VII and\n", " Si XII, for the number of periods of the design.\n", "\n", " Parameters\n", " ----------\n", " x\n", " The period in nanometers and the fraction of Sc.\n", " \"\"\"\n", " r = reflectivity(coating(num_periods_design, x[0] * u.nm, x[1]), wavelength)\n", " return -np.sqrt(r[{\"line\": 1}] * r[{\"line\": 2}]).ndarray\n", "\n", "\n", "result = scipy.optimize.minimize(\n", " merit,\n", " x0=[period_design.to_value(u.nm), fraction_Sc.value],\n", " method=\"Nelder-Mead\",\n", " options=dict(xatol=1e-4, fatol=1e-8),\n", ")\n", "period_and_fraction_best = coating(num_periods_design, result.x[0] * u.nm, result.x[1])\n", "r = reflectivity(period_and_fraction_best, wavelength)\n", "\n", "print(f\"best: Sc fraction {result.x[1]:.3f}, period {result.x[0]:.2f} nm\")\n", "for name, t in zip(names, np.square(r / r_design).ndarray):\n", " print(f\" throughput at {name} relative to the design: {t:.3f}\")" ] }, { "cell_type": "raw", "id": "32", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "The best fraction is a little less than half,\n", "but it raises the throughput at the two lines by less than 1%,\n", "and raises that at He II by about a quarter.\n", "The throughput at He II relative to that at Si XII,\n", "the last column of the table,\n", "falls steadily as the fraction of Sc grows,\n", "so the design keeps half.\n", "\n", "At a fixed period,\n", "more Sc moves the peak toward longer wavelengths,\n", "so an error in the fraction trades one line against the other,\n", "as an error in the period does.\n", "Change the fraction of the design by up to 0.08 either way,\n", "keeping its period,\n", "and find the tolerance on the fraction the same way as on the period." ] }, { "cell_type": "code", "execution_count": null, "id": "33", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "error_fraction = na.linspace(-0.08, 0.08, axis=\"error_fraction\", num=161)\n", "r = na.stack(\n", " [\n", " reflectivity(\n", " coating(num_periods_design, period_design, fraction_Sc + e),\n", " wavelength,\n", " )\n", " for e in error_fraction.ndarray\n", " ],\n", " axis=\"error_fraction\",\n", ")\n", "throughput_error_fraction = np.square(r / r_design)\n", "\n", "fig, ax = plt.subplots(constrained_layout=True)\n", "for i, color in [(1, \"tab:blue\"), (2, \"tab:orange\")]:\n", " na.plt.plot(\n", " fraction_Sc.value + error_fraction,\n", " throughput_error_fraction[{\"line\": i}],\n", " ax=ax,\n", " color=color,\n", " label=names[i],\n", " )\n", "ax.set_xlabel(\"Sc fraction\")\n", "ax.set_ylabel(\"throughput relative to the design\")\n", "ax.legend()\n", "\n", "low, high = tolerance(throughput_error_fraction, error_fraction)\n", "print(f\"tolerance on the Sc fraction: {low:+.3f} to {high:+.3f}\")" ] }, { "cell_type": "raw", "id": "34", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "Specification\n", "-------------\n", "\n", "Collect the parameters of the design into a table which can be sent to the\n", "coater.\n", "The reflectivities are those of the model,\n", "which takes its interfaces and oxide from the sample.\n", "The tolerance on the period assumes the fraction of Sc is exact,\n", "and the tolerance on the fraction assumes the period is exact.\n", "Errors in both move the peak,\n", "so a coating near the limits of both could lose more than 10% at one line." ] }, { "cell_type": "code", "execution_count": null, "id": "35", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "num = num_periods_design\n", "spec = design\n", "low, high = tolerance(throughput_error[num], error)\n", "low_nm, high_nm = (low * period(spec)).to(u.nm), (high * period(spec)).to(u.nm)\n", "low_fraction, high_fraction = tolerance(throughput_error_fraction, error_fraction)\n", "r = reflectivity(spec, wavelength)\n", "r_plot = reflectivity(spec, wavelength_plot)\n", "peak = wavelength_plot[{\"wavelength\": int(r_plot.ndarray.argmax())}]\n", "\n", "rows = [\n", " (\"materials\", \"Si/Sc, Si on top\"),\n", " (\"number of periods\", f\"{num}\"),\n", " (\"period\", f\"{period(spec):.2f}\"),\n", " (\n", " \"tolerance on the period\",\n", " f\"{low.value:+.2f}% to {high.value:+.2f}% ({low_nm:+.2f} to {high_nm:+.2f})\",\n", " ),\n", " (\"Sc fraction of each period\", f\"{fraction_Sc:.2f}\"),\n", " (\"tolerance on the Sc fraction\", f\"{low_fraction:+.3f} to {high_fraction:+.3f}\"),\n", " (\"total thickness\", f\"{thickness(spec):.0f}\"),\n", "]\n", "for name, a in angle.items():\n", " rows.append(\n", " (\n", " f\"angle of incidence on the {name}\",\n", " f\"{np.nanmin(a).ndarray.value:.1f} to {np.nanmax(a).ndarray:.1f}\",\n", " )\n", " )\n", "rows.append((\"peak of the reflectivity (model)\", f\"{peak.ndarray:.1f}\"))\n", "for name, w, ri in zip(names, wavelength.ndarray, r.ndarray):\n", " rows.append((f\"reflectivity at {name} {w:.2f} (model)\", f\"{ri:.3f}\"))\n", "\n", "pandas.DataFrame(\n", " {\"value\": [value for _, value in rows]},\n", " index=[name for name, _ in rows],\n", ")" ] } ], "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.13.3" } }, "nbformat": 4, "nbformat_minor": 5 }