Skip to main content
Virtual Laboratory
Physics Simulations Free · No Account Free & source-available · CC BY-NC-SA 4.0

Magnetic Field of an Electric Current

Electric currents create magnetic fields whose direction follows Ampère's right-hand rule and whose field lines have no endpoints. Field strength obeys B = μ₀|I|/(2πr) near a straight wire, B₀ = μ₀N|I|/(2R) at a loop center, and B = μ₀n|I| inside a long solenoid. Test Oersted's compass deflection, iron filings, and solenoid probes below.

Magnetic Field of an Electric Current — 3D Bench Preview

Interactive 3D Lab Preview

Runs right on this page in fullscreen · No account required

  • Use the two-orientation comparison to explain why a straight wire aligned North–South directly above a resting compass needle produces a clear deflection. Contrast this with an East–West wire, which creates a collinear field and no deflection when weaker than the horizontal geomagnetic reference.
  • Switch accurately between the two forms of Ampère's right-hand rule (thumb along current for a straight wire vs. curled fingers along current for a loop or solenoid) and trace continuous return field lines running S→N inside a solenoid and N→S outside.
  • Apply vector superposition and component addition to 2D cross-sections of perpendicular dot (⊙) and cross (⊗) current-carrying wires to compute the net magnetic flux density B at symmetric points and predict a compass needle's N-pole direction.

Press Esc or your browser Back button anytime to return to the guide.

Principle, Mechanism & Key Concepts

Magnetic Field of an Electric Current

What You Will Investigate
Goal 01

Use the two-orientation comparison to explain why a straight wire aligned North–South directly above a resting compass needle produces a clear deflection. Contrast this with an East–West wire, which creates a collinear field and no deflection when weaker than the horizontal geomagnetic reference.

Goal 02

Switch accurately between the two forms of Ampère's right-hand rule (thumb along current for a straight wire vs. curled fingers along current for a loop or solenoid) and trace continuous return field lines running S→N inside a solenoid and N→S outside.

Goal 03

Apply vector superposition and component addition to 2D cross-sections of perpendicular dot (⊙) and cross (⊗) current-carrying wires to compute the net magnetic flux density B at symmetric points and predict a compass needle's N-pole direction.

In 1820, Oersted discovered during a lecture that an electric current deflects a compass needle, then tested the effect systematically by placing a wire parallel above a resting needle. In this lesson's East–West vs. North–South comparison, why is deflection far easier to observe when the wire runs North–South?

In 1820, Hans Christian Ørsted first observed a current deflecting a magnetic needle during a lecture in Copenhagen, then confirmed it in his paper Experimenta by holding a wire parallel above a resting compass. Left undisturbed, the needle aligns with Earth's local magnetic meridian (roughly North–South; total field near the surface is about 50 μT, and this lesson sets the horizontal geomagnetic reference to 50 μT as a lesson setting). In this bench's two-orientation comparison, placing the wire East–West directly above the needle creates a North–South current field collinear with the horizontal geomagnetic reference: when aligned, it only pulls the needle tighter without turning it, and when opposite yet weaker than the reference, it still produces no deflection (it flips 180° only if opposite and stronger than the horizontal geomagnetic field). Aligning the wire North–South parallel to the needle creates an orthogonal East–West magnetic field (lesson settings: 20.0 μT at 2.0 A, r = 2.0 cm on the straight-wire station; about 27.3 μT at 3.0 A, h = 2.2 cm on the Oersted station), which combines perpendicularly with 50 μT to swing the needle by a clear 28.6°.

