Skip to content

Keep the input phase in the modulator field, optional input phase compensation - #104

Merged
seb5g merged 1 commit into
5.3.xfrom
feature/input-phase
Nov 22, 2026
Merged

seb5g merged 1 commit into
5.3.xfrom
feature/input-phase

Conversation

@seb5g

@seb5g seb5g commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Closes #98. Decisions taken in the question table https://claude.ai/artifact/5umN3yU1phRbV8bJpad4dh.

What changes

  • Modulator field = input field × SLM field. set_phase_in_modulator_plane(phase) takes the SLM phase (wrapped, quantised, crosstalk applied to it alone) and the modulator phase becomes input phase + SLM phase. The SLM field never holds the input phase. The initial phase is an SLM phase.
  • Back-propagation: back_propagate_amplitude (Gerchberg-Saxton, Projections) removes the input phase from the back-propagated phase (slm_phase_from_modulator_phase), so the loops see the true input field.
  • Binary holograms: SLM phase 0, modulator phase = input phase (was forced to 0).
  • New checkbox Compensate input phase in the Input Compensation group (default on), shown when ALGOTYPE is not AMPLITUDE (can_compensate_input_phase): Direct, Binary Threshold, Parallel Lee, Superpixel, OL2014 encode target_phase() = target phase − input phase when it is on. Headless: set_compensate_input_phase(app, bool).
  • Torch based algorithms: optimise the SLM phase, with the input phase in the forward model. Untested (no torch in the test environment).
  • Docs: a Fields and planes section (table of the fields and their data names, figure) and Compensations of the input beam (amplitude list and phase checkbox), with a note on the behaviour change.

Behaviour change

Results change for any input beam whose phase is not flat. A flat input phase gives the previous results.

Tests

tests/test_input_phase.py (11 tests, written first): modulator phase = input + SLM; GS with a curved input gives an output equal to the propagation of input × SLM field and converges as well as with a flat input; initial phase on top of the input phase; binary hologram keeps the input phase; checkbox offered per ALGOTYPE; compensation = encoding target − input phase with a flat input (Lee, Superpixel, Threshold, OL2014); Direct; AlgoApp visibility. Two existing tests now compare the SLM phase with the modulator phase minus the input phase, modulo 2π. Full local suite: 215 passed before that test update, the 3 failures being those comparisons; the two touched files pass (30).


Generated by Claude Code

… the input phase (#98)

The modulator field is the input field times the SLM field: its phase is the input phase plus the SLM phase, the
SLM field never holds the input phase. Back-propagated phases go through slm_phase_from_modulator_phase. The
algorithms controlling the output phase (ALGOTYPE not AMPLITUDE) encode target_phase(): minus the input phase when
the new checkbox 'Compensate input phase' (Input Compensation group, default on) is checked. Docs: fields and planes
table, compensations of the input beam.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKuN83BLrbGKe3ynHHvZQm
@seb5g
seb5g merged commit 28bb776 into 5.3.x Nov 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep the phase of the input beam in the modulator field

2 participants