Optimize MATLAB-driven Lumerical FDTD simulations in workspaces that use Wcli geometry/helper classes, existing .fsp/.lsf interfaces, and result monitors saved to MAT/CSV files. Use when Codex needs to inspect a new Wcli-based photonics workspace, copy and adapt a driver script instead of editing shared Wcli libraries, run and debug parameter sweeps, resume interrupted scans, extract the best monitor value, and generate Markdown/HTML reports with plots.
Use this skill for Wcli-based MATLAB + Lumerical FDTD projects where the workspace already contains shared geometry helpers such as Wcli_wg, Wcli_poly, or Wcli_circuit, plus an existing .fsp / .lsf interface that should stay stable.
Default behavior:
Wcli_* MATLAB files and existing .fsp / .lsf interfaces as shared infrastructure.fullfile, mfilename('fullpath'), and explicit executable paths.Markdown and HTML reports only. Do not generate PDF unless the user explicitly asks.Read references/workspace-adaptation.md before changing a new workspace. Read before generating plots or reports.
Identify:
Wcli_wg.m, Wcli_poly.m, Wcli_circuit.m..fsp, .lsf, and MAT handoff files.Use rg, sed, and MATLAB/terminal inspection to confirm:
basic.mat, T_list, T_net, monitor tables, CSV rows, etc.).Create a new optimizer-focused script by copying the current main driver. Keep the shared workflow recognizable.
Preserve:
.fsp / .lsf interface expectations.Avoid:
Wcli_* shared libraries unless explicitly requested.When adapting older Windows-era scripts:
fullfile.mfilename('fullpath').Use the current workspace’s own para / fdtd_data structures instead of inventing a new interface.
Typical structure:
Keep candidate generation generic:
Always support interrupted runs.
The optimizer should:
When a run crosses calendar days, avoid silently switching to a new date directory if the user expects resume behavior. Add an explicit run_date or run_root option when necessary.
Do not assume the monitor structure from memory alone. Confirm it in the saved files.
Typical checks:
T_list?If the user wants “the best result,” record at minimum:
Always smoke-test the copied optimizer before launching a large search.
Recommended order:
basic.mat and the expected monitor data are produced.If the search later fails:
Produce:
all_results.csvbest_result_summary.matoptimization_log.txt*.md report*.html reportKeep the report focused on:
Use imagesc for 2D sweeps rather than MATLAB heatmap when you need full style control.
For report-quality figures:
imagesc + explicit axes styling for 2D optimization maps.Avoid overloading tables with long absolute paths. Move file paths into a short “File links” subsection using relative links.
See references/reporting.md for the detailed plotting and reporting checklist.
Unless the user asks otherwise, keep this output pattern:
sim* or sim_<variant>_*optimization_report*Markdown and HTMLIf the user asks for a reusable report generator, create a separate script that:
all_results.csvbest_result_summary.matmd/html reports without rerunning FDTD