Skip to content

Add example for phase extraction from Rayleigh coefficients#97

Open
jhpark94 wants to merge 2 commits intokc-ml2:mainfrom
jhpark94:docs/phase-extraction-example
Open

Add example for phase extraction from Rayleigh coefficients#97
jhpark94 wants to merge 2 commits intokc-ml2:mainfrom
jhpark94:docs/phase-extraction-example

Conversation

@jhpark94
Copy link
Copy Markdown

@jhpark94 jhpark94 commented Mar 28, 2026

Summary

  • Adds examples/phase_extraction.py demonstrating how to extract reflection/transmission phase from conv_solve() results
  • Shows the access pattern: result.res.R_s for complex Rayleigh coefficients
  • Documents correct array indexing for 1D gratings: R_s[0, fto]
  • Includes phase vs thickness sweep as a practical use case

Motivation

The tutorial (01-modeling-and-emsolver.ipynb) lists R_s, R_p, T_s, T_p as attributes but does not explain that these are complex-valued or show how to extract phase from them. Phase information is critical for metasurface design and wavefront engineering.

Test plan

  • Example runs without errors
  • |r0|^2 matches de_ri (consistency check)
  • Phase values are physically reasonable

🤖 Generated with Claude Code

Juho Park and others added 2 commits March 27, 2026 21:22
conv_solve() returns complex Rayleigh coefficients (R_s, R_p, T_s, T_p)
that carry phase information, but this is not shown in existing examples.

This example demonstrates:
- Accessing result.res.R_s for complex reflection amplitude
- Extracting phase with np.angle()
- Correct array indexing for 1D gratings: R_s[0, fto]
- Phase variation with grating thickness

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Currently, accessing complex reflection/transmission amplitudes
requires result.res.R_s. This adds top-level properties so users
can write result.R_s directly, consistent with existing result.de_ri.

Changes:
- ResultNumpy, ResultTorch, ResultJax: add R_s, R_p, T_s, T_p properties
- examples/phase_extraction.py: demonstrate usage with result.R_s

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant