Exemplo n.º 1
0
def test_rotate_euler():
    from math import sqrt
    from ase import Atoms

    d = 1.14
    a = Atoms('CO', [(0, 0, 0), (d, 0, 0)])
    a.euler_rotate(phi=90, theta=45, psi=180)
    for p in a[0].position:
        assert p == 0.0
    assert abs(a[1].position[0]) < 1e-15
    d2 = d / sqrt(2)
    assert abs(a[1].position[1] - d2) < 1e-15
    assert abs(a[1].position[2] - d2) < 1e-15
Exemplo n.º 2
0
from math import sqrt
from ase import Atoms

d = 1.14
a = Atoms('CO', [(0, 0, 0), (d, 0, 0)])
a.euler_rotate(phi=90, theta=45, psi=180)
for p in a[0].position:
    assert p == 0.0
assert abs(a[1].position[0]) < 1e-15
d2 = d / sqrt(2)
assert abs(a[1].position[1] - d2) < 1e-15
assert abs(a[1].position[2] - d2) < 1e-15
Exemplo n.º 3
0
# Fill up HCP lattice until N z_coords
count = 0
for l in range(layers):
    for i in range(int(np.ceil(np.sqrt(n)))):
        for j in range(int(np.ceil(np.sqrt(n)))):
            if count >= N:
                break
            
            # Randomise angles
            phi = 180.*random()
            theta = 180.*random()
            psi = 180.*random()
            
            # Arrange in HCP arrangement with minor random x and y displacement
            x = h2o_xy * (i - 0.01*(random() - 0.5)*0 + (1+(-1)**j+(-1)**l)/4.)
            y = h2o_xy * (j - 0.01*(random() - 0.5)*0 + (1+(-1)**l)/4.)
            z = c / 2. + ((1. - layers) / 2. + l) * h2o_z
            offset = np.array([x, y, z])
            
            h2o = Atoms('OH2', positions=pos+offset)
            Atoms.euler_rotate(h2o, phi, theta, psi,
                               center=h2o.get_center_of_mass())
            atoms += h2o
            count += 1

atoms.set_cell([a, a, c])
atoms.set_pbc(1)

io.write('test.xyz', atoms)
io.write('test.pdb', atoms)