Oak Ridge Institute of Science Education
       
"Supporting DOE and other federal agencies' missions to strengthen the
nation's science education and research initiatives"
       
(Special thanks to Marie Westfall and Terri Stone of DOE and ORAU.)
Astuti Kumar | Maxwell Wright | Maximiliano Zamora | Seeley Ferouz | Laura Huang | Ayzhanae Dubose |
Samuel Wall | Auster Zhang | Anita Heath | Victor Leflar | Dennis Gutierrez |
Richard Scalettar (and friends) | Valentin Taufour | Dubarrie Fagout | Jen Garcia | Mayra Leon-Sandoval | Miguel Alba |
What we do:
We learn to code in python! This program evolves the
pole strengths in a random magnetic material.
import random
import math
n=20
ntime=80
magnet=[[0]*n for y in range(n)]
newmagnet=[[0]*n for y in range(n)]
Ja=[[0]*n for y in range(n)]
Jb=[[0]*n for y in range(n)]
Jc=[[0]*n for y in range(n)]
Jd=[[0]*n for y in range(n)]
J=1.0
width=0.8
T=3.0
mix=0.3
for y in range(1,n-2):
for x in range(1,n-2):
magnet[x][y]=random.uniform(-1,1)
print
print("LIST OF MAGNETIC INTERACTION VALUES")
print(" x y Ja Jb Jc Jd ")
for y in range(1,n-2):
for x in range(1,n-2):
Ja[x][y]=J+width*random.uniform(-1,1)
Jb[x][y]=J+width*random.uniform(-1,1)
Jc[x][y]=J+width*random.uniform(-1,1)
Jd[x][y]=J+width*random.uniform(-1,1)
print("%3d" % (x)),
print("%3d " % (y)),
print("%5.3f" % (Ja[x][y])),
print("%5.3f" % (Jb[x][y])),
print("%5.3f" % (Jc[x][y])),
print("%5.3f" % (Jd[x][y]))
print
print("LIST OF STARTING MAGNETIC POLE STRENGTHS")
print(" x y Pole ")
for y in range(1,n-2):
for x in range(1,n-2):
print("%3d" % (x)),
print("%3d " % (y)),
print("%5.3f" % magnet[x][y])
print
print(ntime)
for time in range(0,ntime):
for y in range(1,n-2):
for x in range(1,n-2):
a=magnet[x][y-1]
b=magnet[x][y+1]
c=magnet[x-1][y]
d=magnet[x+1][y]
field=a*Ja[x][y]+b*Jb[x][y]+c*Jc[x][y]+d*Jd[x][y]
field=field/T
newmagnet[x][y]=mix*math.tanh(field)+(1.-mix)*magnet[x][y]
print("LIST OF MAGNETIC POLE STRENGTHS AT TIME STEP"),
print(time)
for y in range(1,n-2):
for x in range(1,n-2):
magnet[x][y]=newmagnet[x][y]
print("%3d" % (x)),
print("%3d " % (y)),
print("%5.3f" % magnet[x][y])
print
print
Here's a movie of magnetic domains forming
that our code produced.