Example #1
0
 def displace_atoms_randomly(self,dR=0.05):
     """
     Displace atoms with random positions up to given radii 
     with Gaussian profile (sigma=dR/2).
     Same for all atoms or list of radii for all atoms.
     """
     from numpy.random import normal
     sin=npy.sin
     cos=npy.cos
     R=self.get_positions()
     if type(dR)!=type([]):
         dR=[dR]*len(R)
     for i in range(len(R)):
         phi,theta=mix.random_direction()
         disp=min(normal(scale=dR[i]/2),dR[i])
         R[i]=R[i]+disp*vec([sin(theta)*cos(phi),sin(theta)*sin(phi),cos(theta)])
     self.set_positions(R)
Example #2
0
 def displace_atoms_randomly(self, dR=0.05):
     """
     Displace atoms with random positions up to given radii 
     with Gaussian profile (sigma=dR/2).
     Same for all atoms or list of radii for all atoms.
     """
     from numpy.random import normal
     sin = npy.sin
     cos = npy.cos
     R = self.get_positions()
     if type(dR) != type([]):
         dR = [dR] * len(R)
     for i in range(len(R)):
         phi, theta = mix.random_direction()
         disp = min(normal(scale=dR[i] / 2), dR[i])
         R[i] = R[i] + disp * vec(
             [sin(theta) * cos(phi),
              sin(theta) * sin(phi),
              cos(theta)])
     self.set_positions(R)
Example #3
0
# C, SCC
calc = Hotbit(SCC=True, txt='test.cal', **default_param)
C = Atoms('C', positions=[(0, 0, 0)], cell=(10, 10, 10), pbc=False)
C.center(vacuum=100)
C.set_calculator(calc)
e = C.get_potential_energy()
if abs(e) > 1E-6:
    raise RuntimeError('energy %f, should be %f' % (e, 0.0))

# rotate Au-dimer
#calc0=Calculator0(SCC=True,txt='test.cal',**default_param)
calc = Hotbit(SCC=True, txt='test.cal', **default_param)
Au2 = Atoms('Au2',
            positions=[(0, 0, 0), (2.6, 0, 0)],
            cell=(10, 10, 10),
            pbc=False)
Au2.center(vacuum=10)
#Au2.set_calculator(calc0)
e = -152.981553763 - (-149.76607940880001)

for i in range(10):
    Au2.set_calculator(calc)
    vector = mix.random_direction(vector=True)
    Au2.rotate(vector * random.rand() * 2 * pi)
    Au2.center(vacuum=10)
    e2 = Au2.get_potential_energy()
    if abs(e - e2) > 1E-4:
        raise RuntimeError('energy for Au2 %f, should be %f (while rotating)' %
                           (e2, e))
Example #4
0
e = C.get_potential_energy()
if abs(e) > 1e-6:
    raise RuntimeError("energy %f, should be %f" % (e, 0.0))

# C, SCC
calc = Hotbit(SCC=True, txt="test.cal", **default_param)
C = Atoms("C", positions=[(0, 0, 0)], cell=(10, 10, 10), pbc=False)
C.center(vacuum=100)
C.set_calculator(calc)
e = C.get_potential_energy()
if abs(e) > 1e-6:
    raise RuntimeError("energy %f, should be %f" % (e, 0.0))


# rotate Au-dimer
# calc0=Calculator0(SCC=True,txt='test.cal',**default_param)
calc = Hotbit(SCC=True, txt="test.cal", **default_param)
Au2 = Atoms("Au2", positions=[(0, 0, 0), (2.6, 0, 0)], cell=(10, 10, 10), pbc=False)
Au2.center(vacuum=10)
# Au2.set_calculator(calc0)
e = -152.981553763 - (-149.76607940880001)

for i in range(10):
    Au2.set_calculator(calc)
    vector = mix.random_direction(vector=True)
    Au2.rotate(vector * random.rand() * 2 * pi)
    Au2.center(vacuum=10)
    e2 = Au2.get_potential_energy()
    if abs(e - e2) > 1e-4:
        raise RuntimeError("energy for Au2 %f, should be %f (while rotating)" % (e2, e))