Skip to content

Setting up an AI assistant

A μfem simulation is a plain Python script, so an AI coding assistant with web access can build one for you: it reads this documentation, copies the closest example, and checks its work against the installed package. This page shows how to set that up.

1. Install μfem

Install μfem into a virtual environment (see Installation). The assistant needs it importable so it can confirm the exact API by introspection.

2. Point the assistant at the docs

Give your assistant (Claude Code, Cursor, Copilot agent, …) this single URL:

https://raiden-numerics.github.io/mufem-doc/llms.txt

That is an llms.txt index. The assistant fetches it, then pulls only the pages it needs for your problem: the model page for your physics, the marker syntax, an example case. Everything else it needs is reachable from there.

3. Describe the simulation

Ask in plain language and include the docs URL. Give the numbers that define the problem, since the physics depends on them: geometry and dimensions, materials, excitations, and what to report. If you leave something out the assistant has to guess it, so state your assumptions or ask it to list the ones it made. For example:

Using the μfem docs at https://raiden-numerics.github.io/mufem-doc/llms.txt, set up an electrostatics simulation of two square parallel plates, 100 mm on a side, separated by a 10 mm air gap, with one plate held at 1 V and the other grounded. Report the stored electric energy. Show me the solver output while it runs, and attach a rendered view of the potential field when it finishes.

The assistant reads the relevant pages, copies the closest case.py from github.com/Raiden-Numerics/mufem, and writes the script.

For the prompt above it produces two files: a geometry.py that builds the two plates as an air box in gmsh (top and bottom faces named PlateTop and PlateBottom), and a case.py that loads the mesh, applies ElectricPotentialCondition at 1 V and 0 V on those faces, and adds a VolumeIntegralReport of the "Electric Energy Density" field.

4. The assistant runs it and reports back

Running the case is part of the job, so ask for it in the prompt (the example above ends with "report the stored electric energy"). Because the prompt also asked to see the run, the assistant streams the solver log while the case executes, so you can watch it build the mesh and converge instead of waiting blind:

Welcome to μfem (0.4.41-dev) by Raiden Numerics LLC.
...
License: Community (Non-commercial)
Total processes: 1
Mesh: Elements(30972) Vertices(7380) Edges(42883) Faces(66476)
Starting.
Iteration | Electrostatics |
        1 |   2.098955e-03 |
Simulation done.
stored energy  U = 4.427094e-12 J
capacitance    C = 8.854188e-12 F
Finishing. Thank you for using the software.

When it finishes, the assistant exports the field and attaches a rendered view of the potential, so you can see the result without opening ParaView yourself:

Electric potential between the two plates, rising linearly from 0 V at the grounded plate to 1 V at the driven plate.

The field rises linearly across the gap and is uniform along the plates, exactly the ideal parallel-plate result.

A good assistant also sanity-checks it: for an ideal parallel-plate capacitor \(C = \varepsilon_0 A / d\) and \(U = \tfrac12 C V^2\), which give \(8.854 \times 10^{-12}\ \text{F}\) and \(4.427 \times 10^{-12}\ \text{J}\). The simulation matches to six significant figures.

Your job is to review the parts that encode the physics you actually want: the geometry and region names, the boundary conditions, and the reported quantities. The assistant writes, runs, and checks the boilerplate; you stay in the loop on the physics.