{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Cholesteric Liquid Crystal\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Example of a cholesteric liquid crystal\nAuthors: O. Castany, C. Molinaro, M. M\u00fcller\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import elli\nimport elli.plot as elliplot\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom scipy.constants import c, pi"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Setup materials and structure\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "glass = elli.IsotropicMaterial(elli.ConstantRefractiveIndex(1.55))\nfront = back = glass\n\n# Liquid crystal oriented along the x direction\n(no, ne) = (1.5, 1.7)\nDn = ne - no\nn_med = (ne + no) / 2\nLC = elli.UniaxialMaterial(\n    elli.ConstantRefractiveIndex(no), elli.ConstantRefractiveIndex(ne)\n)  # ne is along z\nR = elli.rotation_v_theta(elli.E_Y, 90)  # rotation of pi/2 along y\nLC.set_rotation(R)  # apply rotation from z to x\n\n# Cholesteric pitch (nm):\np = 650\n\n# One half turn of a right-handed helix:\nTN = elli.TwistedLayer(LC, p / 2, angle=180, div=35)\n\n# Repetition the helix layer\nN = 15  # number half pitch repetitions\nh = N * p / 2\nL = elli.RepeatedLayers([TN], N)\ns = elli.Structure(front, [L], back)\n\n# Calculation parameters\nlbda_min, lbda_max = 800, 1200  # (nm)\nlbda_B = p * n_med\nlbda_list = np.linspace(lbda_min, lbda_max, 100)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Analytical calculation for the maximal reflection\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "R_th = np.tanh(Dn / n_med * pi * h / p) ** 2\nlbda_B1, lbda_B2 = p * no, p * ne"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Calculation with pyElli\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "data = s.evaluate(lbda_list, 0)\n\nT_pp = data.T_pp\nT_ps = data.T_ps\nT_ss = data.T_ss\nT_sp = data.T_sp\n\n# Transmission coefficients for incident unpolarized light:\nT_pn = 0.5 * (T_pp + T_ps)\nT_sn = 0.5 * (T_sp + T_ss)\nT_nn = T_sn + T_pn\n\n# Transmission coefficients for 's' and 'p' polarized light, with\n# unpolarized measurement.\nT_ns = T_ps + T_ss\nT_np = T_pp + T_sp\n\n# Right-circular wave is reflected in the stop-band.\n# R_LR, T_LR close to zero.\nR_RR = data.Rc_RR\nR_LR = data.Rc_LR\nT_RR = data.Tc_RR\nT_LR = data.Tc_LR\n\n# Left-circular wave is transmitted in the full spectrum.\n# T_RL, R_RL, R_LL close to zero, T_LL close to 1.\nT_LL = data.Tc_LL\nR_LL = data.Rc_LL"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Plotting\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "fig = plt.figure()\nax = fig.add_subplot(1, 1, 1)\n\n# Draw rectangle for \u03bb \u2208 [p\u00b7no, p\u00b7ne], and T \u2208 [0, R_th]\nrectangle = plt.Rectangle((lbda_B1, 0), lbda_B2 - lbda_B1, R_th, color=\"cyan\")\nax.add_patch(rectangle)\n\nax.plot(lbda_list, R_RR, \"--\", label=\"R_RR\")\nax.plot(lbda_list, T_RR, label=\"T_RR\")\nax.plot(lbda_list, T_nn, label=\"T_nn\")\nax.plot(lbda_list, T_ns, label=\"T_ns\")\nax.plot(lbda_list, T_np, label=\"T_np\")\n\nax.legend(loc=\"center right\", bbox_to_anchor=(1.00, 0.50))\n\nax.set_title(\n    \"Right-handed Cholesteric Liquid Crystal, aligned along \\n\"\n    + \"the $x$ direction, with {:.1f} helix pitches.\".format(N / 2.0)\n)\nax.set_xlabel(r\"Wavelength $\\lambda_0$ (nm)\")\nax.set_ylabel(r\"Power transmission $T$ and reflexion $R$\")\nplt.show()\n\nelliplot.draw_structure(s)"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "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.8.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}