Magnetic Field Lines Simulator — Pole Placement & Field Visualization
Freely place N and S poles to draw magnetic field lines in real time. Visualize dipole, quadrupole, and multipole configurations for electromagnetic FEM analysis of motors, transformers, and MRI coils.
Place Magnetic Poles
Click to place • Drag to move • Right-click to delete
Presets
Parameters
Display Options
Results
0
Pole Count
---
Max Field |B|
0
Field Lines
---
Topology
Field
Click the canvas to place a magnetic pole
Theory Notes
🧑🎓 Student × 🎓 Professor — Dialogue
🧑🎓 "What happens to the field lines when you bring two N poles close together? They repel, right?"
🎓 "Right, they repel. In terms of field lines: both N poles push lines outward, so the lines from each pole run out of room and get deflected sideways. That 'pushing against each other' literally is the repulsive force."
🧑🎓 "And with an N and an S pole, they attract — because the field lines connect between them?"
🎓 "Exactly. Lines leaving the N pole terminate at the S pole. Faraday pictured those lines as having a tension that tries to shorten them — and that tension manifests as attraction. Modern electromagnetic FEM formalizes this via the Maxwell stress tensor."
🧑🎓 "How would you actually use this in CAE? What do you judge from looking at field line plots?"
🎓 "In motor design, the key question is whether field lines efficiently cross the air gap between rotor and stator. Leakage flux — lines that wander outside the gap without contributing to torque — means wasted energy. Load up the dipole preset here and watch how the lines concentrate through the center. That concentration pattern is what you're optimizing when you run Ansys Maxwell."
Theory & Key Formulas
Magnetic field from a point pole m (magnetic monopole approximation):
Field line integration (RK4): starting from point $\mathbf{r}$, advance in direction $\hat{B}$ with step size $h$.
CAE Connection: In electromagnetic FEM analysis of motors, transformers, and MRI systems, field line patterns directly indicate design quality. Designs with high leakage flux — lines that escape rather than crossing the air gap — suffer greater losses.
What is a Magnetic Field?
🙋
What exactly are these lines I'm seeing when I place a pole in the simulator? They look like they're coming out of the red "N" and going into the blue "S".
🎓
Exactly! Those are magnetic field lines. They're a visual tool to show the direction and strength of the magnetic force in the space around a magnet. The direction (from N to S) shows where a tiny north pole would be pushed. Try moving the "Pole Strength" slider for a single pole—you'll see the lines get denser (stronger field) or sparser (weaker field).
🙋
Wait, really? So if I place just a north pole, the lines go out forever? But real magnets always have both poles... what's the simulator doing?
🎓
Great observation! You've hit on a key trick in physics. Real magnetic poles come in inseparable pairs (a dipole). But for calculation, we can approximate one end of a very long, thin magnet as a single "point pole" or magnetic monopole. The simulator uses this neat math trick so you can build fields from individual sources. Try placing an "N" and an "S" close together—you've just built a dipole, and the lines connect them!
🙋
That makes sense! So when I add more poles to make a complex shape, the simulator is just adding up these fake "monopole" fields? How does that work mathematically?
🎓
Precisely! This is the principle of superposition. The total magnetic field at any point is the vector sum of the fields from all your placed poles. The simulator calculates this in real time. Play with the "Field Line Density" slider—it changes how many sample lines are drawn from each pole, helping you visualize the summed field strength in different areas.
Physical Model & Key Equations
The simulator models each point pole (N or S) as a source of a radial magnetic field, analogous to the electric field from a point charge. This is the magnetic monopole approximation, useful for constructing complex fields.
$\mathbf{B}(\mathbf{r})$ : Magnetic field vector at position $\mathbf{r}$. $\mu_0$: Magnetic constant (permeability of free space). $m$: Pole strength (positive for North, negative for South). $\mathbf{r}_0$: Position of the point pole. $\hat{r}$ : Unit vector pointing from $\mathbf{r}_0$ to $\mathbf{r}$.
However, a fundamental law of magnetism states that true, isolated magnetic monopoles do not exist. The magnetic field must form closed loops, which is expressed by Gauss's Law for magnetism.
$$\oint_S \mathbf{B}\cdot d\mathbf{A} = 0$$
This equation says the net magnetic flux through any closed surface $S$ is always zero. In practice, this means every field line leaving a north pole must eventually enter a south pole. In the simulator, when you place poles, the drawn lines will always reflect this law, connecting poles or looping back on themselves.
Frequently Asked Questions
First, check whether the magnetic poles are correctly positioned on the screen. Verify that the pole strength (m value) is not set to 0 or extremely small. Also, if the poles are outside the display range, they will not be rendered, so try resetting the view or zooming out.
The direction of the arrows indicates the direction of the magnetic field (magnetic flux density B) at that location. The basic direction is from the N pole to the S pole, with the arrowhead pointing in the direction of the magnetic field. The color or length may also represent the strength of the magnetic field, so please check the legend on the screen.
For a dipole, place one N pole and one S pole close together. For a quadrupole, arrange N, S, N, and S poles alternately in a square or straight line. Observe that the magnetic field line pattern forms a figure-eight shape for a dipole, while for a quadrupole it forms more complex closed loops.
This tool is intended for basic understanding of electromagnetic FEM and is suitable for qualitative visualization of magnetic field line patterns. However, in actual design, factors such as core permeability, eddy currents, and the influence of three-dimensional geometry cannot be ignored, so please use dedicated FEM software for quantitative design.
Real-World Applications
Permanent Magnet Design: Engineers use field visualization to design magnets for speakers, hard drives, and MRI machines. By arranging pole strengths and geometries (like the quadrupole you can create in the simulator), they can shape the magnetic field for a specific purpose, such as creating a very uniform field inside an MRI scanner.
Particle Accelerators & Beam Steering: Complex arrangements of magnets, like quadrupoles and sextupoles, are used to focus and steer beams of charged particles. The simulator helps build intuition for how alternating sequences of N and S poles can pinch or bend a particle beam traveling through the center.
Magnetic Shielding: To protect sensitive equipment from stray magnetic fields, shields are designed using materials that "redirect" field lines. Visualizing how field lines prefer to travel through certain paths (like between nearby poles) is key to understanding how shielding works.
Educational & Diagnostic Tool: Before running complex 3D CAE simulations, physicists and engineers often sketch expected field line patterns. This simulator provides that intuitive first step, helping to diagnose issues or plan experiments by quickly testing different pole configurations.
Common Misunderstandings and Points to Note
First, understand that this simulator deals with an idealized model called "point magnetic poles". In a real bar magnet, N and S poles always exist as a pair, and the poles are spread over a surface, not a "point". Therefore, if you place two N poles extremely close together in the simulator, a repulsive force that is unrealistically strong in reality will be calculated. This is purely a tool for understanding principles; for precise design of actual devices, you'll need higher-accuracy FEM software.
Next, don't misunderstand the meaning of the "Display Density" slider. Increasing it makes the magnetic field lines appear denser, but this does not mean "the magnetic field itself has become stronger". For example, increasing the pole strength from 10 to 20 will strengthen the field, but increasing the display density from 10 to 20 only increases the number of visible lines. Judge the field strength by the "Pole Strength" slider and the crowding of the field lines (the spacing between lines).
Finally, a common pitfall in practical work is "ignoring the influence of surrounding materials". This simulator calculates for a vacuum (air). But in actual design, if there are ferromagnetic materials like iron, magnetic field lines concentrate and are drawn to them (magnetic shielding or magnetic circuit formation), and if there are conductors like copper, eddy currents are generated, working to cancel the magnetic field. The correct step is to first get a feel for the basic "magnetic field in a vacuum" with this tool, and then learn "how it changes when materials are added".
Set pole strength in the sStrengthNum field (typically 1–10 Tesla for permanent magnets, 0.5–5 T for electromagnets)
Adjust sNLinesNum to control field line density (50–200 lines recommended; higher values show finer detail but increase computation)
Define sStepNum as the numerical integration step size (0.01–0.1 units; smaller steps yield smoother trajectories but require longer processing)
Click and drag to place north and south poles on the canvas; the simulator recalculates field lines in real time
Observe how dipoles create closed loops, opposing poles attract with concentrated lines between them, and like poles repel with field line separation
Worked Example
Configure two opposite poles 0.5 m apart with sStrengthNum = 3.0 T, sNLinesNum = 120 lines, sStep = 0.05 units. The simulator traces field paths starting from the north pole, curving smoothly toward the south pole. The field strength at 0.1 m from a 2 T pole approximates 40 mT using the dipole moment scaling. If you then place a third pole (north, 0.3 m away), the field pattern transitions from a simple dipole to a quadrupole, with additional null points appearing where field vectors cancel. Decreasing sStep to 0.02 resolves these singularities more accurately.
Practical Notes
Use sNLinesNum = 80–100 for quick sketches of MRI magnet layouts (typically 1.5–3 T field strength) and 150+ for precision motor design verification
Real neodymium magnets (Nd₂Fe₁₄B) produce surface fields of 0.3–0.6 T; simulate these with sStrengthNum = 0.4 to match experimental measurements
Reduce sStep below 0.03 when poles are closer than 0.2 m to prevent field line jumping across discontinuities
Place poles symmetrically to verify quadrupole and sextupole configurations used in particle accelerator focusing elements