Skip to content

Examples

Examples can be found in the repository.

Or run on Colab:

2D Examples

Getting Started First Steps

1D Simple Plots Open In Colab

2D Standard Shapes Open In Colab

2D Arbitrary Polygons Open In Colab

Misc. Examples Open In Colab

3D Examples

Analytical Shapes 3D Examples

Spheres Open In Colab

3D STL Meshes Open In Colab

3D Stanford Bunny Open In Colab

Upload Your Own Custom Magnet Open In Colab

Forces and Torques

Cubes Open In Colab

Cylinders Open In Colab

Spheres Open In Colab

STL Cubes Open In Colab

STL Pentagonal Prisms Open In Colab

Configuration Examples

Pymagnet includes ready-to-use TOML configuration files in examples/configs/. Run any of them with:

pymagnet examples/configs/single_cube.toml
Config File Description
single_cube.toml Single cube magnet with slice views
single_cylinder.toml Single cylinder magnet
2d_rectangles.toml Two 2D rectangular magnets with contour plot
cube_halbach.toml 8-prism Halbach array
pseudo_Halbach.toml Pseudo-Halbach field assembly
pseudo_Halbach_plot_group.toml Grouped multi-plane slice plots
quadrupolar.toml Quadrupolar magnet arrangement
two_poles.toml Two-pole configuration
cube_volume.toml Volume rendering of a cube magnet
two_cubes_force.toml Force calculation between two cubes
mesh_cube.toml STL mesh cube magnet
mesh_star.toml STL mesh star shape
mesh_bunny.toml Stanford bunny STL mesh
mesh_two_cubes_force.toml Force calculation with STL mesh magnets

See the Configuration page for full documentation.

Binder

The example notebooks can be run as an instance using Binder:

Binder