Tidy3D for VS Code
Build, visualize, and iterate on Tidy3D FDTD simulations right in Visual Studio Code. The extension discovers simulations in Python files and notebooks, opens a 3D viewer next to your code, and (after setup) lets Copilot Chat use the bundled Tidy3D MCP server for contextual docs and examples.
Highlights
- Editor‑native 3D viewer – open simulations alongside your code and see updates as you tweak parameters.
- One‑step setup – register the bundled MCP server, import FlexAgent rules, and connect the latest docs.
- Shareable insights – capture screenshots, toggle structures, or let Copilot control the viewer.
Prerequisites
- Visual Studio Code 1.99.3 or newer.
- Python extension enabled for notebooks and Python files.
- Flexcompute Tidy3D account with an API key: tidy3d.simulation.cloud/account?tab=apikey.
- You don’t need a local Python setup to view simulations. If you plan to execute notebook cells, enable the Python extension and select an interpreter as usual.
- Internet access for the first‑time download of viewer assets and runtimes.
Install the extension
- Open Visual Studio Code and go to the Extensions view (
View → Extensions ).
- Search for Tidy3D by Flexcompute and select Install. Listing: Visual Studio Marketplace.
- Confirm the Python extension is enabled. Restart VS Code if prompted.
Connect your Tidy3D account
- Open the workspace that holds your notebooks or Python scripts.
- Run
Cmd/Ctrl+Shift+P → Tidy3D: Run Tidy3D Workspace Setup (or accept the prompt).
- When asked, paste your API key. The key is stored in your VS Code settings and can be rotated later from the Tidy3D settings panel.
- Setup registers the bundled MCP server, writes FlexAgent rules under
.github/instructions/ , and validates connectivity before enabling the viewer.
Optional: prepare your Python environment (for notebooks)
- Create or select a virtual environment for your notebooks (venv, conda, poetry, rye, hatch, etc.).
- Install the basics:
tidy3d , jupyter (or jupyterlab ), numpy .
- Example with
uv :
- Install uv from the official guide.
- Define dependencies in
pyproject.toml .
- Run
uv sync .
Quickstart notebook
- Download the official Quickstart: StartHere.ipynb.
- Open it in VS Code. If you plan to execute notebook cells, select your Python environment; the viewer itself does not require one.
- Add or open a cell that defines a simulation (e.g.,
td.Simulation(...) ). Detection is automatic; you do not need to execute the cell for the viewer to pick it up.
- Open the viewer via any of:
- Status bar “Tidy3D: N simulations” entry (click)
- Command Palette:
Tidy3D: Open Tidy3D
- Python editor context menu (for
.py files)
- Pick a simulation in the quick pick and explore fields. Edits to code or notebook cells update the viewer automatically.
Work with Copilot
- Ask Copilot to “Validate my Tidy3D simulation” to open the viewer, check mesh quality, and flag configuration issues.
- Explore field slices, materials, or sources while Copilot steers the viewer for you.
- Request design alternatives; Copilot can edit notebooks, rerun simulations, and keep the viewer synced.
Enable Copilot Chat instructions
After you run “Tidy3D: Run Tidy3D Workspace Setup”, the extension drops instruction files under .github/instructions/ .
- In VS Code Settings, enable or verify:
github.copilot.chat.codeGeneration.useInstructionFiles .
- This lets Copilot Chat automatically use the workspace instructions in chat. You can confirm by sending a chat message and expanding “References” to see the loaded instruction files.
Example prompts
- Learn the method – “Explain how FDTD in Tidy3D updates the fields in this notebook.”
- API look‑up – “Find the Tidy3D API for a GaussianBeam source and add it.”
- Troubleshoot – “The run failed with a boundary condition error. Diagnose and fix it.”
- Optimize – “Sweep the waveguide width and plot transmission for each run.”
Commands
Tidy3D: Open Tidy3D (tidy3d.openViewer ) – Command Palette, Python editor context menu (.py), or status bar.
Tidy3D: Run Tidy3D Workspace Setup (tidy3d.installWorkspaceSetup ) – Command Palette.
Settings
tidy3d.apiKey (default: empty) – API key for MCP authentication (workspace‑scoped).
tidy3d.pythonVersion (default: 3.12 ) – Python version used by the built‑in runtime.
tidy3d.viewer.remoteUrl (default: https://tidy3d.simulation.cloud/simulation-viewer ) – Remote viewer UI.
tidy3d.viewer.tidyVersion (default: empty) – Override Tidy3D Python package version used by the viewer.
tidy3d.screenshotsDir (default: reports/.tidy3d-screenshots ) – Folder for viewer screenshots.
tidy3d.viewerBridge.port (default: 0 ) – 0 chooses a free port; set a fixed port to allow external clients.
tidy3d.viewerBridge.bindAddress (default: 127.0.0.1 ) – Interface the local viewer bridge binds to.
tidy3d.mcp.remoteUrl (advanced) – Base URL for the Flexcompute MCP service.
tidy3d.mcp.runCommand (advanced) – Custom command to launch the MCP server; standard args are appended automatically.
tidy3d.mcp.enableViewer (default: true ) – Enables viewer tooling when launching the MCP server.
Privacy and network usage
- First run downloads the Python runtime and viewer bundles; later sessions reuse cached artifacts.
- Simulation data stays local to your VS Code session. Network access is used for extension updates, static viewer assets, and the remote viewer UI when used.
Troubleshooting
- No simulations detected – ensure a variable receives
td.Simulation(...) (or another supported solver type) in the active file.
- Workspace setup missing – confirm the Python extension is active and the file uses the
python language mode.
- Slow first run – wait for initial downloads; you’ll see “Tidy3D Kernel: ready” in the status bar when ready.
- Viewer cannot connect – verify your API key and outbound access to
tidy3d.simulation.cloud .
License
Proprietary – Flexcompute Inc.
| |