{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Surfaces in pyOpTools" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The basic object to create optical components in pyOpTools are the surfaces. They are used to define the border that separates 2 materials (for example air-glass) in an optical component.\n", "\n", "Below are some of the [Surface Objects](../../pyoptools.raytrace.surface.rst) supported by pyOpTools." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pyoptools.all import *\n", "from numpy import pi" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plane Surface\n", "\n", "The [Plane](../../pyoptools.raytrace.surface.plane.rst) surface is the most simple surface class in the library. It is defined as an ideal infininite $XY$ plane, located at $Z=0$. To define the Plane limits, its constructor receives as an argument a sub-class of [Shape](../../pyoptools.raytrace.shape.rst). This sub-classes ([Circular](../../pyoptools.raytrace.shape.circular.rst), [Rectangular](../../pyoptools.raytrace.shape.rectangular.rst), [Triangular](../../pyoptools.raytrace.shape.triangular.rst), etc ) define the limits of the Surface (plane in this case). \n", "\n", "### Some Plane examples\n", "\n", "Below are some examples of Plane surfaces limited by different shapes." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "P1 = Plane(shape=Circular(radius=(25)))\n", "Plot3D(P1, center=(0, 0, 0), size=(60, 60), rot=[(0, 0, 0)], scale=6)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "P2 = Plane(shape=Rectangular(size=(50, 50)))\n", "Plot3D(P2, center=(0, 0, 0), size=(60, 60), rot=[(0, 0, 0)], scale=6)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "P3 = Plane(shape=Triangular(coord=((0, 25), (25, -25), (-25, -25))))\n", "Plot3D(P3, center=(0, 0, 0), size=(60, 60), scale=6)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Spherical Surface\n", "\n", "The [Spherical](../../pyoptools.raytrace.surface.plane.rst) surface is another very useful Class to define optical components. It is used to define an spherical cap that has its vertex located at the origin ($(0,0,0)$). The normal to the spherical cap at $X=0$ and $Y=0$ is the vector $(0,0,1)$. As it was the case with the Plane surface, it is used with a Shape subclass to define its edges.\n", "\n", "### Spherical surface limited by a circular shape example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "S = Spherical(curvature=1 / 200.0, shape=Circular(radius=145.0), reflectivity=0)\n", "Plot3D(S, center=(0, 0, 0), size=(400, 400), scale=1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Cylindrical Surface\n", "\n", "pyOpTools has 2 different types of cylindrical surfaces. The first one is the [Cylinder](../../pyoptools.raytrace.surface.cylinder.rst) , as its name implies defines a closed cylinder. It is mainly used to define the border of a lens. For example a plano-convex lens can be defined as one circular-limited plane, one circular limited spherical surface, and one cylindrical surface.\n", "\n", "Below is an example of a cylindrical surface. Please note that this surface does not receive a [Shape](../../pyoptools.raytrace.shape.rst) subclass." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "S3 = Cylinder(radius=36, length=100, reflectivity=1)\n", "Plot3D(S3, center=(0, 0, 0), size=(100, 100), rot=[(0, pi / 32, 0)], scale=4)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The second class is the [Cylindrical](../../pyoptools.raytrace.surface.plane.rst). " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "S1 = Cylindrical(shape=Rectangular(size=(50, 100)), curvature=1 / 20.0)\n", "Plot3D(S1, center=(0, 0, 0), size=(150, 150), rot=[(pi / 4, 0, 0)], scale=2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "S2 = Cylindrical(shape=Circular(radius=(50)), curvature=1 / 100.0)\n", "Plot3D(S2, center=(0, 0, 0), size=(150, 150), rot=[(-pi / 4, 0, 0)], scale=2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Aspherical Surface" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%latex\n", "$$Z=\\frac{(Ax*x^2+Ay*y^2)}{(1+\\sqrt{(1-(1+Kx)*Ax^2*x^2-(1+Ky)*Ay^2*y^2))}}+ Poly2D()$$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sa = Aspherical(\n", " shape=Rectangular(size=(5, 5)),\n", " Ax=0.2,\n", " Ay=0.2,\n", " Kx=0.1,\n", " Ky=0.15,\n", " poly=Poly2D((0, 0, 0, 0.5, 0, 0.5)),\n", ")\n", "Plot3D(sa, center=(0, 0, 5), size=(10, 10), rot=[(-3 * pi / 10, pi / 4, 0)], scale=40)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sa = Aspherical(\n", " shape=Circular(radius=2.5),\n", " Ax=0.2,\n", " Ay=0.2,\n", " Kx=0.1,\n", " Ky=0.15,\n", " poly=Poly2D((0, 0, 0, 0.5, 0, 0.5)),\n", ")\n", "Plot3D(sa, center=(0, 0, 5), size=(10, 10), rot=[(-3 * pi / 10, pi / 4, 0)], scale=40)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.11.10" } }, "nbformat": 4, "nbformat_minor": 4 }