def __init__(self, start_run, end_run, method): path = method.path(start_run.system()) Run.__init__(self, path, identifier=end_run.system().name(), program=AseInterface(Siesta()), dependency_runs=(start_run, end_run), ) self.__start_run = start_run self.__end_run = end_run self.__method = method
def runDirectory(self): if self.__make_sub_directory: path = Run.runDirectory(self) else: path = self.path() return path
def directoryBaseName(self): system = self.system() if isinstance(system, Run): basename = system.directoryBaseName() else: basename = Run.directoryBaseName(self) return basename
def __init__(self, system, method=Siesta(), path=DEFAULT, identifier=DEFAULT, parameters=DEFAULT, inputs=tuple(), ): parameters = system.defaultParameters(parameters) identifier = parameters.identifier() self.__parameters=parameters self.__system = system.fullyUnrelaxed() self.__method = method Run.__init__( self, path=path, identifier=identifier, inputs=inputs, )
def __init__(self, system, method=NickTransiesta(), path=DEFAULT, identifier=None, parameters=DEFAULT, inputs=tuple(), ): self.__system = system self.__method = method self.__parameters = parameters inputs = list(inputs) inputs.extend(self.determineDependencies(system)) Run.__init__( self, path=path, method=method, identifier=identifier, inputs=inputs, )
def write(self): Run.write(self) method = self.__method initial, final = self.makeInitialAndFinal() kpts = method.setKpts(initial, method.correlationLength()) initial.set_calculator(method.calculator(kpts, label='siesta_0')) groups = groupAtoms(initial, (2,), tolerance=1e-1) max_z = groups[1].positions[:, 2].max() initial = fixBelow(initial, max_z) final = fixBelow(final, max_z) diff = final.positions - initial.positions diff = vectorLength(diff, 1) if diff.max() < 0.4: with open(self.runFile(), 'w') as f: f.write("""raise Exception('Initial and final image too close.')""") return n_images = int(np.ceil(diff.max()/0.4)) images = [initial] for i in range(n_images): image = initial.copy() image = fixBelow(image, max_z) images.append(image) final.set_calculator(method.calculator(kpts, label='siesta_%d'%i)) images.append(final) neb = NEB(images) neb.interpolate() filename = join(self.runDirectory(), 'neb.traj') if not os.path.exists(filename): io.write(filename, images) kpts_string = '(%d, %d, %d)'%tuple(kpts) with open(self.runFile(), 'w') as f: f.write( """from ase import io from ase.neb import NEB from ase.optimize import FIRE, BFGS from Methods import TTT images = io.read('neb.traj@-%d:') for i, image in enumerate(images): image.set_calculator(TTT.calculator(kpts=%s,"""%(n_images + 2, kpts_string) + """label='siesta_%d'%i)) image.get_total_energy() """ + """ k=0.5 neb = NEB(images, k=k, climb=True) qn = FIRE(neb, trajectory='neb.traj') qn.run(fmax=%.3f) """%(method.parameters()['force_tolerance'], method.parameters()['force_tolerance']) ) self.program().saveRunScript(self.runDirectory()) pseudo_dir = join(self.runDirectory(), 'PSEUDO') if not os.path.exists(pseudo_dir): os.makedirs(pseudo_dir) self.program().copyPseudoPotentials(path=pseudo_dir, atoms=initial, parameters=method.parameters(), )