Skip to content
/ ferro Public

ETH Zurich PBS in CG project by Haoanqin Gao and Wu You based on the paper Magnets in motion (2008)

License

Notifications You must be signed in to change notification settings

gaoHNQ/ferro

Repository files navigation

Ferro-in-Motion

Physics simulation with Equivalent Magnetic Dipole Method (EMD) 1 for magnet effects. This project was developed as part of the ETH Zürich course Physics-based Simulation in Computer Graphics (252-0546-00L). For more detailed objectives and scope, see our project proposal. We also include additional materials such as the reference papers or mesh objects here.

Interactions between permanent and induced ferromagnets Meißner–Ochsenfeld effect of a superconductor
Simulation Demo1 Simulation Demo2

Installation

Prerequisites

On Ubuntu system, run the following command for necessary libraries:

apt-get install xorg-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev 

We additionally need to install the reactphysics lib, follow the instructions here https://www.reactphysics3d.com/documentation/index.html#building

Getting Started with Ferro-in-Motion

To fetch the necessary submodules and build the magnetic problems, run

cd ferro
git submodule update --init --recursive # Initialize and update all git submodules
mkdir build && cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..
ninja

Running Examples

The examples/ directory contains multiple interactive demo scripts showcasing the use of the ferro module for simulating magnet effects.

  • examples/my-app: Interactions between four cube-shape permanent magnets and induced spherical ferromagnets
  • examples/field_lines: Interactive visualization of field lines of permanent magnets
  • examples/dragon: Mesh-based permanent magnet in shape of a dragon moving periodically in the scenario to attract induced spherical ferromagnets
  • examples/super_conductor: Meißner–Ochsenfeld effect of a superconductor

If you have successfully built in the previous step, you should be able to see these examples under build/bin/. You can run ./bin/field_lines when locating in the build directory to start with the super conductor example. Have fun playing with them while trying turning magnetization on/off!

Fieldlines Demo

Maxwell's Equations for Magnetostatic Problems

Maxwell's equations describe the governing physics underlying electromagnetic phenomena. For magnetostatic problems, the Maxwell's equations can largely simplify (assuming simple homogeneous, isotropic and non-dispersive media with constant parameters):

From the full Maxwell equations:

$$ \begin{align} \nabla \cdot \mathbf{E} &= \frac{\rho}{\epsilon_0} \\ \mu_0 \nabla \cdot \mathbf{H} &= 0 \\ \nabla \times \mathbf{E} &= -\mu_0 \frac{\partial \mathbf{H}}{\partial t} \\ \nabla \times \mathbf{H} &= \sigma \mathbf{E} + \epsilon_0 \frac{\partial \mathbf{E}}{\partial t} \end{align} $$

simplifies, under magnetostatic assumptions, to:

$$ \begin{align} \mu_0 \nabla \cdot \mathbf{H} &= 0 \\ \nabla \times \mathbf{H} &= \sigma \mathbf{E} =: \mathbf{J} \end{align} $$

where $\mathbf{J} := \sigma \mathbf{E}$ is the current density, which we assume to be non-changing and it incurs the magnetization effect microscopically.

Magnetic Fields $\mathbf{H} = \frac{1}{\mu_0} \mathbf{B}$ and Magnetization $\mathbf{M}$

1. Permanent Magnets

$$ \mathbf{H} = \frac{1}{\mu_0} \mathbf{B} - \mathbf{M} $$

2. Induced Magnetization

Materials experience magnetization only in the presence of an external magnetic field:

$$ \mathbf{M}_i = \frac{3}{\mu_0} \frac{\chi}{1+\chi} \mathbf{B}(\mathbf{r}_i) $$

This also extends to superconductors:

$$ \mathbf{M}_i = -\frac{1}{\mu_0} \mathbf{B}(\mathbf{r}_i) $$

Note: For a visual comparison of $\mathbf{B}$, $\mathbf{H}$, and $\mathbf{M}$ fields inside and outside a cylindrical bar magnet, see e.g. Wikipedia - Magnetic Field.

