Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
66d75ab
initial fdtd
vvahidd Jan 20, 2026
23c3a0d
Merge main into fdtd, preferring main for conflicts
vvahidd Jan 25, 2026
636c293
Merge branch 'main' into fdtd
vvahidd Feb 11, 2026
4643c68
feat: add gsim.meep module, extract common viz/geometry, remove fdtd
vvahidd Feb 12, 2026
9636320
chore: add meep-sim-* to gitignore, minor lint fixes
vvahidd Feb 12, 2026
39a6de5
feat: add 2D overlay visualization, margin config, and expanded meep …
vvahidd Feb 13, 2026
8a44870
feat: add z-crop, replace run_time_factor with until_after_sources
vvahidd Feb 13, 2026
407f51c
feat: replace MarginConfig with DomainConfig, add dielectric backgrou…
vvahidd Feb 13, 2026
03aea3b
feat: add symmetry, decay stopping, and performance optimizations
vvahidd Feb 14, 2026
d3f0343
update
vvahidd Feb 14, 2026
4a8b764
fix: layer draw order and alpha for PDKs with uniform mesh_order
vvahidd Feb 14, 2026
40c8259
fix: S-parameter extraction accuracy and local test automation
vvahidd Feb 14, 2026
768b3dd
feat: add AccuracyConfig for subpixel averaging, polygon simplificati…
vvahidd Feb 14, 2026
c57c1f7
feat: add dft_decay stopping mode and fix decay time cap
vvahidd Feb 14, 2026
682917e
fix: reduce port_margin default to 0.5 and add eigenmode debug logging
vvahidd Feb 14, 2026
dc10c70
feat: add server-side diagnostics and preview-only mode
vvahidd Feb 15, 2026
a40ceb4
feat: add field animation (MP4 + per-frame PNGs) during FDTD time-ste…
vvahidd Feb 15, 2026
620c9e9
refactor: separate set_wavelength into set_source and set_stopping
vvahidd Feb 15, 2026
43cc457
fix: default dft_min_run_time to 100 and remove deprecated set_wavele…
vvahidd Feb 15, 2026
37c80ea
update test-meep notebook to match generate_meep_config.py and make r…
vvahidd Feb 15, 2026
33aeab5
refactor: clean up gsim.meep — remove dead code, DRY patterns, type S…
vvahidd Feb 15, 2026
4e8e15e
fix: improve animation frame plots — smaller figsize, matched colorba…
vvahidd Feb 15, 2026
18224d5
fix: add --shm-size=1g to Docker run to prevent UCX/MPI segfault
vvahidd Feb 15, 2026
8b4c1bd
feat: auto-compute meep_np from problem size
vvahidd Feb 15, 2026
763cb5d
refactor: rename API for physicist-friendly naming (Step 1, JSON unch…
vvahidd Feb 15, 2026
b4f87eb
feat: add declarative meep.Simulation API with typed physics objects
vvahidd Feb 16, 2026
e327559
refactor: delete ModeMonitor, move spectral window onto ModeSource
vvahidd Feb 16, 2026
6faafe5
chore: slim down test-meep notebook, use attribute style consistently
vvahidd Feb 16, 2026
55d0500
refactor: remove legacy MeepSim API, add direct viz pipeline
vvahidd Feb 16, 2026
8f934c8
refactor: replace print() with logging in gsim.meep
vvahidd Feb 16, 2026
2d9df72
update notebook
vvahidd Feb 16, 2026
2062148
refactor: extract build_config() as single source of truth for meep sim
vvahidd Feb 16, 2026
2ef226a
chore: rename test-meep notebook, add to docs, fix concave mesh rende…
vvahidd Feb 16, 2026
52bd73f
refactor: flatten stopping variants into flat FDTD fields
vvahidd Feb 16, 2026
a3bc4b7
chore: add ubcpdk to docs dependencies for notebook builds
vvahidd Feb 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Simulation outputs
sim-data-*/
palace-sim-*/
meep-sim-*/

# files
*.c
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ nav:
- home: index.md
- examples:
- Simple Example: nbs/example.md
- MEEP Y-Branch: nbs/meep_ybranch.md
- Palace CPW: nbs/palace_demo_cpw.md
- Palace Microstrip: nbs/palace_demo_microstrip.md
- api reference:
Expand Down
155 changes: 155 additions & 0 deletions nbs/meep_ybranch.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "0",
"metadata": {},
"source": [
"# Running MEEP Simulations\n",
"\n",
"[MEEP](https://meep.readthedocs.io/) is an open-source FDTD electromagnetic simulator. This notebook demonstrates using the `gsim.meep` API to run an S-parameter simulation on a photonic Y-branch.\n",
"\n",
"**Requirements:**\n",
"\n",
"- UBC PDK: `uv pip install ubcpdk`\n",
"- [GDSFactory+](https://gdsfactory.com) account for cloud simulation"
]
},
{
"cell_type": "markdown",
"id": "1",
"metadata": {},
"source": [
"### Load a pcell from UBC PDK"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"from ubcpdk import PDK, cells\n",
"\n",
"PDK.activate()\n",
"\n",
"c = cells.ebeam_y_1550()\n",
"c"
]
},
{
"cell_type": "markdown",
"id": "3",
"metadata": {},
"source": [
"### Configure and run simulation"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4",
"metadata": {},
"outputs": [],
"source": [
"from gsim import meep\n",
"\n",
"sim = meep.Simulation()\n",
"\n",
"sim.geometry.component = c\n",
"sim.geometry.z_crop = \"auto\"\n",
"\n",
"sim.materials = {\"si\": 3.47, \"SiO2\": 1.44}\n",
"\n",
"sim.source.port = \"o1\"\n",
"sim.source.wavelength = 1.55\n",
"sim.source.bandwidth = 0.01\n",
"sim.source.num_freqs = 11\n",
"\n",
"sim.monitors = [\"o1\", \"o2\", \"o3\"]\n",
"\n",
"sim.domain.pml = 1.0\n",
"sim.domain.margin = 0.5\n",
"sim.domain.margin_z_above = 0.5\n",
"sim.domain.margin_z_below = 0.5\n",
"sim.domain.port_margin = 0.5\n",
"\n",
"sim.solver.resolution = 20\n",
"sim.solver.stopping = \"dft_decay\"\n",
"sim.solver.max_time = 200\n",
"sim.solver.stopping_threshold = 1e-3\n",
"sim.solver.stopping_min_time = 100\n",
"sim.solver.subpixel = False\n",
"sim.solver.simplify_tol = 0.01\n",
"sim.solver.save_geometry = True\n",
"sim.solver.save_fields = True\n",
"sim.solver.save_animation = True\n",
"sim.solver.verbose_interval = 5.0\n",
"\n",
"print(sim.validate_config())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5",
"metadata": {},
"outputs": [],
"source": [
"sim.plot_2d(slices=\"xyz\")"
]
},
{
"cell_type": "markdown",
"id": "6",
"metadata": {},
"source": [
"### Run simulation on cloud"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7",
"metadata": {},
"outputs": [],
"source": [
"# Run on GDSFactory+ cloud\n",
"result = sim.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8",
"metadata": {},
"outputs": [],
"source": [
"result.plot(db=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"metadata": {},
"outputs": [],
"source": [
"result.show_animation()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
42 changes: 41 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ dev = [
"ty>=0.0.13"
]
docs = [
"ihp-gdsfactory>=0.1.4"
"ihp-gdsfactory>=0.1.4",
"ubcpdk @ git+https://github.com/gdsfactory/ubc.git"
]

[[tool.bver.file]]
Expand All @@ -72,6 +73,9 @@ src = "src/gsim/__init__.py"
[tool.bver.git]
commit-template = "Release {new-version}"

[tool.codespell]
ignore-words-list = "doubleclick"

[tool.mypy]
mypy_path = ["src"]
python_version = "3.12"
Expand All @@ -92,6 +96,16 @@ disallow_untyped_defs = false
module = "gsim.palace.*"
warn_return_any = false

[[tool.mypy.overrides]]
check_untyped_defs = false
disable_error_code = ["no-untyped-def", "no-untyped-call", "var-annotated", "assignment"]
disallow_any_generics = false
disallow_untyped_defs = false
# The MEEP subpackage wraps cloud-only MEEP simulation. Relaxed mypy
# to match the Palace approach during early development.
module = "gsim.meep.*"
warn_return_any = false

[[tool.mypy.overrides]]
ignore_errors = true
module = "tests.*"
Expand Down Expand Up @@ -198,6 +212,11 @@ select = ["ALL"]
"INP001", # implicit-namespace-package
"PERF401" # use-list-extend (keeping for readability)
]
"nbs/*.py" = [
"EXE001", # shebang-present-but-not-executable
"INP001", # implicit-namespace-package
"T201" # print (natural in scripts)
]
"scripts/*.py" = [
"ANN", # flake8-annotations
"ARG001", # unused-function-argument
Expand All @@ -220,6 +239,7 @@ select = ["ALL"]
"PLC0415", # allow imports inside tests
"PT011", # pytest-raises-too-broad
"S101", # assert
"SLF001", # private-member-access (testing internal state)
"T201" # print
]

Expand All @@ -228,3 +248,23 @@ convention = "google"

[tool.setuptools.packages.find]
where = ["src"]

[tool.ty.analysis]
# Optional runtime dependencies that are not always installed locally
allowed-unresolved-imports = ["open3d", "open3d.**", "meep", "meep.**"]

[[tool.ty.overrides]]
include = ["tests/**"]

[tool.ty.overrides.rules]
possibly-missing-attribute = "ignore"

[tool.ty.rules]
missing-argument = "ignore"
possibly-missing-attribute = "ignore"
# Suppress rules that generate many false-positives in this codebase
# (optional deps, third-party stubs, matplotlib Axes|None, etc.)
unused-ignore-comment = "ignore"

[tool.ty.src]
include = ["src"]
1 change: 1 addition & 0 deletions src/gsim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Currently includes:
- palace: Palace EM simulation API
- meep: MEEP photonic FDTD simulation API
"""

from __future__ import annotations
Expand Down
4 changes: 4 additions & 0 deletions src/gsim/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from __future__ import annotations

from gsim.common.geometry import Geometry
from gsim.common.geometry_model import GeometryModel, Prism, extract_geometry_model
from gsim.common.stack import (
MATERIALS_DB,
Layer,
Expand All @@ -37,13 +38,16 @@
__all__ = [
"MATERIALS_DB",
"Geometry",
"GeometryModel",
"Layer",
"LayerStack",
"MaterialProperties",
"Prism",
"Stack",
"StackLayer",
"ValidationResult",
"extract_from_pdk",
"extract_geometry_model",
"extract_layer_stack",
"get_material_properties",
"get_stack",
Expand Down
Loading
Loading