cihologramas / pyoptools

Python tools for optical design
GNU General Public License v3.0
136 stars 45 forks source link

Problems with simulating Herriott cell #151

Closed keeqianling closed 3 months ago

keeqianling commented 7 months ago

I'm trying to make a Herriott cell but this error keeps showing up. Is there a problem with the direction of the ray?

image

image

semiversus commented 7 months ago
ramezquitao commented 3 months ago

I just added some options to the System class to limit the number of possible iterations made in a ray propagation. Before this was unlimited, meaning the rays would be propagated for ever in a resonant cavity, causing the kernel to stop.

The following example works now

from pyoptools.all import *
import numpy as np

mirror_diameter = 25.4
f = 100
R = 2*f

S1 = Spherical(shape = Circular(radius=mirror_diameter/2), curvature= 1/R, reflectivity =1)
M1= Component(surflist=[(S1,(0,0,0),(0,0,0))], material = material.schott["N-BK7"])

d= 226

S = System(complist=[(M1, (0,0,0),(0,0,0)),(M1, (0,0,d),(0,-np.pi,0))], max_ray_parent_cnt = 1000)

alpha_x = 0.00461
alpha_y = 0

R= Ray(pos=(0,0,0), dir=(np.tan(alpha_x), np.tan(alpha_y),1))
S.ray_add(R)
S.propagate()

Plot3D(S,center=(0,0,d/2))

One small request, next time you add some code to an issue, don't add it as an image, add it as text, so it can be easily copied and pasted.

Feel free to reopen the issue in case you still have problems.