from ase import * from ase import Atoms as ase_Atoms from hotbit import * from hotbit.atoms import Atoms from box.md import check_energy_conservation from hotbit.test.misc import default_param # check that C1H1-presentation of C6H6 goes right 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 #
n1 = 4 SCC = True cut = 1E10 a1 = Atoms('CH', [(1.42, 0, 0), (2.42, 0.1, 0.1)], container='Wedge') a1.set_container(M=6, height=10) aux = a1.extended_copy([(1, 0, 0)]) a1 += aux a1.set_container(M=3, height=10) n2 = 12 c1 = Hotbit(SCC=SCC, txt='-', kpts=(3, 1, 1), gamma_cut=cut, **default_param) a1.set_calculator(c1) a1.get_potential_energy() a2 = a1.extended_copy((3, 1, 1)) c2 = Hotbit(SCC=SCC, txt='-', kpts=(1, 1, 1), gamma_cut=cut, **default_param) a2.set_calculator(c2) a2.get_potential_energy() # start Mulliken analysis q1 = c1.get_dq() q2 = c2.get_dq()[:4] assert all(abs(q1 - q2) < eps)
from hotbit.atoms import Atoms from box.md import check_energy_conservation from hotbit.test.misc import default_param # check that C1H1-presentation of C6H6 goes right 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')
straight.set_pbc((False,False,True)) 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)
from hotbit.atoms import Atoms from box.systems import nanotube from box.md import check_energy_conservation nkpts=10 # energy of normal infinite (5,0) straight = nanotube(5,0,1.42) calc = Hotbit(SCC=False,txt='chiral.cal',kpts=(1,1,nkpts)) straight.set_calculator(calc) e1 = straight.get_potential_energy() #view(straight) # 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=False,txt='chiral.cal',kpts=(1,1,nkpts)) chiral.set_calculator(calc) 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=False,txt='chiral.cal',kpts=(1,1,1)) #chiral.set_calculator(calc) #conv = check_energy_conservation(chiral,dt=0.5*fs,steps=50,tol=0.01,plot=False) #assert conv
if True: # check that C1H1-presentation of C6H6 goes right n1 = 4 SCC=True cut=1E10 a1 = Atoms('CH',[(1.42,0,0),(2.42,0.1,0.1)],container='Wedge') a1.set_container(M=6,height=10) aux = a1.extended_copy([(1,0,0)]) a1 += aux a1.set_container(M=3,height=10) n2 = 12 c1 = Hotbit(SCC=SCC,txt='-',kpts=(3,1,1),gamma_cut=cut,**default_param) a1.set_calculator(c1) a1.get_potential_energy() a2 = a1.extended_copy((3,1,1)) c2 = Hotbit(SCC=SCC,txt='-',kpts=(1,1,1),gamma_cut=cut,**default_param) a2.set_calculator(c2) a2.get_potential_energy() # start Mulliken analysis q1 = c1.get_dq() q2 = c2.get_dq()[:4] assert all(abs(q1-q2)<eps) # atom mulliken for i in range(4):