In Oersted's two-orientation test, aligning a straight wire parallel to the resting compass needle (North–South) produces an orthogonal magnetic field that clearly deflects the needle. By Ampère's right-hand rule, point the thumb along a straight wire's current or curl the fingers along a loop or solenoid's current (thumb points along internal B toward the N pole). Magnetic field lines have no endpoints; the return lines drawn here connect continuously from N→S outside to S→N inside.
A. 3D Current Magnetic Fields & Right-Hand Rule (Setting: I = 2.0 A, r = 2.0 cm ⇒ B = 20.0 μT)I ↑① Straight Wire (CCW top)② Current Loop (Max center)SNInside: S→N!③ Solenoid (Connected)B. Wire Cross-Section (Left ⊙, Right ⊗)I ↑⊙ ⊙⊙⊗ ⊗⊗Denser near wire (B ∝ |I| / r)C. Oersted Setup: Why North–South?• Horizontal Earth ref B_E runs S → N• N–S wire parallel ⇒ B_I runs E–W Orthogonal sum turns needle clearly!• E–W wire (comparison): B_I ∥ B_E, no turnOrthogonal angle: tan θ = B_I / B_E
2D Visual Guide & Diagram — Magnetic Field of an Electric Current

Cause-and-Effect Chain

01 Orthogonal Alignment Overcomes Earth's Field
Condition: A resting compass needle aligns North–South along the local magnetic meridian (horizontal geomagnetic reference set to 50 μT, lesson setting).

In this lesson's two-orientation comparison, placing the straight wire parallel above the needle (North–South) produces an orthogonal East–West field B_I, giving deflection angle tan θ = B_I / B_E.

→ Closing the switch swings the needle visibly East or West; reversing current reverses the deflection.
02 Right-Hand Rule Unifies All Current Sources
Condition: Any steady current-carrying conductor (long straight wire, single- or multi-turn circular loop, or closely wound solenoid).

For a straight wire, point the right thumb along current and curl fingers along B. For a loop or solenoid, curl the right fingers along current so the thumb points along the internal axial field.

