.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_02_TiO2_multilayer.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_02_TiO2_multilayer.py: Multilayer fit ============== Fits a multilayer model to an ALD grown TiO2 sample on SiO2 / Si. .. GENERATED FROM PYTHON SOURCE LINES 9-13 .. code-block:: Python import elli from elli.fitting import ParamsHist, fit .. GENERATED FROM PYTHON SOURCE LINES 15-22 Load data --------- Load data collected with Sentech Ellipsometer and cut the spectral range (to use Si Aspnes file) The sample is an ALD grown TiO2 sample (with 400 cycles) on commercially available SiO2 / Si substrate. .. GENERATED FROM PYTHON SOURCE LINES 22-24 .. code-block:: Python tss = elli.read_spectraray_psi_delta("TiO2_400cycles.txt").loc[70.06][400:800] .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/pyelli/checkouts/v0.22.0/examples/gallery/plot_02_TiO2_multilayer.py:22: FutureWarning: The behavior of obj[i:j] with a float-dtype index is deprecated. In a future version, this will be treated as positional instead of label-based. For label-based slicing, use obj.loc[i:j] instead .. GENERATED FROM PYTHON SOURCE LINES 25-33 Set start parameters -------------------- Here we set the start parameters for the TiO2 and SiO2 layer. We set the SiO2 layer parameters to a fixed value from another fit of the substrate. See the :ref:`Basic usage` example for details on how to perform such a fit. In general it is a good idea to fit your data layer-wise if possible to yield a better fit quality. .. GENERATED FROM PYTHON SOURCE LINES 33-51 .. code-block:: Python params = ParamsHist() params.add("SiO2_n0", value=1.452, min=-100, max=100, vary=False) params.add("SiO2_n1", value=36.0, min=-40000, max=40000, vary=False) params.add("SiO2_n2", value=0, min=-40000, max=40000, vary=False) params.add("SiO2_k0", value=0, min=-100, max=100, vary=False) params.add("SiO2_k1", value=0, min=-40000, max=40000, vary=False) params.add("SiO2_k2", value=0, min=-40000, max=40000, vary=False) params.add("SiO2_d", value=276.36, min=0, max=40000, vary=False) params.add("TiO2_n0", value=2.236, min=-100, max=100, vary=True) params.add("TiO2_n1", value=451, min=-40000, max=40000, vary=True) params.add("TiO2_n2", value=251, min=-40000, max=40000, vary=True) params.add("TiO2_k0", value=0, min=-100, max=100, vary=False) params.add("TiO2_k1", value=0, min=-40000, max=40000, vary=False) params.add("TiO2_k2", value=0, min=-40000, max=40000, vary=False) params.add("TiO2_d", value=20, min=0, max=40000, vary=True) .. GENERATED FROM PYTHON SOURCE LINES 52-62 Load silicon dispersion from the refractiveindexinfo database ------------------------------------------------------------- You can load any material from the index `refractiveindex.info `__, which is embedded into the software (so you may use it offline, too). Here, we are interested in the literature values for the silicon substrate. First we need to load the database with ``rii_db = elli.db.RII()`` and then we can query it with ``rii_db.get_mat("Si", "Aspnes")`` to load this `entry `__. .. GENERATED FROM PYTHON SOURCE LINES 62-66 .. code-block:: Python rii_db = elli.db.RII() Si = rii_db.get_mat("Si", "Aspnes") .. GENERATED FROM PYTHON SOURCE LINES 67-73 Building the model ------------------ Here the model is build and the experimental structure is returned. For details on this process please refer to the :ref:`Basic usage` example. When executed in an jupyter notebook this displays an interactive graph with which you can select the start parameters before fitting the data. .. GENERATED FROM PYTHON SOURCE LINES 73-99 .. code-block:: Python @fit(tss, params) def model(lbda, params): SiO2 = elli.Cauchy( params["SiO2_n0"], params["SiO2_n1"], params["SiO2_n2"], params["SiO2_k0"], params["SiO2_k1"], params["SiO2_k2"], ).get_mat() TiO2 = elli.Cauchy( params["TiO2_n0"], params["TiO2_n1"], params["TiO2_n2"], params["TiO2_k0"], params["TiO2_k1"], params["TiO2_k2"], ).get_mat() Layer = [elli.Layer(TiO2, params["TiO2_d"]), elli.Layer(SiO2, params["SiO2_d"])] return elli.Structure(elli.AIR, Layer, Si).evaluate(lbda, 70, solver=elli.Solver2x2) # Alternative: Use 4x4 Solver with scipy propagator # return elli.Structure(elli.AIR, Layer, Si).evaluate(lbda, 70, solver=elli.Solver4x4, propagator=elli.PropagatorExpm()) .. GENERATED FROM PYTHON SOURCE LINES 100-103 Plot & Fit model ---------------- We plot the model to see the deviation with the initial parameters. .. GENERATED FROM PYTHON SOURCE LINES 103-106 .. code-block:: Python model.plot() .. rst-class:: sphx-glr-script-out .. code-block:: none FigureWidget({ 'data': [{'hovertemplate': 'variable=Ψ
Wavelength=%{x}
value=%{y}', 'legendgroup': 'Ψ', 'line': {'color': '#636efa', 'dash': 'solid'}, 'marker': {'symbol': 'circle'}, 'mode': 'lines', 'name': 'Ψ', 'showlegend': True, 'type': 'scattergl', 'uid': 'e6c4892a-1cee-4f35-958f-228e5683d2c3', 'x': array([400.07646, 400.51975, 400.96301, ..., 798.88197, 799.30046, 799.71891], shape=(1852,)), 'xaxis': 'x', 'y': array([32.75947, 32.84076, 32.84675, ..., nan, nan, nan], shape=(1852,)), 'yaxis': 'y'}, {'hovertemplate': 'variable=Δ
Wavelength=%{x}
value=%{y}', 'legendgroup': 'Δ', 'line': {'color': '#EF553B', 'dash': 'solid'}, 'marker': {'symbol': 'circle'}, 'mode': 'lines', 'name': 'Δ', 'showlegend': True, 'type': 'scattergl', 'uid': 'b52813e3-0585-4bb2-a8d7-a12ed6be613f', 'x': array([400.07646, 400.51975, 400.96301, ..., 798.88197, 799.30046, 799.71891], shape=(1852,)), 'xaxis': 'x', 'y': array([-132.57268, -132.11725, -131.5141 , ..., nan, nan, nan], shape=(1852,)), 'yaxis': 'y'}, {'hovertemplate': 'variable=Ψ_fit
Wavelength=%{x}
value=%{y}', 'legendgroup': 'Ψ_fit', 'line': {'color': '#00cc96', 'dash': 'solid'}, 'marker': {'symbol': 'circle'}, 'mode': 'lines', 'name': 'Ψ_fit', 'showlegend': True, 'type': 'scattergl', 'uid': '6457b2be-b0cc-4975-9160-ea382f4b28a5', 'x': array([400.07646, 400.51975, 400.96301, ..., 798.88197, 799.30046, 799.71891], shape=(1852,)), 'xaxis': 'x', 'y': array([ nan, nan, nan, ..., 21.13502205, 21.16231399, 21.18955407], shape=(1852,)), 'yaxis': 'y'}, {'hovertemplate': 'variable=Δ_fit
Wavelength=%{x}
value=%{y}', 'legendgroup': 'Δ_fit', 'line': {'color': '#ab63fa', 'dash': 'solid'}, 'marker': {'symbol': 'circle'}, 'mode': 'lines', 'name': 'Δ_fit', 'showlegend': True, 'type': 'scattergl', 'uid': 'd3680228-8f78-4c86-9d37-1b8eb113e090', 'x': array([400.07646, 400.51975, 400.96301, ..., 798.88197, 799.30046, 799.71891], shape=(1852,)), 'xaxis': 'x', 'y': array([ nan, nan, nan, ..., -111.09599625, -110.98086027, -110.86609469], shape=(1852,)), 'yaxis': 'y'}], 'layout': {'legend': {'title': {'text': 'variable'}, 'tracegroupgap': 0}, 'margin': {'t': 60}, 'template': '...', 'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': 'Wavelength'}}, 'yaxis': {'anchor': 'x', 'domain': [0.0, 1.0], 'title': {'text': 'value'}}} }) .. GENERATED FROM PYTHON SOURCE LINES 107-109 Now lets perform the fit and plot the comparison of calculation and experimental data afterwards. .. GENERATED FROM PYTHON SOURCE LINES 109-112 .. code-block:: Python fit_stats = model.fit() model.plot() .. rst-class:: sphx-glr-script-out .. code-block:: none FigureWidget({ 'data': [{'hovertemplate': 'variable=Ψ
Wavelength=%{x}
value=%{y}', 'legendgroup': 'Ψ', 'line': {'color': '#636efa', 'dash': 'solid'}, 'marker': {'symbol': 'circle'}, 'mode': 'lines', 'name': 'Ψ', 'showlegend': True, 'type': 'scattergl', 'uid': '1b9039d3-a341-4b69-b8f2-bf7f8dc909c7', 'x': array([400.07646, 400.51975, 400.96301, ..., 798.88197, 799.30046, 799.71891], shape=(1852,)), 'xaxis': 'x', 'y': array([32.75947, 32.84076, 32.84675, ..., nan, nan, nan], shape=(1852,)), 'yaxis': 'y'}, {'hovertemplate': 'variable=Δ
Wavelength=%{x}
value=%{y}', 'legendgroup': 'Δ', 'line': {'color': '#EF553B', 'dash': 'solid'}, 'marker': {'symbol': 'circle'}, 'mode': 'lines', 'name': 'Δ', 'showlegend': True, 'type': 'scattergl', 'uid': '4ec1145d-e812-4478-8a0e-072d20681816', 'x': array([400.07646, 400.51975, 400.96301, ..., 798.88197, 799.30046, 799.71891], shape=(1852,)), 'xaxis': 'x', 'y': array([-132.57268, -132.11725, -131.5141 , ..., nan, nan, nan], shape=(1852,)), 'yaxis': 'y'}, {'hovertemplate': 'variable=Ψ_fit
Wavelength=%{x}
value=%{y}', 'legendgroup': 'Ψ_fit', 'line': {'color': '#00cc96', 'dash': 'solid'}, 'marker': {'symbol': 'circle'}, 'mode': 'lines', 'name': 'Ψ_fit', 'showlegend': True, 'type': 'scattergl', 'uid': '393f4958-45bb-42c4-b214-4514225866fc', 'x': array([400.07646, 400.51975, 400.96301, ..., 798.88197, 799.30046, 799.71891], shape=(1852,)), 'xaxis': 'x', 'y': array([ nan, nan, nan, ..., 20.20488814, 20.23141868, 20.25790068], shape=(1852,)), 'yaxis': 'y'}, {'hovertemplate': 'variable=Δ_fit
Wavelength=%{x}
value=%{y}', 'legendgroup': 'Δ_fit', 'line': {'color': '#ab63fa', 'dash': 'solid'}, 'marker': {'symbol': 'circle'}, 'mode': 'lines', 'name': 'Δ_fit', 'showlegend': True, 'type': 'scattergl', 'uid': 'f9e54b35-22f7-44cb-9e6c-aab8798090a9', 'x': array([400.07646, 400.51975, 400.96301, ..., 798.88197, 799.30046, 799.71891], shape=(1852,)), 'xaxis': 'x', 'y': array([ nan, nan, nan, ..., -118.64650334, -118.5165033 , -118.38691232], shape=(1852,)), 'yaxis': 'y'}], 'layout': {'legend': {'title': {'text': 'variable'}, 'tracegroupgap': 0}, 'margin': {'t': 60}, 'template': '...', 'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': 'Wavelength'}}, 'yaxis': {'anchor': 'x', 'domain': [0.0, 1.0], 'title': {'text': 'value'}}} }) .. GENERATED FROM PYTHON SOURCE LINES 113-114 We can also have a look at the fit statistics. .. GENERATED FROM PYTHON SOURCE LINES 114-116 .. code-block:: Python fit_stats .. raw:: html

Fit Result



.. GENERATED FROM PYTHON SOURCE LINES 117-121 References ---------- `Here `_ you can find the latest jupyter notebook and data files of this example. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.720 seconds) .. _sphx_glr_download_auto_examples_plot_02_TiO2_multilayer.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_TiO2_multilayer.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_TiO2_multilayer.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_TiO2_multilayer.zip `