def test_unitcellfilter_hcp(asap3, testdir):
    cu = bulk('Cu', 'hcp', a=3.6 / 2.0**0.5)
    cu.cell[1, 0] -= 0.05
    cu *= (6, 6, 3)
    cu.calc = asap3.EMT()
    print(cu.get_forces())
    print(cu.get_stress())
    f = UnitCellFilter(cu)
    opt = MDMin(f, dt=0.01)
    with Trajectory('Cu-hcp.traj', 'w', cu) as t:
        opt.attach(t)
        opt.run(0.2)
Beispiel #2
0
size = 5

atoms = FaceCenteredCubic(size=(size,size,size), symbol="Cu", pbc=True)
defsize = atoms.get_volume()
atoms.set_cell(atoms.get_cell() * 1.1, scale_atoms=True)
atoms.set_calculator(EMT())

def printvol(a):
    print "Volume:", a.get_volume(), " energy:",\
          atoms.get_potential_energy() + atoms.get_kinetic_energy(),\
          " stress:", atoms.get_stress()[:3]

f = StrainFilter(atoms, [1, 1, 1, 0, 0, 0])
opt = MDMin(f, logfile="/dev/null", dt=0.01/(atoms.get_cell()[0,0]))
printvol(atoms)
opt.attach(printvol, 10, atoms)
opt.run(0.01)
printvol(atoms)
print "Original vol:", defsize
print
stress = atoms.get_stress()
for i in range(6):
    ReportTest("Stress component %d (T=0)" % (i,), stress[0], 0.0, 1e-5)

atoms = FaceCenteredCubic(size=(size,size,size), symbol="Cu", pbc=True)
atoms.set_calculator(EMT())
dyn = Langevin(atoms, 10*units.fs, 500*units.kB, 0.02)
dyn.attach(printvol, 100, atoms)
dyn.run(500)

print