# Simple Cubic Lattice

Today, let’s have some fun playing with perspective rendering in Python! My graphics package of choice is VPython:

<code>sudo apt-get install python-visual</code>

Suppose we want to represent a simple cubic lattice: Using the visual package, we can create a collection of spheres at positions $(i,j,k)$ with $i,j,k = -L…L$.

from visual import sphere
L = 5
R = 0.3
for i in range(-L,L+1):
for j in range(-L,L+1):
for k in range(-L,L+1):
sphere(pos=[i,j,k],radius=R)

Resulting in this beautiful rendering:

But what if we want to change the color? Simply alter the last line:

<code>sphere(pos=[i,j,k],radius=R).color = color.blue</code>

Less atoms? Alter the value of L.

 L = 1

Same number of atoms with smaller radii? Alter the value of R.

 R = 0.2

Want more advanced computational physics with Python?