コード例 #1
0
ファイル: C6H6_wedge.py プロジェクト: molguin-qc/hotbit
SCC=True
cut=3.0
atoms = Atoms('CH',[(1.42,0,0),(2.0,1.0,0.2)],container='Wedge')
atoms.set_container(M=6,height=10)

calc = Hotbit(SCC=SCC,txt='tmp.cal',kpts=(6,1,1),gamma_cut=cut,**default_param)
atoms.set_calculator(calc)
e1 = atoms.get_potential_energy()

atoms6 = ase_Atoms(pbc=False)
atoms6 += atoms.extended_copy([(i-2,0,0) for i in range(6)])
#view(atoms)
calc = Hotbit(SCC=SCC,txt='tmp.cal',gamma_cut=cut,**default_param)
atoms6.set_calculator(calc)
e6 = atoms6.get_potential_energy()

assert abs(6*e1-e6)<1E-5


#
# energy conservation
#
atoms = Atoms('CH',[(1.42,0,0),(2.0,0.5,0.3)],container='Wedge')
atoms.set_container(M=6,height=10)
calc = Hotbit(SCC=SCC,txt='tmp.cal',kpts=(6,1,1),gamma_cut=cut,**default_param)
atoms.set_calculator(calc)

atoms.rattle(0.1)
assert check_energy_conservation(atoms,dt=0.2*units.fs,steps=30,tol=0.01,plot=False)

コード例 #2
0
    # Relax (twist) the structure
    q = optimize.FIRE(atoms,trajectory='polyethene.trj',logfile=None)
    q.run(fmax=0.5)

    # Displace atoms from their equilibrium positions and check forces
    atoms.rattle(0.1)

    # Check electrostatics only
#    atoms.set_initial_charges([1.0,1.0,1.0,1.0,-1.0,-1.0,-1.0,-1.0])
#    atoms.set_calculator(calc.st.es)

    # Check forces from finite differences
    ffd, f0, err = check_forces(atoms, dx=1e-6)
    if debug:
        print "Finite differences forces:"
        print ffd
        print "Analytical forces:"
        print f0
        print "Difference:"
        print abs(ffd-f0)
        print "Error:"
        print err

    assert err < 1e-5

    # Check energy conservation from a molecular dynamics run
    assert check_energy_conservation(atoms,dt=0.25*units.fs,steps=100,
                                     tol=0.01,plot=debug)

コード例 #3
0
ファイル: graphene.py プロジェクト: nateharms/hotbit
import ase.units as units
from ase import *
from hotbit import *
from box.md import check_energy_conservation
from box.systems import graphene
from numpy import *
from hotbit.test.misc import default_param

R=1.416552
nkpts = 10

# graphene's cohesion energy
atoms=graphene(2,2,R)
atoms=Atoms('C2',[(0,0,0),(2*cos(pi/6)*R,R,0)],pbc=(True,True,False),\
            cell=array([[2*cos(pi/6)*R,0,0],[R*cos(pi/6),R*1.5,0],[0,0,5]]) )

calc=Hotbit(SCC=False,txt='graphene.cal',kpts=(nkpts,nkpts,1),**default_param) 
atoms.set_calculator(calc)
coh = atoms.get_potential_energy()/2
assert abs(-9.626283-coh)<1E-5


# energy conservation
atoms[0].z+=0.1
calc=Hotbit(SCC=False,txt='graphene.cal',kpts=(3,3,1),**default_param) 
atoms.set_calculator(calc)
assert check_energy_conservation(atoms,dt=0.5*units.fs,steps=30,tol=1E-2,plot=False)


コード例 #4
0
ファイル: Au_chain.py プロジェクト: pastewka/hotbit
from ase import *
from hotbit import *
from box.md import check_energy_conservation
from ase import io

M = 7
atoms = Atoms('Au2', [(5, 0, 0), (5, 2.5, 0.3)], container='Wedge')
atoms.set_container(M=M, height=5.0)
calc = Hotbit(SCC=False, txt='-', kpts=(M, 1, 1))
atoms.set_calculator(calc)

e1 = atoms.get_potential_energy()

whole = atoms.extended_copy((M, 1, 1))
calc = Hotbit(SCC=False, txt='-')
whole.set_calculator(calc)
e2 = whole.get_potential_energy()

assert abs(M * e1 - e2) < 1E-10

assert check_energy_conservation(atoms,
                                 dt=2.5 * units.fs,
                                 steps=50,
                                 tol=0.01,
                                 plot=False)

#dyn = VelocityVerlet(atoms,2.5*fs)
#traj = PickleTrajectory('koe.traj','w',atoms)
#dyn.attach(traj.write)
#dyn.run(100)
コード例 #5
0
ファイル: CNT5_0_SCC.py プロジェクト: molguin-qc/hotbit
for i in range(len(straight)):
    if straight[i].z<1.0:
        r=sqrt(straight[i].x**2+straight[i].y**2)
        c=(1+r)/r
        x,y,z = c*straight[i].x,c*straight[i].y,straight[i].z
        straight+=Atom('H',(x,y,z))
#view(straight)
calc = Hotbit(SCC=SCC,txt='chiral.cal',kpts=(1,1,nkpts),gamma_cut=cut)
straight.set_calculator(calc)
e1 = straight.get_potential_energy()



# same thing, but calculate by twisting 2*pi/5 while translating
height = straight.get_cell()[2,2]
chiral = Atoms(container='Chiral')
chiral += straight
chiral.set_container(height=height,angle=2*pi/5)
calc = Hotbit(SCC=SCC,txt='chiral.cal',kpts=(1,1,nkpts),gamma_cut=cut)
chiral.set_calculator(calc)
view(chiral)
e2 = chiral.get_potential_energy()
assert abs(e1-e2)<1E-6


# check the energy conservation for the chiral situation
chiral.rattle(0.1)
calc = Hotbit(SCC=SCC,txt='chiral.cal',width=0.1,kpts=(1,1,1),gamma_cut=cut) #,verbose_SCC=True)
chiral.set_calculator(calc)
assert check_energy_conservation(chiral,dt=0.5*fs,steps=50,tol=0.02,plot=True)
コード例 #6
0
ファイル: polyethene_twisted.py プロジェクト: pastewka/hotbit
    q = optimize.FIRE(atoms, trajectory='polyethene.trj', logfile=None)
    q.run(fmax=0.5)

    # Displace atoms from their equilibrium positions and check forces
    atoms.rattle(0.1)

    # Check electrostatics only
    #    atoms.set_initial_charges([1.0,1.0,1.0,1.0,-1.0,-1.0,-1.0,-1.0])
    #    atoms.set_calculator(calc.st.es)

    # Check forces from finite differences
    ffd, f0, err = check_forces(atoms, dx=1e-6)
    if debug:
        print "Finite differences forces:"
        print ffd
        print "Analytical forces:"
        print f0
        print "Difference:"
        print abs(ffd - f0)
        print "Error:"
        print err

    assert err < 1e-5

    # Check energy conservation from a molecular dynamics run
    assert check_energy_conservation(atoms,
                                     dt=0.25 * units.fs,
                                     steps=100,
                                     tol=0.01,
                                     plot=debug)