Skip to content

Problems with Asphere component #193

Description

@grahamnaylor-pf

I have an optical layout that I would like to simulate using an aspherical surface. This causes a kernel crash, however if I replace the surface with spherical it traces the rays with no issues. Is there a problem with the aspheric component? The code below should give the same shape as an Aspherical component as the first commented version of a Spherical component:

%matplotlib inline
from pyoptools.all import *
import math
import numpy as np

mirror_shape = Circular(radius=300.0)

mirror_surface = Spherical(

curvature=1.0/500.0,

shape=mirror_shape,

reflectivity=1.0

)

mirror_surface = Aspherical(
shape=mirror_shape,
Ax=0.002,
Ay=0.002,
Kx=0, # Elliptical in X (-1 < K < 0) circle K=0
Ky=0, # Parabolic in Y if K = -1
reflectivity=1.0
)

mirror_comp = Component(surflist=[(mirror_surface, (0, 0, 0), (0, 0, 0))])

screen = CCD(size=(1000, 2000)) # Creates a 500x500mm screen
screen2 = CCD(size=(1000, 2000)) # Creates a 500x500mm screen

horizontal_screen_comp = Component(
surflist=[
(screen,(0,0,0), (np.pi/2,0,0)) ] )

L1,L2=-1500,-100
num_points = 5 #8
start_points = np.array((np.zeros(num_points),np.zeros(num_points),np.linspace(L1,L2,num_points))).transpose()
h1,h2 = 50,70
stop_points = np.array((np.zeros(num_points),np.linspace(h1,h2,num_points),np.zeros(num_points))).transpose()
w1,w2 = -49,49
side_offsets = np.array((np.linspace(w1,w2,num_points),np.zeros(num_points),np.zeros(num_points))).transpose()

rect_ap = OpticalStop(shape=Rectangular(size=(200, 400)), ap_shape=Rectangular(size=(100, 20)))

APC = Component(surflist=[(rect_ap, (0, 0, 0), (0, 0, 0))])

system = System(complist=[(mirror_comp,(0,130,330),(1.95,0,0)), (APC, (0, 60, 0), (0, 0, 0)),(screen,(0,-200,500),(np.pi/2,0,0)), (screen,(0,150,900),(1.2*np.pi/2,0,0))], n=1) #try adding: , (APC, (0, 0, 100), (0, 0, 0))

TS_rays = []
color=0
for start in start_points:
my_color = (1-color, 0.4, color)
color=color+1/num_points
for stop in stop_points:
for sideways in side_offsets:
vector=stop-start
r = Ray(origin=start, direction=(stop + sideways - start), wl=0.632, draw_color=my_color)
TS_rays.append(r)

#previously tried direction=cartesian_to_angles(stop - start)

4. Add rays and propagate

system.ray_add(TS_rays)
system.propagate()
Plot3D(system, size=(1000, 600))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions