Ohm's Law

No preview image

3 collaborators

Uri_dolphin3 Uri Wilensky (Author)
Default-person Pratim Sengupta (Author)
Default-person Daniel Kornhauser (Team member)


(This model has yet to be categorized with any tags)
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 4.0beta8 • Viewed 271 times • Downloaded 24 times • Run 0 times
Download the 'Ohm's Law' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


$Id: Ohm's Law.nlogo 37529 2008-01-03 20:38:02Z craig $


This model illustrates how a steady current as well as resistance emerge from simple interactions between electrons and atoms in a wire and battery terminals. It shows how the linear relationship between current (I), resistance(R) and voltage (V) as expressed in Ohm's Law (i.e., V = I * R) emerges from these interactions.


The wire in this model (gray region) is composed of atoms, which in turn are made of negatively charged electrons and positively charged nuclei. According to the Bohr model of the atom, these electrons revolve in concentric shells around the nucleus. However, in each atom, the electrons that are farthest away from the nucleus (i.e., the electrons that are in the outermost shell of each atom) behave as if they are free from the nuclear attraction. These outermost electrons from each atom are called "free electrons". These free electrons obey some rules that are specified in the Procedures tab of the model. The applied electric field due to the battery imparts a steady velocity to the electrons in the direction of the positive terminal. The positive battery terminal (black region), which is actually an enormous collection of positive charges, acts as a sink for negative charges or electron, whereas, the negative battery terminal (red region) is a large source of negative charges or electrons.

Note that electrons reappear on the other side at the negative terminal after crossing into the positive terminal of the battery. This is a greatly simplified representation of the continuous process of charge generation in the battery maintaining a constant voltage (or potential difference) between the two terminals.

Voltage in the battery gives rise to a constant electric field throughout the wire, imparting a steady drift to the electrons while they move in the wire connecting the two terminals. In addition to this drift, the electrons also collide with the atomic nuclei in the wire, giving rise to electrical resistance in the wire. However, to reduce the complexity of the model, these nuclei are not shown in the model.


The TOTAL-ELECTRONS slider allows selecting the total number of free electrons in both the wires. This number is kept constant throughout a single run of the model.

The VOLTAGE slider indicates the magnitude of voltage between the battery terminals. It imparts a steady velocity to the electrons. However, as the next paragraph explains, this velocity also depends on the rate at which the electron collides with the atomic nuclei in the wires.

The COLLISION-RATE-WITH-NUCLEI slider is inversely proportional to how far an electron travels on average without colliding with atomic nuclei. The collision rate of electrons in a wire causes resistance. The collision-rate affects the motion of electrons in it in another way: the net velocity of the electrons is also reduced in proportion to the collision rate.

The button COLOR & TRACE ONE ELECTRON asks an electron to change color and trace its path. If you want to go back to the default settings (with all electrons red and no traces), you need to press SETUP again.

The button WATCH ONE ELECTRON highlights a single electron (chosen randomly) so that you can observe its motion in particular. If you want to go back to the default settings (with all electrons red and no traces), you need to press SETUP again.


When you observe the trace of the path of an electron by pressing the COLOR & TRACE ONE ELECTRON button, how does the path change when you increase or decrease the COLLISION-RATE-WITH-NUCLEI ?


1) Run the model with the default settings. Note the current and number of electrons in the wire.

2a) Increase the collision-rate of electrons with the nuclei. How does the value of current in the wire change? How does the motion of electrons change?

2b) Reduce the collision-rate of electrons with the nuclei. How does the value of current in the wire change? How does the motion of electrons change?

3a) Press WATCH ONE ELECTRON. Using the tick counter, note how much model time the electron takes to travel through the wire. Repeat this observation several times for the same value of collision-rate-with-nuclei. Now calculate the average speed of the electron from these observations.

3b) Repeat 3a for a few different values of the slider COLLISION-RATE-WITH-NUCLEI. What do you notice?

3c) How can you calculate current in the wire from the average speed of an electron through it?

4) Look for the "Procedures for measuring current" section in the Procedures tab. How is current in each wire calculated in this model? Are this method and 3(b) equivalent to each other?

5) Based on your interactions with the model, how would now explain the concepts of current and resistance?


Can you create a series circuit (with two wires in series) by extending this model?


Electrons wrap around the world both vertically and horizontally.



Series Circuit

Parallel Circuit


This model is a part of the NIELS curriculum. The NIELS curriculum is currently under development at Northwestern's Center for Connected Learning and Computer-Based Modeling. For more information about the NIELS curriculum please refer to http://ccl.northwestern.edu/NIELS.

Thanks to Daniel Kornhauser for his work on the design of this model.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

breed [electrons electron]
globals [
  current         ;; current measurement, accumulates for 100 ticks
  last-current    ;; current measurement from previous 100 tick period

;;; Setup Procedures ;;;

to setup
  set-default-shape electrons "circle 2"

  ;; create wire & terminals
  ask patches
    [ set pcolor gray ]
  ask patches with [pxcor >= max-pxcor - 4 ]
    [ set pcolor red ]
  ask patches with [pxcor <= min-pxcor + 4 ]
    [ set pcolor black ]

  ;; create electrons
  create-electrons total-electrons
    setxy random-xcor random-ycor
    set color orange - 2
    set size 1.5

  ;; create labels for the battery terminals
  ask patch (min-pxcor + 4) 0
    [ set plabel "+" ]
  ask patch (max-pxcor - 1) 0
    [ set plabel "-" ]

  ;; since the battery-positive is a sink for negative charges,
  ;; move electrons immediately to the battery-negative
  ask electrons [ if pcolor = black [ set xcor xcor - 7 ] ]

;;; Runtime Procedures ;;;

to go
  ;; Rules for electrons
  ask electrons
    ;; wiggle randomly, performing simple point collisions with invisible
    ;; nuclei in the wire and steadily drifting forward due to the electric field
    ;; contribute to current measurement
  ;; advance tick counter and update the view
  ;; measure and plot current
  if ticks mod 100 = 0
    [ do-plot ]

;; rules for electrons ;;

to move
  ;; perform collisions with (invisible) atoms
  if random-float 1.0 < collision-rate-with-nuclei
    [ rt random 360 ]
  fd 0.3
  ;; drift due to electric field towards the battery-positive
  set xcor xcor - 0.5 * voltage / collision-rate-with-nuclei

;; Plotting procedures ;;

to do-plot
  set-current-plot "Current"
  plotxy (ticks - 100) current / 100
  set last-current current / 100
  set current 0

;; Procedures for measuring current ;;

;; count number of electrons arriving at the battery-positive per tick

to add-current
  if pcolor = black [
    set current current + 1
    set xcor xcor - 6

There is only one version of this model, created almost 14 years ago by Uri Wilensky.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.