.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_interpolated_tip_area.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_interpolated_tip_area.py: Interpolated Tip Area Function ============================== This example uses a tabulated contact-depth/contact-area calibration curve as an interpolated tip area function and compares it with analytical references. .. GENERATED FROM PYTHON SOURCE LINES 8-15 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from scipy.interpolate import interp1d from micromechanics.indentation import Tip .. GENERATED FROM PYTHON SOURCE LINES 16-19 Some calibrations are available as measured points rather than polynomial prefactors. Here we create such a table by perturbing the perfect Berkovich area with a shallow-depth rounding term. .. GENERATED FROM PYTHON SOURCE LINES 19-25 .. code-block:: Python calibration_depth = np.linspace(0.02, 0.8, 18) perfect_reference = Tip("perfect") measured_area = perfect_reference.areaFunction(calibration_depth.copy()) measured_area *= 1.0 + 0.18*np.exp(-calibration_depth/0.16) .. GENERATED FROM PYTHON SOURCE LINES 26-28 ``Tip`` accepts an interpolation function for ``Ac = f(hc)``. The interpolation can then be used anywhere a regular tip area function is expected. .. GENERATED FROM PYTHON SOURCE LINES 28-33 .. code-block:: Python interpolated_area = interp1d(calibration_depth, measured_area, fill_value="extrapolate") interpolated_tip = Tip(interpFunction=interpolated_area) spherical_tip = Tip(shape=[3.0, 70.3, "sphere"]) .. GENERATED FROM PYTHON SOURCE LINES 34-37 Compare the interpolated calibration with the perfect Berkovich and spherical references. Differences at shallow depth are especially important because small contact-depth errors strongly affect hardness. .. GENERATED FROM PYTHON SOURCE LINES 37-52 .. code-block:: Python contact_depth = np.linspace(0.02, 0.8, 120) area_interpolated = interpolated_tip.areaFunction(contact_depth.copy()) area_perfect = perfect_reference.areaFunction(contact_depth.copy()) area_sphere = spherical_tip.areaFunction(contact_depth.copy()) fig, ax = plt.subplots() ax.plot(calibration_depth, measured_area, "o", label="calibration points") ax.plot(contact_depth, area_interpolated, label="interpolated tip") ax.plot(contact_depth, area_perfect, "--", label="perfect Berkovich") ax.plot(contact_depth, area_sphere, ":", label="spherical tip") ax.set_xlabel(r"contact depth [$\mathrm{\mu m}$]") ax.set_ylabel(r"projected contact area [$\mathrm{\mu m^2}$]") ax.legend() .. image-sg:: /auto_examples/images/sphx_glr_plot_interpolated_tip_area_001.png :alt: plot interpolated tip area :srcset: /auto_examples/images/sphx_glr_plot_interpolated_tip_area_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 53-55 The representation confirms that this tip is driven by an interpolation function instead of polynomial prefactors. .. GENERATED FROM PYTHON SOURCE LINES 55-57 .. code-block:: Python print(interpolated_tip) .. rst-class:: sphx-glr-script-out .. code-block:: none compliance: 0.0; with interpolation function with 18 points .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.071 seconds) .. _sphx_glr_download_auto_examples_plot_interpolated_tip_area.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_interpolated_tip_area.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_interpolated_tip_area.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_interpolated_tip_area.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_