A Byte of PhysicsLogo

Fields due to currents

Current is moving charge with a direction. That direction makes its magnetic field different from a scalar heat or potential field: at a point beside a wire, the field circulates around the wire instead of pointing straight away from it. A program needs a coordinate convention before it can draw or add such vectors. This lesson uses x right, y up, and z out of the screen. Positive current in a straight wire therefore points in +z, and the right-hand rule makes the field circulate counter-clockwise when viewed from +z.

Think like a programmer

Represent a wire as ordered source segments, not as an unlabelled line on a canvas. Each segment carries a start point, end point, current, and medium/permeability policy. Calculate its contribution in a pure function, sum contributions at a named probe, and keep rendering downstream of that calculation. Test a symmetry case and an analytic reference before trusting an attractive arrow plot.

Model checklist

Inputs
Ordered wire geometry, current in amperes, probe positions in metres, permeability, segment count, singularity-exclusion radius, and coordinate convention.
State
Source segments, probe field vectors in tesla, field-sum diagnostics, resolution, and any excluded near-wire samples.
Rule
For each probe, add the oriented Biot–Savart contributions from all wire segments; for an infinite straight z-directed reference wire, use the analytic circular field.
Output
Magnetic-field vector B, magnitude, direction, convergence change, and a list of omitted or regularized samples.
Check
Reversing current negates B; equal and opposite currents cancel at a symmetric probe; the infinite-wire reference has |B| proportional to |I|/r; a refined finite-wire sum approaches its declared reference away from the wire.
\[d\mathbf B=\frac{\mu}{4\pi}\frac{I\,d\boldsymbol\ell\times\mathbf R}{\lVert\mathbf R\rVert^3}\]

Here, dℓ is a tiny vector in the direction of conventional current and R points from that source element to the probe. The cross product is the direction contract: swapping the operand order silently reverses every arrow. μ is the medium permeability; the simple lab uses vacuum permeability, approximately 1.25663706212 × 10⁻⁶ T·m/A. Its units are useful: the result is tesla after a length contribution, current, and inverse-square geometry are combined.

For one ideal infinitely long wire at the origin, the segment integral has a compact regression answer:

\[\lVert\mathbf B(r)\rVert=\frac{\mu_0\lvert I\rvert}{2\pi r},\qquad \mathbf B(x,y)=\frac{\mu_0 I}{2\pi(x^2+y^2)}(-y,x)\]

The second form is especially convenient in code. At probe (r, 0), a positive current must give a positive y component; reversing the current must negate it. At twice the probe radius, the magnitude must halve. Those small tests expose coordinate and denominator mistakes before a finite-segment model introduces discretization error.

Loading the interactive visual. The lesson text and model remain available while it starts.

For a finite or curved wire, divide the path into short directed pieces and form a weighted vector sum. Halve the maximum segment length while keeping the same physical probe and report the difference between successive estimates. Do not compare a point that moves with the mesh, and do not treat a picture with more arrows as evidence of convergence. A useful output record contains the probe coordinate, field vector, field magnitude, segment count, smallest source-to-probe distance, and the estimated refinement change.

The singularity at a wire is not a JavaScript edge case. The ideal thin-wire model predicts an unbounded field at r = 0, where it has no physical cross-sectional information. Reject or explicitly regularize probes inside a named wire radius; never substitute zero and call that a physical field. A real conductor also has finite radius, current distribution, material response, and sometimes time-dependent electromagnetic fields.

Try this experiment

Prediction: At the same probe, reversing an ideal straight-wire current reverses the field vector; doubling the probe radius halves its magnitude.

Start at (0.50 m, 0) with +4 A. Record the signed y component in microtesla. Reverse the current without moving the probe and predict the new vector. Reset the current, double the radius, and compare the magnitude ratio. Then write a segment-sum test that checks a finite straight wire approaches the analytic reference only for probes far from its ends.

Where this model breaks

The Biot–Savart static-current model is not a complete electromagnetic solver. It omits signal delay, radiation, displacement current, magnetic materials unless μ is modeled, skin effects, finite conductor cross-section, and quantum material behaviour. Near a wire, a point-source/point-probe approximation and coarse segment mesh can both fail. Keep physical approximation error separate from numerical convergence error.

Summary

Treat current-generated magnetism as an oriented vector computation. Establish the straight-wire reference, then use directed segment sums with units, singularity policy, symmetry tests, and mesh-refinement evidence.

Glossary

Sources

Model contract

Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.

\[\text{observable output} = f(\text{inputs},\,\text{state})\]
Inputs
Quantities you set or measure, with units and useful bounds.
State
Values the program must retain to reproduce the next result.
Rule
The relationship or update that turns inputs and state into a result.
Check
A known limit, unit check, invariant, or measured result that can expose a bad model.

Implement the idea as a model

For Fields Due to Currents, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Magnetism and Induction, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.

Guided experiment

Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.

Where this model breaks

This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.

Summary

Treat Fields Due to Currents as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.

Glossary

  • Input: a measured value or chosen parameter supplied to a model.
  • State: the smallest set of values needed to continue or reproduce a model.
  • Validation: comparing an output with a known result, limit, invariant, or measurement.

Self-check

  1. Which values are inputs, and which values must remain state?
  2. What observable result would tell you the model is behaving as expected?
  3. Which assumption would you test first before applying the model to a real system?

Model review: turn Fields Due to Currents into a test

Approximate current-generated magnetic fields with oriented segments and convergence checks.

  1. Name the inputs and units that the magnetism and induction model needs.
  2. Separate the state you must keep from values you can calculate when needed.
  3. Write one rule that maps the current state and inputs to an observable result.
  4. Choose a limiting case, unit check, invariant, or known result before trusting an output.
  5. State one assumption you would change before using this simplified model for a real decision.

Share to: