$npx -y skills add svd-ai-lab/sim-plugin-comsol --skill comsolUse when the user asks Codex, Claude Code, ChatGPT-style coding agents, or another AI agent to build, inspect, run, debug, or revise COMSOL Multiphysics / COMSOL Desktop models. Choose the simplest real COMSOL control path for the task: saved .mph inspection, local COMSOL docum
| 1 | # comsol-sim |
| 2 | |
| 3 | This file is the **COMSOL Multiphysics** agent workflow index. Its job is to |
| 4 | help an agent choose and execute the most reliable real COMSOL control path for |
| 5 | the task: saved `.mph` inspection, local COMSOL documentation, direct COMSOL |
| 6 | executables, a server-backed Java API session, or the sim COMSOL runtime when |
| 7 | that adds useful structure. |
| 8 | |
| 9 | This skill is self-contained for COMSOL work. Do not require a separate skill |
| 10 | checkout or an external sim-cli skill. Use this file for COMSOL workflow |
| 11 | routing, and load the plugin-bundled references below only when the task needs |
| 12 | them. |
| 13 | |
| 14 | --- |
| 15 | |
| 16 | ## COMSOL-specific layered content |
| 17 | |
| 18 | Choose the control path from the task and the current COMSOL state. Identify |
| 19 | whether you have a saved `.mph`, a standalone Desktop, an `mphclient` connected |
| 20 | to `comsolmphserver`, an external `comsolmphserver`, or no running session. |
| 21 | Then pick the smallest path that can produce real evidence. |
| 22 | |
| 23 | | Path | Use it for | Evidence to collect | |
| 24 | |---|---|---| |
| 25 | | saved `.mph` inspection | Offline summaries, archive diffs, parameters, physics tags, mesh/solution metadata, and artifact review without starting COMSOL. | `inspect_mph(path)`, `MphArchive`, or `mph_diff` output. | |
| 26 | | local COMSOL docs | Unknown physics feature names, module capability, property names, examples, and API terms before writing code. | `sim-comsol-doc search` / `retrieve` hits from the installed COMSOL help tree. | |
| 27 | | direct `comsolbatch -inputfile` | Running a saved model headlessly, stripping solutions with `-norun`, regression/CI/fan-out over `.mph` files, and one-shot saved-model output artifacts. | output `.mph`, `-batchlog`, shell exit status, and extracted KPIs/artifacts. | |
| 28 | | `comsolcompile` + `comsolbatch` | Settled Java recipes that build, solve, and extract KPIs in a fresh COMSOL process. | compiled class, batch log/stdout KPI lines, output `.mph` or exported data. | |
| 29 | | `comsolmphserver` / Java API | Stateful model exploration, live property/tag probing, incremental mutation, debugging, and API work where the agent needs to ask the live model questions. | model tags/properties, run/build results, saved checkpoints, and explicit model identity. | |
| 30 | | sim runtime / shared Desktop | The same server-backed Java API work when the plugin's structured `inspect`/`exec`/checkpoint tools or managed visible Model Builder collaboration are useful. | `session.health`, `comsol.model.identity`, `last.result`, live binding checks, checkpoints. | |
| 31 | |
| 32 | If the user already has a `comsolmphserver` plus `comsol.exe mphclient -host |
| 33 | ... -port ...` Desktop open with the target model loaded, attach the agent |
| 34 | without launching another Desktop client: |
| 35 | |
| 36 | ```powershell |
| 37 | uv run sim connect --solver comsol --ui-mode no_gui ` |
| 38 | --driver-option attach_only=true ` |
| 39 | --driver-option port=<port> |
| 40 | ``` |
| 41 | |
| 42 | Then verify model tags and binding through `session.health`/`ModelUtil.tags()`. |
| 43 | Use `visual_mode=shared-desktop` only when the plugin should launch or manage |
| 44 | the visible Desktop client. |
| 45 | |
| 46 | For the `comsolcompile` path, Java code needs chain-style |
| 47 | `model.X("tag").Y("tag2")...` calls. There is no public `Component`, |
| 48 | `Geometry`, `HeatTransfer`, etc. type; writing `Component comp = ...` |
| 49 | gets `cannot be resolved to a type` from `comsolcompile`. Read |
| 50 | [`base/reference/java_batch_patterns.md`](base/reference/java_batch_patterns.md) |
| 51 | before writing a batch `.java`. |
| 52 | |
| 53 | ### Choosing between live session and batch |
| 54 | |
| 55 | These are not either/or - they compose. The natural arc is **explore live -> solidify -> graduate to batch**: |
| 56 | |
| 57 | 1. **Explore live.** Use local docs, saved `.mph` inspection, or a |
| 58 | server-backed Java API session to discover model shape, tags, properties, |
| 59 | and module behavior. |
| 60 | 2. **Solidify.** Once the workflow is settled and known-good, capture it as a |
| 61 | batch `.java` file (`comsolcompile` + `comsolbatch`) or, for a saved model, |
| 62 | a `comsolbatch -inputfile` run. |
| 63 | 3. **Graduate to batch.** Run the captured recipe headless for |
| 64 | reproducible/CI/fan-out execution — fresh process each run, no session-state |
| 65 | drift, no `comsolmphserver` lifecycle, parallelizable across cases. |
| 66 | |
| 67 | Quick test: if you still need to *ask the live model questions*, stay in a |
| 68 | session. If you are *executing a recipe you already trust*, run it as batch. |
| 69 | |
| 70 | For the sim runtime, use `uv run sim check comsol` when `sim-cli` is available, |
| 71 | then `uv run sim connect --solver comsol`, then inspect `session.h |