.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples_gallery/fields/plot_nematic_field.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_examples_gallery_fields_plot_nematic_field.py: Plotting a nematic field ======================== This example shows how to visualize a nematic tensor field :math:`\boldsymbol Q = S(\boldsymbol n \otimes \boldsymbol n - \mathbb{1}/2)`. The field shown here contains a :math:`+\frac12` defect at the origin, where the director :math:`\boldsymbol n` rotates by :math:`\pi` around the defect and the nematic order :math:`S` vanishes. .. GENERATED FROM PYTHON SOURCE LINES 11-22 .. image-sg:: /examples_gallery/fields/images/sphx_glr_plot_nematic_field_001.png :alt: Nematic field with a $+1/2$ defect :srcset: /examples_gallery/fields/images/sphx_glr_plot_nematic_field_001.png :class: sphx-glr-single-img .. code-block:: Python from pde import CartesianGrid, Tensor2Field grid = CartesianGrid([[-2, 2], [-2, 2]], 24) order = "tanh(2 * sqrt(x**2 + y**2))" # nematic order vanishing at the defect q_xx = f"0.5 * {order} * x / sqrt(x**2 + y**2)" q_xy = f"0.5 * {order} * y / sqrt(x**2 + y**2)" field = Tensor2Field.from_expression(grid, [[q_xx, q_xy], [q_xy, f"-({q_xx})"]]) field.plot(kind="nematic", title="Nematic field with a $+1/2$ defect") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.321 seconds) .. _sphx_glr_download_examples_gallery_fields_plot_nematic_field.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_nematic_field.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_nematic_field.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_nematic_field.zip `