# 構造最適化

## CO

```from ase import Atom, Atoms
d = 1.1
atom1 = Atom('C', (0, 0, 0))
atom2 = Atom('O', (d, 0, 0))
molecule1 = Atoms([atom1, atom2], cell = (6, 6, 6), pbc = True)

from ase.calculators.jacapo import Jacapo
solver1 = Jacapo('sample.nc', nbands = 8, ft = 0.01, atoms = molecule1)

from ase.optimize import QuasiNewton
dynamics1 = QuasiNewton(molecule1, trajectory = 'sample.traj')
dynamics1.run(fmax = 0.05)```

1. CO2
2. H2O
3. NH3
4. CH4

1. H: 1
2. C: 4
3. N: 5
4. O: 6

## 演習

1. H2OのOを固定し二つのHを動かす計算をする
```a1 = (5.0, 0.0, 0.0)
a2 = (0.0, 5.0, 0.0)
a3 = (0.0, 0.0, 5.0)
v1 = (0.50, 0.50, 0.50)
v2 = (0.72, 0.50, 0.50)
v3 = (0.50, 0.72, 0.50)

from ase import Atom, Atoms
p1 = Atom('O', v1, tag = 1) # <--
p2 = Atom('H', v2)
p3 = Atom('H', v3)
molecule1 = Atoms([p1, p2, p3], pbc = True)
molecule1.set_cell([a1, a2, a3], scale_atoms=True)

from ase.constraints import FixAtoms
fixatom1 = [atomx.tag == 1 for atomx in molecule1]

from ase.calculators.jacapo import Jacapo
solver1 = Jacapo('water.nc', nbands = 8, ft = 0.01, atoms = molecule1)

from ase.optimize import QuasiNewton
dynamics1 = QuasiNewton(molecule1, trajectory = 'water.traj')
dynamics1.run(fmax = 0.04)
print molecule1.get_positions()
print molecule1.get_forces()```

Stay Alive設定をOnにするとどうなるかも確かめよ

`solver1 = Jacapo('water.nc', nbands = 8, stay_alive = True, ft = 0.01, atoms = molecule1)`
2. trajファイルをxyzファイルに変換する
`\$ traj2xyz water.traj water.xyz`

traj2xyzが無かった場合はtraj2xyzをつくる。

```\$ chmod a+x traj2xyz
\$ ./traj2xyz water.traj water.xyz```
3. water.xyzをiMolかJmolで表示させる。
seminar/optimizing.1402991839.txt.gz · 最終更新: 2014/06/17 16:57 by kimi