Warning
There is an issue with the generation of documentation from notebooks, such as this page, that causes interactive plots generated using the Plot3D function to appear incorrect. The examples should produce correct 3D plots when executed directly in Jupyter Lab.
Surfaces in pyOpTools¶
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.
Below are some of the Surface Objects supported by pyOpTools.
[1]:
from pyoptools.all import *
from numpy import pi
Plane Surface¶
The Plane surface is the most simple surface class in the library. It is defined as an ideal infininite plane, located at . To define the Plane limits, its constructor receives as an argument a sub-class of Shape. This sub-classes (Circular, Rectangular, Triangular, etc ) define the limits of the Surface (plane in this case).
Some Plane examples¶
Below are some examples of Plane surfaces limited by different shapes.
[2]:
P1=Plane(shape=Circular(radius=(25)))
Plot3D(P1,center=(0,0,0),size=(60,60),rot=[(0,0,0)],scale=6)
[2]:
[3]:
P2=Plane(shape=Rectangular(size=(50,50)))
Plot3D(P2,center=(0,0,0),size=(60,60),rot=[(0,0,0)],scale=6)
[3]:
[4]:
P3=Plane(shape=Triangular(coord=((0,25),(25,-25),(-25,-25))))
Plot3D(P3,center=(0,0,0),size=(60,60),scale=6)
[4]:
Spherical Surface¶
The Spherical 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 (). The normal to the spherical cap at and is the vector . As it was the case with the Plane surface, it is used with a Shape subclass to define its edges.
Spherical surface limited by a circular shape example¶
[5]:
S=Spherical(curvature=1/200., shape=Circular(radius=145.),reflectivity=0)
Plot3D(S,center=(0,0,0),size=(400,400),scale=1)
[5]:
Cylindrical Surface¶
pyOpTools has 2 different types of cylindrical surfaces. The first one is the Cylinder , 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.
Below is an example of a cylindrical surface. Please note that this surface does not receive a Shape subclass.
[6]:
S3=Cylinder(radius=36,length=100,reflectivity=1)
Plot3D(S3,center=(0,0,0),size=(100,100),rot=[(0,pi/32,0)],scale=4)
[6]:
The second class is the Cylindrical.
[7]:
S1=Cylindrical(shape=Rectangular(size=(50,100)),curvature=1/20.)
Plot3D(S1,center=(0,0,0),size=(150,150),rot=[(pi/4,0,0)],scale=2)
/home/docs/checkouts/readthedocs.org/user_builds/pyoptools/envs/latest/lib/python3.7/site-packages/pyoptools-0.2.0-py3.7-linux-x86_64.egg/pyoptools/gui/ipywidgets.py:29: RuntimeWarning: invalid value encountered in sqrt
points, polylist = S.polylist()
/home/docs/checkouts/readthedocs.org/user_builds/pyoptools/envs/latest/lib/python3.7/site-packages/jupyter_client/session.py:718: UserWarning: Message serialization failed with:
Out of range float values are not JSON compliant
Supporting this message is deprecated in jupyter-client 7, please make sure your message is JSON-compliant
content = self.pack(content)
[7]:
[8]:
S2=Cylindrical(shape=Circular(radius=(50)),curvature=1/100.)
Plot3D(S2,center=(0,0,0),size=(150,150),rot=[(-pi/4,0,0)],scale=2)
[8]:
Aspherical Surface¶
[9]:
%%latex
$$Z=\frac{(Ax*x^2+Ay*y^2)}{(1+\sqrt{(1-(1+Kx)*Ax^2*x^2-(1+Ky)*Ay^2*y^2))}}+ poly2d()$$
[10]:
sa=Aspherical(shape=Rectangular(size=(5,5)),Ax=.2,Ay=.2,Kx=.1, Ky=.15, poly=poly2d((0,0,0,.5,0,.5)))
Plot3D(sa,center=(0,0,5),size=(10,10),rot=[(-3*pi/10,pi/4,0)],scale=40)
[10]:
[11]:
sa=Aspherical(shape=Circular(radius=2.5),Ax=.2,Ay=.2,Kx=.1, Ky=.15, poly=poly2d((0,0,0,.5,0,.5)))
Plot3D(sa,center=(0,0,5),size=(10,10),rot=[(-3*pi/10,pi/4,0)],scale=40)
[11]:
[ ]:
[ ]: