LumericalFDTD Analysis logo

LumericalFDTD Analysis

Community
Lex669
LumericalFDTD-analysis

分析 Ansys Lumerical FDTD 仿真结果 — 读取.npz数据、计算光学指标、生成发表级图表。当你需要分析FDTD结果、绘制场分布图、计算透射率/衍射效率时使用此skill。 Analyze Ansys Lumerical FDTD simulation results — load .npz data, compute optical metrics, generate publication-quality figures. Use when analyzing FDTD results, plotting field distributions, computing transmission/diffraction efficiency.

Overview

PublisherLex669
RepositoryLumericalFDTD-skill
Skill nameLumericalFDTD-analysis
Stars
45
Forks
5
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by Lex669 on GitHub. Read the source before you install it.

Installation

Install the LumericalFDTD Analysis AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Lex669/LumericalFDTD-skill/tree/main/skills/LumericalFDTD-analysis
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Lex669/LumericalFDTD-skill.git /tmp/LumericalFDTD-skill
mkdir -p .claude/skills
cp -r /tmp/LumericalFDTD-skill/skills/LumericalFDTD-analysis .claude/skills/LumericalFDTD-analysis
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable LumericalFDTD Analysis in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads LumericalFDTD Analysis on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so LumericalFDTD Analysis is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

FDTD 数据分析器

职责范围

本 skill 仅负责数据分析与可视化阶段:读取 .npz 数据、计算光学指标、绘制图表、验证验收条件。输出 .png 图表文件。

不负责:结构建模(→ LumericalFDTD-modeling)、仿真执行(→ LumericalFDTD-simulation)、端到端全流程(→ LumericalFDTD)。

前置条件

.npz 数据文件必须已存在于 data/ 目录。若不存在,先运行仿真。

工作流

1. 确认数据可用

bash
ls path/to/project/data/
# 确认 results.npz 等文件存在

2. 编写分析脚本

按模板生成 *_analysis.py(纯数据分析,不调 lumapi.FDTD)。

每次运行分析脚本必须新建独立的 run 子目录保存图表(pic/<label>_run_<NN>/),禁止直接写入 pic/ 根目录。下方模板内嵌的 new_run_dir() 辅助函数及调用必须完整保留,不得删除或改写;label 需按本次仿真内容填写(规则见「图表归档约定」)。

python
import os
import glob
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

def new_run_dir(pic_dir, label):
    """本次运行的图表目录 pic/<label>_run_<NN>(NN 自动递增,从 01 起补零)"""
    n = 0
    for d in glob.glob(os.path.join(pic_dir, label + "_run_*")):
        suffix = os.path.basename(d)[len(label) + 5:]  # 去掉 "<label>_run_" 前缀
        if suffix.isdigit():
            n = max(n, int(suffix))
    run_dir = os.path.join(pic_dir, f"{label}_run_{n + 1:02d}")
    os.makedirs(run_dir, exist_ok=True)
    return run_dir

# label = 本次仿真内容的 1-3 个区分关键词(snake_case,如 glass_gaussian / si_planewave_1550nm)
pic_dir = os.path.join(project_dir, "pic")
run_dir = new_run_dir(pic_dir, "glass_gaussian")

# 加载数据
data = np.load(os.path.join(data_dir, "results.npz"), allow_pickle=True)
E = data["E"]
T = data["T"]
wavelengths = data["wavelengths"]
# ...

# 计算指标
transmission = np.abs(T)**2
# ...

# 绘图
fig, ax = plt.subplots(figsize=(8, 5))
ax.plot(wavelengths * 1e6, transmission)
ax.set_xlabel("Wavelength (μm)")
ax.set_ylabel("Transmission")
ax.set_title("Transmission Spectrum")
fig.savefig(os.path.join(run_dir, "transmission.png"), dpi=150)
plt.close()

3. 运行分析脚本

bash
& 'PYTHON_PATH' 'path/to/project_analysis.py'

分析脚本秒级完成,可反复执行迭代图表样式;每次运行都会在 pic/ 下新建一个递增序号的 run 子目录,历史图表自动保留、不会被覆盖,最新一版在序号最大(NN 最大)的目录中。

4. 验证结果

进入最新 run 子目录(NN 最大者,如 pic/glass_gaussian_run_02/),检查其中的 .png 图表是否满足验收条件:

验收维度检查项
透射率峰值/谷值在预期波长?数值合理(0-1)?
场分布模式图样是否符合物理预期?
衍射图案Airy 环是否可见?中央亮斑尺寸是否符合 r₁ = 1.22λL/D?
图表质量坐标轴标注、单位、图例是否齐全?分辨率是否足够?

图表归档约定(必须遵守)

  1. 每次运行一个目录:运行分析脚本即新建 pic/<label>_run_<NN>/ 子目录,所有图表保存其中。子目录内保留固定文件名(transmission.png、field.png 等)不再改动——由目录区分内容与版本。禁止直接 savefig 到 pic/ 根目录。本文件「常用分析类型」中的代码片段仅为绘图逻辑,成文脚本必须补 plt.savefig(os.path.join(run_dir, "xxx.png"), dpi=150)。
  2. 标签由内容生成:若用户未指定标签,由模型根据本次仿真内容取 1–3 个最具区分度的关键词——材料(glass/si)、光源类型(gaussian/planewave)、短关键参数(1550nm),用下划线连接,如 glass_gaussian。默认小写 ASCII snake_case(仅字母/数字/下划线,无空格无标点),保证跨平台兼容;用户偏好中文标签(如 玻璃_高斯)亦可。同一内容的后续运行复用同一标签。
  3. 序号自动递增:NN 从 01 起两位补零;同标签第 N 次运行取 pic/<label>_run_* 中最大序号 + 1——由 new_run_dir() 自动扫描完成,禁止人工猜测序号。判断"最新运行"一律以最大 NN 为准(数值比较,勿用字符串排序)。

常用分析类型

透射/反射谱

python
T = fdtd.getresult("monitor", "T")
plt.plot(wavelengths * 1e6, np.abs(T)**2)
plt.xlabel("Wavelength (μm)")
plt.ylabel("Transmission")

近场/远场分布

python
E = np.abs(Ex**2 + Ey**2 + Ez**2)  # |E|^2 intensity
I_1d = np.sum(I, axis=1)           # Quasi-2D: 沿 y 求和 -> 1D profile
plt.plot(x * 1e6, I_1d / I_1d.max())

衍射效率

python
P_total = np.sum(I, axis=(0, 1, 2))
P_central = np.sum(I_central_region, axis=(0, 1, 2))
efficiency = P_central / P_total

宽带波长索引

python
# 频率线性递增 → 波长递减
wl_short_idx = n_freq - 1   # 最短波长(高频端)
wl_long_idx = 0              # 最长波长(低频端)

输出

  • *_analysis.py — 分析脚本(可反复迭代)
  • pic/<label>_run_<NN>/ — 每次运行一个子目录,内含固定名图表(transmission.png、field.png 等,dpi ≥ 150)
  • 可选:更新 REPORT.md — 结果摘要和图表说明,注明本次图表的 run 目录(如 pic/glass_gaussian_run_02/)

参考文档

参考文件何时读取
../LumericalFDTD/references/building-blocks.md结果提取语法、数据形状、宽带波长索引细节
../LumericalFDTD/references/diffraction.md衍射效率计算、远场投影

Frequently asked questions

What does the LumericalFDTD Analysis AI skill do?

分析 Ansys Lumerical FDTD 仿真结果 — 读取.npz数据、计算光学指标、生成发表级图表。当你需要分析FDTD结果、绘制场分布图、计算透射率/衍射效率时使用此skill。 Analyze Ansys Lumerical FDTD simulation results — load .npz data, compute optical metrics, generate publication-quality figures. Use when analyzing FDTD results, plotting field distributions, computing transmission/diffraction efficiency.

Why use LumericalFDTD Analysis on TypingMind?

Because you install it once and use it with any model. LumericalFDTD Analysis is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install LumericalFDTD Analysis in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Lex669/LumericalFDTD-skill/tree/main/skills/LumericalFDTD-analysis. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use LumericalFDTD Analysis?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with LumericalFDTD Analysis?

As many as you like. As long as a model supports skills, you can use LumericalFDTD Analysis with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the LumericalFDTD Analysis AI skill free?

Yes. It is published on GitHub by Lex669 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