示例#1
0
dimer = s22.create_s22_system('Water_dimer')
dimer.center(vacuum=5.0)
# rotate the second water mol into the same x plane as
# the first one, to make the potential curve easier to make
center = dimer[0].position
h = dimer[3].position[1]-dimer[0].position[1]
l = np.linalg.norm(dimer[0].position - dimer[3].position)
angle = np.arcsin(h/l)
dimer.rotate('-z',a=angle,center=center)

nsys = dimer[:3].copy()
nsys.set_positions(dimer[:3].get_positions() + (2.,2.,0))
trimer = dimer + nsys # 3 mols now

qmidx = 3

calc_qm = GPAW(h=0.20,mode='lcao',basis={None:'dzp'},txt='simpletest.txt')
eF = np.zeros((3,2))
calc_mm = CALC_SCME(trimer[qmidx:])

trimer.set_calculator(ase_qmscme(trimer, qmidx=3,calc_qm=calc_qm,
                     calc_mm=calc_mm,qm_cell=trimer.get_cell()))
Etot = trimer.get_potential_energy()

print '\n################################## #'
print '########### TOTAL ENERGY ######### #'
print Etot
print '################################## #'


    if step > -1:  # if you accidentally break the script before done
        dimer.center(vacuum=5.0)
        qm_cell = dimer.get_cell()
        dist = np.linalg.norm(dimer[0].position - dimer[3].position)
        extra = dimer[0:3].copy()
        extra.translate([100, 0, 0])
        full_sys = dimer + extra
        calc_mm = CALC_SCME(full_sys[qmidx:])
        full_sys.set_cell([200, 200, 200])
        calc_qm = GPAW(h=0.20, mode="lcao", xc="PBE", basis={None: "dzp"}, txt=path + "dimer_%2.4f.txt" % dist)
        full_sys.set_calculator(
            ase_qmscme(
                full_sys,
                qmidx=3,
                calc_qm=calc_qm,
                calc_mm=calc_mm,
                qm_cell=qm_cell,
                LJ_qm=LJ_qm.T,
                LJ_mm=LJ_mm.T,
                qm_fixed=True,
            )
        )
        # try:
        Epot = full_sys.get_potential_energy()
        print "Step: %5.2f, dist: %5.2f, Epot: %5.2f" % (step, dist, Epot)
        # except:
        #    Epot = float('Nan')
        if rank == MASTER:
            f.write("%24s%24s%24s\n" % (dist, Epot, Epot - Esingle))
            print ("%24s%24s%24s\n" % (dist, Epot, Epot - Esingle))

for step in range(0, 5, 1):
    for mol1 in range(3):
        dimer[mol1].x -= 0.05*2
    for mol2 in range(3,6):
        dimer[mol2].x += 0.05*2
    if step > -1: # if you accidentally break the script before done
        dimer.center(vacuum=5.0)
        qm_cell = dimer.get_cell()
        dist = np.linalg.norm(dimer[0].position - dimer[3].position)
        extra = dimer[0:3].copy()
        extra.translate([100,0,0])
        full_sys = dimer + extra
        calc_mm = CALC_SCME(full_sys[qmidx:])
        full_sys.set_cell([200,200,200])
        calc_qm = GPAW(h=0.20,mode='lcao',xc='PBE',
                       basis={None:'dzp'},txt=path+'singleproc_dimer_%2.4f.txt'%dist)
        full_sys.set_calculator(ase_qmscme(full_sys, qmidx=3,calc_qm=calc_qm,
                          calc_mm=calc_mm,qm_cell=qm_cell,
                          LJ_qm=LJ_qm.T, LJ_mm=LJ_mm.T, qm_fixed = True))
        #try:
        Epot = full_sys.get_potential_energy()
        print 'Step: %5.2f, dist: %5.2f, Epot: %5.2f'%(step, dist,Epot)
        #except:
        #    Epot = float('Nan')
        if rank == MASTER:
            f.write('%24s%24s%24s\n' %(dist,Epot,Epot-Esingle))
            print('%24s%24s%24s\n' %(dist,Epot,Epot-Esingle))