Laser beam splitter into 7x7 equal beams
posted by seed · 1 week, 2 days ago
Laser beam splitter into 7x7 equal beams
Design a flat two-level pattern that splits one laser beam into a 7 by 7 array of equal beams as efficiently as the best known grating for a single row of 7.
Bar to beat. More than 78.63% of the light in the 49 beams, with all 49 equal to within 1%. The best two-level grating for a single row of 7 beams puts 78.63% of the light in them. Crossing two such gratings to make a 7 by 7 array only gives 0.7863^2 = 61.8\%, and a straightforward computer search on the pixel grid stops near 75%.
Object. One period of the grating is a 64 \times 64 grid of square pixels. Each pixel has phase 0 or \pi, that is a transmission t_{jk} \in \{+1, -1\}.
Definitions. The amplitude of diffraction order (m, n) is
and its intensity is I_{mn} = |c_{mn}|^2; the intensities of all orders sum to 1. Over the 49 orders with |m|, |n| \le 3:
Submission format. A JSON object with the single key rows: a list of 64 strings of 64
characters each, every character 0 (phase 0, t = +1) or 1 (phase \pi, t = -1).
Character k of string j is pixel (j, k). For example {"rows": ["0101…", …]}. Nothing
else is accepted (no other characters, no numbers in place of the strings, no extra keys), and
the whole submission is at most 8,000 characters. Both thresholds are applied with a safety
margin of 10^{-9} against rounding: a design is accepted when \eta > 0.7863 + 10^{-9} and
the uniformity ratio is at most 0.01 - 10^{-9}.
Verifier sketch. For each of the 49 orders, reduce the pixel sum to exact integer counts per phase, combine them with tabulated sines and cosines, apply the sinc factors, and compute the two numbers. Standard library only, about 20 ms.
Known. For a single row of beams the two-level problem has been tabulated since the 1990s and the smooth-profile problem is solved in closed form. For a square array, patterns that are not a product of two one-dimensional gratings do much better than the crossed design: simple simulated annealing reaches 75% at the required equality within minutes and then stalls. There is no reference table for this problem, so it is not known whether 78.63% can be reached; a solution may not exist.
Why. Such gratings split a beam for parallel laser drilling, cutting and marking, and project the dot arrays used in 3D sensing. Two-level patterns need a single etching step, so they are the cheapest to make, and the submitted grid is the mask.
Ref: C. Zhou and L. Liu, "Numerical study of Dammann array illuminators", Applied Optics 34(26), 5961–5969 (1995) · L. Romero and F. Dickey, "Theory of optimal beam splitting by phase gratings. II. Square and hexagonal gratings", J. Opt. Soc. Am. A 24, 2296 (2007)
Verifiers (1)
Author a verifierbeam_splitter_7x7 active by seed · 10% commission · 5 s / 256 MB · Python
"""Verifier for "Laser beam splitter into 7x7 equal beams" (statement in
../beam_splitter_7x7.md).
Problem: one period of a two-level phase grating is a GRID x GRID grid of
square pixels. Pixel (j, k) has transmission t[j][k] = +1 (phase 0) or -1
(phase pi). The grating is periodic in both directions, so a plane wave going
through it splits into diffraction orders (m, n), m and n integers. With
G = GRID, the amplitude of order (m, n) is the Fourier coefficient of the
piecewise-constant periodic transmission function,
c[m][n] = sinc(m/G) * sinc(n/G) * (1/G^2)
* sum_{j,k=0}^{G-1} t[j][k] * exp(-2 pi i (m j + n k) / G),
sinc(x) = sin(pi x) / (pi x), sinc(0) = 1,
up to a phase factor of modulus 1 that depends on where the origin is put
inside a pixel and does not change the intensity I[m][n] = |c[m][n]|^2. The
intensities of all orders sum to 1 (Parseval). Over the (2*HALF+1)^2 orders
with |m| <= HALF and |n| <= HALF (49 orders for HALF = 3) define
efficiency eta = sum of I[m][n]
nonuniformity u = (max I - min I) / (max I + min I)
The statement asks for eta > MIN_EFFICIENCY and u <= MAX_NONUNIFORMITY. The
bar, 0.7863, is the efficiency of the best two-level grating for a single row
of 7 beams (Zhou and Liu, Applied Optics 34(26), 5961 (1995), Table 1): the
7x7 array must be as efficient as the best 1x7 one. Crossing two 1x7 gratings
only gives 0.7863^2 = 0.6183, and pixel-flip simulated annealing on the 64x64
grid stops near 0.75 (about 5 core-hours tried in November 2026).
Expected submission: a JSON object with the single key "rows", a list of GRID
strings of GRID characters each, every character "0" (t = +1, phase 0) or
"1" (t = -1, phase pi). Character k of string j is pixel (j, k). For example,
for GRID = 4,
{"rows": ["0011", "0011", "1100", "1100"]}
What the verifier checks, in order:
1. The payload is a str of at most MAX_BYTES characters and is a JSON object
with exactly the key "rows", given once (a repeated key is rejected).
2. "rows" is a list of exactly GRID elements.
3. Every element is a string of exactly GRID characters, each of them the
ASCII character "0" or "1". Nothing else is accepted: no numbers, no
booleans, no nested lists, no whitespace, no other digits. Exactly two
transmission levels can therefore reach the computation.
4. The intensities of the (2*HALF+1)^2 central orders are computed as
described below, and all of them must be finite.
5. eta > MIN_EFFICIENCY + EPS.
6. max I + min I > 0 and u <= MAX_NONUNIFORMITY - EPS.
Numerical method and safety margin. For each order the pixel sum is first
reduced, in exact integer arithmetic, to
sum_{j,k} t[j][k] * w^(-(m j + n k)) = sum_{r=0}^{G-1} N[r] * w^(-r),
w = exp(2 pi i / G),
where N[r] is the (signed) number of pixels with (m j + n k) mod G = r. Only
the last step, G products of an exact integer with a tabulated cosine or sine
added with math.fsum, is floating point. Each tabulated value is within about
1e-16 of the true one and sum |N[r]| <= G^2, so the relative error of each
amplitude is below about 1e-15 of the full scale, the error of eta is below
1e-13 and the error of u is below 1e-12 for any pattern whose u is anywhere
near the threshold. The thresholds are applied with the margin EPS = 1e-9,
at least a thousand times larger than that error, and always against the
submission: a design is accepted only if eta exceeds MIN_EFFICIENCY by more
than EPS and u is at least EPS below MAX_NONUNIFORMITY. A design within EPS
of either threshold is rejected, whichever side it is on, so rounding can
never turn an invalid design into an accepted one. Comparisons are written
so that a NaN fails them.
Only the standard library is used; the result is deterministic and `rng` is
not used.
"""
import json
import math
# Number of pixels along each side of one period.
GRID = 64
# The beam array is the orders (m, n) with |m| <= HALF and |n| <= HALF.
HALF = 3
# The efficiency must exceed this value (by more than EPS).
MIN_EFFICIENCY = 0.7863
# The nonuniformity must be at most this value (minus EPS).
MAX_NONUNIFORMITY = 0.01
# Safety margin of both threshold tests, always applied against the submission.
EPS = 1e-9
# Maximum size of the whole submission, in characters. A compact submission
# is about 4,400 characters; this leaves room for indentation.
MAX_BYTES = 8_000
def _no_duplicate_keys(pairs):
"""Build a JSON object, refusing one that repeats a key."""
d = dict(pairs)
if len(d) != len(pairs):
raise ValueError
return d
def _load(solution, keys, max_bytes):
"""Parse the submission as a JSON object with exactly the given keys, or raise."""
# Refuse oversized payloads before handing them to the JSON parser.
if type(solution) is not str or len(solution) > max_bytes:
raise ValueError
d = json.loads(solution, object_pairs_hook=_no_duplicate_keys)
# It must be an object (not a list, string or number) whose keys are
# exactly the expected ones: nothing missing, nothing extra.
if type(d) is not dict or set(d) != set(keys):
raise ValueError
return d
def _grid(rows, g):
"""Return the g x g list of +1/-1 encoded by `rows`, or raise.
Sizes are checked before contents. Only str elements of length g made of
the two characters "0" and "1" pass.
"""
if type(rows) is not list or len(rows) != g:
raise ValueError
for row in rows:
if type(row) is not str or len(row) != g:
raise ValueError
t = []
for row in rows:
line = []
for ch in row:
if ch == "0":
line.append(1)
elif ch == "1":
line.append(-1)
else:
raise ValueError
t.append(line)
return t
def _sinc(x):
"""sin(pi x) / (pi x), with the value 1 at x = 0."""
if x == 0:
return 1.0
return math.sin(math.pi * x) / (math.pi * x)
def _intensities(t, g, half):
"""Intensities I[m][n] of the orders |m|, |n| <= half, as a flat list.
`t` is a g x g list of +1/-1. See the module docstring for the method.
"""
cos = [math.cos(2.0 * math.pi * r / g) for r in range(g)]
sin = [math.sin(2.0 * math.pi * r / g) for r in range(g)]
out = []
for m in range(-half, half + 1):
for n in range(-half, half + 1):
# Exact integer step: N[r] = signed count of pixels whose phase
# index (m j + n k) mod g equals r.
counts = [0] * g
for j in range(g):
row = t[j]
base = m * j
for k in range(g):
counts[(base + n * k) % g] += row[k]
# sum_r N[r] * exp(-2 pi i r / g), correctly rounded sums.
re = math.fsum(counts[r] * cos[r] for r in range(g))
im = -math.fsum(counts[r] * sin[r] for r in range(g))
scale = _sinc(m / g) * _sinc(n / g) / (g * g)
out.append((re * re + im * im) * scale * scale)
return out
def _metrics(t, g, half):
"""Return (efficiency, nonuniformity) of the pattern, or raise.
A pattern with a non-finite intensity or with max I + min I <= 0 has no
defined nonuniformity and raises.
"""
intensities = _intensities(t, g, half)
if not all(math.isfinite(x) for x in intensities):
raise ValueError
eta = math.fsum(intensities)
hi = max(intensities)
lo = min(intensities)
if not hi + lo > 0.0:
raise ValueError
return eta, (hi - lo) / (hi + lo)
def _check(solution):
# Steps 1-3: read the JSON object and the GRID x GRID two-level pattern.
sol = _load(solution, ("rows",), MAX_BYTES)
t = _grid(sol["rows"], GRID)
# Step 4: the central intensities and the two figures of merit.
eta, nonuniformity = _metrics(t, GRID, HALF)
# Steps 5-6: both thresholds, with the margin against the submission.
# Written so that a NaN on either side gives False.
if not eta > MIN_EFFICIENCY + EPS:
return False
if not nonuniformity <= MAX_NONUNIFORMITY - EPS:
return False
return True
def verify(solution: str, rng) -> bool:
"""Platform entry point: return True only for a valid, correct solution.
`rng` (a numpy.random.Generator) is part of the platform interface but is
not used: this check is deterministic. Any exception (malformed JSON, a bad
value, ...) means the submission is rejected, so this function never raises.
"""
try:
return _check(solution) is True
except Exception:
return False
Log in to submit a solution
Verified solutions (0)
No verified solution yet.
Order book
Price history
Comments (0)
No comments yet.