Magnetic Force on a Wire

JJ Ben-Joseph headshot JJ Ben-Joseph

Wire deflection under magnetic force; kinetic energy red, spring energy blue.

Simulation not started.

Magnetic Force on a Conductor

A straight conductor carrying current through a magnetic field experiences a force described by the Lorentz law. When the wire is free to move, this force can set it into motion. Our simulator transforms the algebraic expression F=ILBsinθ into a dynamic mass–spring system so you can watch the deflection evolve. The current I flows along the wire of length L; a uniform magnetic field of magnitude B makes an angle θ with the wire. The resulting force direction follows the right-hand rule and is perpendicular to both the current and field. To illustrate motion within the plane of the screen, we choose the magnetic field to point into the page so that the force acts upward when current runs to the right.

Variables and Assumptions

Inputs are constrained to SI units: amperes for current, meters for length, tesla for field, kilograms for mass, newtons per meter for spring stiffness, and newton-seconds per meter for viscous damping. The wire is modeled as a rigid bar attached to a horizontal spring that allows only vertical motion. The angle θ is measured between the current direction and magnetic field; by keeping the field perpendicular to the screen, varying θ is equivalent to rotating the wire within the plane. A positive angle yields a force out of the page; to keep the visualization two-dimensional, we project that force onto the upward direction. Though simplified, this arrangement captures the essential dependence on sinθ.

Deriving the Equations

The net vertical force on the mass attached to the wire combines magnetic, spring, and damping contributions:

m d2y dt2 = ILBsinθ - ky - c dy dt

Rearranging gives the familiar second-order ordinary differential equation for a damped driven harmonic oscillator:

d2y dt2 + c m dy dt + k m y = ILBsinθ m

The right-hand side is a constant drive term. Our numerical solution uses a fourth-order Runge–Kutta algorithm to update position y and velocity v. Kinetic energy is 12mv2 and spring potential energy is 12ky2. We plot both energies and total mechanical energy to monitor dissipation.

Numerical Scheme

RK4 advances the state vector (y, v) with timestep Δt. At each step the algorithm evaluates the acceleration function four times:

  1. Compute acceleration using the current y and v.
  2. Estimate mid-step values using half the timestep.
  3. Repeat for a second mid-step with updated estimates.
  4. Blend the four slopes to produce a high-accuracy update.

Input validation clamps Δt between 0.001 s and 0.05 s to preserve stability. If invalid numbers appear (NaN or infinite), the script halts and reports an error via the live region.

Worked Example

Suppose a 0.2 m wire of mass 0.05 kg carries 10 A through a 0.5 T field at 90°. The magnetic force is F=10×0.2×0.5=1 N upward. With spring constant 5 N/m and damping 0.1 N·s/m, the wire accelerates until the spring force balances the magnetic drive at a static displacement of 0.2 m. Running the animation reveals a transient oscillation that decays as damping removes energy. The CSV file logs time, displacement, velocity, and energies, enabling verification: the static displacement matches Fk.

Comparison Table

Changing parameters highlights physical trends. The table compares the peak displacement and settling time for three cases with all else equal:

Case Peak y (m) Settling time (s)
Baseline (I=10 A) 0.23 2.5
Higher current (I=15 A) 0.35 3.0
Stiffer spring (k=10 N/m) 0.12 1.8

How to Read the Animation

The canvas shows a horizontal wire (gray rectangle) anchored to a spring on the left. Blue X symbols represent the magnetic field directed into the screen. When the simulation runs, a red dot marks the wire's center moving up or down. A green arrow indicates the magnetic force. The energy bar below the canvas depicts kinetic energy in red and spring potential in blue; gray indicates total mechanical energy. Keyboard focus on the canvas allows pressing the spacebar to toggle play/pause. Screen-reader users receive updates through the summary region describing time, displacement, velocity, and energies.

Limitations and Further Study

The model assumes the wire remains rigid and the magnetic field uniform. Real motors involve distributed coils and spatially varying fields requiring integration along the wire. Induced currents, heating, and nonlinear magnetic materials are ignored. We restrict motion to one dimension; in reality, the force vector may point out of the plane, necessitating 3‑D visualization. Despite simplifications, the simulator conveys the essential relationship between current, field, and mechanical response. Extensions could include rotating loops, AC driving currents, or coupling multiple wire segments.

References and Related Tools

Background on the Lorentz force and applications can be found in standard texts such as D. J. Griffiths, Introduction to Electrodynamics. For more dynamical systems, explore the mass–spring simulator, the RC circuit transient tool, or the double-slit wave animation.

Embed this calculator

Copy and paste the HTML below to add the Current-Carrying Wire Force Simulator to your website.