| 1 |
import numpy as np |
| 2 |
from ase import Atoms |
| 3 |
from gpaw import GPAW |
| 4 |
|
| 5 |
d = 1.54 |
| 6 |
dx = d * (2 / 3)**0.5 |
| 7 |
dz = d / 3**0.5 |
| 8 |
h = 1.1 |
| 9 |
|
| 10 |
|
| 11 |
def cnh2n(n): |
| 12 |
assert n % 2 == 1 |
| 13 |
positions = [] |
| 14 |
for i in range(n): |
| 15 |
x = i * dx |
| 16 |
z = dz * (i % 2) |
| 17 |
positions.append((x, 0, z)) |
| 18 |
if i == 0: |
| 19 |
positions.append((x, 0, -h)) |
| 20 |
positions.append((x - dx, 0, dz)) |
| 21 |
elif i == n - 1: |
| 22 |
positions.append((x, 0, -h)) |
| 23 |
positions.append((x + dx, 0, dz)) |
| 24 |
elif i % 2 == 0: |
| 25 |
positions.append((x, -h * (2 / 3)**0.5, -h / 3**0.5)) |
| 26 |
positions.append((x, h * (2 / 3)**0.5, -h / 3**0.5)) |
| 27 |
else: |
| 28 |
positions.append((x, -h * (2 / 3)**0.5, z + h / 3**0.5)) |
| 29 |
positions.append((x, h * (2 / 3)**0.5, z + h / 3**0.5)) |
| 30 |
|
| 31 |
atoms = Atoms(f'(CH2){n}', positions) |
| 32 |
atoms.set_distance(0, 2, h, 0) |
| 33 |
atoms.set_distance(-3, -1, h, 0) |
| 34 |
magmoms = np.zeros(3 * n) |
| 35 |
magmoms[0] = 1.0 |
| 36 |
magmoms[-3] = 1.0 |
| 37 |
atoms.set_initial_magnetic_moments(magmoms) |
| 38 |
return atoms |
| 39 |
|
| 40 |
|
| 41 |
if __name__ == '__main__': |
| 42 |
for n in range(3, 13, 2): |
| 43 |
atoms = cnh2n(n) |
| 44 |
d = atoms.get_distance(0, -3) |
| 45 |
atoms.center(vacuum=2 * d) |
| 46 |
name = f'C{n}H{2 * n}' |
| 47 |
atoms.calc = GPAW(mode='lcao', |
| 48 |
basis='dzp', |
| 49 |
xc='PBE', |
| 50 |
txt=name + '.txt') |
| 51 |
atoms.get_potential_energy() |
| 52 |
atoms.calc.write(name + '.gpw', 'all') |