Equivalent Dipole Method (EDM): Magnetized Object as an Aggregation of Dipoles

Leveraging the infinitesimal definition of magnetization $\mathbf{M} = \frac{d\mathbf{m}}{dV}$, we compute the magnetic moment $\mathbf{m}_i$ of a cell indexed with $i$, located at $\mathbf{r}_i$ as:

$$ \mathbf{m}_i = \frac{1}{N} \mathbf{M} V $$

Field Strength Approximation

To calculate the magnetic $\mathbf{B}$-field at a point $\mathbf{r}$ as a result from the dipole source centered at $\mathbf{r}'$, we approximate the field strength using truncated multipole series expansion as in Jackson (1999)2, i.e. we replace the Biot-Savart exact integral in the first equality with an analytical formula assuming simple geometry.

$$ \mathbf{B}(\mathbf{r}) = \frac{\mu_0}{4\pi} \int \frac{\mathbf{J}(\mathbf{r}') \times (\mathbf{r} - \mathbf{r}')}{|\mathbf{r} - \mathbf{r}'|^3} d^3\mathbf{r}' $$

$$ \approx \frac{\mu_0}{4\pi} \left[ \frac{3\mathbf{n}(\mathbf{n} \cdot \mathbf{m}) - \mathbf{m}}{|\mathbf{r} - \mathbf{r}_O|^3} \right] \approx \frac{\mu_0}{4\pi} \sum_{i=1}^{N} \left[ \frac{3\mathbf{n}_i(\mathbf{n}_i \cdot \mathbf{m}_i) - \mathbf{m}_i}{|\mathbf{r} - \mathbf{r}_i|^3} \right] $$

In the first simplification, $\mathbf{n} = \frac{\mathbf{r} - \mathbf{r}_O}{|\mathbf{r} - \mathbf{r}_O|}$ is the unit vector pointing from the dipole’s center at $\mathbf{r}_O$ toward the field evaluation point $\mathbf{r}$.

The last approximate equality follows from the assumption of the EDM, allowing us to sum up the aggregated contribution of all $N$ cells.

Reproducing Benchmarks

In order to verify the correctness of our implementation, we additionally include an analytical benchmark in examples/benchmark/benchmark.cpp to test the force computation of 3D permanent magnets using analytical formula that has been derived and experimentally verified by Akoun and Yonnet 3.

Computed Force vs Analytical Wall Time per Cell Count

Comparison of simulated force between discretized magnets and the analytical solution with increasing cell granularity.

Computation time required for evaluating all pairwise cell interactions

To reproduce the above tables, first run ./bin/benchmark after building from source. Ensure that the output files benchmark_results_{cellnum}cells.json are present in the examples/benchmark directory.

To visualize the results, use the provided Julia script. If you do not already have the required Julia packages, you can install them by running the following command in the Julia REPL:

using Pkg
Pkg.add(["CairoMakie", "JSON", "Statistics", "Colors"])

Then run the visualization script with:

julia akoun_yonnet_benchmark.jl

Execute this command from the examples/benchmark folder containing the results and the script.

Rendering of the Scenes

We used Blender to render the simulated physics; the associated .blend file can be found here.

We also created a realistic magnet surface, which can be used in your own rendering scenes if desired. The corresponding file is attached in the cloud storage linked above.

Procedural Magnet Surface Rendering

Footnotes

  1. Magnets in Motion
    B. Thomaszewski, A. Gumann, S. Pabst, W. Straßer.
    ACM Trans. Graph., 27(5):162, 2008.
    doi:10.1145/1409060.1409115

  2. Classical Electrodynamics Jackson JD (John David Jackson).
    Wiley; 1999.. 3rd ed. New York, NY
    CERN Library

  3. 3D analytical calculation of the forces exerted between two cuboidal magnets
    G. Akoun, J.-P. Yonnet.
    IEEE Transactions on Magnetics, 20:1962–1964, 1984.
    doi:10.1109/TMAG.1984.1063554

About

ETH Zurich PBS in CG project by Haoanqin Gao and Wu You based on the paper Magnets in motion (2008)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages