photonhub 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. photonhub-0.1.0/.gitignore +102 -0
  2. photonhub-0.1.0/LICENSE +201 -0
  3. photonhub-0.1.0/PKG-INFO +243 -0
  4. photonhub-0.1.0/README.md +181 -0
  5. photonhub-0.1.0/docs/img/sim_showcase.png +0 -0
  6. photonhub-0.1.0/photonhub/__init__.py +143 -0
  7. photonhub-0.1.0/photonhub/_env.py +46 -0
  8. photonhub-0.1.0/photonhub/_mcp_cli.py +25 -0
  9. photonhub-0.1.0/photonhub/_viz_cli.py +26 -0
  10. photonhub-0.1.0/photonhub/bundle.py +284 -0
  11. photonhub-0.1.0/photonhub/capabilities.py +105 -0
  12. photonhub-0.1.0/photonhub/components/__init__.py +94 -0
  13. photonhub-0.1.0/photonhub/components/_bounds.py +62 -0
  14. photonhub-0.1.0/photonhub/components/base.py +117 -0
  15. photonhub-0.1.0/photonhub/components/grid.py +1437 -0
  16. photonhub-0.1.0/photonhub/components/medium.py +30 -0
  17. photonhub-0.1.0/photonhub/components/monitors.py +367 -0
  18. photonhub-0.1.0/photonhub/components/run.py +56 -0
  19. photonhub-0.1.0/photonhub/components/simulation.py +1896 -0
  20. photonhub-0.1.0/photonhub/components/source_time.py +245 -0
  21. photonhub-0.1.0/photonhub/components/sources.py +491 -0
  22. photonhub-0.1.0/photonhub/components/structures.py +383 -0
  23. photonhub-0.1.0/photonhub/cost.py +292 -0
  24. photonhub-0.1.0/photonhub/data.py +969 -0
  25. photonhub-0.1.0/photonhub/executor/__init__.py +15 -0
  26. photonhub-0.1.0/photonhub/executor/__main__.py +48 -0
  27. photonhub-0.1.0/photonhub/executor/core.py +106 -0
  28. photonhub-0.1.0/photonhub/executor/handler.py +92 -0
  29. photonhub-0.1.0/photonhub/gds.py +416 -0
  30. photonhub-0.1.0/photonhub/hdf5.py +256 -0
  31. photonhub-0.1.0/photonhub/inverse_design.py +793 -0
  32. photonhub-0.1.0/photonhub/library.py +1017 -0
  33. photonhub-0.1.0/photonhub/materials.py +1309 -0
  34. photonhub-0.1.0/photonhub/mcp_server.py +106 -0
  35. photonhub-0.1.0/photonhub/plugins/__init__.py +229 -0
  36. photonhub-0.1.0/photonhub/plugins/_constants.py +56 -0
  37. photonhub-0.1.0/photonhub/plugins/cvcs.py +302 -0
  38. photonhub-0.1.0/photonhub/plugins/diffraction.py +505 -0
  39. photonhub-0.1.0/photonhub/plugins/eme.py +1719 -0
  40. photonhub-0.1.0/photonhub/plugins/eq_current_source.py +500 -0
  41. photonhub-0.1.0/photonhub/plugins/gaussian_beam.py +675 -0
  42. photonhub-0.1.0/photonhub/plugins/import_source.py +348 -0
  43. photonhub-0.1.0/photonhub/plugins/kfj_smoothing.py +429 -0
  44. photonhub-0.1.0/photonhub/plugins/mode_devices.py +1169 -0
  45. photonhub-0.1.0/photonhub/plugins/mode_overlap.py +1752 -0
  46. photonhub-0.1.0/photonhub/plugins/mode_tracking.py +268 -0
  47. photonhub-0.1.0/photonhub/plugins/modes.py +525 -0
  48. photonhub-0.1.0/photonhub/plugins/near_field.py +670 -0
  49. photonhub-0.1.0/photonhub/plugins/propagate.py +247 -0
  50. photonhub-0.1.0/photonhub/plugins/resonance.py +616 -0
  51. photonhub-0.1.0/photonhub/plugins/smatrix.py +461 -0
  52. photonhub-0.1.0/photonhub/plugins/smatrix_driver.py +628 -0
  53. photonhub-0.1.0/photonhub/plugins/spectral_completion.py +477 -0
  54. photonhub-0.1.0/photonhub/plugins/thin_lens.py +373 -0
  55. photonhub-0.1.0/photonhub/plugins/vector_modes.py +2329 -0
  56. photonhub-0.1.0/photonhub/plugins/waveguide.py +315 -0
  57. photonhub-0.1.0/photonhub/plugins/yee_mode.py +1385 -0
  58. photonhub-0.1.0/photonhub/release.py +852 -0
  59. photonhub-0.1.0/photonhub/replicate/__init__.py +66 -0
  60. photonhub-0.1.0/photonhub/replicate/build.py +568 -0
  61. photonhub-0.1.0/photonhub/replicate/convergence.py +246 -0
  62. photonhub-0.1.0/photonhub/replicate/driver.py +255 -0
  63. photonhub-0.1.0/photonhub/replicate/geometry.py +436 -0
  64. photonhub-0.1.0/photonhub/replicate/notebook.py +395 -0
  65. photonhub-0.1.0/photonhub/replicate/report.py +338 -0
  66. photonhub-0.1.0/photonhub/replicate/spec.py +386 -0
  67. photonhub-0.1.0/photonhub/runners/__init__.py +5 -0
  68. photonhub-0.1.0/photonhub/runners/batch.py +247 -0
  69. photonhub-0.1.0/photonhub/runners/local.py +129 -0
  70. photonhub-0.1.0/photonhub/runners/phsolver.py +492 -0
  71. photonhub-0.1.0/photonhub/runners/progress.py +168 -0
  72. photonhub-0.1.0/photonhub/schema.py +63 -0
  73. photonhub-0.1.0/photonhub/viz/__init__.py +30 -0
  74. photonhub-0.1.0/photonhub/viz/_geometry.py +337 -0
  75. photonhub-0.1.0/photonhub/viz/_style.py +330 -0
  76. photonhub-0.1.0/photonhub/viz/checks.py +373 -0
  77. photonhub-0.1.0/photonhub/viz/eps.py +392 -0
  78. photonhub-0.1.0/photonhub/viz/examples/README.md +86 -0
  79. photonhub-0.1.0/photonhub/viz/examples/fresnel_slab.sim.json +105 -0
  80. photonhub-0.1.0/photonhub/viz/examples/mode_converter.sim.json +68827 -0
  81. photonhub-0.1.0/photonhub/viz/field.py +277 -0
  82. photonhub-0.1.0/photonhub/viz/figures.py +295 -0
  83. photonhub-0.1.0/photonhub/viz/interactive.py +208 -0
  84. photonhub-0.1.0/photonhub/viz/ledger.py +1056 -0
  85. photonhub-0.1.0/photonhub/viz/mode.py +120 -0
  86. photonhub-0.1.0/photonhub/viz/notebook.py +785 -0
  87. photonhub-0.1.0/photonhub/viz/scene.py +92 -0
  88. photonhub-0.1.0/photonhub/viz/scene3d.py +709 -0
  89. photonhub-0.1.0/photonhub/viz/server.py +3623 -0
  90. photonhub-0.1.0/photonhub/viz/service.py +2591 -0
  91. photonhub-0.1.0/photonhub/viz/source.py +60 -0
  92. photonhub-0.1.0/photonhub/viz/spectrum.py +83 -0
  93. photonhub-0.1.0/photonhub/web/__init__.py +61 -0
  94. photonhub-0.1.0/photonhub/web/_ids.py +26 -0
  95. photonhub-0.1.0/photonhub/web/actions.py +202 -0
  96. photonhub-0.1.0/photonhub/web/batch.py +155 -0
  97. photonhub-0.1.0/photonhub/web/cache.py +231 -0
  98. photonhub-0.1.0/photonhub/web/client.py +352 -0
  99. photonhub-0.1.0/photonhub/web/config.py +222 -0
  100. photonhub-0.1.0/photonhub/web/run.py +300 -0
  101. photonhub-0.1.0/pyproject.toml +73 -0
  102. photonhub-0.1.0/tests/__init__.py +6 -0
  103. photonhub-0.1.0/tests/conftest.py +49 -0
  104. photonhub-0.1.0/tests/helpers.py +66 -0
  105. photonhub-0.1.0/tests/test_absorber.py +90 -0
  106. photonhub-0.1.0/tests/test_acceptance_gate.py +122 -0
  107. photonhub-0.1.0/tests/test_anisotropic_media.py +78 -0
  108. photonhub-0.1.0/tests/test_auto_mode_bank.py +208 -0
  109. photonhub-0.1.0/tests/test_automesh.py +1248 -0
  110. photonhub-0.1.0/tests/test_barwicz_full_filter.py +215 -0
  111. photonhub-0.1.0/tests/test_barwicz_microring.py +883 -0
  112. photonhub-0.1.0/tests/test_barwicz_notebook.py +125 -0
  113. photonhub-0.1.0/tests/test_batch.py +174 -0
  114. photonhub-0.1.0/tests/test_benchmark_run.py +145 -0
  115. photonhub-0.1.0/tests/test_beta_bootstrap.py +211 -0
  116. photonhub-0.1.0/tests/test_beta_workbench_smoke.py +228 -0
  117. photonhub-0.1.0/tests/test_capabilities.py +81 -0
  118. photonhub-0.1.0/tests/test_components_scoring.py +116 -0
  119. photonhub-0.1.0/tests/test_cosine_crossing.py +143 -0
  120. photonhub-0.1.0/tests/test_cost.py +194 -0
  121. photonhub-0.1.0/tests/test_custom_medium.py +111 -0
  122. photonhub-0.1.0/tests/test_cvcs.py +325 -0
  123. photonhub-0.1.0/tests/test_cw_pmc.py +64 -0
  124. photonhub-0.1.0/tests/test_data.py +518 -0
  125. photonhub-0.1.0/tests/test_desktop_beta_distribution_workflow.py +1270 -0
  126. photonhub-0.1.0/tests/test_desktop_beta_gcs_publish.py +1819 -0
  127. photonhub-0.1.0/tests/test_dft_quarter_snap.py +289 -0
  128. photonhub-0.1.0/tests/test_diffraction.py +444 -0
  129. photonhub-0.1.0/tests/test_eme.py +472 -0
  130. photonhub-0.1.0/tests/test_eme_accuracy_audit.py +276 -0
  131. photonhub-0.1.0/tests/test_eme_generalized.py +726 -0
  132. photonhub-0.1.0/tests/test_eme_radiation.py +597 -0
  133. photonhub-0.1.0/tests/test_eq_current_source.py +305 -0
  134. photonhub-0.1.0/tests/test_executor.py +102 -0
  135. photonhub-0.1.0/tests/test_gaussian_beam.py +547 -0
  136. photonhub-0.1.0/tests/test_gds.py +298 -0
  137. photonhub-0.1.0/tests/test_gds_export.py +118 -0
  138. photonhub-0.1.0/tests/test_geometry.py +211 -0
  139. photonhub-0.1.0/tests/test_graded_grid.py +234 -0
  140. photonhub-0.1.0/tests/test_graded_mode_stack.py +215 -0
  141. photonhub-0.1.0/tests/test_hdf5.py +370 -0
  142. photonhub-0.1.0/tests/test_import_source.py +196 -0
  143. photonhub-0.1.0/tests/test_interval_space.py +65 -0
  144. photonhub-0.1.0/tests/test_inverse_design.py +417 -0
  145. photonhub-0.1.0/tests/test_library.py +272 -0
  146. photonhub-0.1.0/tests/test_material_boundaries.py +331 -0
  147. photonhub-0.1.0/tests/test_materials.py +401 -0
  148. photonhub-0.1.0/tests/test_mcp_cli.py +106 -0
  149. photonhub-0.1.0/tests/test_metal_materials.py +65 -0
  150. photonhub-0.1.0/tests/test_mode_devices.py +434 -0
  151. photonhub-0.1.0/tests/test_mode_eps_anchor.py +270 -0
  152. photonhub-0.1.0/tests/test_mode_flux_commensurate.py +287 -0
  153. photonhub-0.1.0/tests/test_mode_launch.py +181 -0
  154. photonhub-0.1.0/tests/test_mode_overlap.py +745 -0
  155. photonhub-0.1.0/tests/test_mode_overlap_pair.py +481 -0
  156. photonhub-0.1.0/tests/test_mode_overlap_tidy3d.py +101 -0
  157. photonhub-0.1.0/tests/test_mode_source_broadband.py +206 -0
  158. photonhub-0.1.0/tests/test_mode_source_vector.py +377 -0
  159. photonhub-0.1.0/tests/test_mode_tracking.py +195 -0
  160. photonhub-0.1.0/tests/test_models.py +1353 -0
  161. photonhub-0.1.0/tests/test_modes_by_freq.py +107 -0
  162. photonhub-0.1.0/tests/test_modesolver.py +296 -0
  163. photonhub-0.1.0/tests/test_multi_pole_media.py +146 -0
  164. photonhub-0.1.0/tests/test_multimode_monitor.py +545 -0
  165. photonhub-0.1.0/tests/test_near_field.py +442 -0
  166. photonhub-0.1.0/tests/test_oblique_bloch.py +91 -0
  167. photonhub-0.1.0/tests/test_paid_cloud_quotes.py +156 -0
  168. photonhub-0.1.0/tests/test_pole_fit.py +94 -0
  169. photonhub-0.1.0/tests/test_progress.py +113 -0
  170. photonhub-0.1.0/tests/test_propagate.py +158 -0
  171. photonhub-0.1.0/tests/test_release.py +362 -0
  172. photonhub-0.1.0/tests/test_replicate_build.py +132 -0
  173. photonhub-0.1.0/tests/test_replicate_convergence.py +142 -0
  174. photonhub-0.1.0/tests/test_replicate_integration.py +65 -0
  175. photonhub-0.1.0/tests/test_replicate_metalens.py +89 -0
  176. photonhub-0.1.0/tests/test_replicate_nanobeam.py +97 -0
  177. photonhub-0.1.0/tests/test_replicate_notebook.py +73 -0
  178. photonhub-0.1.0/tests/test_replicate_report.py +167 -0
  179. photonhub-0.1.0/tests/test_replicate_spec.py +100 -0
  180. photonhub-0.1.0/tests/test_replicate_yjunction.py +113 -0
  181. photonhub-0.1.0/tests/test_resonance.py +369 -0
  182. photonhub-0.1.0/tests/test_roundtrip.py +215 -0
  183. photonhub-0.1.0/tests/test_run_ledger.py +928 -0
  184. photonhub-0.1.0/tests/test_run_local.py +440 -0
  185. photonhub-0.1.0/tests/test_runpod_mi300x_gate.py +1140 -0
  186. photonhub-0.1.0/tests/test_schema.py +172 -0
  187. photonhub-0.1.0/tests/test_simulation_files.py +87 -0
  188. photonhub-0.1.0/tests/test_smatrix.py +476 -0
  189. photonhub-0.1.0/tests/test_smatrix_driver.py +376 -0
  190. photonhub-0.1.0/tests/test_solver_image_contract.py +472 -0
  191. photonhub-0.1.0/tests/test_source_time_tuning.py +220 -0
  192. photonhub-0.1.0/tests/test_spectral_completion.py +335 -0
  193. photonhub-0.1.0/tests/test_subpixel.py +160 -0
  194. photonhub-0.1.0/tests/test_symmetry.py +97 -0
  195. photonhub-0.1.0/tests/test_tfsf_box.py +51 -0
  196. photonhub-0.1.0/tests/test_thin_lens.py +143 -0
  197. photonhub-0.1.0/tests/test_vector_modesolver.py +506 -0
  198. photonhub-0.1.0/tests/test_viz.py +1253 -0
  199. photonhub-0.1.0/tests/test_viz_boot_revision.py +31 -0
  200. photonhub-0.1.0/tests/test_viz_checks.py +510 -0
  201. photonhub-0.1.0/tests/test_viz_cloud_workbench.py +995 -0
  202. photonhub-0.1.0/tests/test_viz_gds_import.py +214 -0
  203. photonhub-0.1.0/tests/test_viz_modal_ports.py +1067 -0
  204. photonhub-0.1.0/tests/test_viz_notebook.py +404 -0
  205. photonhub-0.1.0/tests/test_viz_patch_specs.py +76 -0
  206. photonhub-0.1.0/tests/test_viz_security.py +268 -0
  207. photonhub-0.1.0/tests/test_viz_workbench.py +1990 -0
  208. photonhub-0.1.0/tests/test_waveguide.py +128 -0
  209. photonhub-0.1.0/tests/test_web.py +1567 -0
  210. photonhub-0.1.0/tests/test_yee_eme_basis.py +399 -0
  211. photonhub-0.1.0/tests/test_yee_hardwall_benchmark.py +75 -0
  212. photonhub-0.1.0/tests/test_yee_kfj_modes.py +158 -0
  213. photonhub-0.1.0/tests/test_yee_mode.py +158 -0
  214. photonhub-0.1.0/tests/test_yee_native_overlap.py +152 -0
  215. photonhub-0.1.0/tests/test_yee_port_modes.py +183 -0
  216. photonhub-0.1.0/tests/test_yee_symmetry.py +295 -0
