mufem: fast and accurate simulations

mufem (pronounced /ˈmjuːfɛm/) is a finite-element simulation code for electromagnetics, photonics, and plasmas, and their coupled multi-physics problems, built for industry-relevant engineering applications.

mufem is driven through a Python interface, making it ideal for exploratory work, parametric studies and design optimization, and a natural fit for agentic workflows. mufem is free for both academic and commercial use.

For questions or support, please open an issue or contact us at info@raiden-numerics.com.

This repository hosts a quick introduction to mufem together with a collection of validation and example cases. For platform-specific setup see the Installation guide, and for tutorials and the full API reference see the mufem documentation.

Marquee

Why mufem

Python-native
build, run, and post-process simulations from a clean Python API; ideal for parametric sweeps, optimization, and agentic workflows.
Multi-physics
model electromagnetic, thermal, and structural phenomena and their interactions, all within a single framework.
Advanced discretization
built on MFEM for high-order finite elements on curved, unstructured, non-conformal, and Cartesian meshes.
GPU-accelerated
parallel CPU and GPU solvers that scale efficiently from a single laptop to a large cluster.
Validated
continuously tested against established benchmark suites and published experimental, analytical, and reference results.
Free
the community version is free for academic and commercial use, with no license fees, covering most workflows.

Quick example

Solve the electrostatic field inside a cube held at 1 V across two faces. The simulation reads a mesh whose tagged attributes (a Cube volume and its Anode/Cathode boundary faces) are referenced by markers ("Cube" @ Vol, "Anode" @ Bnd, …):

import mufem
import mufem.electromagnetics.electrostatics as estat
from mufem import Vol, Bnd

sim = mufem.Simulation.New(name="Charged Cube", mesh_path="cube.msh")
sim.set_runner(mufem.SteadyRunner(total_iterations=1))

# Electrostatics model on the tagged "Cube" volume
model = estat.ElectrostaticsModel(order=2)
sim.get_model_manager().add_model(model)
model.add_material(estat.ElectrostaticMaterial(name="Air", marker="Cube" @ Vol))

# Apply 1 V across the cube: anode at 1 V, cathode grounded
model.add_conditions([
    estat.ElectricPotentialCondition(name="Anode", marker="Anode" @ Bnd, electric_potential=1.0),
    estat.ElectricPotentialCondition(name="Cathode", marker="Cathode" @ Bnd, electric_potential=0.0),
])

# Report the stored electric energy
report = mufem.VolumeIntegralReport(name="Energy", cff_name="Electric Energy Density")
sim.get_report_manager().add_report(report)

sim.run()
print("Electric energy:", report.evaluate(), "J")

# Export the fields for visualization (ParaView / VTK)
vis = sim.get_field_exporter()
vis.set_output_directory("ChargedCubeOutput")
vis.add_field_output("Electric Potential")
vis.add_field_output("Electric Field")
vis.save()

See the electrostatics cases for full, runnable examples, including mesh generation and comparison against reference results.

**[Locked rotor (TEAM 24)](https://github.com/Raiden-Numerics/mufem/blob/main/Electromagnetics/Compumag-Team24-Locked-Rotor/README.md)** Study the transient rotor torque and coil currents of a rotating machine using the **Time-Domain Magnetic** model coupled to an **Excitation Coil**.
**[Dipole antenna (Stutzman 2012)](https://github.com/Raiden-Numerics/mufem/blob/main/Electromagnetics/Stutzman_2012_Dipole_Antenna/README.md)** Compute the full-wave radiation pattern and far-field of a dipole antenna using the **Time-Harmonic Maxwell** model.
**[Felix cylinder (TEAM 1b)](https://github.com/Raiden-Numerics/mufem/blob/main/Electromagnetics/Compumag-Team1b-Felix-Cylinder/README.md)** Resolve induced eddy-current density and ohmic losses in a conducting cylinder using the **Time-Domain Magnetic** model.

Models

mufem provides finite-element models across several physics domains, composable for coupled multi-physics:

See the documentation for the full model list and details.

Getting started

First create and activate a virtual environment:

python -m venv mufem-venv
source mufem-venv/bin/activate

Then install the latest release from PyPI:

pip install mufem

See the Installation guide for platform-specific instructions, and the mufem documentation for tutorials and API reference.

That is all you need to run the validation cases below directly.

Validation cases

This repository collects validation examples for mufem (tested against the pinned version). After following the Installation guide, run a specific case with:

(mufem-venv) pymufem Electromagnetics/Compumag-Team1b-Felix-Cylinder/case.py

Electromagnetics

mufem supports both low-frequency (magnetostatics, eddy currents, time-domain and time-harmonic magnetics) and high-frequency (full-wave Maxwell) electromagnetics.

Structural

Continuous Integration

Examples · Linux x86-64 · Python 3.12 Smoke · Linux x86-64 · Python 3.13 Smoke · Linux x86-64 · Python 3.14 Smoke · Windows x86-64 · Python 3.13 Smoke · macOS arm64 · Python 3.13