Electrical conduction can be described at several scales. A circuit model uses terminal voltage and current. A local continuum model uses electric field and current density. A carrier model adds density, mobility, scattering, and diffusion. A quantum transport model is needed when phase coherence or device dimensions invalidate local drift.
More detail is not automatically more accurate. Use the least detailed model whose assumptions match the material, geometry, temperature, frequency, and length scale of the question.
For an ohmic component at fixed conditions,
\[V=IR\]This is a constitutive relation, not a universal law for every device. A diode, heated filament, battery, and gas discharge need not have constant \(R\).
For a uniform conductor of length \(L\), cross-sectional area \(A\), and resistivity \(\rho\),
\[R=\rho\frac{L}{A}\]This follows from the local relationship
\[\mathbf J=\sigma\mathbf E,\qquad \rho=\frac{1}{\sigma}\]when current density and field are approximately uniform. Since \(I=JA\) and \(V=EL\), the geometric resistance formula follows.
resistivity, length, area, voltage = 1.68e-8, 2.0, 1e-6, 1.0
resistance = resistivity * length / area
assert resistance > 0
current = voltage / resistance
print(f"Resistance: {resistance:.6f} ohm; current: {current:.3f} A")
Doubling length doubles resistance; doubling cross-section halves it. These scalings fail if temperature, material, or geometry changes at the same time.
Current density is charge transported per area per time. For one carrier type,
\[\mathbf J=nq\mathbf v_d\]where \(n\) is number density, \(q\) is signed carrier charge, and \(\mathbf v_d\) is average drift velocity.
Electrons have negative charge and drift opposite the applied electric field in a simple material. Their conventional current points along the field because both \(q\) and
\(\mathbf v_d\)reverse relative to positive-carrier intuition.
The drift speed is usually much smaller than the speed at which an electrical disturbance propagates through a circuit. Establishment of fields and energy flow is an electromagnetic boundary-value problem; it is not the time for one electron to traverse the entire wire.
The classical Drude model treats carriers as undergoing collisions with mean relaxation time \(\tau\). For a carrier of charge \(q\) and effective mass \(m^*\), the average steady drift is
\[\mathbf v_d=\frac{q\tau}{m^*}\mathbf E\]and
\[\mathbf J=\frac{nq^2\tau}{m^*}\mathbf E,\qquad \sigma=\frac{nq^2\tau}{m^*}\]The charge is squared in conductivity, so conductivity is positive for either charge sign in this simple isotropic model. Define the positive mobility
\[\mu=\frac{|q|\tau}{m^*}\]to obtain
\[\sigma=n|q|\mu\]Drude theory explains several broad trends but treats scattering classically and does not correctly capture all electronic heat capacity, Hall coefficients, or quantum band effects. In crystals, \(m^*\) represents band response and may be a tensor.
If a characteristic carrier speed is \(v\), the mean free path is
\[\ell=v\tau\]When device dimensions are much larger than relevant mean free paths and local equilibrium is reasonable, diffusive transport models are useful. When a device is comparable to or shorter than the mean free path, carriers can cross ballistically and a local resistivity may cease to describe the conductance.
Coherence length adds another scale. Quantum interference can matter even in a sample larger than a momentum mean free path if phase information persists. State which lengths are being compared rather than labeling a device “nanoscale” and assuming one regime.
Carrier density gradients also produce current. Using \(e>0\), electron density \(n\), and hole density \(p\), conventional current densities in an isotropic nondegenerate model are
\[\mathbf J_n=en\mu_n\mathbf E+eD_n\nabla n\] \[\mathbf J_p=ep\mu_p\mathbf E-eD_p\nabla p\]The diffusion signs differ because electrons carry charge \(-e\) while holes are treated as positive carriers. With uniform densities, only drift remains. With zero field, carriers diffuse from high number density to low number density, while electron conventional current points opposite electron particle flux.
For nondegenerate carriers near thermal equilibrium, mobility and diffusion coefficient obey the Einstein relation
\[\frac{D}{\mu}=\frac{k_{\mathrm B}T}{e}\]This form does not apply unchanged to every degenerate carrier gas or strongly driven system.
q, n, p, mu_n, mu_p, field = 1.602176634e-19, 1e21, 1e15, 0.14, 0.05, 10.0
D_n, D_p, gradient_n, gradient_p = 0.0036, 0.0013, 1e20, -1e14
J_n = q * n * mu_n * field + q * D_n * gradient_n
J_p = q * p * mu_p * field - q * D_p * gradient_p
print("Electron and hole currents (A/m^2):", J_n, J_p)
Local carrier populations change through current divergence, generation, and recombination. With conventional currents and rates \(G\) and \(R\),
\[\frac{\partial n}{\partial t}=\frac{1}{e}\nabla\cdot\mathbf J_n+G_n-R_n\] \[\frac{\partial p}{\partial t}=-\frac{1}{e}\nabla\cdot\mathbf J_p+G_p-R_p\]These signs follow from electron charge being negative and hole charge being positive. Integrating over a device should reproduce the boundary current plus net generation and recombination. That global balance is a stronger check than a smooth carrier-density plot.
The electric field is often solved self-consistently from electrostatic potential \(\varphi\):
\[\mathbf E=-\nabla\varphi,\qquad \nabla\cdot(\epsilon\nabla\varphi)=-\rho_{\mathrm{charge}}\]Contacts supply boundary conditions and can dominate device behavior. Assuming ideal ohmic contacts is a model choice, not a default fact.
In ordinary metals, carrier density changes relatively little with temperature, while lattice vibrations increase scattering. Resistivity therefore usually rises with temperature over a broad range and is often approximated locally by
\[\rho(T)\approx\rho(T_0)\left[1+\alpha(T-T_0)\right]\]The coefficient \(\alpha\) and valid temperature interval must be supplied. The approximation can fail at low temperature, near phase transitions, or when self-heating is large.
In semiconductors, temperature can strongly change carrier density as well as mobility, so resistance may decrease as temperature rises. A single universal “hotter means more resistance” rule is false.
Local electrical power transferred to matter is
\[p_{\mathrm{volume}}=\mathbf J\cdot\mathbf E\]For a lumped passive resistor,
\[P=IV=I^2R=\frac{V^2}{R}\]The last three forms require consistent terminal sign conventions and ohmic resistance. Electrical energy transferred over time is \(W=\int P\,dt\). If heating changes resistivity, current and temperature must be solved together; holding resistance fixed is then inconsistent.
In a short coherent conductor, transport can be described through transmission channels. A two-spin-degenerate Landauer form is
\[G=\frac{2e^2}{h}\sum_nT_n\]where \(0\leq T_n\leq1\) is a channel transmission. Resistance now includes contact and transmission physics and does not generally scale as \(L/A\). This regime shows why choosing a model by scale matters.
Use a lumped resistor for steady terminal behavior of a uniform ohmic sample. Use spatial Ohm or heat equations for nonuniform fields and self-heating. Use drift–diffusion for semiconductor carrier profiles under its local-equilibrium assumptions. Use ballistic or quantum transport when dimensions, mean free path, and coherence demand it.
Check:
Nonlinear contacts, magnetic fields, thermoelectric effects, frequency dependence, strong correlations, superconductivity, and quantum coherence can all require additional equations. Report the omitted physics beside any conduction result.
Use a fixed electron density and mobility to calculate a drift current. The question for this calculation is precise: how does drift current density change when we change applied electric field, while keeping the other choices fixed? The earlier sections explain the physical relationship. Here we turn one part of that relationship into a calculation that you can run, inspect, and change in Google Colab.
Density gradients, field-dependent mobility, and heating are omitted from this slice. Keep that sentence beside the results. A formula can return a number outside its useful range, and a plotting library will usually draw that number without asking whether the physical assumptions still hold. The selected interval is from -100 to 100 V/m. It gives us a specific domain to discuss instead of leaving the graph's range to a software default.
Use the notebook link above the lesson, run the setup cell, and then run the cells in order. The code below is also included there. NumPy handles the arrays of numerical values, SymPy keeps the equation symbolic, and Matplotlib draws the results. If these libraries or notebook cells are unfamiliar, start with Your first physics notebook.
In this small example, q stands for applied electric field, expressed in V/m. The output is
drift current density, expressed in A/m^2. The equation below uses the numerical values in those
units. Any fixed coefficients therefore carry the units needed to make the relation
consistent. A value supplied in another unit must be converted before it enters this
expression.
This is a function of one changing input. It is not a statement that the physical system has only one variable. We deliberately hold the other inputs fixed so that one cause of variation is visible. Changing several inputs at once would make it harder to tell which change produced the output difference. Write down the held-fixed choices before trying a different experiment.
At 10 V/m, the expression gives 224.305 A/m^2. This is our reference calculation. It is a prediction of the stated example, not a new measurement. Its displayed digits help us compare implementations. They should not be read as a claim that physical inputs are known to six significant figures.
import numpy as np
import sympy as sp
import matplotlib.pyplot as plt
q = sp.Symbol("q", real=True)
expression = sp.sympify("1.602176634e-19*1e21*0.14*q", locals={"q": q})
reference_input = 10.0
reference_output = float(expression.subs(q, reference_input))
print("Input:", reference_input, "V/m")
print("Predicted drift current density:", reference_output, "A/m^2")
sp.Symbol declares a mathematical symbol. It does not assign a numerical measurement
to that symbol. subs then replaces the symbol with our chosen input, and float
converts the resulting symbolic number into a standard Python numerical value.
Keeping these steps separate lets us inspect the equation before numerical substitution.
It also prevents a later plot from becoming the only surviving record of the model.
Before drawing hundreds of points, calculate three. The lower endpoint gives -2243.05 A/m^2. The midpoint, at 0 V/m, gives 0 A/m^2. The upper endpoint gives 2243.05 A/m^2. Read these together with the assumptions: they describe different choices of applied electric field within the same example, with the other inputs held fixed.
These three values are a useful first check, but they do not establish the shape between them. Two endpoints can be equal even when the curve bends or oscillates in between. Likewise, a large change between endpoints does not tell us whether the relationship is linear. We need the equation and intermediate samples to answer those questions.
evaluate = sp.lambdify(q, expression, modules="numpy")
inputs = np.array([-100.0, 0.0, 100.0])
outputs = np.asarray(evaluate(inputs), dtype=float)
outputs = np.broadcast_to(outputs, inputs.shape)
for input_value, output_value in zip(inputs, outputs):
print(f"{input_value:.6g} V/m -> {output_value:.6g} A/m^2")
assert np.all(np.isfinite(outputs))
lambdify turns the symbolic expression into a numerical function. We explicitly select
NumPy as its numerical backend so it can accept an array. The same expression now has
two useful forms: one for algebra and one for calculating many cases. The assertion
checks that the chosen inputs produce finite outputs. It would catch an infinity or an
undefined numerical result, but a finite value can still be physically inappropriate.
The horizontal axis shows applied electric field; the vertical axis shows drift current density. Every plotted point is a prediction of the same expression. We mark the reference case separately so that a reader can connect the earlier printed value to its place on the curve. The axis labels include units because a shape without a scale cannot tell us the size of a physical effect.
input_grid = np.linspace(-100.0, 100.0, 301)
output_grid = np.asarray(evaluate(input_grid), dtype=float)
output_grid = np.broadcast_to(output_grid, input_grid.shape)
fig, ax = plt.subplots(figsize=(7, 4))
ax.plot(input_grid, output_grid, label="Stated model")
ax.scatter([reference_input], [reference_output], label="Reference case", zorder=3)
ax.set_xlabel("Applied electric field (V/m)")
ax.set_ylabel("Drift current density (A/m^2)")
ax.legend()
ax.grid(alpha=0.25)
fig.tight_layout()
plt.show()
Look for a sign change, a turning point, or a region where the curve becomes steep. Connect each feature to the expression rather than to the colour of the line. If the curve has a minimum or maximum, changing the input in opposite directions may have similar effects on the output near that point. If it is nearly straight over a short interval, a local linear approximation may be useful even when the complete expression is nonlinear.
Increasing the number of samples makes the line smoother and may reveal features that a coarse grid missed. It does not improve the physical inputs or enlarge the model's validity range. For quantities that can take only discrete values, use the line as a guide to the relationship and interpret only the allowed input values. A plotting function does not enforce such restrictions for you.
A derivative asks a more specific question than the whole graph: how quickly does drift current density change near the reference input? Its units are the output unit divided by the input unit. For this calculation, the derivative at 10 V/m is 22.4305 in those ratio units. Locally, the output increases as the input increases. This statement is local; the sign or size of the slope can be different elsewhere on the curve.
\[f'(q) = 22.43047287600000064712\]For a small input change, multiply the derivative by that change to estimate the output change. Then compare that estimate with a fresh evaluation of the full expression. The distinction between these two calculations matters: the derivative gives a tangent approximation, while substitution evaluates the chosen expression at the new point.
slope_expression = sp.diff(expression, q)
slope_at_reference = float(slope_expression.subs(q, reference_input))
changed_input = 11.0
linear_prediction = reference_output + slope_at_reference * (
changed_input - reference_input
)
full_prediction = float(evaluate(changed_input))
print("Symbolic derivative:", slope_expression)
print("Tangent prediction:", linear_prediction, "A/m^2")
print("Full expression:", full_prediction, "A/m^2")
print("Approximation difference:", full_prediction - linear_prediction, "A/m^2")
Here the changed input is 11 V/m. The tangent estimate is 246.735 A/m^2, while the full expression gives 246.735 A/m^2. If the two values are close, it means the chosen input change is small enough for this local approximation at this point. It does not mean the entire model is linear. If the slope is zero, a quadratic or higher-order term may supply the leading change instead.
This is also the beginning of uncertainty propagation. If the input has a small stated standard uncertainty, the magnitude of the slope times that uncertainty estimates one contribution to output uncertainty. Do not automatically use the same rule for a wide interval, a discontinuity, a turning point with zero first derivative, or several correlated uncertain inputs. Those situations need more of the model than one slope.
We can estimate the same slope from values on either side of the reference point. Subtract the lower output from the upper output and divide by twice the input step. Parentheses are essential: the entire output difference must be divided by the entire input interval. Without them, Python can execute a different mathematical expression while still producing a plausible number.
The calculation below uses three decreasing step sizes. Each estimate is compared with the symbolic derivative, so the reference is independent of the numerical difference formula. Near an endpoint, it is acceptable here to evaluate a small extension only because the displayed mathematical expression is smooth there; such a check does not assert that extrapolated values describe additional physical cases.
input_span = 200.0
for fraction in [1e-2, 1e-3, 1e-4]:
step = input_span * fraction
upper = float(evaluate(reference_input + step))
lower = float(evaluate(reference_input - step))
numerical_slope = (upper - lower) / (2 * step)
difference = numerical_slope - slope_at_reference
print(f"step={step:.6g}: slope={numerical_slope:.6g}, difference={difference:.6g}")
For a smooth function, reducing the step often reduces the approximation error at first. Very small steps can eventually make subtraction of nearly equal floating-point values less reliable. Therefore “smaller” is not an unlimited guarantee of “better.” Compare the observed behaviour over a useful range of steps instead of choosing the smallest number the computer can represent.
An absolute slope difference is useful when the expected slope is near zero. A relative difference would divide by a very small reference and could look enormous even when the absolute discrepancy is tiny. Away from zero, a relative difference can help compare quantities with very different scales. The tolerance should reflect the question and the numerical method, rather than a universal decimal threshold copied into every test.
Make one copy of the reference calculation before editing it. Choose a second value of applied electric field inside the stated interval, predict whether drift current density will rise or fall, and then evaluate the expression. Place the prediction and the result in a text cell. If they disagree, identify whether the mistake was in the sign, the unit conversion, the algebra, or the assumption about how the curve behaves.
Next choose a shorter plotting interval around the reference point. Compare the local curve with its tangent approximation. Then widen the interval again. The difference shows why a useful local estimate need not describe the whole range. Keep the axis labels and numerical scale visible when comparing the plots; automatic axis limits can make two different effects appear equally large.
Finally, return to the physical limit stated at the start: Density gradients, field-dependent mobility, and heating are omitted from this slice. Describe one change to the setup that would violate that limit. State what new input, equation, or observation would be needed before trusting an answer in the changed situation. This last step connects the Python experiment to the physics instead of treating successful execution as the only criterion for a useful result.
Before saving, restart the runtime and run all cells in order. A result that depends on an earlier, now-deleted input cell is not reproducible from the saved notebook. Keep unrounded values for later calculations, round only the reported output, and label any new data as measured, assumed, or generated. The graph and printed values should remain traceable to the same expression and the same choices of inputs.
There is another way to check that the expression and its derivative describe the same relationship. Add up the small output changes predicted by the slope across the chosen input interval. In the continuous limit, this integral equals the output at the upper endpoint minus the output at the lower endpoint. The result has units of A/m^2: the input unit in the integration cancels the input unit in the denominator of the slope.
This statement is about the mathematics of this particular relationship. It does not assign a new physical meaning to an arbitrary area under a graph. For example, an area under force versus distance represents work, while an area under a different pair of quantities may represent something else or have no standard name. Always carry the axis units through the calculation before naming an integral.
slope_function = sp.lambdify(q, slope_expression, modules="numpy")
endpoint_change = float(evaluate(100.0) - evaluate(-100.0))
for points in [101, 201, 401]:
grid = np.linspace(-100.0, 100.0, points)
slopes = np.asarray(slope_function(grid), dtype=float)
slopes = np.broadcast_to(slopes, grid.shape)
integrated_change = np.trapezoid(slopes, grid)
print(
points,
"integrated change:",
integrated_change,
"endpoint change:",
endpoint_change,
)
The trapezoidal rule joins neighbouring slope samples with straight segments and adds their signed areas. A negative contribution remains negative; replacing every slope by its magnitude would calculate a different quantity. Increasing the sample count provides a practical refinement check. If the values do not settle toward the endpoint difference, first inspect the interval, singularities, and array ordering.
Do not conclude that two agreeing calculations prove the model is physically complete. Both use the same selected relationship, so an omitted effect would be omitted from both. Their agreement is evidence that the numerical tools implement that relationship consistently. Comparing with an independent experiment or a more appropriate physical model is a separate test.
Keep this comparison in the notebook when you change the expression. It is particularly useful after adding a coefficient, changing a sign convention, or converting an input unit. A code cell that produces a smooth graph can conceal these mistakes; a second calculation of the same output change gives you another place to notice them.