def make_bonds(bond_length = 3.0)
		# initialize an empty array
		@bonds = Array.new
		
		# Make bonds between all atoms
    # stack = atoms.dup
    atoms_extended = atoms.dup
    if periodic?
        v1 = lattice_vectors[0]
        v2 = lattice_vectors[1]
        atoms.each{|a|
        [-1, 0, 1].each{|n1|
              [-1, 0, 1].each{|n2|               
                  atoms_extended << a.displace(n1*v1[0] + n2*v2[0], n1*v1[1] + n2*v2[1], n1*v1[2] + n2*v2[2])
              }
          }
        }
      end
      
		tree = KDTree.new(atoms_extended, 3)
    atoms.each{|a|
      r = 4
      neighbors = tree.find([a.x-r, a.x+r], [a.y-r, a.y+r], [a.z-r, a.z+r])
      neighbors.each{|n|
        b = Bond.new(a, n)
        @bonds << b if b.length < bond_length
      }
    }
		
    # atom1 = stack.pop
    # while (not stack.empty?)
    #   stack.each{|atom2|
    #     b = Bond.new(atom1, atom2)
    #     @bonds << b if b.length < bond_length
    #     if periodic?
    #           v1 = lattice_vectors[0]
    #           v2 = lattice_vectors[1]
    #       [-1, 0, 1].each{|n1|
    #         [-1, 0, 1].each{|n2|               
    #               b = Bond.new(atom1, atom2.displace(n1*v1[0] + n2*v2[0], n1*v1[1] + n2*v2[1], n1*v1[2] + n2*v2[2]))
    #               @bonds << b if b.length < bond_length
    #         }
    #       }
    #     end
    #   }
    #   atom1 = stack.pop
    # end
	end
def make_bonds(bond_length = 3.0)
		# initialize an empty array
		@bonds = Array.new
		
		# Make bonds between all atoms
    # stack = atoms.dup
    atoms_extended = atoms.dup
    if periodic?
        v1 = lattice_vectors[0]
        v2 = lattice_vectors[1]
        atoms.each{|a|
        [-1, 0, 1].each{|n1|
              [-1, 0, 1].each{|n2|               
                  atoms_extended << a.displace(n1*v1[0] + n2*v2[0], n1*v1[1] + n2*v2[1], n1*v1[2] + n2*v2[2])
              }
          }
        }
      end
      
		tree = KDTree.new(atoms_extended, 3)
    atoms.each{|a|
      r = 4
      neighbors = tree.find([a.x-r, a.x+r], [a.y-r, a.y+r], [a.z-r, a.z+r])
      neighbors.each{|n|
        b = Bond.new(a, n)
        @bonds << b if b.length < bond_length
      }
    }
		
    # atom1 = stack.pop
    # while (not stack.empty?)
    #   stack.each{|atom2|
    #     b = Bond.new(atom1, atom2)
    #     @bonds << b if b.length < bond_length
    #     if periodic?
    #           v1 = lattice_vectors[0]
    #           v2 = lattice_vectors[1]
    #       [-1, 0, 1].each{|n1|
    #         [-1, 0, 1].each{|n2|               
    #               b = Bond.new(atom1, atom2.displace(n1*v1[0] + n2*v2[0], n1*v1[1] + n2*v2[1], n1*v1[2] + n2*v2[2]))
    #               @bonds << b if b.length < bond_length
    #         }
    #       }
    #     end
    #   }
    #   atom1 = stack.pop
    # end
	end
Generate and cache bonds for this geometry.
 A bond will be generated for every pair of atoms closer than +bond_length+