rayoptics.elem.profiles module
Module for different surface profile shapes
The profiles module captures the geometric shape aspect of the optical interface. The
SurfaceProfile
base class specifies an api that subclasses implement to provide different shapes. It also provides generic implementations of ray-profile intersections.
- intersect_parabola(cv, p, d, z_dir=1.0)[source]
Intersect a parabolid, starting from an arbitrary point.
- Parameters:
cv – vertex curvature
p – start point of the ray in the profile’s coordinate system
d – direction cosine of the ray in the profile’s coordinate system
z_dir – +1 if propagation positive direction, -1 if otherwise
- class SurfaceProfile[source]
Bases:
object
Base class for surface profiles.
- f(p)[source]
Returns the value of the profile surface function at point \(\boldsymbol{p}\).
\(f({\boldsymbol{p}}) = 0\)
where \(\boldsymbol{p}=({x, y, z})^T\)
- df(p)[source]
Returns the gradient of the profile surface function at point \(\boldsymbol{p}\).
\(df(\boldsymbol{p}) = \partial{f(\boldsymbol{p})}/\partial{\boldsymbol{p}}\)
- profile(sd, dir=1, steps=6)[source]
Return a 2d polyline approximating the surface profile.
- Parameters:
sd – semi-diameter of the profile
dir – +1 for profile from neg to postive direction, -1 if otherwise
steps – number of points to generate
- intersect(p0, d, eps, z_dir)[source]
Intersect a profile, starting from an arbitrary point.
- Parameters:
p0 – start point of the ray in the profile’s coordinate system
d – direction cosine of the ray in the profile’s coordinate system
z_dir – +1 if propagation positive direction, -1 if otherwise
eps – numeric tolerance for convergence of any iterative procedure
- Returns:
distance to intersection point s1, intersection point p
- Return type:
- Raises:
- intersect_welford(p, d, eps, z_dir)[source]
Intersect a profile, starting from an arbitrary point.
From Welford, Aberrations of Optical Systems (ISBN-10: 0852745648), eqs 4.34 thru 4.41.
- Parameters:
p0 – start point of the ray in the profile’s coordinate system
d – direction cosine of the ray in the profile’s coordinate system
z_dir – +1 if propagation positive direction, -1 if otherwise
eps – numeric tolerance for convergence of any iterative procedure
- Returns:
distance to intersection point s1, intersection point p
- Return type:
- Raises:
- intersect_spencer(p0, d, eps, z_dir)[source]
Intersect a profile, starting from an arbitrary point.
From Spencer and Murty, General Ray-Tracing Procedure
- Parameters:
p0 – start point of the ray in the profile’s coordinate system
d – direction cosine of the ray in the profile’s coordinate system
z_dir – +1 if propagation positive direction, -1 if otherwise
eps – numeric tolerance for convergence of any iterative procedure
- Returns:
distance to intersection point s1, intersection point p
- Return type:
- Raises:
- intersect_scipy(p0, d, eps, z_dir)[source]
Intersect a profile, starting from an arbitrary point.
Uses the newton method of scipy.optimize.root_scalar.
- Parameters:
p0 – start point of the ray in the profile’s coordinate system
d – direction cosine of the ray in the profile’s coordinate system
z_dir – +1 if propagation positive direction, -1 if otherwise
eps – numeric tolerance for convergence of any iterative procedure
- Returns:
distance to intersection point s1, intersection point p
- Return type:
- Raises:
- class Spherical(c=0.0, r=None)[source]
Bases:
SurfaceProfile
Spherical surface profile parameterized by curvature.
The sag \(z\) is given by:
\(z = R - \sqrt{R^2 - x^2 - y^2}\)
where \(R = 1/c\)
—
- __init__(c=0.0, r=None)[source]
initialize a Spherical profile.
- Parameters:
c – curvature
r – radius of curvature. If zero, taken as planar. If r is specified, it overrides any input for c (curvature).
- property r
- f(p)[source]
surface function for Spherical profile
This function implements Spencer’s eq 25, with kappa=1 (i.e. spherical).
To see this, start with the code: F = p[2] - 0.5*cv*(np.dot(p, p))
Expand np.dot(p, p): F = p[2] - 0.5*cv*(p[0]*p[0] + p[1]*p[1] + p[2]*p[2])
in Spencer’s notation: rho**2 = p[0]*p[0] + p[1]*p[1] Z = p[2]
Substituting notation, the result is: F = Z - 0.5*cv*(rho**2 + Z**2)
which is Spencer’s eq 25.
- class Conic(c=0.0, cc=0.0, r=None, ec=None)[source]
Bases:
SurfaceProfile
Conic surface profile parameterized by curvature and conic constant.
Conics produced for conic constant values:
cc > 0.0: oblate spheroid
cc = 0.0: sphere
cc < 0.0 and > -1.0: ellipsoid
cc = -1.0: paraboloid
cc < -1.0: hyperboloid
Conics produced for conic asphere values:
ec > 1.0: oblate spheroid
ec = 1.0: sphere
ec > 0.0 and < 1.0: ellipsoid
ec = 0.0: paraboloid
ec < 0.0: hyperboloid
The conic constant is related to the conic asphere as:
cc = ec - 1
The sag \(z\) is given by:
\(z(r)=\dfrac{cr^2}{1+\sqrt[](1-\textbf{ec } c^2 r^2)}\)
where \(r^2 = x^2+y^2\)
—
- __init__(c=0.0, cc=0.0, r=None, ec=None)[source]
initialize a Conic profile.
- Parameters:
c – curvature
r – radius of curvature. If zero, taken as planar. If r is specified, it overrides any input for c (curvature).
cc – conic constant
ec – conic asphere (= cc + 1). If ec is specified, it overrides any input for the conic constant (cc).
- property r
- property ec
- f(p)[source]
surface function for Conic profile
This function implements Spencer’s eq 25, with kappa = ec = 1 + cc
- append_pt_to_2d_profile(surface_profile, y, poly_profile)[source]
calc surface sag at y and append to poly if ok, else return None
- class EvenPolynomial(c=0.0, cc=0.0, r=None, ec=None, coefs=None)[source]
Bases:
SurfaceProfile
Even Polynomial asphere, even terms up to 20th order, on base conic.
Conics produced for conic constant values:
cc > 0.0: oblate spheroid
cc = 0.0: sphere
cc < 0.0 and > -1.0: ellipsoid
cc = -1.0: paraboloid
cc < -1.0: hyperboloid
Conics produced for conic asphere values:
ec > 1.0: oblate spheroid
ec = 1.0: sphere
ec > 0.0 and < 1.0: ellipsoid
ec = 0.0: paraboloid
ec < 0.0: hyperboloid
The conic constant is related to the conic asphere as:
cc = ec - 1
The sag \(z\) is given by:
\(z(r)=\dfrac{cr^2}{1+\sqrt[](1-\textbf{ec } c^2 r^2)}+\sum_{i=1}^{20} a_ir^{2i}\)
where \(r^2=x^2+y^2\)
—
- initial_size = 10
- __init__(c=0.0, cc=0.0, r=None, ec=None, coefs=None)[source]
initialize a EvenPolynomial profile.
- Parameters:
c – curvature
r – radius of curvature. If zero, taken as planar. If r is specified, it overrides any input for c (curvature).
cc – conic constant
ec – conic asphere (= cc + 1). If ec is specified, it overrides any input for the conic constant (cc).
coefs – a list of even power coefficents, starting with the quadratic term, and not exceeding the 20th order term.
- property r
- property ec
- f(p)[source]
Returns the value of the profile surface function at point \(\boldsymbol{p}\).
\(f({\boldsymbol{p}}) = 0\)
where \(\boldsymbol{p}=({x, y, z})^T\)
- class RadialPolynomial(c=0.0, cc=None, r=None, ec=1.0, coefs=None)[source]
Bases:
SurfaceProfile
Radial Polynomial asphere, both even and odd terms, on base conic.
Conics produced for conic constant values:
cc > 0.0: oblate spheroid
cc = 0.0: sphere
cc < 0.0 and > -1.0: ellipsoid
cc = -1.0: paraboloid
cc < -1.0: hyperboloid
Conics produced for conic asphere values:
ec > 1.0: oblate spheroid
ec = 1.0: sphere
ec > 0.0 and < 1.0: ellipsoid
ec = 0.0: paraboloid
ec < 0.0: hyperboloid
The conic constant is related to the conic asphere as:
cc = ec - 1
The sag \(z\) is given by:
\(z(r)=\dfrac{cr^2}{1+\sqrt[](1-\textbf{ec } c^2 r^2)}+\sum_{i=1}^{10} a_ir^i\)
where \(r^2 = x^2+y^2\)
—
- initial_size = 10
- __init__(c=0.0, cc=None, r=None, ec=1.0, coefs=None)[source]
initialize a RadialPolynomial profile.
- Parameters:
c – curvature
r – radius of curvature. If zero, taken as planar. If r is specified, it overrides any input for c (curvature).
ec – conic asphere.
cc – conic constant (= ec - 1). If cc is specified, it overrides any input for the conic asphere (ec).
coefs – a list of radial coefficents, starting with the linear term, and not exceeding the 10th order term.
- property r
- property cc
- f(p)[source]
Returns the value of the profile surface function at point \(\boldsymbol{p}\).
\(f({\boldsymbol{p}}) = 0\)
where \(\boldsymbol{p}=({x, y, z})^T\)
- class YToroid(c=0.0, cR=0, cc=0.0, r=None, rR=None, ec=None, coefs=None)[source]
Bases:
SurfaceProfile
Y Aspheric toroid, even terms up to 20th order, on base conic.
Conics produced for conic constant values:
cc > 0.0: oblate spheroid
cc = 0.0: sphere
cc < 0.0 and > -1.0: ellipsoid
cc = -1.0: paraboloid
cc < -1.0: hyperboloid
Conics produced for conic asphere values:
ec > 1.0: oblate spheroid
ec = 1.0: sphere
ec > 0.0 and < 1.0: ellipsoid
ec = 0.0: paraboloid
ec < 0.0: hyperboloid
The conic constant is related to the conic asphere as:
cc = ec - 1
The sag \(z\) is given by:
\(z=f(y)-\frac{1}{2}\textbf{cR}[x^2+z^2-f^2(y)]\)
where \(f(y)=\dfrac{cy^2}{1+\sqrt[](1-\textbf{ec } c^2 y^2)}+\sum_{i=1}^{20} a_iy^{2i}\)
is the sweep profile curve.
- initial_size = 10
- __init__(c=0.0, cR=0, cc=0.0, r=None, rR=None, ec=None, coefs=None)[source]
initialize a EvenPolynomial profile.
- Parameters:
c – curvature
r – radius of curvature. If zero, taken as planar. If r is specified, it overrides any input for c (curvature).
cR – toric sweep radius of curvature
rR – toric sweep radius
cc – conic constant
ec – conic asphere (= cc + 1). If ec is specified, it overrides any input for the conic constant (cc).
coefs – a list of even power coefficents, starting with the quadratic term, and not exceeding the 20th order term.
- property r
- property rR
- property ec
- f(p)[source]
Returns the value of the profile surface function at point \(\boldsymbol{p}\).
\(f({\boldsymbol{p}}) = 0\)
where \(\boldsymbol{p}=({x, y, z})^T\)
- class XToroid(c=0.0, cR=0, cc=0.0, r=None, rR=None, ec=None, coefs=None)[source]
Bases:
YToroid
X Aspheric toroid, even terms up to 20th order, on base conic.
Leverages the YToroid implementation.
Conics produced for conic constant values:
cc > 0.0: oblate spheroid
cc = 0.0: sphere
cc < 0.0 and > -1.0: ellipsoid
cc = -1.0: paraboloid
cc < -1.0: hyperboloid
Conics produced for conic asphere values:
ec > 1.0: oblate spheroid
ec = 1.0: sphere
ec > 0.0 and < 1.0: ellipsoid
ec = 0.0: paraboloid
ec < 0.0: hyperboloid
The conic constant is related to the conic asphere as:
cc = ec - 1
The sag \(z\) is given by:
\(z=f(x)-\frac{1}{2}\textbf{cR}[y^2+z^2-f^2(x)]\)
where \(f(x)=\dfrac{cx^2}{1+\sqrt[](1-\textbf{ec } c^2 x^2)}+\sum_{i=1}^{20} a_ix^{2i}\)
is the sweep profile curve.
- __init__(c=0.0, cR=0, cc=0.0, r=None, rR=None, ec=None, coefs=None)[source]
initialize a EvenPolynomial profile.
- Parameters:
c – curvature
r – radius of curvature. If zero, taken as planar. If r is specified, it overrides any input for c (curvature).
cR – toric sweep radius of curvature
rR – toric sweep radius
cc – conic constant
ec – conic asphere (= cc + 1). If ec is specified, it overrides any input for the conic constant (cc).
coefs – a list of even power coefficents, starting with the quadratic term, and not exceeding the 20th order term.