→ Inside a solenoid, the field is strong and nearly uniform (pointing S → N); outside, return lines spread out sparsely from N back to S.
03 Vector Superposition Gives the Net Field
Condition: A point in space exposed to magnetic fields from two or more current-carrying wires (or a current plus Earth's field).

Magnetic flux density B is a vector (unit: tesla, T; 1 T = 10⁶ μT). Find each component direction with the right-hand rule first, then combine vectors by the parallelogram rule (or signed algebraic sums along a shared axis).

→ Equal, opposite fields cancel (B_net = 0); perpendicular fields combine by the Pythagorean theorem, B_net = √(B₁² + B₂²).

Core Formulas & Quantitative Relations

Rule 1 · Ampère's Right-Hand Rule (Two Standard Grips)
Straight wire: right thumb → I, curled fingers → B | Loop / Solenoid: curled right fingers → I, thumb → internal B (N pole)

Always use your right hand. When holding a pen in your right hand during class or problem solving, it is easy to raise your free left hand out of habit, which reverses every direction.

Law 2 · Extended Field-Strength Equations & Vector Superposition
B = μ₀|I| / (2πr) ∝ |I|/r | Loop center B₀ = μ₀N|I| / (2R) | Long solenoid B = μ₀n|I|

Here B denotes magnitude using |I| (from the Biot–Savart law and Ampère's law), with direction given by the right-hand rule. In air or vacuum, we use μ₀ = 4π × 10⁻⁷ T·m/A (NIST CODATA 2022 value: 1.256 637 061 27 × 10⁻⁶ N/A²). Parallel wires attract when currents flow in the same direction and repel when currents flow in opposite directions.

Principle 3 · Endpoint-Free Field Lines & Compass-Needle Convention
External return lines: N pole → S pole | Inside magnet / solenoid: S pole → N pole (no endpoints; drawn return lines connect inside and out)

A small compass needle placed inside the center of a solenoid aligns its N pole with the local field direction—pointing toward the solenoid's N pole, not toward its S pole.

From 3D Field Lines to 2D Diagrams: Zero-Field Quadrants of Perpendicular Wires

2D electromagnetism problems frequently show two perpendicular or parallel wires with dot (⊙) and cross (⊗) symbols and ask which quadrants can have net magnetic field equal to 0:

  • Step ① (Mark each wire's half-planes separately): for an upward vertical current I₁, the field points out of the page (⊙) to the left and into the page (⊗) to the right. For a rightward horizontal current I₂, the field points out of the page (⊙) above and into the page (⊗) below.
  • Step ② (Add same-direction components and subtract opposite ones): in Quadrant I (⊗ + ⊙) and Quadrant III (⊙ + ⊗), the two fields oppose and can cancel. When I₁ = I₂, the zero-field line lies right along the angle bisector (if currents differ, it shifts toward the weaker current). In Quadrant II (⊙ + ⊙) and Quadrant IV (⊗ + ⊗), the fields reinforce.
Model A · Perpendicular Wires (Assume I₁ = I₂)Model B · Compass N Pole Inside SolenoidI₁ ↑I₂ →Q II: ⊙+⊙ StrongQ I: ⊗+⊙ Can be 0!Q III: ⊙+⊗ Can be 0!Q IV: ⊗+⊗ StrongWhen I₁ = I₂, B_net = 0 on Q I & Q III bisectorLeft S poleRight N poleInternal field points right (S→N)Internal needle N (red) points right to N pole!

Concept Breakdown

01

Electrostatic field lines start and end on charges, whereas magnetic field lines have no endpoints (the return lines drawn here connect inside and outside).

Magnetic field lines look much like electric field lines—what is the fundamental difference?

Electrostatic field lines begin on positive charges and terminate on negative charges. Because no magnetic monopole has ever been observed, magnetic fields are divergence-free (∇·B = 0), so magnetic field lines have neither starting points nor endpoints. For a bar magnet or a finite solenoid, aside from the central symmetry axis extending to infinity at both ends, every return field line drawn in this lesson runs from the N pole back to the S pole outside and continues from S to N inside to form a continuous loop. That is why a compass placed at the center inside a solenoid points its N pole along the internal field (S→N) toward the solenoid's N pole, whereas a compass in the side return region outside points along the external return line (N→S) toward the S pole.

Try in the 3D bench: Open Step 8 (Inside solenoid, Station ③), turn on 3D field lines, and drag two compass needles—one into the center of the bore and one into the side return region—to contrast internal S→N (center 8128 μT, lesson setting) with external N→S return lines.
02

The first current creates a magnetic field at the second wire's location, which then exerts a magnetic force on the second current.

Why do two parallel wires attract with same-direction currents and repel with opposite currents?

A magnetic field is a real physical field that mediates magnetic forces (only the field lines are geometric visual aids). Picture two vertical parallel wires carrying upward currents I₁ (left) and I₂ (right). By Ampère's right-hand rule, left wire I₁ produces a magnetic field pointing into the page (⊗) at wire I₂. Applying the magnetic-force hand rule to upward current I₂ in an into-the-page field gives a force pointing left—toward wire I₁. Same-direction parallel currents therefore attract; reversing one current reverses the force, causing the wires to repel.

Try in the 3D bench: Open Step 4 (B vs. distance, Station ①) and drag the 3D probe or Radial r slider from 2.0 cm to 4.0 cm to verify B ∝ |I|/r for a single straight wire (dropping from 20.0 μT to 10.0 μT, lesson setting; this bench models a single wire to test B ∝ 1/r, while two-wire magnetic forces are covered in the follow-up lesson).
03

Modern physics explains magnetization and demagnetization through ferromagnetic domains growing and aligning, while Ampère's molecular current hypothesis serves as a historical equivalent-loop model.

Why does an iron nail become magnetized near a magnet, and why does heating above its Curie temperature or striking it without an external field weaken its magnetism?

In the 19th century, Ampère proposed the molecular current hypothesis, modeling magnets as collections of tiny circulating currents to unify permanent magnets and electromagnets before electrons and spin were discovered (the circulating loops in this bench's 3D viewer are an illustrative equivalent model). In modern physics (OpenStax Physics §20.1, Figs. 20.7–20.8), ferromagnetic materials such as iron, cobalt, and nickel contain microscopic regions called magnetic domains where atomic magnetic moments align spontaneously. In unmagnetized soft iron, domain orientations point randomly and cancel. In an external magnetic field, domains aligned with the field grow and rotate into alignment, producing strong net magnetism. Conversely, heating a ferromagnet with no external field above its Curie temperature (for elemental iron, 1043 K, about 770 °C; OpenStax §20.1 & USGS Bulletin 2131; alloy magnets vary with composition) uses thermal agitation to randomize domain order. Striking a magnet sharply with no external field weakens magnetism via mechanical disturbance (whereas tapping it inside an external field actually helps domains align, Fig. 20.7)—heating and mechanical shock are distinct demagnetization mechanisms.

Try in the 3D bench: Click Right-Hand Lab (shortcut M) and open tab ② Molecular Currents (Illustrative) to compare aligned equivalent loops against thermally disrupted loops (corresponding in modern physics to ferromagnetic domain growth and orientation).

Reference & Comparison Table

Magnetic Field Geometry, Right-Hand Rule, and Benchmark Probe Readings for Three Current Sources (Lesson setting: I = 2.0 A, air / no iron core)
Current SourceRight-Hand Rule Grip3D Field-Line GeometryInterior / Center Field FeaturesBenchmark Probe Readings (Lesson Setting)
Long straight wireThumb along current I; curled fingers along BConcentric circles in planes perpendicular to the wireDenser closer to the wire (B ∝ |I|/r)20.0 μT at r = 2.0 cm (0.40× Earth); 10.0 μT at r = 4.0 cm (0.20× Earth)
Circular current loop (R = 5.0 cm)Curled fingers along loop current; thumb along axial BReturn loops wrapping the wire plus the central axisPerpendicular to loop plane and strongest at center (B ∝ N·|I|)Center: 25.1 μT (1 turn), 50.3 μT (2 turns), 251 μT (10 turns); 1 turn at z = 5.0 cm: 8.89 μT
Closely wound solenoid (L = 12.0 cm, 400 turns)Curled fingers along coil current; thumb along internal B (N pole)Bar-magnet-like return loops plus central symmetry axisNearly uniform inside (S→N); drops to roughly half at the endsInterior center z = 0: 8128 μT (163× Earth); end face z = 6.0 cm: 4156 μT (0.51× center)
Common Misconceptions

Common Misconceptions

In the East–West vs. North–South comparison, should I place the straight wire East–West above the compass needle to see a clearer deflection?

No. When the bench's current field (27.3 μT, lesson setting) is weaker than the horizontal geomagnetic reference (50 μT, lesson setting), an East–West wire creates a North–South field collinear with Earth's field, leaving the needle undeflected. Aligning the wire North–South parallel to the resting needle generates an orthogonal East–West field that yields a clear 28.6° deflection. Test both orientations in Step 1 of the 3D bench.

Do magnetic field lines run from the N pole to the S pole both outside and inside a solenoid?

Only outside. External return lines run from N to S, but inside a solenoid or bar magnet the field lines continue from the S pole back to the N pole so the loops have no endpoints. A compass needle placed inside the solenoid therefore points its N pole toward the solenoid's N pole. Verify this directly by dragging needles inside and alongside the solenoid in Step 8.

If a diagram leaves blank space between magnetic field lines, does that mean there is no magnetic field there?

No. A magnetic field is a real, measurable physical field that exists continuously everywhere in space—even in the gaps between drawn lines. Only the field lines themselves are visual aids drawn at representative spacing to show direction and relative strength. Drag the 3D probe continuously across the acrylic (plexiglass) boards in Steps 2–7 to see smooth, nonzero readings everywhere.

Practice Quiz

Test your understanding with 6 diagnostic questions

Check concepts, graphs, and experimental error reasoning with immediate feedback for every choice.

Embed & Source Availability

Embed this simulation

Paste this iframe snippet into your non-commercial course page or learning platform.

Free & Source-Available (CC BY-NC-SA 4.0)

This simulation is licensed under CC BY-NC-SA 4.0 for non-commercial educational use, embedding, and adaptation with attribution.

Browse All 159 Free Labs →
Sources, Revision & Feedback

Sources, Revision & Feedback

Quiz →