import ase.units as units from numpy import array, linspace import matplotlib.pyplot as plt import numpy # Create the MgO crystal a = 4.194 cryst = Crystal( crystal(['Mg', 'O'], [(0, 0, 0), (0.5, 0.5, 0.5)], spacegroup=225, cellpar=[a, a, a, 90, 90, 90])) # Create the calculator running on one, eight-core node. # This is specific to the setup on my cluster. # You have to adapt this part to your environment calc = ClusterVasp(nodes=1, ppn=8) # Assign the calculator to the crystal cryst.set_calculator(calc) # Set the calculation parameters calc.set(prec='Accurate', xc='PBE', lreal=False, nsw=30, ediff=1e-8, ibrion=2, kpts=[3, 3, 3]) # Set the calculation mode first. # Full structure optimization in this case.
def secban(msg): print() print(max(0,(60-len(msg))//2-1)*' ',msg) print(60*'-') banner('Structure optimization on MgO') a = 4.291 MgO = crystal(['Mg', 'O'], [(0, 0, 0), (0.5, 0.5, 0.5)], spacegroup=225, cellpar=[a, a, a, 90, 90, 90]) ################################## # Provide your own calculator here ################################## calc=ClusterVasp(nodes=1,ppn=8) # The calculator must be runnable in an isolated directory # Without disturbing other running instances of the same calculator # They are run in separate processes (not threads!) MgO.set_calculator(calc) calc.set(prec = 'Accurate', xc = 'PBE', lreal = False, isif=2, nsw=20, ibrion=2, kpts=[1,1,1]) print("Residual pressure: %.3f GPa" % (MgO.get_pressure()/GPa)) calc.clean() banner('Volume scan on MgO (+/- 5%)') systems=[] for av in numpy.linspace(a*0.95,a*1.05,5): systems.append(crystal(['Mg', 'O'], [(0, 0, 0), (0.5, 0.5, 0.5)], spacegroup=225,
print(n+1,end='') while not r.get_calculator().calc_finished() : print('.',end='') sys.stdout.flush() sleep(10) print(end=' ') sys.stdout.flush() print() a=4 ; c=crystal('Si',[(0,0,0)],spacegroup=221,cellpar=[a,a,a,90,90,90]) spglib.get_spacegroup(c) block=False calc = ClusterVasp(block=block) calc.set(prec = 'Accurate', xc = 'PBE', lreal = False, nsw=30, ediff=1e-8, ibrion=2, kpts=[3,3,3]) calc.set(isif=3) c.set_calculator(calc) l=ParCalculate(c,calc,cleanup=False,block=block) s = l[0] wait_for_results(l) print(s.get_forces(), s.get_cell(), s.get_stress(), s.get_pressure())