@@ -0,0 +1,102 @@
1
+ # Build trees
2
+ build/
3
+ build-*/
4
+ !desktop/electron/build-hooks/
5
+ cmake-build-*/
6
+
7
+ # desktop viz dev: local result bundle generated for testing serve-viz
8
+ .devbundle/
9
+
10
+ # Native desktop packaging outputs and downloaded/frozen toolchains. The
11
+ # packaging recipes, locks, and verifier remain committed under this directory.
12
+ /desktop/packaging/.cache/
13
+ /desktop/packaging/.work/
14
+ /desktop/packaging/artifacts/
15
+ /desktop/packaging/dist/
16
+ /desktop/packaging/stage/
17
+
18
+ # Documentation site build output. docs-site/build.sh renders into
19
+ # website/docs/ so the existing leapfield Firebase site serves it at
20
+ # /docs; the rendered HTML is generated and never committed.
21
+ website/docs/
22
+
23
+ # Python
24
+ .venv/
25
+ venv/
26
+ __pycache__/
27
+ *.py[cod]
28
+ *.egg-info/
29
+ dist/
30
+ .pytest_cache/
31
+ .ruff_cache/
32
+
33
+ # Outputs / artifacts
34
+ out/
35
+ *.bin
36
+ *.hdf5
37
+ *.h5
38
+ benchmarks/results/local/
39
+ # generated acceptance reports (per-component PDF + npz + run log); CPU run ->
40
+ # reports/, a --device gpu run -> reports_gpu/. Regenerated by make_reports.py.
41
+ benchmarks/acceptance/reports/
42
+ benchmarks/acceptance/reports_*/
43
+ # Rented-GPU session bundles (tools/gpu_session.sh); scp home, commit only the
44
+ # results/*.jsonl under benchmarks/results/, never the raw logs/tarballs.
45
+ artifacts/
46
+
47
+ # Editors / OS
48
+ .DS_Store
49
+ .idea/
50
+ .vscode/
51
+ *.swp
52
+
53
+ # Claude scratch
54
+ .claude/*.local.json
55
+ /.claude/launch.json
56
+ /.claude/worktrees/
57
+
58
+ # Local agent/worktree state (never part of the product source tree)
59
+ /.codex/
60
+ /.worktrees/
61
+
62
+ # Local paper library and duplicate presentation export
63
+ /literature/
64
+ /*.pdf
65
+ /presentation/PhotonHub Intro.html
66
+
67
+ # benchmark run artifacts
68
+ benchmarks/waveguide/results.npz
69
+ # Component benchmark raw runs (sim.json echo + manifest + monitor .bin DFT
70
+ # fields): reproducible, gitignored. The curated sim/ph.json, results/*.json,
71
+ # compare.json and compare.png ARE committed.
72
+ benchmarks/components/*/run/
73
+ # GDS-import benchmark raw runs (same convention as components/); the curated
74
+ # gds/, sim/ph.json, results/ph_cpu.json, spectrum.png ARE committed.
75
+ benchmarks/gds/*/run/
76
+ # Raw field arrays (reproducible from a run); the field_z0.png / field_gpu25.png
77
+ # viz IS committed.
78
+ benchmarks/gds/*/results/*.npz
79
+ # §16.6 subpixel A/B/C sims + results (off/diagonal/full off-diagonal tensor):
80
+ # regenerated by gen_subpixel_compare.py / make_gpu_report.py, so gitignored.
81
+ benchmarks/gds/*/sim/ph_gpu25_nd_*.json
82
+ benchmarks/gds/*/results/ph_gpu25_nd_*.json
83
+ # CPU subpixel A/B/C run logs (transient); the report .json + .pdf ARE committed.
84
+ benchmarks/gds/report/cpu_run*.log
85
+ # Subpixel convergence benchmark raw outputs (reproducible from the script); the
86
+ # script + README + convergence.png ARE committed.
87
+ benchmarks/subpixel/results.json
88
+ benchmarks/subpixel/run.log
89
+
90
+ # Bent-mode Tidy3D reference: user-generated (needs an API key) + its preview.
91
+ # subpixel-parity run logs (transient); the .json/.md/.png ARE committed.
92
+ benchmarks/tidy3d/refs/*/subpixel_parity_run.log
93
+ # The PhotonHub side (refs/bent_modes/photonhub.json) IS committed.
94
+ benchmarks/tidy3d/refs/bent_modes/tidy3d.json
95
+ benchmarks/tidy3d/refs/bent_modes/tidy3d_crosssection.png
96
+ # co-location comparison run log (transient); the .json/.pdf ARE committed.
97
+ benchmarks/gds/report/colocation_run.log
98
+ .devrun/
99
+
100
+ # Local review/render scratch (never product source or evidence)
101
+ /tmp/
102
+ website/.firebase/
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Zhetao J.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,243 @@
1
+ Metadata-Version: 2.5
2
+ Name: photonhub
3
+ Version: 0.1.0
4
+ Summary: Python client for the PhotonHub GPU FDTD photonics solver
5
+ Project-URL: Homepage, https://leapfield.app/
6
+ Project-URL: Repository, https://github.com/Leapfield/photonhub-sdk
7
+ Project-URL: Beta access and support, https://leapfield.app/#request
8
+ Author: LeapField
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: FDTD,electromagnetics,photonics,simulation
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Topic :: Scientific/Engineering :: Physics
18
+ Requires-Python: >=3.11
19
+ Requires-Dist: certifi
20
+ Requires-Dist: matplotlib
21
+ Requires-Dist: numpy
22
+ Requires-Dist: pydantic>=2.6
23
+ Requires-Dist: scipy
24
+ Requires-Dist: xarray
25
+ Provides-Extra: app
26
+ Requires-Dist: fastapi; extra == 'app'
27
+ Requires-Dist: gdstk; extra == 'app'
28
+ Requires-Dist: h5py; extra == 'app'
29
+ Requires-Dist: mcp<2,>=1; extra == 'app'
30
+ Requires-Dist: plotly; extra == 'app'
31
+ Requires-Dist: uvicorn; extra == 'app'
32
+ Provides-Extra: gds
33
+ Requires-Dist: gdstk; extra == 'gds'
34
+ Provides-Extra: hdf5
35
+ Requires-Dist: h5py; extra == 'hdf5'
36
+ Provides-Extra: mcp
37
+ Requires-Dist: mcp<2,>=1; extra == 'mcp'
38
+ Provides-Extra: notebook
39
+ Requires-Dist: nbformat; extra == 'notebook'
40
+ Provides-Extra: replicate
41
+ Requires-Dist: pyyaml; extra == 'replicate'
42
+ Provides-Extra: server
43
+ Requires-Dist: fastapi; extra == 'server'
44
+ Requires-Dist: uvicorn; extra == 'server'
45
+ Provides-Extra: test
46
+ Requires-Dist: fastapi; extra == 'test'
47
+ Requires-Dist: gdstk; extra == 'test'
48
+ Requires-Dist: h5py; extra == 'test'
49
+ Requires-Dist: httpx; extra == 'test'
50
+ Requires-Dist: ipywidgets; extra == 'test'
51
+ Requires-Dist: mcp<2,>=1; extra == 'test'
52
+ Requires-Dist: nbformat; extra == 'test'
53
+ Requires-Dist: plotly; extra == 'test'
54
+ Requires-Dist: pytest; extra == 'test'
55
+ Requires-Dist: pyyaml; extra == 'test'
56
+ Requires-Dist: ruff; extra == 'test'
57
+ Requires-Dist: uvicorn; extra == 'test'
58
+ Provides-Extra: viz
59
+ Requires-Dist: ipywidgets; extra == 'viz'
60
+ Requires-Dist: plotly; extra == 'viz'
61
+ Description-Content-Type: text/markdown
62
+
63
+ # photonhub
64
+
65
+ Python client for the PhotonHub FDTD solver. The pydantic models in
66
+ `photonhub.components` are the single source of truth for the simulation
67
+ JSON wire format; the published simulation schema is generated from them via
68
+ `python -m photonhub.schema emit`.
69
+
70
+ ## Install
71
+
72
+ Python 3.11+:
73
+
74
+ ```sh
75
+ python -m pip install "photonhub @ git+https://github.com/Leapfield/photonhub-sdk"
76
+ ```
77
+
78
+ (From a monorepo checkout: `python -m pip install ./photonhub`.)
79
+
80
+ That installs the full scripting client: build simulations, estimate cost,
81
+ run on the **cloud GPU** (`ph.web.run(sim)` with your beta API key), and read
82
+ results — no compiler, no engine build. **Local** runs (`ph.run_local`) also
83
+ need the `phsolver` engine binary, which pip does not ship: the desktop
84
+ Workbench install bundles one (point `$PHOTONHUB_SOLVER` at it or put it on
85
+ `PATH`), and developers with the monorepo build it with
86
+ `cmake -S engine -B build && cmake --build build`.
87
+
88
+ Optional extras: `photonhub[viz]` (interactive/3D plots), `[gds]` (GDSII
89
+ import/export), `[hdf5]` (HDF5 result export), `[replicate]`, `[notebook]`,
90
+ and the service extras below.
91
+
92
+ ```python
93
+ import photonhub as ph
94
+
95
+ sim = ph.Simulation(
96
+ size_um=(4.0, 4.0, 4.0),
97
+ grid=ph.UniformGridSpec(dl_um=0.05),
98
+ run=ph.RunSpec(run_time_s=8.0e-14),
99
+ sources=[
100
+ ph.PointDipole(
101
+ center_um=(2.0, 2.0, 2.0),
102
+ polarization="Ez",
103
+ source_time=ph.GaussianPulse(freq0_hz=1.934e14, fwidth_hz=4.0e13),
104
+ )
105
+ ],
106
+ monitors=[
107
+ ph.FieldTimeMonitor(name="probe", center_um=(3.0, 2.0, 2.0), fields=["Ez"]),
108
+ ph.FieldSnapshotMonitor(name="final", fields=["Ex", "Ey", "Ez"]),
109
+ ],
110
+ )
111
+
112
+ data = ph.run_local(sim) # finds phsolver, runs it, parses outputs
113
+ probe = data["probe"] # xarray.DataArray, dims ('t', 'component')
114
+ ```
115
+
116
+ Optional command-line services are kept out of the base SDK dependency set:
117
+
118
+ ```sh
119
+ python -m pip install 'photonhub[mcp]'
120
+ photonhub-mcp # optionally pass a result directory to preload
121
+
122
+ python -m pip install 'photonhub[server]'
123
+ photonhub-serve-viz # local result/preview HTTP service
124
+ ```
125
+
126
+ The `photonhub[app]` extra includes both service dependency sets plus the
127
+ Workbench file-format integrations.
128
+
129
+ ## See your simulation before you run it
130
+
131
+ Every `Simulation` plots itself — geometry, sources, monitors, PML, and the
132
+ **permittivity the solver actually meshes** — with matplotlib (built in; plotly
133
+ for 3D). `grid=True` overlays the Yee cell edges so you can check resolution:
134
+
135
+ ```python
136
+ sim.plot(z=0.11) # scene cross-section
137
+ sim.plot_eps(z=0.11, grid=True) # rasterized ε + the Yee mesh overlay
138
+ sim.plot_3d() # interactive 3D (pip install photonhub[viz])
139
+ ```
140
+
141
+ ## What you can do today
142
+
143
+ Shipped surface as of schema **v1.20.0-alpha.1** (validated dispersive solver
144
+ core — multi-pole Lorentz + Drude ADE with a fitted metals library (Au/Ag/Cu/Al)
145
+ and PEC structures, with recorded MI300X CPU↔GPU equivalence for the pre-1.18
146
+ surface under the numerical contract's tolerances — plus full-vector mode
147
+ injection, GDS import (`ph.import_gds`), adjoint gradients, and the silicon-PIC
148
+ MVP):
149
+
150
+ - **Run a simulation:** `ph.run_local(sim)` (subprocess + file protocol;
151
+ `device="cpu"|"gpu"|"gpu:N"`), `ph.run_async(sim)` and `ph.Batch(...)` for many
152
+ sims in flight.
153
+ - **Know the cost first:** `sim.cost_estimate()` (or `ph.estimate_cost(sim)`)
154
+ returns a dollar estimate
155
+ from an overridable Tcell-step planning rate *before* you press run; the
156
+ default is an estimator input, not a production billing commitment.
157
+ - **Geometry:** `Box`, `Sphere`, `Cylinder` (full, or an annular sector / ring
158
+ via `inner_radius_um` + `angle_start` / `angle_stop`), and `PolySlab` (an
159
+ extruded polygon — e.g. a taper).
160
+ - **Sources:** `PointDipole`, `PlaneWave` (normal-incidence TF/SF; oblique
161
+ via `Simulation.with_oblique_plane_wave` + Bloch boundaries, schema 1.18),
162
+ the closed `TfsfBox` scattering box (single-run cross-sections with PML on
163
+ all sides), and the recommended `mode_launch` waveguide-mode builder — all
164
+ driven by a `GaussianPulse` or a steady-state `CW` carrier. The
165
+ `ModeSource` wire type remains for legacy scalar and continuous-adjoint
166
+ compatibility.
167
+ - **Monitors:** `FieldTimeMonitor`, `FieldSnapshotMonitor`, `FieldDftMonitor`,
168
+ and `FluxMonitor` — fp64 DFT field and flux power. A DFT plane may carry the
169
+ optional `ModePort` authoring recipe; the engine strictly validates and then
170
+ ignores that metadata while recording the same raw fields, and result
171
+ post-processing performs the requested modal projection. Workbench keeps one
172
+ shared wavelength sweep across ports; port planes/windows stay outside
173
+ PML/absorber cells; and preflight requires one downstream driven port linked
174
+ to the first wire-order normalization source with no other active excitation,
175
+ so an unevaluable S-column is rejected before the time-domain run.
176
+ - **Component library:** `ph.library.straight / bend / taper / crossing /
177
+ coupler / ring` — each returns a `Component` (structures + ports) in ~one line.
178
+ - **Material library:** `ph.materials` — 16 literature materials (cSi, SiO2,
179
+ Si3N4, GaAs, InP, Ge, LiNbO3, sapphire, AlN, TiO2, MgF2, CaF2, PMMA, ...)
180
+ with cited dispersion data and validity ranges. `cSi.medium(1.55)` freezes
181
+ the index at one wavelength; `cSi.medium(band_um=(1.5, 1.6))` least-squares
182
+ fits the engine's single Lorentz pole over the band (Courant-safe pole
183
+ placement, ≤1e-4 index error over 100 nm). Bring measured ellipsometry data
184
+ via `materials.Material.from_nk_data(...)`.
185
+ - **Mode-resolved transmission:** the recommended `photonhub.plugins` pipeline —
186
+ `solve_yee_mode` → `mode_launch` → `mode_monitor` →
187
+ `transmission(out, in, data)` — returns `{freq_hz: T}`. Use
188
+ `solve_yee_mode_bank` / `solve_modes_by_freq` for a broadband launch and readout;
189
+ the legacy `ModeSolver` / `mode_source` path remains for scalar and adjoint
190
+ compatibility. Full complex multiport S-matrices:
191
+ `plugins.smatrix` (`SPort` + `assemble_smatrix`, one run per driven port —
192
+ the analogue of Tidy3D's ComponentModeler).
193
+ - **Meshing:** `UniformGridSpec`, or `GradedGridSpec` + `auto_grid` for a
194
+ cells-per-λ graded mesh; `MeshOverride` (Tidy3D `MeshOverrideStructure`) forces
195
+ a target spacing inside a geometry regardless of material —
196
+ `sim.with_mesh_overrides(MeshOverride(geometry=Box(...), dl_um=(0.02,0.02,None)))`.
197
+ Graded meshes run on CPU, single GPU, and multi-GPU with PML/absorber,
198
+ dispersive media, DFT/flux monitors, and plane-wave/mode sources. The one
199
+ unsupported combination is graded + `subpixel_method="tensor_full"`.
200
+ - **Mode solving:** the FDE plugins provide the lightweight semi-vectorial
201
+ `ModeSolver` and the full-vector `VectorModeSolver`, including bent/leaky
202
+ modes with complex `n_eff` and bend-loss readout.
203
+ - **Visualization:** `Simulation.plot` / `plot_eps` (draws Box / Sphere /
204
+ Cylinder / PolySlab; `grid=True` overlays the Yee mesh) / `plot_3d`,
205
+ `SimulationData.plot_field`, and the module-level `photonhub.viz.plot_mode`
206
+ (FDE mode heatmap) and `photonhub.viz.plot_spectrum` (`T` vs λ).
207
+ - **Export:** HDF5 converter for the parsed results.
208
+ - **Correctness aids:** pydantic models reject structural errors at
209
+ construction, the capability manifest catches client/engine drift, and
210
+ `phsolver validate` is authoritative for grid/device constraints. Subpixel
211
+ smoothing supports Box / Sphere / Cylinder / PolySlab; non-dispersive scenes
212
+ default to contour smoothing, while dispersive scenes default off unless the
213
+ user opts in.
214
+
215
+ ### Limits (today)
216
+
217
+ This is a validated **dispersive** solver core plus the silicon-PIC MVP:
218
+
219
+ - Dispersion is **multi-pole ADE** — up to 6 Lorentz + Drude poles per medium
220
+ (metals/plasmonics; numerical definition in `engine/NUMERICS.md` §19; the
221
+ single-pole paths are in the recorded MI300X equivalence suite under §8
222
+ tolerances, the multi-pole/Drude scenes await their first hardware run) on
223
+ top of relative permittivity + Ohmic conductivity; a passivity-enforced
224
+ CCPR fitter and anisotropic poles are still open. Explicit
225
+ subpixel + Lorentz runs are supported and equivalence-tested, but the client
226
+ keeps their construction default off and warns callers to use the stabilized
227
+ PML profile.
228
+ - S-matrix assembly (`plugins.smatrix`) costs **one simulation per driven
229
+ port** — there is no single-run multiport solve.
230
+
231
+ Net: shapes go in and **mode-resolved transmission** comes out — solve the
232
+ eigenmode, inject it with `mode_launch`, ratio two `mode_monitor` planes, and plot
233
+ `T(λ)`; or assemble the full S-matrix with `plugins.smatrix`.
234
+
235
+ ## Learn more
236
+
237
+ - **[API documentation and guides](https://leapfield.app/docs/)** — the full reference for
238
+ every public symbol in this package, plus install and quickstart guides.
239
+ - [PhotonHub product overview](https://leapfield.app/#product)
240
+ - [Request beta access or support](https://leapfield.app/#request)
241
+
242
+ The project source tree also includes an end-to-end quickstart, examples index,
243
+ and **twenty-six-notebook** gallery.