femm
An MCP server that lets an AI agent drive FEMM 5 end-to-end: build and solve models, run physics experiments, validate results, and generate reports.
Manage FEMM sessions: check installation, open/list/close headless or GUI engines, run self-tests.
Create, open, save, and define FEMM documents for magnetics, electrostatics, heat flow, and current flow.
Draw and edit geometry: nodes, segments, arcs, rectangles, circles, polygons, selections, moves, copies, mirrors, scaling, groups, and DXF import/export.
Work with materials and properties: search/load FEMM materials, add custom materials and B-H curves, set block labels, boundaries, circuits, conductors, and point properties.
Mesh and solve models, including smart mesh settings and solution loading.
Post-process results: point values, line/block integrals, circuit results, air-gap results, field statistics, mesh arrays, field plots, and bitmap screenshots.
Run experiments: force vs position, torque vs angle, cogging, back-EMF, inductance/Ld-Lq, AC sweeps, parametric studies, and magnet operating-point checks.
Validate physics with health checks, analytic estimates, unit conversions, and consistency rules.
Access FEMM documentation and command catalog, including API search, manual sections, examples, and verified FEMM 5 facts.
Script FEMM directly with raw commands, MicroPython evaluation/scripts, Lua scripts, journals, and standalone pyFEMM export.
Generate and compare reports, and parse FEMM model/solution files offline.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@femm Build a C-core actuator with a 1 mm gap and 200 turns at 2 A; solve and report pull force."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
FEMM Agent Suite
Let an AI agent build, solve, sweep and verify FEMM 5 models in magnetics, electrostatics, heat flow and current flow, and show you the physics checks that prove each number.
Contents: What you can ask · Why this exists · Install · Tool groups · Skills · Video tour · Architecture · Validation · FEMM 5 facts you will hit · Python API · Development · Licence · Acknowledgement
What you can ask
Build a planar C-core actuator with a 1 mm gap, 200 turns at 2 A and a 20 mm stack, solve it, and tell me the gap flux density and the pull force. Check both against hand calculations.
Here is my 12-slot / 4-pole surface-PM motor. Run cogging torque by rotating the rotor and again with the air-gap element, and tell me whether the two agree.
Open-circuit back-EMF at 1000 rpm, Ld and Lq, and the mean torque at iq = 10 A. Is the torque consistent with 3/2 p psi iq?
Sweep a round copper conductor from 1 Hz to 10 kHz and compare R(f) with the Bessel solution. Does the input power match the losses?
This FEMM 4.2 Lua script uses "M-19 Steel" and "NdFeB 32 MGOe". Run it on FEMM 5, port it to Python, and tell me which materials changed.
The agent uses the MCP tools and the skill family below. Every tool answers with
{"ok", "result" | "error": {"message", "hint"}, "session", "seconds"}, errors carry the next
action as a hint, and the skills teach the agent to back each number with a health check and an
analytic estimate before calling it a result. The server enforces the last part too: a solve
returns checked: false with the exact femm_health_check(...) call to make next, health checks
roll up into one verdict (PASS / CHECK / FAIL), femm_estimate(..., fem_value=) grades a FEM
number against its formula, and femm_report lists its doubts. Clients without skills call
femm_guide; femm_doctor (or python -m femm_agent --doctor) diagnoses the install.
Related MCP server: Magnetics SME MCP Server
Why this exists
FEMM is the finite element program a generation of engineers learned magnetics with. FEMM 5 (femm-qt, by David Meeker) is the first FEMM with cross-platform scripting: a Qt build for Windows, macOS and Linux, a headless engine, and a plain TCP protocol that any language can speak, with MicroPython inside the engine instead of Lua 4.
An agent still cannot just "call FEMM". It needs:
validated building blocks: tools that put arguments in the right order for each physics (the 12-argument
mi_addboundprop, the frequency that moves position betweenmi_probdefandci_probdef), save before analysing, handle stateful selections, and turn every FEMM error into an actionable hint;physics checks: energy and coenergy identities, force and torque by two methods, AC power balance, flux conservation, saturation, boundary distance, magnet operating points, plus 25 closed-form estimates to compare against;
a catalog: all 677 FEMM 5 scripting commands with arguments, return values and code tables, the four material libraries, and a record of FEMM 5 behaviour verified live.
This suite is meant as the golden-standard library a future finite element workflow can build on: an MCP server with 91 tools, a pure-Python engineering layer (health rules, estimates, experiments, file parser), and eleven Claude skills that teach the agent how a FEMM user works and when not to trust a number.
Install
Requirements: FEMM 5.0 (build 06oct2026 or newer), Python 3.10 or newer, and Claude Code or any MCP client. FEMM itself is not bundled.
Windows
git clone https://github.com/Zwl20085/femm-agent-suite
cd femm-agent-suite
.\scripts\install.ps1 # venv + package, MCP server "femm", the 11 skills
.\scripts\install.ps1 -FemmDir "D:\femm-qt\bin" # if FEMM is not in a default locationmacOS / Linux
git clone https://github.com/Zwl20085/femm-agent-suite
cd femm-agent-suite
./scripts/install.sh # same steps
FEMM_DIR=~/.local/opt/femm-qt/bin ./scripts/install.shRestart Claude Code and ask: run the FEMM self-test. It solves an axisymmetric thick solenoid and compares the centre field with the closed form (0.7 % on build 06oct2026), and checks materials, units, bulk getters and circuits.
Plugin (the plugin starts the server with uv):
/plugin marketplace add Zwl20085/femm-agent-suite
/plugin install femm@femm-agent-suiteManual registration with any Python 3.10+ that has the package installed
(pip install -e . in the clone):
claude mcp add femm -- <python> -m femm_agent
claude mcp add femm -e FEMM_DIR=/path/to/femm-qt/bin -- <python> -m femm_agentCopy .claude/skills/* to ~/.claude/skills/ to install the skills by hand.
Other MCP clients (stdio):
{"mcpServers": {"femm": {"command": "<python>", "args": ["-m", "femm_agent"],
"env": {"FEMM_DIR": "C:/femm-qt/bin"}}}}The console script femm-mcp is the same server.
Variable | Meaning | Default |
| FEMM 5 bin folder (holding | auto: |
| root of the per-session work dirs (models, arrays, plots, reports) |
|
Tool groups
91 tools in 12 groups. One line per tool: .claude/skills/femm/references/tool-map.md.
Group | Tools | Headline tools |
session | 7 |
|
document | 7 |
|
geometry | 18 |
|
properties | 10 |
|
materials | 6 |
|
mesh and solve | 4 |
|
post-processing | 10 |
|
scripting | 6 |
|
docs | 6 |
|
experiments | 9 |
|
health | 3 |
|
report | 5 |
|
Anything without a curated tool is one femm_call away; the call is checked against the
677-command catalog first.
Skills
Eleven skills in .claude/skills/. The router femm is the entry point and
states the safety rules; each specialised skill has references/ for depth.
Skill | Use it for |
| Start here: which skill next, safety rules, tool map, FEMM 5 vs 4.2, self-check tasks |
| The core loop for magnetostatic and AC problems: boundaries, the air-gap element recipe, circuits, the feedback ladder |
| The other three physics: probdef, conductors, boundary types, point-value layouts, integral codes |
| Drawing, selection by coordinates, groups, copy/rotate for slots and poles, DXF, symmetry, meshing failures |
| Library search, the FEMM 4.2 rename map, B-H curves, magnets, laminations, MS/m vs S/m |
| Force vs position, torque vs angle, cogging by two routes, back-EMF, Ld/Lq, AC sweep, parametric, magnet operating point |
| Every health rule, its tolerance, the 25 estimates, how to report PASS / FAIL / CHECK |
| Point values, block and line integral codes, bulk arrays, field statistics, plots, reports, comparisons |
|
|
| Slot/pole choice, winding factor, magnet load line, Carter, dq torque, and a parametrised SPM model in one call |
| Every error hint, engine and port problems, GUI vs headless, results that look wrong |
Video tour
A 109-second narrated introduction to the suite: the problem, the architecture, an agent building and proving a 12-slot / 4-pole motor, the validation table, the skills and the install.
Architecture
MCP client (Claude Code, ...)
| stdio
v
femm_agent.server ---- 12 tool groups, 91 tools, envelope {ok, result | error{message, hint}}
|-- sessions.py named FEMM engines: port, pid, physics, open document, solved flag, work dir
| `-- ipc.py FemmLink: TCP 127.0.0.1, one MicroPython line per request, reply parsing,
| timeouts, journal of every line sent (no pyFEMM import needed)
|-- catalog.py data/commands.json: 677 commands, arguments, returns, code tables
|-- materials.py data/materials/*.json + the installed .dat libraries, 4.2 rename map
|-- experiments.py force-position, torque-angle, cogging, back-EMF (+ experiments_sweeps.py:
| inductance / L(I), AC sweep, parametric; preflight.py: groups, circuits, sectors)
|-- health.py pure physics invariants (unit tested) diagnostics.py live health check
|-- estimate.py 25 closed-form references (+ estimate_meta.py: unit, assumptions, tolerance, verdict)
|-- guide.py / doctor.py skills for skill-less clients, environment diagnosis units.py conversions
|-- benchmarks.py validated models: ccore, coilgun, spm, round_wire
`-- femfile.py, plotting.py, reporting.py file parser, field maps, Markdown reports
|
v TCP, one engine per session
femm_headless(w) --port N or femm_gui --port N
(FEMM 5: MicroPython engine, tangle mesher, fkn / belasolv / hsolv / csolv solvers)Each session spawns its own headless engine on a free port (launch about 0.5 s), so several models
can run side by side. Bulk results (whole-mesh nodes, elements, B) are written to .npz/.csv in
the work dir and summarised; they never flood the agent's context.
Validation
Measured live on FEMM 5.0 build 06oct2026 (Windows, headless) by examples/ and tests/live/.
Case | FEMM 5 via the suite | Reference | Agreement |
Thick solenoid centre field (self-test, axisymmetric, 500 turns, 1 A) |
| B0 = mu0 J l ln[(b + sqrt(b^2 + l^2)) / (a + sqrt(a^2 + l^2))] | 0.695 % |
C-core gap flux density | 0.238 T | mu0 N I / (2g + l_fe/mu_r) = 0.2405 T | 1 % (fringing) |
C-core energy | W = W' = 1/2 L I^2 = 0.0149452 J | identity for a linear model | 0.00 % |
C-core force at 1 mm | -9.74 N; WST vs virtual work 1.6 % RMS over 1-3 mm | 2 B^2 A / 2 mu0 = -9.21 N | 6 % (fringing, leakage) |
SPM cogging, peak to peak | 0.3824 N·m (rotate + re-mesh) | 0.3835 N·m (air-gap element) | 0.3 % |
SPM mean torque, iq = 10 A | 1.415 N·m | 3/2 p psi_d iq from FEM flux linkage = 1.428 N·m | 0.9 % |
SPM back-EMF fundamental, 1000 rpm | 9.973 V (rotate) | 9.977 V (air-gap element) | 0.04 % |
SPM inductances | Ld 0.427 mH, Lq 0.421 mH | mutuals reciprocal | 0.4 % |
Round copper wire R(f), r = 5 mm | 1 Hz - 10 kHz sweep | exact Bessel internal impedance | 0.0 % to 100 Hz, 0.1 % at 1 kHz, 1.3 % at 10 kHz |
AC power balance | 1/2 Re(V conj I) | block-integral total losses | 0.00 % |
Parallel-plate capacitor, heat-flow slab, current-flow strip | charge and energy, heat flux, current density | eps A / d, k dT / L, sigma V / L | within 1 % |
The C-core inductance (7.47 mH vs 4.81 mH from the no-fringing formula) is the reminder that a formula is a reference, not a target: the skills teach the agent to explain the gap, not to tune it away.
FEMM 5 facts you will hit
Material names changed.
M-19 SteelisM-19 14 mil,Pure IronisARMCO Pure Iron,1010 Steelis1010 Steel (hot rolled), andNdFeB 32 MGOehas no entry (nearestN33). FEMM raisesCouldn't load "..." from the materials library;femm_material_searchmaps the old names.Commands exist only with a document.
mi_*appears afternewdocument(0),mo_*only after a solution is loaded, andmi_analyzerefuses an unsaved model.One line per request. Multi-line MicroPython goes through
exec(open(path).read()); lines over 64 KiB are split by the engine.One client per engine, and the engine dies with it. A second connection gets
femm-qt is already connected to another client; a headless engine exits within about 0.5 s of its client disconnecting.No screenshots headless.
mo_savebitmapsucceeds but writes nothing without the GUI; the suite renders field maps from the bulk mesh arrays instead.The air-gap element needs a
<No Mesh>annulus, the stress-tensor block integral reads about zero across it (usemo_gapintegral), and an unknown boundary name returns zeros, not an error.pyFEMM helpers are not engine commands.
mo_getband 61 other conveniences answername 'mo_getb' isn't defined; usemo_getpointvalues(14 values). Standalone pyFEMM finds the engine only throughFEMM_DIR.Units. Magnetic current density is in MA/m^2, magnetic conductivity in MS/m, current-flow conductivity in S/m; the post-processor reports depth in metres, the pre-processor in problem units.
All verified behaviour is collected in docs/femm5-facts.md and served to
the agent by femm_facts.
Python API
The engineering layer works without an MCP client. From examples/ccore/run_ccore.py:
from pathlib import Path
from femm_agent import benchmarks, diagnostics, experiments, ipc
out = Path("out").resolve()
out.mkdir(exist_ok=True)
link = ipc.launch(port=ipc.pick_free_port(49700), cwd=str(out)) # headless FEMM 5 engine
try:
model = (out / "ccore.fem").as_posix()
meta = benchmarks.build_ccore(link, model) # validated C-core benchmark
link.call("mi_analyze", 1)
link.call("mi_loadsolution")
x, y = meta["probe_gap_point"]
print("gap B", abs(link.call("mo_getpointvalues", x, y)[2]), "T",
"analytic", meta["estimate"]["gap_B_T"])
hc = diagnostics.run(link, model, force_groups=[1], reaction_groups=[2, 3])
print(hc["summary"])
fr = experiments.force_vs_position(link, [1], dy=0.25, steps=9,
out_dir=out / "experiments", restore_path=model)
print(fr["summary"], fr["files"]["csv"])
finally:
link.close() # the engine exits with itFull examples with reports: examples/ccore/run_ccore.py and examples/spm_motor/run_spm.py (about 130 solves,
about 25 s). See examples/README.md.
Development
python -m venv .venv; .venv\Scripts\pip install -e ".[dev]"
.venv\Scripts\python -m pytest # offline suite: a fake engine, no FEMM needed (runs in CI)
.venv\Scripts\python -m pytest -m live # live tests against a local FEMM 5
.venv\Scripts\python -m femm_agent # run the MCP server on stdiotests/test_tool_names.py fails if this README or any skill names a femm_* tool that is not
registered. Repository layout:
Path | What |
| server, IPC, sessions, tool groups, engineering layer |
|
|
| verified FEMM 5 behaviour, with evidence tags |
| the eleven skills |
| end-to-end C-core and SPM scripts |
| installers for Windows and macOS / Linux |
| offline tests; |
Contributions: see CONTRIBUTING.md. Only document behaviour observed on a real
FEMM 5, and mark the rest unverified.
Support the project
On first use on a machine, femm_status / femm_selftest ask the agent to offer you a GitHub star
for this repository. It is opt-in and asked once: the agent stars it (via gh, else it opens the
page in your browser) only if you say yes. Answering no silences it for good; the answer is kept in
state.json under FEMM_AGENT_HOME (default %LOCALAPPDATA%emm-agent-suite, ~/.local/state/femm-agent-suite).
Licence
The suite is MIT licensed (LICENSE). FEMM 5 itself is not part of this repository and
is not redistributed: the femm-qt application, engine, mesher, bindings and material libraries are
MIT, and the finite element solvers (fkn, belasolv, hsolv, csolv) are GPLv3 or later. The
suite talks to FEMM over its TCP interface and does not link the solvers. The JSON summaries in
data/ are generated from the installed FEMM 5 libraries and keep their MIT licence.
Acknowledgement
FEMM is the work of David Meeker. Thank you for decades of a free, rigorous 2D field solver, and for FEMM 5's open scripting interface that made this project possible. Get FEMM 5 from femm.info: download page. This project is independent and not affiliated with or endorsed by the FEMM author.
Available Tools
88 toolsfemm_add_arcsA
Add arcs [[x1, y1, x2, y2, angle_deg, maxseg_deg], ...]: from (x1,y1) counter-clockwise to
(x2,y2) sweeping angle_deg (0 < angle <= 180); maxseg_deg is the arc discretisation
(1 deg fine, 5-10 coarse; air gaps want <= 1). End nodes are created as needed.
Inputs: arcs (required), session.
femm_add_block_labelA
Add a block label at (x, y) inside a closed region and assign its properties in one call.
material: a name already loaded/defined (femm_material_load / femm_material_add), or "" for a hole. mesh_size: max element size in problem units, None = automatic. Magnetics only: circuit (name from femm_add_circuit, "" for none), magdir (magnetisation direction in degrees for magnets), turns (number of turns of this block in the circuit; negative = opposite direction). group: integer group for selection/integrals. Each closed region needs exactly one label; a label in the wrong region is a common bug (check with femm_geometry_summary).
Inputs: x (required), y (required), material (required), group, +5 more.
femm_add_boundaryA
Define a boundary condition for the current physics and (optionally) assign it.
Magnetics bc_type (mi_addboundprop, 12 args): prescribed_a (A = a0 + a1x + a2y, phase phi; A=0 is the usual outer boundary), small_skin_depth (mu = relative permeability, sigma MS/m), mixed (c0, c1 complex OK), strategic_dual_image, periodic, antiperiodic, periodic_air_gap / antiperiodic_air_gap (sliding band: inner_angle/outer_angle = rotor/stator shift in degrees). Assign it to BOTH concentric arcs of the gap annulus and put a "" block label inside the annulus (verified: without it the solver stops with "a region has no material assigned"). Electrostatics: fixed_voltage (value = V), mixed (c0, c1), surface_charge (flux = C/m^2), periodic, antiperiodic. Currentflow: fixed_voltage (value), mixed, surface_current (flux), periodic, antiperiodic. Heatflow: fixed_temperature (value = K), heat_flux (flux W/m^2), convection (h W/m^2K, t_inf K), radiation (beta emissivity, t_inf_rad K), periodic, antiperiodic. segments / arcs: [[x, y], ...] points ON the segments/arcs (e.g. midpoints) to assign this boundary to (each picks the nearest). Periodic pairs need one boundary per pair, assigned to both sides. For an unbounded open boundary see femm_call('mi_makeABC').
Inputs: name (required), h, a0, a1, +18 more.
femm_add_circuitA
Magnetics: define a circuit carrying current amps (peak for AC; [re, im] or "1+2j" for
phase). series=True: every block in it carries current per turn (set turns on the block
labels; stranded coils). series=False (parallel): current is the total, split between
blocks by impedance (solid conductors). Results: femm_circuit_results.
Inputs: name (required), series, current, session.
femm_add_conductorA
Electrostatics / heat flow / current flow: define a conductor property. fixed: electrostatics 'voltage' (value V) or 'charge' (value C/m); heatflow 'temperature' (value K) or 'flux' (value W/m, total heat); currentflow 'voltage' (V) or 'current' (A; complex OK at AC). Assign it to segments/arcs/nodes with femm_set_segment_prop(conductor=name) etc. Results after solving: femm_circuit_results(name).
Inputs: name (required), fixed, value, session.
femm_add_nodesA
Add nodes at [[x, y], ...] (problem units; axi: x is r >= 0). Existing nodes at the same place are reused by FEMM. Usually you want femm_draw_polygon / femm_add_segments instead.
Inputs: points (required), session.
femm_add_point_propB
Define a nodal point property and optionally assign it to the nodes nearest points.
magnetics: value = prescribed A (Wb/m), source = point current (A).
electrostatics: value = V, source = point charge (C/m). heatflow: value = T (K),
source = point heat (W/m). currentflow: value = V, source = point current (A/m).
Inputs: name (required), value, points, source, +1 more.
femm_add_segmentsB
Add straight segments [[[x1,y1],[x2,y2]], ...] (or [x1,y1,x2,y2] each). End nodes are created as needed. Segments that cross are split by FEMM at the intersection.
Inputs: segments (required), session.
femm_api_getB
Full catalog entry of one command: args (name, type, optional, description), return value, integer code tables (enums), read_only flag, notes (e.g. pyFEMM-only helpers the engine does not define), and where it is documented in the manual.
Inputs: name (required).
femm_api_searchA
Search the catalog of every FEMM 5 scripting command (name, signature, description). physics: magnetics|electrostatics|heatflow|currentflow (common commands always included); phase: pre (mi_/ei_/hi_/ci_) or post (mo_/eo_/ho_/co_). Examples: 'block integral', 'air gap', 'boundary', 'bitmap', 'mi_addmaterial'. Then femm_api_get(name) for full args.
Inputs: query (required), limit, phase, physics.
femm_block_integralA
Integrate over blocks: select the blocks containing points and/or every block in
group (list of group numbers), then evaluate xo_blockintegral for each code.
Magnetics codes (manual 3.7.1): 0 A.J, 1 A, 2 field energy (J), 3 hysteresis/lamination
loss, 4 resistive loss (W), 5 area, 6 total loss, 7 total current, 8/9 integral of Bx/By,
10 volume, 11/12 Lorentz force x/y, 15 Lorentz torque, 17 coenergy, 18/19 weighted
stress tensor force x/y (N, select the moving part surrounded by air), 22 stress tensor
torque (N m), 24 R^2... Other physics: see femm_api_get('eo_blockintegral') etc.
Defaults: magnetics [2,17,5,10,7]; electrostatics [0,1,2]; heatflow [0,1,2]; currentflow [0,1,4,5].
Planar results are per the problem depth (total, not per metre).
Inputs: codes, group, points, session.
femm_build_benchmarkA
Build a validated benchmark model from scratch (new magnetics document, saved to path,
default <work_dir>/.fem) and return its groups, circuits and analytic estimates:
'ccore' (planar U-core + armature, groups armature=1 core=2 coil=3, circuit 'coil'),
'coilgun' (axisymmetric coil + iron slug group 1), 'spm' (12-slot 4-pole surface PM machine,
params rotor_method='rotate'|'age', rotor groups [1,10] or AGE boundary 'AGE', circuits A/B/C),
'round_wire' (copper wire in an A=0 circle for AC sweeps). params are the builder keyword
arguments (e.g. {"gap": 0.5, "turns": 100}); see femm_agent.benchmarks.
Inputs: kind (required), path, params, session.
femm_callA
Call any FEMM 5 scripting command by name with positional args, e.g.
femm_call('mi_makeABC', [7, 50, 0, 0, 0]) or femm_call('mo_getgapb', ['AGE', 15]).
The call is checked against the command catalog first; warnings (wrong arity or types,
unknown name, pyFEMM-only helpers such as mo_getb that the engine lacks) are returned in
warnings, and the call is still sent unless the name is unknown to both the catalog and
the engine. Strings are quoted for you; complex values: [re, im] is NOT converted here,
pass a string expression via femm_eval instead. Use femm_api_search to find commands.
Inputs: command (required), args, session.
femm_check_ruleA
Run one pure physics rule on numbers you already have (no FEMM call). Call with rule='list' to see them. Examples: femm_check_rule("energy_consistency", {"energy": 0.0149, "flux_linkages": [0.0149], "currents": [2]}); femm_check_rule("power_balance", {"p_input": 1.2, "p_losses": 1.19}); femm_check_rule("force_consistency", {"f_a": -9.7, "f_b": -9.2, "tolerance": 0.1}). Returns {name, ok, value, expected, tolerance, message}.
Inputs: rule (required), args.
femm_circuit_resultsA
Magnetics: current (A), voltage drop (V) and flux linkage (Wb) of circuit name
(mo_getcircuitproperties), with derived inductance L = flux/current (for a circuit alone in
the model; mutual effects included), resistance (DC) or impedance V/I (AC).
Electrostatics/heat/current: conductor results (xo_getconductorproperties): voltage &
charge, temperature & heat flux, or voltage & current.
Inputs: name (required), session.
femm_clear_selectedC
Deselect everything in the pre-processor.
Inputs: session.
femm_close_documentA
Close the current pre-processor document and its post-processor (if any). The engine keeps running; call femm_new_document or femm_open next.
Inputs: session.
femm_compare_resultsA
A/B comparison of two experiment results (paths to the experiment .json files, or JSON
text): every numeric summary value and every common numeric column (rows matched on the first
column, e.g. angle). Use it to compare mesh refinements, the rotate vs air-gap-element
methods, or two designs. Differences beyond rtol are flagged.
Inputs: a (required), b (required), rtol, label_a, +1 more.
femm_copy_selectedA
Copy the selection copies times, each shifted by a further (dx, dy) or rotated by a
further rotate_deg about about (default origin). Typical: one slot drawn, then
femm_select(kind='group') + femm_copy_selected(rotate_deg=360/Q, copies=Q-1, entities='group').
Inputs: dx, dy, about, copies, +3 more.
femm_create_meshA
Mesh the model without solving (xi_createmesh) to check that meshing succeeds. FEMM requires a saved file, so the model is saved first. FEMM 5 returns no element count from createmesh; the count is reported by femm_solve (fast: a 10k-element static solve takes well under a second). Meshing errors usually mean open regions or overlapping lines.
Inputs: session.
femm_delete_selectedB
Delete the current selection. kind: all | nodes | segments | arcs | labels (deleting nodes also deletes segments/arcs attached to them).
Inputs: kind, session.
femm_draw_circleA
Full circle of radius r around (cx, cy) as four 90-degree arcs (nodes at 0/90/180/270 deg). maxseg = arc discretisation in degrees. For a half circle in axi models, use femm_add_arcs.
Inputs: r (required), cx (required), cy (required), maxseg, +1 more.
femm_draw_polygonB
Polygon through [[x, y], ...]: nodes + segments, closed back to the first point by default. Returns the vertex centroid (a block-label candidate only if the polygon is convex).
Inputs: points (required), closed, session.
femm_draw_polylineB
Open chain of segments through [[x, y], ...] (not closed). Same as femm_draw_polygon(closed=False).
Inputs: points (required), session.
femm_draw_rectangleA
Axis-aligned rectangle with opposite corners (x1,y1), (x2,y2): 4 nodes + 4 segments. Add a block label inside it afterwards (femm_add_block_label).
Inputs: x1 (required), x2 (required), y1 (required), y2 (required), +1 more.
femm_estimateA
Analytic sanity references in SI units (m, A, T, H, N, N*m). Call with no name to list the formulas and their arguments. Examples: femm_estimate("ccore_gap_b", {"turns": 200, "current": 2, "gap": 0.002, "iron_path": 0.18, "mu_r": 2000}); femm_estimate("dq_torque", {"pole_pairs": 2, "psi_d": 0.05, "psi_q": 0, "i_d": 0, "i_q": 10}); femm_estimate("skin_depth", {"freq": 1000, "sigma": 58e6}). Others: solenoid / loop / thick- solenoid fields, inductances, Maxwell force B^2 A/2mu0, Carter coefficient, PM load line, SPM gap flux and flux linkage, cogging period, capacitances, resistance, round-wire AC impedance. Compare FEMM results to these within the idealisation error (fringing, leakage, saturation).
Inputs: args, name.
femm_evalA
Evaluate ONE LINE of MicroPython inside FEMM and return its value (tab-separated reply parsed to numbers/lists). Statements return null; expressions return their value. A newline is rejected: for multi-line code use femm_run_script. Examples: 'mo_getpointvalues(0,0)[1]', 'mi_getboundingbox()', '[mo_getgapb("AGE",a)[0] for a in range(0,90,10)]'. Variables persist between calls in the same session.
Inputs: expression (required), session.
femm_examples_listA
Example models and scripts shipped with FEMM 5 (examples/ and pyfemm/examples/): name,
path, size, and for models the header (problem type, units, frequency, depth). Filter by
substring query and/or extension ('.fem', '.py', '.lua', ...). Open one with femm_open.
Inputs: query, extension.
femm_experiment_ac_sweepA
Time-harmonic frequency sweep (Hz): per frequency, circuit phasors (peak amplitudes) ->
Z = V/I, R(f), L(f) = Im Z / omega, and losses (total / resistive / hysteresis) over all blocks.
Check: 1/2 Re(V conj I) equals total losses. Other probdef settings are kept and the original
frequency restored. current overrides every swept circuit's current. Conductors must have
conductivity and the mesh must resolve the skin depth (femm_estimate skin_depth).
Inputs: frequencies (required), current, session, circuits.
femm_experiment_backemfB
Open-circuit back-EMF: flux linkage of each circuit (default all) over one electrical period
(360/pole_pairs mech deg, steps samples), EMF = omega * dpsi/dtheta (spectral derivative),
fundamental / THD / harmonics / line-line EMF / Ke. Currents are zeroed and restored.
psi_estimate (Wb, peak) adds an analytic comparison (femm_estimate spm_flux_linkage_fundamental).
Inputs: pole_pairs (required), rotate_groups (required), rpm, steps, +6 more.
femm_experiment_bh_checkA
Permanent-magnet operating points: solves, then per magnet block label the mean and minimum flux density along its magnetisation direction (B_m), H_m, permeance coefficient Pc and B_m/Br. Flags demagnetisation risk when min B_m < min_fraction * Br. Labels with a magdir formula are skipped.
Inputs: session, min_fraction.
femm_experiment_coggingA
Cogging torque: all circuit currents set to 0, torque over periods cogging periods
(360/lcm(slots, poles) mech deg, steps samples incl. end point) and its harmonics.
poles is the number of poles (2p). Same rotor options as femm_experiment_torque_vs_angle.
Checks: zero mean, periodic end points, WST vs virtual work. Currents are restored.
Inputs: poles (required), slots (required), rotate_groups (required), steps, +6 more.
femm_experiment_force_vs_positionA
Force vs position: move the parts in groups by (dx, dy) PROBLEM UNITS per step, re-solve,
and record the weighted-stress-tensor force on force_groups (default groups), the total
coenergy and every circuit's flux linkage. Health check: WST force vs virtual work dW'/ds.
Use for actuators, plungers, coilguns (axisymmetric: dy moves along z). The moving parts must be surrounded by air and carry their own group number (femm_set_group). Geometry is moved back at the end and the model is left solved at the start position. Example: femm_experiment_force_vs_position(groups=[1], dy=0.25, steps=9). Returns rows [position, Fx, Fy, F_along_motion, F_virtual_work, coenergy, psi_*] and csv/json/png paths.
Inputs: groups (required), dx, dy, steps, +3 more.
femm_experiment_inductanceB
Inductance from flux linkage. Default: self/mutual matrix L_jk = (psi_j(I_k=current) - psi_j(0)) / current
for circuits (default all) - subtracting the zero-current solve removes magnet flux. Linear
models get an energy check (W = 1/2 L I^2).
dq mode: dq = {"circuits": ["A","B","C"], "pole_pairs": p, "theta0_deg": 0, "id": 5, "iq": 5}
at the present rotor position (theta0 = electrical angle of the d-axis from phase A) gives
psi_pm, Ld, Lq, saliency and the dq torque, checked against the FEM torque on torque_groups
(WST) or gap_boundary (air-gap element).
Inputs: dq, current, session, circuits, +2 more.
femm_experiment_parametricA
Generic parametric study. Every case re-opens the same saved base model, applies its setup, solves and collects outputs. case: {"name": "Hc=900k", "params": {"hc": 9e5}, "commands": [{"command": "mi_modifymaterial", "args": ["N42", 3, 9e5]}]} (preprocessor commands only: mi_/ei_/hi_/ci_). template: optional multi-line MicroPython run inside FEMM per case, formatted with params, e.g. "mi_selectgroup(1)\nmi_movetranslate({dx}, 0)". outputs: {"name", "kind": "point", "x", "y", "quantity": "B|Bx|By|A|H|mu|J"} | {"kind": "block", "code": 22, "groups": [1]} | {"kind": "circuit", "circuit": "A", "quantity": "flux|current|voltage|L|R"} | {"kind": "gap", "boundary": "AGE", "code": 0} | {"kind": "line", "points": [[x,y],...], "code": 3} | {"kind": "expr", "expression": "..."}.
Inputs: cases (required), outputs (required), session, template.
femm_experiment_torque_vs_angleA
Rotor torque vs mechanical angle (degrees, end point included).
method='rotate': rotates rotate_groups about center (default [0, 0]) each step and re-meshes;
torque = WST block integral on torque_groups (default rotate_groups; exclude a rotor-side air
layer from torque_groups). Needs an air layer split by a circle in the gap so the rotor can turn.
method='age': the model has a FEMM 5 'Periodic Air Gap' boundary (BdryFormat 6) named
gap_boundary; its inner angle is stepped and torque = mo_gapintegral (mesh never changes).
drive = {"circuits": ["A","B","C"], "pole_pairs": p, "id": 0, "iq": 10, "theta0_deg": 0}
makes the phase currents follow the rotor (amplitude-invariant dq; theta_e = p*angle + theta0)
and adds a mean-torque check against 3/2 p (psi_d iq - psi_q id).
Inputs: rotate_groups (required), stop, drive, start, +7 more.
femm_export_dxfC
Write the current geometry to a DXF file (xi_savedxf).
Inputs: path (required), session.
femm_export_pyfemm_scriptB
Write the session journal as a standalone pyFEMM script (import femm; femm.openfemm(1); femm.mi_...(); femm.closefemm()) so the user can re-run the whole model without the agent. Default path: <work_dir>/scripts/_pyfemm.py. femm_eval expressions that are not plain calls are kept as comments.
Inputs: path, session, headless.
femm_factsB
Verified FEMM 5 behaviour collected by this project (docs/femm5-facts.md): command
quirks, units, what works headless, renamed materials. query returns only the sections
that mention it. Read this before trusting FEMM 4.2 habits.
Inputs: query.
femm_field_statsA
Area-weighted statistics of the main field over the mesh, from the bulk arrays (fast, no file). Magnetics: |B| min/max/mean/rms/p95, saturated area fraction (|B| >= threshold, default 1.6 T) and number of elements above 2 T. Other physics: |D|, |F| or |J| per element and V/T at nodes. region: 'all' or 'group:N[,M]' (give the blocks of one material a group number with femm_add_block_label(group=N) to get per-material stats).
Inputs: region, session, threshold.
femm_file_summaryA
Parse a FEMM text file offline (no engine): .fem/.fee/.feh/.fec models or .ans/.res/.anh/.anc solutions. Returns problem definition, materials (with use counts, nonlinear/magnet flags), boundaries (type names, segment counts), circuits (net turns), groups, counts, bounding box, magnets. arrays=True on a solution also writes _mesh.npz (nodes, elements) next to it.
Inputs: path (required), arrays.
femm_gap_resultsA
Air-gap (sliding band) results for a periodic/antiperiodic air-gap boundary boundary
(femm_add_boundary bc_type='periodic_air_gap'): torque (mo_gapintegral 0), force (1),
stored energy (2) [include_ac adds 2x torque/force and interaction terms]; Br/Bt at
angle (deg); the Br/Bt distribution at npts angles saved to CSV with stats; and the
harmonics largest Br harmonics (mo_getallgapharmonics). Magnetics only.
Warning: FEMM returns zeros (not an error) for an unknown boundary name.
Inputs: boundary (required), npts, angle, session, +2 more.
femm_geometry_summaryA
Counts of nodes, segments, arcs, block labels and the defined materials, boundaries, circuits/conductors, plus the bounding box. FEMM 5 has no pre-processor count getters, so this saves the model (to its current path, or <work_dir>/model.) and reads the counts from the saved file. Use it to sanity-check a model before meshing.
Inputs: session.
femm_health_checkA
Judge whether the loaded magnetics solution is physically sane. Needs femm_solve first.
Runs (subset via checks): mesh (element count, worst triangle angle), precision, energy
(W = W' and W = 1/2 sum I psi for linear models without magnets), saturation (share of steel
above b_limit T; linear iron over 2.2 T), boundary (|B| at the outer boundary vs peak),
torque (WST on rotor_groups vs -stator_groups; air-gap element torque if present), force
(force_groups vs -reaction_groups), ac (1/2 Re(V conj I) = losses), flux (two cuts
[[p1,p2],[p3,p4]] must carry the same flux), pm (magnet operating points).
Returns {checks: [{name, ok, value, expected, tolerance, message}], summary, facts}.
Inputs: checks, b_limit, session, flux_lines, +4 more.
femm_import_dxfA
Import a DXF drawing into the current model (xi_readdxf). tolerance merges nodes closer
than this (problem units); leave None for FEMM's default. Check the result with
femm_geometry_summary, then add block labels.
Inputs: path (required), session, tolerance.
femm_journalA
The raw command lines this session sent to FEMM (most recent limit), i.e. exactly what
the engine executed; commands FEMM refused are prefixed '#! ' with the error. save=True also writes the full journal as a replayable in-process
script (<work_dir>/scripts/journal.py: run it with femm_run_script(path=...)).
Internal pings are filtered out. Use femm_export_pyfemm_script for a standalone file.
Inputs: save, limit, session.
femm_line_integralB
Line integrals along a contour of straight pieces through [[x, y], ...] (use many points to follow a curve). Magnetics codes: 0 B.n (flux; total, average), 1 H.t (MMF), 2 length (and surface area), 3 stress tensor force, 4 stress tensor torque, 5 (B.n)^2. Electrostatics: 0 E.t, 1 D.n (charge), 2 length, 3 force, 4 torque. Heat: 0 G.t (dT), 1 F.n (heat flow), 2 length, 3 average T. Current: 0 E.t, 1 J.n (current), 2 length, ... Defaults: the first three/four.
Inputs: contour (required), codes, session.
femm_load_solutionB
Load the existing solution of the current (already solved) model into the post-processor (xi_loadsolution) without re-solving. Fails if the model was never solved.
Inputs: session.
femm_make_plotA
Sample a quantity along a contour (straight pieces through [[x, y], ...]) to a text file (xo_makeplot with a filename; works headless). Magnetics plot_type: 0 A, 1 |B|, 2 B.n, 3 B.t, 4 |H|, 5 H.n, 6 H.t, 7 J eddy, 8 J source+eddy. Electrostatics: 0 V, 1 |D|, 2 D.n, 3 D.t, 4 |E|, 5 E.n, 6 E.t. Heat: 0 T, 1 |F|, 2 F.n, 3 F.t, 4 |G|, 5 G.n, 6 G.t. Current: 0 V, 1 |J|, 2 J.n, 3 J.t, 4 |E|, ... Returns the file path, column header and min/max/mean of the sampled values (position is distance along the contour).
Inputs: contour (required), npts, path, session, +1 more.
femm_manual_sectionB
Read the installed FEMM 5 manual (manual.pdf, extracted to text once and cached). query: a section number ('3.7.1'), a heading ('Data Extraction Commands', 'Boundary Conditions', 'Air Gap'), or a keyword ('mo_gapintegral', 'Kelvin'): headings return the section text, keywords return snippets with their section names.
Inputs: query (required), refresh, max_chars.
femm_material_addA
Define a custom material for the session's physics (xi_addmaterial). Only the arguments of that physics are used; *_y defaults to *_x. magnetics: mu_x, mu_y (relative), h_c (A/m, magnets), j (source current density MA/m^2, complex OK), sigma (MS/m), lam_d (lamination thickness mm), phi_hmax (hysteresis angle deg), lam_fill (0..1), lam_type (0 none, 1 laminated x, 2 laminated y, 3 magnet wire, 4 stranded, 5 litz, 6 square wire), phi_hx, phi_hy, n_strands, wire_d (mm); bh_points [[B_T, H_A/m], ...] makes it nonlinear (mu ignored). electrostatics: eps_x, eps_y (relative), qv (C/m^3). heatflow: k_x, k_y (W/m/K), qv (W/m^3), kt (volumetric heat capacity MJ/m^3/K). currentflow: sigma_x, sigma_y (S/m), eps_x, eps_y, ltx, lty (loss tangents).
Inputs: name (required), j, kt, qv, +22 more.
femm_material_add_bhA
Give material name a nonlinear curve. Magnetics: points = [[B (T), H (A/m)], ...]
starting at [0, 0], B and H strictly increasing (mi_addbhpoint). Heat flow: points =
[[T (K), k (W/m/K)], ...] (hi_addtkpoint). clear_first removes the existing curve.
The material must already exist in the model (femm_material_add or femm_material_load).
Inputs: name (required), points (required), session, clear_first.
femm_material_getA
Full library record of one material (all keys of the .dat block: Mu_x, H_c, Sigma in MS/m, d_lam in mm, LamFill, LamType, WireD, ...). include_curve=True adds the B-H (or T-k) points. On a miss, returns suggestions (and the FEMM 4.2 -> 5 rename if known).
Inputs: name (required), physics, include_curve.
femm_material_loadA
Copy materials from the FEMM 5 library into the current model (xi_getmaterial), for the session's physics. Names must match FEMM 5 exactly ('M-19 14 mil', 'N42', 'Copper', 'Air', '18 AWG'). On a miss the result lists suggestions; with fallback_to_suggestion=True the best suggestion (e.g. FEMM 4.2 'M-19 Steel' -> 'M-19 14 mil') is loaded instead and reported in 'renamed' (use those names in femm_add_block_label).
Inputs: names (required), session, fallback_to_suggestion.
femm_material_modifyA
Change properties of a material already in the model (xi_modifymaterial), e.g. {"mu_x": 2000, "sigma": 0} or {"name": "M19-hot"}. Keys per physics: magnetics name mu_x mu_y h_c j sigma lam_d phi_hmax lam_fill lam_type phi_hx phi_hy n_strands wire_d; electrostatics name eps_x eps_y qv; heatflow name k_x k_y qv kt; currentflow name sigma_x sigma_y eps_x eps_y ltx lty. Re-solve afterwards.
Inputs: name (required), changes (required), session.
femm_material_searchA
Fuzzy search of the FEMM 5 material library (no engine needed). Matches names and folders: 'M-19', 'silicon iron', 'N42', 'NdFeB', 'AWG 18', 'stainless', 'pure iron'. FEMM 4.2 names ('M-19 Steel', 'NdFeB 32 MGOe') are mapped to their FEMM 5 equivalents and ranked first. physics: magnetics|electrostatics|heatflow|currentflow. Returns name, folder and key properties (mu_r, Hc, sigma, nonlinear?). Empty query + folder lists a folder; empty query alone returns the family index.
Inputs: limit, query, folder, physics.
femm_mesh_arraysA
Dump the solution mesh and fields to a file in the session work dir and return the path, shape and min/max/mean per column (never the raw arrays). which: all, or a comma list of nodes, elements, and per physics: magnetics b (B1,B2 per element), a (A per element); electrostatics v (per node), d; heatflow t (per node), f; currentflow v (per node), j. Element rows are n1,n2,n3 (node indices), cx, cy, area, group. fmt: npz (numpy) or csv. Load with numpy.load(path).
Inputs: fmt, name, which, session.
femm_mirror_selectedA
Mirror-copy the selection about the line through (x1,y1)-(x2,y2) (the original stays).
Inputs: x1 (required), x2 (required), y1 (required), y2 (required), +2 more.
femm_modify_circuitB
Change a circuit: current (A, real; for complex use femm_call('mi_modifycircprop', ...)), series/parallel, or rename (mi_modifycircprop propnum 1 / 2 / 0). Re-solve afterwards.
Inputs: name (required), series, current, session, +1 more.
femm_move_selectedA
Move the selection: translate by (dx, dy), or rotate by rotate_deg (counter-clockwise)
about about=[x, y] (default origin). entities: nodes|segments|labels|arcs|group restricts
what moves (default: FEMM's current edit mode; use 'group' after femm_select(kind='group')).
Inputs: dx, dy, about, session, +2 more.
femm_new_documentA
Create a new empty model: physics = magnetics | electrostatics | heatflow | currentflow. This defines the mi_/ei_/hi_/ci_ commands. Next: femm_problem_define (units, planar/axi, depth, frequency), then geometry, materials, labels, boundaries, femm_solve.
Inputs: physics, session.
femm_openB
Open a FEMM model (.fem/.fee/.feh/.fec) or a solution (.ans/.res/.anh/.anc). Relative paths resolve against the session work dir; use forward slashes. Opening a solution makes the post-processor tools (femm_point_values, ...) available directly.
Inputs: path (required), session.
femm_plot_fieldA
|B| colour map of the loaded magnetics solution rendered from the bulk mesh arrays (works
headless, no GUI screenshot). zoom = [xmin, xmax, ymin, ymax] in problem units; default file
<work_dir>/field_B.png; save_arrays also writes the nodes/elements/B arrays as .npz.
Inputs: path, zoom, session, save_arrays.
femm_point_valuesA
Field values at [[x, y], ...] (problem units), labelled for the physics, plus the magnitude (|B|, |E|, |F| or |J|). Components are x/y for planar and r/z for axisymmetric models. Magnetics keys: A, Bx/By (T), sigma (MS/m), energy_density (J/m^3), Hx/Hy (A/m), J_eddy, J_source (MA/m^2, verified), mux/muy (relative), P_ohmic, P_hyst (W/m^3), fill_factor. Complex (AC) values come back as {"re", "im"} (peak). A point outside the model gives outside=true. Up to a few hundred points per call is fine (~1 ms each).
Inputs: points (required), session.
femm_problem_defineA
Define the problem for the current physics (wraps xi_probdef with the right argument order).
units: millimeters|centimeters|meters|inches|mils|micrometers (aliases mm, cm, m, in, um).
problem_type: planar | axi (axisymmetric: x is r >= 0, y is z, depth ignored).
depth: out-of-plane length for planar models, in units (defaults to 1 unit with a warning:
set it! e.g. stack length). frequency (Hz): magnetics (0 = magnetostatic) and currentflow
only. precision: solver tolerance (1e-8 typical). min_angle: mesh quality, 30 deg default.
ac_solver: magnetics only, 0 or 1 (successive approximation / Newton; see manual 2.2.6).
prev_solution, time_step: heatflow transient only (previous .anh file, seconds).
Orders used: mi(freq,units,type,prec,depth,minang,acsolver); ei(units,type,prec,depth,minang);
hi(units,type,prec,depth,minang,prevsoln,dt); ci(units,type,freq,prec,depth,minang).
Inputs: depth, units, session, ac_solver, +6 more.
femm_problem_infoB
Problem definition as FEMM reports it (xi_getprobleminfo, and xo_getprobleminfo after a solve: note the post-processor reports depth in metres), the geometry bounding box, and node/element counts when solved.
Inputs: session.
femm_reportB
Write report.md + report.json (+ figures/) to <work_dir>/reports//.
include (default all): "model" (parsed model summary), "health" (femm_health_check on the
loaded solution), "field" (|B| map PNG from the bulk mesh arrays, zoom = [xmin, xmax, ymin,
ymax] in problem units), "experiments" (this session's experiment results, or the result
.json paths in experiment_files). Returns the paths; open report.md to read it.
Inputs: zoom, notes, title, include, +2 more.
femm_run_luaA
Run a legacy FEMM 4.2 Lua script unchanged with FEMM 5's bundled Lua 4 interpreter
(bin/femm-lua.bat on Windows: femm-lua -h -p <free port> script.lua args). It spawns its
own engine (not a session) and exits when done. VERIFIED on Windows with a small
newdocument/mi_probdef/mi_addnode/print script. Returns stdout/stderr/exit code. To port a
Lua script permanently, rewrite it with femm_run_script (MicroPython) instead.
Inputs: path (required), args, timeout, headless.
femm_run_scriptA
Run a multi-line MicroPython script with FEMM's commands as globals (mi_addnode(...) etc.,
no femm. prefix). Give code or path (.py).
mode=inprocess (default): written to <work_dir>/scripts and executed inside this session's
engine with exec(open(p).read()) (VERIFIED on FEMM 5): it sees and changes the session's
model; set a global result (or result_var) to return a value; print() output is NOT
captured (the engine's stdout is discarded).
mode=batch: runs femm_headless --port <free> -run script.py args... as a separate engine
(fresh state, exits at the end); returns stdout, stderr and exit code (1 on a script
error, with the message in stderr). Use for long independent jobs or sys.argv-driven scripts.
Inputs: args, code, mode, path, +3 more.
femm_saveA
Save the current model (xi_saveas). path absolute or relative to the work dir; the
extension is added if missing. Without path: re-save the current file, or
<work_dir>/model. for a new model. femm_solve saves automatically.
Inputs: path, session.
femm_save_bitmapA
Screenshot of the current view to an image file (xo_savebitmap / xi_savebitmap), .png or .bmp. VERIFIED: works only in a session opened with femm_session_open(headless=False) (a GUI window); the headless engine accepts the command but writes nothing. view: post (solution plot) or pre (geometry). density: show a density plot of plot_type (magnetics 'bmag','breal','bimag','hmag','jmag',...; electrostatics 0 V,1 |D|,2 |E|; heatflow 0 T,1 |F|,2 |G|; currentflow 0..8, 3 = |J|). Leave plot_type, lower and upper unset for FEMM's default auto-scaled plot (|B|, V, T or |J|); an explicit plot_type needs lower/upper limits. view='pre' after a solve switches focus back to the geometry window. contours: number of flux/equipotential lines. zoom: [x1, y1, x2, y2] or None = natural. For data plots that work headless use femm_make_plot or femm_mesh_arrays.
Inputs: path (required), view, zoom, lower, +7 more.
femm_scale_selectedC
Scale the selection by factor about about=[x, y] (default origin).
Inputs: factor (required), about, session, entities.
femm_selectA
Select objects for a following edit (femm_move_selected, femm_delete_selected,
femm_set_group ...). kind:
nodes | segments | arcs | labels -> nearest object to each of points [[x, y], ...]
group -> every object in group
rectangle -> objects inside rectangle=[x1, y1, x2, y2]
circle -> objects inside circle=[cx, cy, R]
entities (rectangle/circle only): nodes|segments|labels|arcs|all.
Returns what FEMM reports for each pick (the coordinates of the selected object).
Inputs: kind (required), group, circle, points, +4 more.
femm_select_blockB
Post-processor block selection for femm_call('mo_blockintegral', [code]) workflows.
action=select clears, then selects the blocks containing points and/or groups;
action=clear clears the selection. (femm_block_integral does select+integrate+clear itself.)
Inputs: group, action, points, session.
femm_selftestA
End-to-end check of the install with a known answer (~1-2 s). In a separate session "selftest" it builds an axisymmetric thick solenoid (a=10 mm, b=12 mm, L=100 mm, 500 turns, 1 A), solves, and compares |B| at the centre with the analytic formula B0 = mu0Jl*ln[(b+sqrt(b^2+l^2))/(a+sqrt(a^2+l^2))] (expect < 1 % error). Also checks library material loading, the error path for a FEMM 4.2 name, current-density units, bulk getters, circuit results and timing. Returns pass/fail per check.
Inputs: keep_session, tolerance_pct.
femm_session_closeA
Quit the FEMM engine of session name (unsaved work is lost: call femm_save first).
Inputs: name.
femm_session_listB
All open sessions: port, pid, physics, document, solved flag, call/error counts.
Inputs: no named parameters.
femm_session_openA
Start (or reuse) a named FEMM engine. Every other tool takes session (default "main")
and opens it lazily, so call this only to choose options.
headless=True spawns femm_headlessw (no window, fastest). headless=False opens the
femm_gui window: needed for femm_save_bitmap (screenshots are not written headless).
attach=True connects to an engine already listening on port (e.g. a GUI the user
started) instead of spawning one. work_dir is the engine's current directory; relative
paths in other tools resolve there (default ~/femm-agent-work/, env FEMM_AGENT_WORK).
Inputs: name, port, attach, headless, +1 more.
femm_set_arc_propB
Select the arcs nearest each of points and set discretisation (max_seg_deg, degrees per
straight piece; air gaps want <= 1), boundary name, hide flag, group, (non-magnetics) conductor.
Inputs: points (required), hide, group, session, +3 more.
femm_set_block_propB
Change the properties of the existing block label nearest (x, y) (same arguments as femm_add_block_label). Use to swap materials or currents between solves.
Inputs: x (required), y (required), material (required), group, +5 more.
femm_set_commentC
Store a free-text comment/description in the model file (xi_setcomment). Single line.
Inputs: comment (required), session.
femm_set_groupB
Put the selected objects into group number group (used for moving rotors, for
femm_block_integral(group=...) and femm_field_stats(region='group:N')).
Inputs: group (required), session.
femm_set_node_propB
Select the nodes nearest each of points and set a point property (from
femm_add_point_prop, "" = none), group and (non-magnetics) conductor.
Inputs: points (required), prop, group, session, +1 more.
femm_set_segment_propB
Select the segments nearest each of points (e.g. midpoints) and set boundary name ("" = none),
mesh_size (max element size along the segment; None = automatic), hide-in-postprocessor flag,
group, and (non-magnetics) conductor name.
Inputs: points (required), hide, group, session, +3 more.
femm_smartmeshA
Smart meshing (automatic refinement near small features). state: on | off | default. scope: document (xi_smartmesh, saved with the model) or global (smartmesh(), whole engine; 'default' defers to each file). Turn off for very large models to cut element count, then set mesh sizes explicitly on block labels.
Inputs: scope, state, session.
femm_solveA
Save, solve and load the solution in one call (xi_saveas + xi_analyze + xi_loadsolution). path: where to save (default: current file or <work_dir>/model.). timeout in seconds for the solver (AC/nonlinear models with >100k elements can take minutes). Returns solve time, node and element counts and the solution file. After this the post-processing tools (femm_point_values, femm_block_integral, femm_circuit_results, ...) work. Re-run after every geometry/material/current change: the loaded solution does not update itself.
Inputs: path, session, timeout, hide_window, +1 more.
femm_statusA
Where FEMM 5 is installed, its version, open sessions, work dir, catalog/material counts.
Call this first. If install.found is false, nothing else can run: install FEMM 5
(https://www.femm.info) or set FEMM_DIR to the folder holding femm_headless.
check_version runs femm_headless --version once (cached, ~0.3 s).
Inputs: check_version.
femm_units_convertA
Unit conversions used with FEMM. conversion='length' needs from_unit/to_unit among inches, millimeters, centimeters, mils, meters, micrometers (aliases mm, in, um ...). Others (value in, result out): deg2rad, rad2deg, rpm_to_rad_s, awg_diameter_mm (AWG gauge -> mm, pyFEMM AWG()), iec_diameter_mm, tesla_to_gauss, gauss_to_tesla, oersted_to_a_per_m, a_per_m_to_oersted, hc_from_br (T -> A/m, needs mu_r, default 1.05), br_from_hc, br_from_mgoe / hc_from_mgoe (grade -> Br or Hc for mi_addmaterial), mgoe_from_br, mgoe_to_j_per_m3.
Inputs: value (required), conversion (required), mu_r, to_unit, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 88 tools
Despite 88 tools, most have clearly distinct purposes and detailed descriptions that clarify scope. However, several overlapping families exist—plotting (make_plot, plot_field, save_bitmap), field extraction (point_values, block_integral, line_integral, mesh_arrays, field_stats), and reference (api_get, api_search, manual_section, facts)—where an agent could misselect without careful reading.
All tools use the femm_ prefix and snake_case with consistent verb_noun patterns (e.g., femm_add_nodes, femm_solve, femm_experiment_torque_vs_angle). A few noun-only names like femm_status are still predictable and readable.
88 tools is far beyond the recommended 3–15 and exceeds even the 25+ 'too many' threshold, representing an extreme mismatch for a single MCP server. Many tools could be consolidated or exposed through a more compact workflow layer.
The surface covers the full FEMM lifecycle: document creation, geometry, materials, boundaries, meshing, solving, extensive post-processing, parametric experiments, reporting, and a generic femm_call/femm_eval escape hatch for any missing command. No obvious dead ends for the domain.
Maintenance
Related MCP Connectors
Build, check, and export parametric CAD models in your ForgeCAD Projects from your AI agent.
Parametric 3D CAD for AI agents: build print-ready parts, check them, export STL, 3MF or STEP.
Structural FEM for AI agents, also as a Claude skill and plugin: frames, buckling, Eurocode checks.
AI-callable calculators and engineering models with real formulas. No hallucinated math.
Related MCP Servers
- AlicenseBqualityBmaintenanceEnables AI agents to automate multiphysics simulations in COMSOL Multiphysics, covering model management, geometry building, physics configuration, and results visualization. It supports complex simulation workflows through the MCP protocol and includes integrated knowledge retrieval for documentation and troubleshooting.931,012MIT
- FlicenseNot gradedqualityDmaintenanceProvides specialized tools for electromagnetics and magnetic circuit analysis, including field calculations, material property lookups, and unit conversions. It enables AI agents to perform precise physics computations and reason through complex engineering problems using real-world equations.-
- AlicenseCqualityDmaintenanceEnables AI agents to read and write .mph model files, control the COMSOL desktop GUI in real time, and run complete modeling, meshing, solving, and post-processing workflows.231MIT
- AlicenseAqualityBmaintenanceThe official MCP interface for AgentFEM, giving AI agents seven typed tools to create, validate, run, inspect, and verify finite-element simulations while preserving scientific evidence.744 PyPI1Apache 2.0